From: vincent@cubedesigners.com Date: Tue, 18 Jun 2013 14:51:16 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=d607d62f82e61bbc2e6bd5a1b303c85ea961d87b;p=cubeextranet.git --- diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index c6b67e875..b57e596ce 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -427,6 +427,7 @@ class commonCore extends cubeCore { $db->book_collection->nom('varchar', 64, false); $db->book_collection->datas('text', 0, false); $db->book_collection->theme('text', 0, false); + $db->book_collection->settings('text', 0, false); $db->book_collection->proprietaire('integer', 0, false); // Clés $db->book_collection->primary('pk_book_collection', 'collection_id'); diff --git a/inc/config.inc.php b/inc/config.inc.php index aeae00700..051f77af2 100644 --- a/inc/config.inc.php +++ b/inc/config.inc.php @@ -15,7 +15,7 @@ define('MXMLC_PATH', '/usr/local/flex/bin/mxmlc'); define('MXMLC_PATH_3', '/usr/local/flex_sdk_3.6/bin/mxmlc'); define('AS3_SOURCES', '/home/as/sources/as/as3'); define('AS3_FLUIDBOOK_SOURCES', '/home/as/sources/fluidbook'); -define('PHONEGAP_PLUGINS','/home/as/sources/phonegap-plugins'); +define('PHONEGAP_PLUGINS', '/home/as/sources/phonegap-plugins'); define('MONITOR_PERFS', true); @@ -27,6 +27,7 @@ define('ICONS', WEBROOT . '/fluidbook/icones/'); define('WS_STATS', 'http://stats.fluidbook.com/'); define('WS_FILES', ROOT . '/fluidbook'); define('WS_BOOKS', WS_FILES . '/books'); +define('WS_COLLECTIONS', WS_FILES . '/collections'); define('WS_DOCS', WS_FILES . '/docs'); define('WS_ICONS', WS_FILES . '/icones'); define('WS_THEMES', WS_FILES . '/themes'); @@ -45,7 +46,7 @@ define('L10N', dirname(__FILE__) . '/../l10n'); define('JS_PATH', WEBROOT . '/js'); define('JS', JS_PATH); -define('MINIMIZE_JS',false); +define('MINIMIZE_JS', false); define('JOURNEE', 8); define('TAUX_JOURNALIER', 500); diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index c12c1820a..2272fec07 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -1133,6 +1133,14 @@ class wsAjax extends cubeAjax { return $res; } + public static function exportCollection($args, &$x) { + $id = $args[1]; + $os = $args[2]; + + $exporter = new wsExporter(); + $exporter->exportCollection($id, $os); + } + } ?> \ No newline at end of file diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 952ee548d..5a05a1468 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -295,7 +295,8 @@ class wsUrl { $res.='

' . __('Paramètres avancés') . '

'; $res.=''; - $res.=''; + $res.=''; + $res.=''; $res.='
' . __('Version phonegap') . '' . form::combo(array('settings[phonegap]','phonegap'), $phonegapVersions, $collection->settings['phonegap']) . '
' . __('Version phonegap') . '' . form::combo(array('settings[phonegap]', 'phonegap'), $phonegapVersions, $collection->settings['phonegap']) . '
' . __('Identifiant de l\'application') . '' . form::field(array('settings[namespace]', 'namespace'), 64, 64, $collection->settings['namespace']) . '
'; @@ -314,6 +315,9 @@ class wsUrl { $res.='

' . __('Versions') . '

'; + $res.='

' . __('Export') . '

'; + $res.='' . $core->typo->Ajouter(__('Exporter pour Android')) . ' ' . $core->typo->Ajouter(__('Exporter pour iOS')) . ''; + return $res; } diff --git a/inc/ws/Util/_common.php b/inc/ws/Util/_common.php index 78d7cbb5e..847f42242 100644 --- a/inc/ws/Util/_common.php +++ b/inc/ws/Util/_common.php @@ -10,6 +10,7 @@ $__autoload['wsSWF2HTMLMatrix'] = dirname(__FILE__) . '/class.ws.swf2html.php'; $__autoload['wsSecureSWF'] = dirname(__FILE__) . '/class.ws.secure.swf.php'; $__autoload['wsTools'] = dirname(__FILE__) . '/class.ws.tools.php'; $__autoload['wsHTML5Compiler'] = dirname(__FILE__) . '/html5/class.ws.html5.compiler.php'; +$__autoload['wsHTML5AppCompiler'] = dirname(__FILE__) . '/html5/app/class.ws.html5.app.compiler.php'; $__autoload['wsHTML5CompilerDev'] = dirname(__FILE__) . '/html5/class.ws.html5.compiler.php'; $__autoload['wsHTML5Link'] = dirname(__FILE__) . '/html5/class.ws.html5.links.php'; $__autoload['wsPDFFontExtractor'] = dirname(__FILE__) . '/fontextractor/class.ws.pdf.fontextractor.php'; diff --git a/inc/ws/Util/class.ws.exporter.php b/inc/ws/Util/class.ws.exporter.php index 9f1959a95..6cc756e5b 100644 --- a/inc/ws/Util/class.ws.exporter.php +++ b/inc/ws/Util/class.ws.exporter.php @@ -14,6 +14,41 @@ class wsExporter { public $destinationFile; public $x; + public function exportCollection($collectionId, $os) { + global $core; + $compiler = new wsHTML5AppCompiler($collectionId, $os, 'collection'); + $dir = $compiler->compile(); + + $collection = $compiler->collection; + $d = str_replace('.', '/', $collection->settings['namespace']); + $dest = $d . '/www/'; + + $this->_createProject($os, $collection->nom, $collection->settings['namespace']); + $this->_transfertPhonegap($os, $dir, $dest); + } + + protected function _createProject($os, $name, $ns) { + if ($os == 'ios') { + + $dir = '/Phonegap/Projects/' . str_replace('.', '/', $ns); + $sdir = '/mnt/macbox' . $dir; + if (file_exists($sdir)) { + return; + } + `sudo /usr/local/bin/remountmac`; + mkdir($sdir, 0777, true); + $cl = new CubeIT_CommandLine('/Phonegap/Cordova/bin/create'); + $cl->setArg('shared'); + $cl->setArg(null, $dir); + $cl->setArg(null, $ns); + $cl->setArg(null, CubeIT_Text::str2URL($name)); + $cl->setSSH('paris.cubedesigners.com', 'vincent', 'iquique', 22022); + $cl->execute(); + } elseif ($os == 'android') { + + } + } + public function export($book_id, &$x, $action = 'download', $version = 'online', $destinationDir = null, $destinationFile = null) { global $core; @@ -163,9 +198,6 @@ class wsExporter { $lftp->setArg('e', implode(';', $commandes)); $lftp->setArg(null, $u['host']); $lftp->execute(); - - fb($lftp->commande); - fb($lftp->output); } protected function _rsync($src, $dest, $erase = false, $chown = null) { @@ -199,9 +231,6 @@ class wsExporter { $cp->setArg(null, rtrim($dest, '/') . '/'); $cp->execute(); - fb($cp->commande); - fb($cp->output); - if (!is_null($chown)) { `chown -R $chown $dest`; } diff --git a/inc/ws/Util/html5/app/class.ws.html5.app.compiler.php b/inc/ws/Util/html5/app/class.ws.html5.app.compiler.php new file mode 100644 index 000000000..792c590fb --- /dev/null +++ b/inc/ws/Util/html5/app/class.ws.html5.app.compiler.php @@ -0,0 +1,97 @@ +collectionId = $collectionId; + $dao = new wsDAOCollection($core->con); + $this->collection = $dao->selectById($this->collectionId); + + if ($phonegapVersion == 'collection') { + $phonegapVersion = $this->collection->settings['phonegap']; + } + + $this->phonegapVersion = wsHTML5Compiler::getPhonegapVersion($phonegapVersion); + $this->os = $os; + + $this->vdir = $this->dir = WS_COLLECTIONS . '/app/' . $this->collectionId . '/'; + $this->wdir = WS_COLLECTIONS . '/working/' . $this->collectionId; + $this->sdir = WS_COMPILE_ASSETS . '/_html5app/'; + } + + protected function copy($s, $t) { + if (!file_exists($s)) { + return; + } + 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 copyRecursive($source, $dest) { + if (is_dir($source)) { + $iterator = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST + ); + + foreach ($iterator as $file) { + if ($file->isDir()) { + $dirtocreate = $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(); + if (!file_exists($dirtocreate)) { + mkdir($dirtocreate, 0777, true); + } + } else { + $this->copy($file, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); + } + } + } else { + $this->copy($source, $dest); + } + } + + function compile() { + $this->copyRecursive($this->sdir, $this->vdir); + + $this->writeStyle(); + $this->writeScript(); + $this->writeIndex(); + + return $this->vdir; + } + + function writeScript() { + $config = array(); + $config['id'] = $this->collectionId; + + $this->copy(WS_COMPILE_ASSETS . '/_html5/js/libs/phonegap/' . $this->phonegapVersion . '/cordova-' . $this->os . '.js', $this->vdir . '/js/cordova.js'); + file_put_contents($this->vdir . '/js/app.js', 'DATAS = ' . CubeIT_Util_Json::encode($config) . ';'); + } + + function writeIndex() { + + } + + function writeStyle() { + $c = array(); + $c[] = 'body{background-image:url("data/images/' . $this->collection->theme['back'] . '");}'; + file_put_contents($this->vdir . '/data/app.css', implode("\n", $c)); + } + +} + +?> diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 19ad74b58..406c36c73 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -143,7 +143,7 @@ class wsHTML5Compiler { function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false) { global $core; - $this->phonegapVersion = $this->getPhonegapVersion($phonegapVersion); + $this->phonegapVersion = self::getPhonegapVersion($phonegapVersion); if ($version == 'stable') { $this->assets = WS_COMPILE_ASSETS . '/_html5prod'; @@ -221,7 +221,7 @@ class wsHTML5Compiler { $this->config = cubeObject::merge($this->book->parametres->toStandardObject(), $this->theme->parametres->toStandardObject()); } - public function getPhonegapVersion($v) { + public static function getPhonegapVersion($v) { if ($v != 'latest') { return $v; }