From 2e2b729b0fda12355d5324ad696c7b0718cc487d Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 7 Nov 2012 14:30:45 +0000 Subject: [PATCH] --- inc/commons/class.common.core.php | 1 + inc/commons/class.common.tools.php | 2 +- inc/ws/Controlleur/class.ws.ajax.php | 21 ++++++++++- inc/ws/Controlleur/class.ws.url.php | 4 ++ inc/ws/DAO/class.ws.dao.book.php | 1 + inc/ws/Metier/class.ws.book.php | 1 + inc/ws/Util/class.ws.tools.php | 12 +++++- inc/ws/Util/html5/class.ws.html5.compiler.php | 37 +++++++++++-------- inc/ws/Util/html5/class.ws.html5.links.php | 13 +++++-- .../Util/packager/class.ws.packager.html.php | 3 +- .../packager/class.ws.packager.phonegap.php | 8 ++-- inc/ws/Util/packager/class.ws.packager.php | 20 +++++++--- inc/ws/Util/packager/class.ws.packager.v1.php | 6 +-- .../packager/class.ws.packager.win.inst.php | 2 +- 14 files changed, 92 insertions(+), 39 deletions(-) diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index 2efe43ba7..9ce5c9055 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -379,6 +379,7 @@ class commonCore extends cubeCore { $db->books->composition_update('integer', 0, false); $db->books->dir_references('varchar', 256, false); $db->books->dir_hosting('varchar', 256, false); + $db->books->dir_macbook_phonegap_ios('varchar', 256, false); $db->books->lucene_time('integer', 0, false); // Clés $db->books->primary('pk_books', 'book_id'); diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index 72fd7c426..f7b816c44 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -539,7 +539,7 @@ class commonTools { header('Content-type: application/json'); ob_end_clean(); - $geocoder = new CubeIT_Services_Google_Geocoder(); + $geocoder = new CubeIT_Services_Google_Geocoder(864000, false); $r = $geocoder->geocode(urldecode($_GET['address']), $_GET['region'], true); echo CubeIT_Util_Json::encode($r); exit; diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index 62ba48614..ae0d64672 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -253,6 +253,10 @@ class wsAjax extends cubeAjax { if ($book->parametres->version == 1) { $version = 'v1'; } + if (stristr($server, 'phonegap')) { + $version = 'phonegap'; + } + fb(time(), 'start making package'); $package = wsPackager::package($book_id, $version, false); @@ -263,6 +267,9 @@ class wsAjax extends cubeAjax { } else if ($server == 'hosting') { $root = '/home/fluidbook/hosting'; $url = 'http://hosting.fluidbook.com/'; + } else if ($server == 'macbook_phonegap_ios') { + $root = '/mnt/macbook/Phonegap/Projects/'; + $url = null; } $e = explode('/', $_POST['dir']); @@ -282,17 +289,27 @@ class wsAjax extends cubeAjax { mkdir($finalDir, 0777, true); } - $cp = new cubeCommandLine('cp'); + /** --del -r -z -v * */ + $cp = new cubeCommandLine('rsync'); $cp->setPath(CONVERTER_PATH); + $cp->setArg('del'); + $cp->setArg('t'); $cp->setArg('r'); + $cp->setArg('z'); + $cp->setArg('v'); $cp->setArg(null, $package . '*'); $cp->setArg(null, $finalDir); $cp->execute(); + fb($cp->commande); + fb($cp->output); + fb(time(), 'end transfert'); $x->addClosePopup(); - $x->addTruePopup($url . $dir . '/'); + if (!is_null($url)) { + $x->addTruePopup($url . $dir . '/'); + } } public static function statusBook($args, &$x) { diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 58a1cf3ff..91e33f46b 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -201,6 +201,7 @@ class wsUrl { $versions = array(); $versions['hosting'] = array('title' => __("Le serveur d'hébergement"), 'icon' => cubeMedia::silk('server_go.png')); $versions['references'] = array('title' => __("L'espace références"), 'icon' => cubeMedia::silk('server_add.png')); + $versions['macbook_phonegap_ios'] = array('title' => __("Projet Phonegap IOS"), 'icon' => cubeMedia::silk('server_add.png')); foreach ($versions as $k => $v) { $res .= '
  • ' . $v['icon'] . $v['title'] . '
  • '; @@ -1013,6 +1014,9 @@ html{height:100%}' . "\n"; } elseif ($server == 'hosting') { $s = __("Serveur d'hébergement"); $dir = $book->dir_hosting; + } elseif ($server == 'macbook_phonegap_ios') { + $s = __("Projet Phonegap iOS"); + $dir = $book->dir_macbook_phonegap_ios; } if ($dir == '') { diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index e1756fc04..7b6b3b7f2 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -44,6 +44,7 @@ class wsDAOBook extends commonDAO { $book->composition_update = $r->composition_update; $book->dir_references = $r->dir_references; $book->dir_hosting = $r->dir_hosting; + $book->dir_macbook_phonegap_ios = $r->dir_macbook_phonegap_ios; return $book; } diff --git a/inc/ws/Metier/class.ws.book.php b/inc/ws/Metier/class.ws.book.php index 110eb45a1..043c8f688 100644 --- a/inc/ws/Metier/class.ws.book.php +++ b/inc/ws/Metier/class.ws.book.php @@ -34,6 +34,7 @@ class wsBook extends cubeMetier { protected $version; protected $dir_references; protected $dir_hosting; + protected $dir_macbook_phonegap_ios; public function __get($varname) { if (!property_exists($this, $varname)) { diff --git a/inc/ws/Util/class.ws.tools.php b/inc/ws/Util/class.ws.tools.php index c1749b5ee..08e3486fb 100644 --- a/inc/ws/Util/class.ws.tools.php +++ b/inc/ws/Util/class.ws.tools.php @@ -41,7 +41,7 @@ class wsTools { $svg = str_replace('$colorize', '#' . $color, $svg); file_put_contents($svgColorized, $svg); } - copy($svgColorized, $dest . '/' . $icon . '.svg'); + self::copy($svgColorized, $dest . '/' . $icon . '.svg'); // PNG $png = $dirColorized . '/' . $icon . '.png'; @@ -62,7 +62,15 @@ class wsTools { $batik->setManualArg($svgColorized); $batik->execute(); } - copy($png, $dest . '/' . $icon . '.png'); + self::copy($png, $dest . '/' . $icon . '.png'); + } + + public static function copy($source, $dest) { + if(!file_exists($source)){ + return; + } + copy($source, $dest); + touch($dest, filemtime($source)); } } diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 532a226a7..44e7dabd1 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -70,6 +70,7 @@ class wsHTML5Compiler { 'js/widget.js' ); public $pluginCSS = array(); + public $pluginJs = array(); protected $cssX = array(); protected $cssY = array(); protected $cssWidths = array(); @@ -90,7 +91,7 @@ class wsHTML5Compiler { protected $pages; protected $theme; protected $version; - protected $book_id; + public $book_id; protected $themeRoot; /** @@ -224,15 +225,15 @@ class wsHTML5Compiler { // Copy style folder $from = $this->assets . '/style'; $to = $this->vdir; - `cp -r $from $to`; + `cp -p -r $from $to`; // Copy images folder $from = $this->assets . '/images'; - `cp -r $from $to`; + `cp -p -r $from $to`; // Copy swf if (file_exists($this->vdir . '/swf')) { - copy($this->assets . '/swf/video.swf', $this->vdir . '/swf/video.swf'); + $this->copy($this->assets . '/swf/video.swf', $this->vdir . '/swf/video.swf'); } $this->loadPlugins(); @@ -270,7 +271,7 @@ class wsHTML5Compiler { if (file_exists($dir . '/plugin.js')) { $f = $d . '/plugin.js'; - $this->jsFiles[] = $f; + $this->pluginJs[] = $f; $this->copy($dir . '/plugin.js', $this->vdir . '/' . $f); } if (file_exists($dir . '/plugin.css')) { @@ -286,17 +287,18 @@ class wsHTML5Compiler { } protected function getVideosFormats($poster = true) { - if ($this->phoenag == 'ios') { + if (!$this->phonegap) { + $res = array('mp4', 'ogv', 'webm', 'flv'); + } elseif ($this->phonegap == 'ios') { $res = array('mp4'); } else if ($this->phonegap == 'android') { $res = array('ogv', 'webm'); } - if (!$this->phonegap) { - $res[] = 'flv'; - } + if ($poster) { $res[] = 'jpg'; } + return $res; } protected function writeCache() { @@ -435,6 +437,9 @@ class wsHTML5Compiler { } $script .= '' . "\n"; $script .= '' . "\n"; + foreach ($this->pluginJs as $p) { + $script .= '' . "\n"; + } $description = ''; if ($this->book->parametres->seoDescription) { @@ -522,7 +527,7 @@ class wsHTML5Compiler { $l = explode(',', $l1); $flag = $l[1]; - copy(cubeMedia::getFlagFile($flag), $flagsDir . '/' . $flag . '.png'); + $this->copy(cubeMedia::getFlagFile($flag), $flagsDir . '/' . $flag . '.png'); $l[3] = cubeText::ucfirst($iso[$l[0]]); $m[] = implode(',', $l); } @@ -533,7 +538,7 @@ class wsHTML5Compiler { protected function writeExtras() { if ($this->theme->parametres->afterSearch != '') { - copy($this->themeRoot . '/' . $this->theme->parametres->afterSearch, $this->vdir . '/data/images/' . $this->theme->parametres->afterSearch); + $this->copy($this->themeRoot . '/' . $this->theme->parametres->afterSearch, $this->vdir . '/data/images/' . $this->theme->parametres->afterSearch); } } @@ -715,12 +720,12 @@ class wsHTML5Compiler { if (file_exists($t) && filemtime($t) >= filemtime($s) && filesize($s) == filesize($t)) { return; } - if (!file_exists(dirname($t))) { mkdir(dirname($t), 0777, true); } copy($s, $t); + touch($t, filemtime($s)); } protected function writeCSS($file, $links) { @@ -810,7 +815,7 @@ class wsHTML5Compiler { break; } if ($this->theme->parametres->backgroundImage != '') { - copy($this->themeRoot . '/' . $this->theme->parametres->backgroundImage, $this->vdir . '/data/images/' . $this->theme->parametres->backgroundImage); + $this->copy($this->themeRoot . '/' . $this->theme->parametres->backgroundImage, $this->vdir . '/data/images/' . $this->theme->parametres->backgroundImage); $body.='background-image:url(../images/' . $this->theme->parametres->backgroundImage . ');'; $body.='background-position:'; @@ -848,7 +853,7 @@ class wsHTML5Compiler { $header.='height:' . $this->theme->parametres->menuHeight . 'px;'; $header.='background-color:' . self::colorToCSS($this->theme->parametres->menuColor) . ';'; if ($this->theme->parametres->menuImage != '') { - copy($this->themeRoot . '/' . $this->theme->parametres->menuImage, $this->vdir . '/data/images/' . $this->theme->parametres->menuImage); + $this->copy($this->themeRoot . '/' . $this->theme->parametres->menuImage, $this->vdir . '/data/images/' . $this->theme->parametres->menuImage); $header.='background-image:url(../images/' . $this->theme->parametres->menuImage . ');'; $header.='background-repeat:no-repeat;'; $header.='background-size:100% ' . $this->theme->parametres->menuHeight . 'px;'; @@ -863,7 +868,7 @@ class wsHTML5Compiler { // Logo $logo = '#logo{'; if ($this->theme->parametres->logo) { - copy($this->themeRoot . '/' . $this->theme->parametres->logo, $this->vdir . '/data/images/' . $this->theme->parametres->logo); + $this->copy($this->themeRoot . '/' . $this->theme->parametres->logo, $this->vdir . '/data/images/' . $this->theme->parametres->logo); $dim = getimagesize($this->vdir . '/data/images/' . $this->theme->parametres->logo); $logo.='background-image:url(../images/' . $this->theme->parametres->logo . ');width:' . $dim[0] . 'px;height:' . $dim[1] . 'px;'; } @@ -955,7 +960,7 @@ class wsHTML5Compiler { if (file_exists($d) && filemtime($d) >= filemtime($s) && filesize($d) == filesize($s)) { continue; } - copy($s, $d); + $this->copy($s, $d); } } } diff --git a/inc/ws/Util/html5/class.ws.html5.links.php b/inc/ws/Util/html5/class.ws.html5.links.php index 7a270c03f..a243977c4 100644 --- a/inc/ws/Util/html5/class.ws.html5.links.php +++ b/inc/ws/Util/html5/class.ws.html5.links.php @@ -103,7 +103,7 @@ class wsHTML5Link { public function getCSSContainer() { - + if (!($this instanceof contentLink) && $this->page % 2 == 1) { $this->page--; $this->left+=$this->compiler->width; @@ -233,10 +233,10 @@ class videoLink extends wsHTML5Link { $w = round($this->width * $this->compiler->getCssScale()); $h = round($this->height * $this->compiler->getCssScale()); - return self::makeVideoTag($this, $w, $h); + return self::makeVideoTag($this, $w, $h, $this->compiler); } - public static function makeVideoTag($linkDatas, $w = null, $h = null) { + public static function makeVideoTag($linkDatas, $w = null, $h = null, $compiler = null) { $file = $linkDatas->to; $e = explode('.', $file); $ext = array_pop($e); @@ -250,6 +250,11 @@ class videoLink extends wsHTML5Link { $res = '
    book_id . '/' . $basename . '.jpg'; + $dim = getimagesize($path); + $res.='data-width="' . $dim[0] . '" data-height="' . $dim[1] . '" '; } $res.=' data-autoplay="' . $autoplay . '"'; $res.=' data-controls="' . $controls . '"'; @@ -275,7 +280,7 @@ class videoPopupLink extends normalLink { } public function getAdditionnalContent() { - return ' data-video="' . rawurlencode(videoLink::makeVideoTag($this)) . '" '; + return ' data-video="' . rawurlencode(videoLink::makeVideoTag($this, null, null, $this->compiler)) . '" '; } } diff --git a/inc/ws/Util/packager/class.ws.packager.html.php b/inc/ws/Util/packager/class.ws.packager.html.php index 538694e4b..0554ac599 100644 --- a/inc/ws/Util/packager/class.ws.packager.html.php +++ b/inc/ws/Util/packager/class.ws.packager.html.php @@ -192,13 +192,14 @@ class wsPackagerHTML extends wsPackager { $cp = new cubeCommandLine('cp'); $cp->setPath(CONVERTER_PATH); $cp->setArg('r'); + $cp->setArg('p'); $cp->setArg(null, WS_BOOKS . '/html5/' . $this->book_id . '/*'); $cp->setArg(null, $dest); $cp->execute(); $filesToAdd = array('.htaccess', 'web.config'); foreach ($filesToAdd as $f) { - copy(WS_COMPILE_ASSETS . '/_html5/' . $f, $dest . '/' . $f); + $this->copy(WS_COMPILE_ASSETS . '/_html5/' . $f, $dest . '/' . $f); } $filesToDelete = array('indext.html', 'indexu.html', 'data/datas.js'); diff --git a/inc/ws/Util/packager/class.ws.packager.phonegap.php b/inc/ws/Util/packager/class.ws.packager.phonegap.php index 2d310b928..03415cd2a 100644 --- a/inc/ws/Util/packager/class.ws.packager.phonegap.php +++ b/inc/ws/Util/packager/class.ws.packager.phonegap.php @@ -19,7 +19,6 @@ class wsPackagerPhonegap extends wsPackager { unlink($this->vdir . '/indexu.html'); unlink($this->vdir . '/widget.html'); unlink($this->vdir . '/cache.appcache'); - //rmdir($this->vdir . '/data'); $this->resources = $this->vdir . '/Resources'; @@ -88,9 +87,10 @@ class wsPackagerPhonegap extends wsPackager { public function makePackage($zip) { parent::makePackage($zip); - $res = $this->zip(); - $this->postPackage(); - return $res; + if ($zip) { + return $this->zip(); + } + return $this->vdir; } } diff --git a/inc/ws/Util/packager/class.ws.packager.php b/inc/ws/Util/packager/class.ws.packager.php index c6be5fc57..8e9b84afb 100644 --- a/inc/ws/Util/packager/class.ws.packager.php +++ b/inc/ws/Util/packager/class.ws.packager.php @@ -91,6 +91,7 @@ class wsPackager { // Copie du FB vers un répertoire temporaire $cp = new cubeCommandLine('cp'); $cp->setArg('R'); + $cp->setArg('p'); $cp->setArg(null, WS_BOOKS . '/final/' . $this->book->book_id . '/*'); $cp->setArg(null, $this->vdir); $cp->execute(); @@ -104,10 +105,11 @@ class wsPackager { $s = WS_COMPILE_ASSETS . '/' . $source; if (is_file($s) && !file_exists($this->vdir . $dest)) { - copy($s, $this->vdir . $dest); + $this->copy($s, $this->vdir . $dest); } else if (is_dir($s)) { $cp = new cubeCommandLine('cp'); $cp->setArg('R'); + $cp->setArg('p'); $cp->setArg(null, $s); $cp->setArg(null, $this->vdir); $cp->execute(); @@ -166,11 +168,11 @@ class wsPackager { $zip->setArg('u'); $zip->setArg(null, '.'); $zip->execute(); - - if(!file_exists(WS_FILES.'/packager/download')){ - mkdir(WS_FILES.'/packager/download',0777,true); + + if (!file_exists(WS_FILES . '/packager/download')) { + mkdir(WS_FILES . '/packager/download', 0777, true); } - + fb($zip->commande); fb($zip->output); @@ -218,6 +220,14 @@ class wsPackager { } } + public function copy($source, $dest) { + if(!file_exists($source)){ + return; + } + copy($source, $dest); + touch($dest, filemtime($source)); + } + } ?> \ No newline at end of file diff --git a/inc/ws/Util/packager/class.ws.packager.v1.php b/inc/ws/Util/packager/class.ws.packager.v1.php index ee89e31b3..9090e2a7a 100644 --- a/inc/ws/Util/packager/class.ws.packager.v1.php +++ b/inc/ws/Util/packager/class.ws.packager.v1.php @@ -42,7 +42,7 @@ class wsPackagerV1 extends wsPackagerHTML { protected function copyThumbnails() { foreach ($this->pages as $book_page => $infos) { - copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/p' . $book_page . '.jpg'); + $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/p' . $book_page . '.jpg'); } } @@ -248,7 +248,7 @@ class wsPackagerV1 extends wsPackagerHTML { if (!file_exists($src) || !is_file($src)) { $src = WS_THEMES . '/spacer.png'; } - copy($src, $images . '/' . $file); + $this->copy($src, $images . '/' . $file); } $cp = new cubeCommandLine('cp'); @@ -278,7 +278,7 @@ class wsPackagerV1 extends wsPackagerHTML { $src = $this->workingDir . '/' . $file; if (file_exists($src) && is_file($src)) { - $res= copy($src, $dir . $file); + $res= $this->copy($src, $dir . $file); return $res; } return false; diff --git a/inc/ws/Util/packager/class.ws.packager.win.inst.php b/inc/ws/Util/packager/class.ws.packager.win.inst.php index 886ff7dd2..b9805857d 100644 --- a/inc/ws/Util/packager/class.ws.packager.win.inst.php +++ b/inc/ws/Util/packager/class.ws.packager.win.inst.php @@ -39,7 +39,7 @@ class wsPackagerWinINST extends wsPackagerWinEXE { $nsi = str_replace('$output', $this->getPathBase('exe'), $nsi); $favicon = $this->vdir . '/data/fluidbook.ico'; if ($this->theme->parametres->favicon == '') { - copy(WS_COMPILE_ASSETS . '/fluidbook.ico',$favicon); + $this->copy(WS_COMPILE_ASSETS . '/fluidbook.ico',$favicon); } $nsi = str_replace('$favicon', $favicon, $nsi); -- 2.39.5