]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 18 Jun 2013 14:51:16 +0000 (14:51 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 18 Jun 2013 14:51:16 +0000 (14:51 +0000)
inc/commons/class.common.core.php
inc/config.inc.php
inc/ws/Controlleur/class.ws.ajax.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/Util/_common.php
inc/ws/Util/class.ws.exporter.php
inc/ws/Util/html5/app/class.ws.html5.app.compiler.php [new file with mode: 0644]
inc/ws/Util/html5/class.ws.html5.compiler.php

index c6b67e8759bc7d818efe59206cdc2f516daab3f0..b57e596ceef2248599df8fae871e1a22ceeabc2e 100644 (file)
@@ -427,6 +427,7 @@ class commonCore extends cubeCore {
                $db->book_collection->nom('varchar', 64, false);\r
                $db->book_collection->datas('text', 0, false);\r
                $db->book_collection->theme('text', 0, false);\r
+               $db->book_collection->settings('text', 0, false);\r
                $db->book_collection->proprietaire('integer', 0, false);\r
                // Clés\r
                $db->book_collection->primary('pk_book_collection', 'collection_id');\r
index aeae00700d8c61614d88a31e29370d8d3d97dbb2..051f77af2f4053cab9d41ef7d9dea227f02fc0c8 100644 (file)
@@ -15,7 +15,7 @@ define('MXMLC_PATH', '/usr/local/flex/bin/mxmlc');
 define('MXMLC_PATH_3', '/usr/local/flex_sdk_3.6/bin/mxmlc');\r
 define('AS3_SOURCES', '/home/as/sources/as/as3');\r
 define('AS3_FLUIDBOOK_SOURCES', '/home/as/sources/fluidbook');\r
-define('PHONEGAP_PLUGINS','/home/as/sources/phonegap-plugins');\r
+define('PHONEGAP_PLUGINS', '/home/as/sources/phonegap-plugins');\r
 \r
 define('MONITOR_PERFS', true);\r
 \r
@@ -27,6 +27,7 @@ define('ICONS', WEBROOT . '/fluidbook/icones/');
 define('WS_STATS', 'http://stats.fluidbook.com/');\r
 define('WS_FILES', ROOT . '/fluidbook');\r
 define('WS_BOOKS', WS_FILES . '/books');\r
+define('WS_COLLECTIONS', WS_FILES . '/collections');\r
 define('WS_DOCS', WS_FILES . '/docs');\r
 define('WS_ICONS', WS_FILES . '/icones');\r
 define('WS_THEMES', WS_FILES . '/themes');\r
@@ -45,7 +46,7 @@ define('L10N', dirname(__FILE__) . '/../l10n');
 \r
 define('JS_PATH', WEBROOT . '/js');\r
 define('JS', JS_PATH);\r
-define('MINIMIZE_JS',false);\r
+define('MINIMIZE_JS', false);\r
 \r
 define('JOURNEE', 8);\r
 define('TAUX_JOURNALIER', 500);\r
index c12c1820a899cbd97cf3bda2451bec710ff8dc98..2272fec07735d1f41ab1230eddcec2c759f7318f 100644 (file)
@@ -1133,6 +1133,14 @@ class wsAjax extends cubeAjax {
                return $res;\r
        }\r
 \r
+       public static function exportCollection($args, &$x) {\r
+               $id = $args[1];\r
+               $os = $args[2];\r
+\r
+               $exporter = new wsExporter();\r
+               $exporter->exportCollection($id, $os);\r
+       }\r
+\r
 }\r
 \r
 ?>
\ No newline at end of file
index 952ee548de2fdb124bf85a92f3dc71f6bd9c6975..5a05a146833331e13ed2dea2c425c1ba32e6c7fa 100644 (file)
@@ -295,7 +295,8 @@ class wsUrl {
 \r
                $res.='<h3>' . __('Paramètres avancés') . '</h3>';\r
                $res.='<table class="max">';\r
-               $res.='<tr><td class="min nowrap">' . __('Version phonegap') . '</td><td>' . form::combo(array('settings[phonegap]','phonegap'), $phonegapVersions, $collection->settings['phonegap']) . '</td></tr>';\r
+               $res.='<tr><td class="min nowrap">' . __('Version phonegap') . '</td><td>' . form::combo(array('settings[phonegap]', 'phonegap'), $phonegapVersions, $collection->settings['phonegap']) . '</td></tr>';\r
+               $res.='<tr><td class="min nowrap">' . __('Identifiant de l\'application') . '</td><td>' . form::field(array('settings[namespace]', 'namespace'), 64, 64, $collection->settings['namespace']) . '</td></tr>';\r
                $res.='</table>';\r
 \r
 \r
@@ -314,6 +315,9 @@ class wsUrl {
                $res.='<h3>' . __('Versions') . '</h3>';\r
 \r
 \r
+               $res.='<h3>' . __('Export') . '</h3>';\r
+               $res.='<a href="#" class="right ajax" rel="exportCollection/' . $collection->collection_id . '/android">' . $core->typo->Ajouter(__('Exporter pour Android')) . '</a> <a href="#" class="right ajax" rel="exportCollection/' . $collection->collection_id . '/ios">' . $core->typo->Ajouter(__('Exporter pour iOS')) . '</a>';\r
+\r
                return $res;\r
        }\r
 \r
index 78d7cbb5e28e7e49eb40bd46aed947e7b6418c92..847f42242945bb0ffb78a8ad3607b9ccf0f74c97 100644 (file)
@@ -10,6 +10,7 @@ $__autoload['wsSWF2HTMLMatrix'] = dirname(__FILE__) . '/class.ws.swf2html.php';
 $__autoload['wsSecureSWF'] = dirname(__FILE__) . '/class.ws.secure.swf.php';\r
 $__autoload['wsTools'] = dirname(__FILE__) . '/class.ws.tools.php';\r
 $__autoload['wsHTML5Compiler'] = dirname(__FILE__) . '/html5/class.ws.html5.compiler.php';\r
+$__autoload['wsHTML5AppCompiler'] = dirname(__FILE__) . '/html5/app/class.ws.html5.app.compiler.php';\r
 $__autoload['wsHTML5CompilerDev'] = dirname(__FILE__) . '/html5/class.ws.html5.compiler.php';\r
 $__autoload['wsHTML5Link'] = dirname(__FILE__) . '/html5/class.ws.html5.links.php';\r
 $__autoload['wsPDFFontExtractor'] = dirname(__FILE__) . '/fontextractor/class.ws.pdf.fontextractor.php';\r
index 9f1959a959ac8195d079dbd7d910f1c2a1fe351a..6cc756e5b83f8054a5fd9ab0c1676da930dc2378 100644 (file)
@@ -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 (file)
index 0000000..792c590
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+
+class wsHTML5AppCompiler {
+
+       public $collectionId, $collection;
+       public $assets;
+       public $dir, $vdir, $wdir, $sdir;
+       public $os;
+       public $phonegapVersion;
+
+       public function __construct($collectionId, $os, $phonegapVersion = 'latest') {
+
+               global $core;
+
+               $this->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));
+       }
+
+}
+
+?>
index 19ad74b58b19a9ecfb5c2e6989e0f3da3f74fde3..406c36c730997b78d6db822a0b7ba2839d3b5e64 100644 (file)
@@ -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;
                }