$this->fields['linkMultimediaQuality'] = array('type' => 'float', 'default' => 1.0, 'editable' => true, 'label' => __('Qualité de rendu des animations'), 'grade' => 5);\r
$this->fields['linkCornerSize'] = array('type' => 'integer', 'default' => '10', 'editable' => true, 'label' => __('Taille des liens de coins de page'), 'hint' => __("Pourcentage de la largeur de la page"));\r
$this->fields['videoReset'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Réinitialiser les vidéos après la lecture'), 'grade' => 3);\r
+ $this->fields['videoBigPlay'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Afficher le gros bouton Play'), 'grade' => 3);\r
$this->forms['multimedia'] = array('label' => __('Liens et multimédia'),\r
- 'fieldsnames' => array('permanentLinks', 'linkBlinkTime', 'customLinkClass', 'linkTooltipManager', 'linkCornerSize', '|', 'linkTracker', 'linkTrackerRegexp', '|', 'linkMultimediaPerformanceMode', 'linkMultimediaQuality', '|', 'videoReset'));\r
+ 'fieldsnames' => array('permanentLinks', 'linkBlinkTime', 'customLinkClass', 'linkTooltipManager', 'linkCornerSize', '|', 'linkTracker', 'linkTrackerRegexp', '|', 'linkMultimediaPerformanceMode', 'linkMultimediaQuality', '|', 'videoReset', 'videoBigPlay'));\r
//.\r
$this->fields['externalArchives'] = array('type' => 'freefile', 'default' => '', 'editable' => true,\r
'label' => __('Archives'), 'grade' => 3, 'fileFilter' => $swfFilter);\r
class wsPackagerPhonegap extends wsPackager {
+ protected $splashdone = array();
+
public function __construct($book_id, $vdir = null, $whole = true) {
parent::__construct($book_id, $vdir, $whole);
$this->version = 'phonegap';
unlink($this->vdir . '/www/cache.appcache');
rmdir($this->vdir . '/data');
- $this->makeCompileScripts();
+ $this->makeConfig();
}
- protected function makeCompileScripts() {
+ protected function makeConfig() {
+ $config = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" version="1.0.0" id="com.fluidbook.phonegap.' . $this->book_id . '" />');
+ $ns = $config->getNamespaces();
+ $config->addChild('name', $this->book->parametres->title);
+ $config->addChild('description');
+ $author = $config->addChild('author', 'Fluidbook');
+ $author->addAttribute('href', 'http://www.fluidbook.com');
+ $author->addAttribute('email', 'contact@fluidbook.com');
+ $preferences = array('phonegap-version' => '2.0.0',
+ 'target-device' => 'universal',
+ 'fullscreen' => 'false',
+ 'webviewbounce' => 'false',
+ 'prerendered-icon' => 'true',
+ 'stay-in-webview' => 'false',
+ 'ios-statusbarstyle' => 'black-opaque',
+ 'exit-on-suspend' => 'false');
+
+ foreach ($preferences as $k => $v) {
+ $p = $config->addChild('preference');
+ $p->addAttribute('name', $k);
+ $p->addAttribute('value', $v);
+ }
+
+ $access = $config->addChild('access');
+ $access->addAttribute('origin', '*');
+
+ $icon = $config->addChild('icon');
+ $icon->addAttribute('src', 'icon.png');
+ if ($this->theme->parametres->favicon != '') {
+ copy($this->themeRoot . '/' . $this->theme->parametres->favicon, $this->vdir . '/icon.png');
+ } else {
+ copy(WS_COMPILE_ASSETS . '/_ico/phonegap.png', $this->vdir . '/icon.png');
+ }
+
+
+ $ios = array('320x480', '640x960', '1024x768', '768x1024');
+ $android = array('ldpi' => '320x480', 'mdpi' => '640x960', 'hdpi' => '1024x768', 'xhdpi' => '1280x1920');
+
+ if (!file_exists($this->vdir . '/splash')) {
+ mkdir($this->vdir . '/splash');
+ }
+
+ foreach ($ios as $size) {
+ list($width, $height) = explode('x', $size);
+ $this->_makeSplash($width, $height);
- $projectPath = '~/Documents/PhonegapApps/Fluidbook_' . $this->book_id;
- $projectName = 'Fluidbook_' . $this->book_id;
+ $s = $config->addChild('splash');
+ $s->addAttribute('src', 'splash/' . $size . '.png', $ns['gap']);
+ $s->addAttribute('width', $width);
+ $s->addAttribute('height', $height);
+ }
- $create = '#! /bin/sh' . "\n";
- $create .='DIR="$( cd "$( dirname "$0" )" && pwd )"' . "\n";
- $create .='rm -rf ' . $projectPath . "\n";
- $create .= '~/Documents/Cordova/bin/create ' . $projectPath . ' com.fluidbook.ios.' . $this->book_id . ' ' . $projectName . "\n";
- $create .='cp -R $DIR/www ' . $projectPath . "\n";
- $create .='open ' . $projectPath . "\n";
- file_put_contents($this->vdir . '/create', $create);
- chmod($this->vdir . '/create', 0755);
+ foreach ($android as $density => $size) {
+ list($width, $height) = explode('x', $size);
+ $this->_makeSplash($width, $height);
- $build = '#! /bin/sh' . "\n";
- $build.=$projectPath . '/cordova/debug' . "\n";
- file_put_contents($this->vdir . '/build', $build);
- chmod($this->vdir . '/build', 0755);
+ $s = $config->addChild('splash', null, $ns['gap']);
+ $s->addAttribute('src', 'splash/' . $size . '.png');
+ $s->addAttribute('platform', 'android', $ns['gap']);
+ $s->addAttribute('density', $density, $ns['gap']);
+ }
+ copy($this->vdir . '/splash/768x1024.png', $this->vdir . '/splash.png');
+ file_put_contents($this->vdir . '/config.xml', $config->asXML());
+ }
+
+ protected function _makeSplash($width, $height) {
+ if (isset($this->splashdone[$width . 'x' . $height])) {
+ return;
+ }
+
+ $im = imagecreatetruecolor($width, $height);
+ // Draw Background
+ $back = imagecolorhexallocate($this->theme->parametres->backgroundColor);
+ imagefill($im, 0, 0, $back);
+ // Draw image
+ $this->_drawBackImage($im, $width, $height);
+
+ imagepng($im, $this->vdir . '/splash/' . $width . 'x' . $height . '.png');
+
+ $this->splashdone[$width . 'x' . $height] = true;
+ }
+
+ protected function _drawBackImage($im, $width, $height) {
+ if ($this->theme->parametres->backgroundImage == '') {
+ return;
+ }
+ $backimage = $this->themeRoot . '/' . $this->theme->parametres->backgroundImage;
+ if (!file_exists($backimage)) {
+ return;
+ }
+ $im2 = imagecreatefromfile($backimage);
+ $w2 = imagesx($im2);
+ $h2 = imagesy($im2);
+
+ imagecopyresampled($im, $im2, 0, 0, 0, 0, $width, $height, $w2, $h2);
+
+ imagedestroy($im2);
}
public function makePackage($zip) {
}
+function imagecolorhexallocate($im, $hex, $alpha = 0) {
+ $hex = trim($hex, '#');
+ if (strlen($hex) < 6) {
+ $diff = 6 - strlen($hex);
+ $hex = str_repeat('0', $diff) . $hex;
+ }
+ if (!preg_match("|[0-9a-fA-F]{6}|i", $hex)) {
+ return false;
+ }
+
+ for ($i = 0; $i < 3; $i++) {
+ $temp = substr($hex, 2 * $i, 2);
+ $rgb[$i] = 16 * hexdec(substr($temp, 0, 1)) + hexdec(substr($temp, 1, 1));
+ }
+
+ if (!$alpha) {
+ return imagecolorallocate($im, $rgb[0], $rgb[1], $rgb[2]);
+ } else {
+ return imagecolorallocatealpha($im, $rgb[0], $rgb[1], $rgb[2], $alpha);
+ }
+}
+
+function imagecreatefromfile($file) {
+ if (!file_exists($file)) {
+ return false;
+ }
+
+ $dim = getimagesize($file);
+ switch ($dim[2]) {
+ case 1:
+ $format = "gif";
+ break;
+ case 2:
+ $format = "jpeg";
+ break;
+ case 3:
+ $format = "png";
+ break;
+ default:;
+ } // switch
+ $function = "imagecreatefrom" . $format;
+ return $function($file);
+}
+
?>