]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 21 Jun 2013 16:55:33 +0000 (16:55 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 21 Jun 2013 16:55:33 +0000 (16:55 +0000)
14 files changed:
.htaccess
fluidbook/back.jpg [new file with mode: 0644]
inc/commons/class.common.tools.php
inc/ws/Controlleur/class.ws.ajax.php
inc/ws/Controlleur/class.ws.services.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/Util/class.ws.exporter.php
inc/ws/Util/html5/app/class.ws.html5.app.compiler.php
inc/ws/Util/html5/class.ws.html5.compiler.php
inc/ws/Util/packager/class.ws.packager.phonegap.php
inc/ws/Util/packager/class.ws.packager.php
js/common.js
js/ws.js
style/ws/style.css

index fcd44da2450b8e413682e65ccbd9992977955864..e559b86a55ccb21a6edd5a0a8ccbe41f5a227155 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -14,6 +14,20 @@ AddCharset UTF-8 log
        Header set Access-Control-Allow-Origin "*"\r
 </IfModule>\r
 \r
+<IfModule mod_deflate.c>\r
+       SetOutputFilter DEFLATE\r
+       SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|swf|zip|exe|mp3|f4v|ogv|ogg|ogm|webm|mp4|flv|gz|pdf|swc)$ no-gzip dont-vary\r
+       \r
+       <IfModule mod_headers.c>\r
+               Header append Vary User-Agent\r
+       </IfModule>\r
+       \r
+       BrowserMatch ^Mozilla/4 gzip-only-text/html\r
+       BrowserMatch ^Mozilla/4\.0[678] no-gzip\r
+       BrowserMatch \bMSIE !no-gzip !gzip-only-text/html\r
+</IfModule>\r
+\r
+\r
 <IfModule mod_rewrite.c>\r
        RewriteEngine on\r
        RewriteBase /\r
diff --git a/fluidbook/back.jpg b/fluidbook/back.jpg
new file mode 100644 (file)
index 0000000..809d9b3
Binary files /dev/null and b/fluidbook/back.jpg differ
index 9eb896a16fff6e3c6a7a823c5bcb5bdea7193e33..daebf438cf7baa93e7d4c722a60cdfaca329c5a9 100644 (file)
@@ -836,6 +836,27 @@ class commonTools {
                }
        }
 
+       public static function copyWsAssets() {
+               commonDroits::min(5);
+               global $core;
+               $res = commonPage::barre();
+               $res .= commonPage::tMain();
+               $res .= commonPage::bh();
+               $res.='<form id="copywsassets" action="copywsassets" method="post">';
+               $res.='<table class="liste">';
+               $res.='<tr><th><strong>' . __("Copie de fichiers entre deux fluidbook") . '</strong></th></tr>';
+               $res.='<tr><td>Fluidbook source</td><td>' . form::field('source', 5, 6) . '</td></tr>';
+               $res.='<tr><td>Fluidbook destination</td><td>' . form::field('dest', 5, 6) . '</td></tr>';
+               $res.='<tr><td>Fichiers à transférer</td><td id="f">Entrez le numéro du fluidbook source pour sélectionner les fichiers à transférer</td></tr>';
+               $res.='<tr><td class="right" colspan="2"><a href="#" class="submit">' . $core->typo->BoutonOK(__('Copier')) . '</a></td></td>';
+               $res.='</table>';
+               $res.='</form>';
+               $res .= '</div>';
+               $res .= commonPage::bf();
+               $res .= commonPage::bMain();
+               return $res;
+       }
+
        protected static function searchGoogle($q, $cx, $key) {
                global $core;
 
index b2ea17c6b8fb61c18f07b375f79243cf321d1576..f8b19ef687c0d26fa59f713fecf529d1aec5f36e 100644 (file)
@@ -24,7 +24,7 @@ class wsAjax extends cubeAjax {
        public static function saveClient($args, &$x) {\r
                global $core;\r
                $dao = new commonDAOEntreprise($core->con);\r
-               // Creation de l'entreprise\r
+// Creation de l'entreprise\r
                if ($_POST['entreprise_id'] == 'new') {\r
                        if (!isset($_POST['ws_admin']) || !$_POST['ws_admin']) {\r
                                $_POST['ws_admin'] = $core->user->utilisateur_id;\r
@@ -35,7 +35,7 @@ class wsAjax extends cubeAjax {
                        $_POST['ws_admin'] = $core->user->utilisateur_id;\r
                }\r
                $entreprise = $dao->sauve($_POST);\r
-               // Si c'est une nouvelle entreprise, on crée également le contact\r
+// Si c'est une nouvelle entreprise, on crée également le contact\r
                if ($_POST['entreprise_id'] == 'new') {\r
                        $data = $_POST['contact'];\r
                        $data['entreprise'] = $entreprise->entreprise_id;\r
@@ -231,10 +231,12 @@ class wsAjax extends cubeAjax {
                        if (isset($_FILES[$t]) && !$_FILES[$t]['error']) {\r
                                $ext = CubeIT_Files::getExtension($_FILES[$t]['name']);\r
                                move_uploaded_file($_FILES[$t]['tmp_name'], $wdir . '/' . $t . '.' . $ext);\r
-                               $_POST['theme'][$t] = $t . '.' . $ext;\r
+                               $save['theme'][$t] = $t . '.' . $ext;\r
                        }\r
                }\r
 \r
+\r
+\r
                foreach ($_POST['group'] as $gid => $group) {\r
                        if ($gid && $gid == 'new_') {\r
                                continue;\r
@@ -450,13 +452,13 @@ class wsAjax extends cubeAjax {
                if (!self::valideDemandeDevis($x)) {\r
                        return;\r
                }\r
-               // L'utilisateur est-il déjà dans la base ?\r
+// L'utilisateur est-il déjà dans la base ?\r
                $daoUtilisateur = new commonDAOUtilisateur($core->con);\r
                $utilisateur = $daoUtilisateur->selectByEmail($_POST['email']);\r
                if ($utilisateur != null) {\r
                        $utilisateur_id = $utilisateur->utilisateur_id;\r
                } else {\r
-                       // Création de l'entreprise\r
+// Création de l'entreprise\r
                        $daoEntreprise = new commonDAOEntreprise($core->con);\r
                        $datas = array();\r
                        $datas['entreprise_id'] = 'new';\r
@@ -474,7 +476,7 @@ class wsAjax extends cubeAjax {
                        $datas['ws_grade'] = 1;\r
                        $datas['ws_admin'] = 1;\r
                        $entreprise = $daoEntreprise->sauve($datas);\r
-                       // Création de l'utilisateur\r
+// Création de l'utilisateur\r
                        $datas = array();\r
                        $datas['utilisateur_id'] = 'new';\r
                        $datas['prenom'] = $_POST['prenom'];\r
@@ -574,7 +576,7 @@ class wsAjax extends cubeAjax {
                        $_POST['site'] = $_POST['site_internet'];\r
                }\r
                file_put_contents(ROOT . '/cache/demandeDevis.txt', print_r($_POST, true));\r
-               // Validation des champs de formulaires\r
+// Validation des champs de formulaires\r
                $ok = true;\r
                return $ok;\r
        }\r
@@ -643,14 +645,14 @@ class wsAjax extends cubeAjax {
                } elseif ($demande->status > 1) {\r
                        $res = __("Cette demande est actuellement en cours de traitement");\r
                } else {\r
-                       // On place la demande comme en cours d'édition\r
+// On place la demande comme en cours d'édition\r
                        $dao->setAdministrateur($demande->demande_id, $core->user->utilisateur_id);\r
 \r
-                       // On vérifie que l'utilisateur n'est pas déjà géré par un revendeur\r
+// On vérifie que l'utilisateur n'est pas déjà géré par un revendeur\r
                        $demandeur = $daoUtilisateur->selectById($demande->utilisateur, 'utilisateurs_entreprise');\r
                        $administrateurs = $daoUtilisateur->selectWSAdministrateursId();\r
                        if (!is_null($demandeur->ws_admin) && !in_array($demandeur->ws_admin, $administrateurs)) {\r
-                               // Si déjà géré par un revendeur\r
+// Si déjà géré par un revendeur\r
                                $revendeur = $daoUtilisateur->selectById($demandeur->ws_admin, 'utilisateurs_entreprise');\r
                                $actions[__('Je confie la demande à') . ' ' . $revendeur->rs . ' (' . $revendeur->prenom . ' ' . $revendeur->nom . ')'] = $demandeur->ws_admin;\r
                        } else {\r
@@ -1053,7 +1055,7 @@ class wsAjax extends cubeAjax {
 \r
                $env = Zend_Mobile_Push_Apns::SERVER_SANDBOX_URI;\r
 \r
-               // Notifications\r
+// Notifications\r
 \r
                $apns = new Zend_Mobile_Push_Apns();\r
                if ($env == Zend_Mobile_Push_Apns::SERVER_SANDBOX_URI) {\r
@@ -1077,6 +1079,108 @@ class wsAjax extends cubeAjax {
                $apns->close();\r
        }\r
 \r
-}\r
+       public function fluidbookAssets($args, &$x) {\r
+               $id = $args[1];\r
+               if (!$id) {\r
+                       $c = __('Entrez le numéro du fluidbook source pour sélectionner les fichiers à transférer');\r
+               } else {\r
+                       $dr = opendir(WS_BOOKS . '/working/' . $id);\r
+                       $files = array();\r
+                       while ($f = readdir($dr)) {\r
+                               if ($f == '.' || $f == '..') {\r
+                                       continue;\r
+                               }\r
+\r
+                               $files[$f] = $f;\r
+                               $checked[] = $f;\r
+                       }\r
+\r
+                       ksort($files);\r
+\r
+                       if (!count($files)) {\r
+                               $c = __('Aucun fichier à transférer');\r
+                       } else {\r
+                               $c = cubeForm::checkMultiple('files', $files, count($files), $checked);\r
+                       }\r
+               }\r
+\r
+               $x->addContent('f', $c);\r
+       }\r
+\r
+       public function copywsassets($args, &$x) {\r
+               if (!isset($_POST['files']) || !count($_POST['files'])) {\r
+                       $x->addAlert(__('Aucun fichier sélectionné'));\r
+                       return;\r
+               } elseif (!isset($_POST['dest']) || !$_POST['dest']) {\r
+                       $x->addAlert(__('Destination invalide'));\r
+                       return;\r
+               }\r
+\r
+               $d = WS_BOOKS . '/working/' . $_POST['dest'];\r
+               if (!file_exists($d)) {\r
+                       mkdir($d, 0777, true);\r
+               }\r
+               $s = WS_BOOKS . '/working/' . $_POST['source'];\r
+\r
+               foreach ($_POST['files'] as $f) {\r
+                       copy($s . '/' . $f, $d . '/' . $f);\r
+               }\r
+               $x->addAlert(__('Copie effectuée'));\r
+       }\r
+\r
+       public static function collectionVersionCreate($args, &$x) {\r
+               global $core;\r
+               $id = $args[1];\r
 \r
+               $compiler = new wsHTML5AppCompiler($id);\r
+               $time = $compiler->createVersion();\r
+\r
+               file_put_contents(WS_COLLECTIONS . '/versions/' . $id . '/' . $time . '/composition.json', json_encode($compiler->collection->datas));\r
+\r
+               $c = $core->con->openCursor('book_collection_compile');\r
+               $c->collection_id = $id;\r
+               $c->compile_date = $time;\r
+               $c->online = 0;\r
+               $c->insert();\r
+\r
+               $x->addReload();\r
+       }\r
+\r
+       public static function collectionVersionPublish($args, &$x) {\r
+               global $core;\r
+\r
+               $id = $args[1];\r
+               $date = $args[2];\r
+\r
+               $c = $core->con->openCursor('book_collection_compile');\r
+               $c->online = 0;\r
+               $c->update('WHERE collection_id=\'' . $core->con->escape($id) . '\' AND online=1');\r
+\r
+               $c = $core->con->openCursor('book_collection_compile');\r
+               $c->online = 1;\r
+               $c->update('WHERE collection_id=\'' . $core->con->escape($id) . '\' AND compile_date=\'' . $core->con->escape($date) . '\'');\r
+\r
+               $cache = WS_COLLECTIONS . '/ws/' . $id . '.json';\r
+               if (file_exists($cache)) {\r
+                       unlink($cache);\r
+               }\r
+\r
+               $x->addReload();\r
+       }\r
+\r
+       public static function collectionVersionDelete($args, &$x) {\r
+               global $core;\r
+\r
+               $id = $args[1];\r
+               $date = $args[2];\r
+\r
+               if ($id && $date) {\r
+                       $d = WS_COLLECTIONS . '/versions/' . $id . '/' . $date;\r
+                       `rm -rf $d`;\r
+                       $core->con->execute('DELETE FROM book_collection_compile WHERE collection_id=\'' . $core->con->escape($id) . '\' AND compile_date=\'' . $core->con->escape($date) . '\'');\r
+               }\r
+               $x->addReload();\r
+       }\r
+\r
+}\r
 ?>
\ No newline at end of file
index a4b65a2997d0a8b2bb5154a5ecfe2f525dbde57d..d91e7757d48eb4c0488ab701e14924994883dc54 100644 (file)
@@ -552,9 +552,40 @@ class wsServices extends cubeFlashGateway {
        }\r
 \r
        public function collection() {\r
+               global $core;\r
+               $id = $this->callArgs[0];\r
                $this->outputXML = false;\r
                header('Content-type: application/json');\r
-               echo '[]';\r
+\r
+               $cache = WS_COLLECTIONS . '/ws/' . $id . '.json';\r
+               $limit = TIME - 7200;\r
+               if (!file_exists($cache) || filemtime($cache) < $limit) {\r
+                       $r = $core->con->select('SELECT * FROM book_collection_compile WHERE online=1 AND collection_id=\'' . $core->con->escape($id) . '\'');\r
+                       $r->fetch();\r
+                       $version = $r->compile_date;\r
+\r
+                       $composition = json_decode(file_get_contents(WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/composition.json'));\r
+\r
+                       $couvertures = array();\r
+                       foreach ($composition as $k => $g) {\r
+                               foreach ($g->publications as $l => $p) {\r
+                                       $couv = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/ios/' . $p->id . '/data/background/36/t1.jpg';\r
+                                       $couvertures[$p->id] = base64_encode(file_get_contents($couv));\r
+                               }\r
+                       }\r
+\r
+                       $d = array('id' => $id, 'time' => $version, 'datas' => $composition, 'couvertures' => $couvertures);\r
+\r
+                       $dao = new wsDAOCollection($core->con);\r
+                       $col = $dao->selectById($id);\r
+\r
+                       $json = json_encode($d);\r
+                       file_put_contents($cache, $json);\r
+                       echo $json;\r
+               } else {\r
+                       echo file_get_contents($cache);\r
+               }\r
+\r
                exit;\r
        }\r
 \r
index 761725406d08973962cb7fc6d0f81592554fc31f..c08d364af1fdd8d7973fef1809834d75496ee666 100644 (file)
@@ -214,7 +214,6 @@ class wsUrl {
                $collection = $dao->selectById($args[1]);\r
 \r
                $shortcuts = array();\r
-               $shortcuts[] = '<a href="#" id="newGroup">' . $core->typo->Ajouter('Nouveau groupe') . '</a>';\r
 \r
                $res = commonPage::barre(null, null, null, $shortcuts);\r
                $res .= commonPage::tMain();\r
@@ -231,13 +230,13 @@ class wsUrl {
                global $core;\r
 \r
                $res = '<h1>Gestion de la collection &laquo; ' . $collection->nom . ' &raquo; <em># ' . $collection->collection_id . '</em></h1>';\r
-               $res.='<form method="post" action="saveCollectionComposition" enctype="multipart/form-data>';\r
+               $res.='<form method="post" action="saveCollectionComposition" enctype="multipart/form-data">';\r
                $res.='<table class="max">';\r
                $res.='<tr><td class="min nowrap">#</td><td>' . form::hidden('collection_id', $collection->collection_id) . $collection->collection_id . '</td></tr>';\r
                $res.='<tr><td class="min nowrap">' . __('Nom de la collection') . '</td><td>' . form::field('nom', 20, 64, $collection->nom) . '</td></tr>';\r
-\r
                $res.='</table>';\r
                $res.='<h3>' . __('Composition') . '</h3>';\r
+               $res.='<a href="#" id="newGroup">' . $core->typo->Ajouter(__('Nouveau groupe')) . '</a><br /><br />';\r
                $res .= '<ul>';\r
 \r
 \r
@@ -315,8 +314,26 @@ class wsUrl {
                $res.='</form>';\r
                $res.='<p class="clear"></p>';\r
                $res.='<h3>' . __('Versions') . '</h3>';\r
-\r
-               $res.='<a href="#" class="right ajax" rel="publishCollection/' . $collection->collection_id . '">' . $core->typo->Ajouter(__('Publier et notifier les utilisateurs')) . '</a>';\r
+               $res.='<a href="#" class="ajax" rel="collectionVersionCreate/' . $collection->collection_id . '">' . $core->typo->Ajouter(__('Créer une version')) . '</a><br /><br />';\r
+               $r = $core->con->select('SELECT * FROM book_collection_compile WHERE collection_id=\'' . $collection->collection_id . '\' ORDER BY compile_date DESC');\r
+               if (!$r->count()) {\r
+                       $res.=__('Aucune version de la collection n\'a été crée');\r
+               } else {\r
+                       $res.='<table class="max">';\r
+                       $res.='<tr><th class="left">' . __('Date') . '</th><th class="left">' . __('Publiée') . '</th><th class="min nowrap"></th><th class="min nowrap"></th></tr>';\r
+                       while ($r->fetch()) {\r
+                               if (!$r->online) {\r
+                                       $publish = '<a class="ajax download btbook" rel="collectionVersionPublish/' . $r->collection_id . '/' . $r->compile_date . '" href="#"><div></div><span>' . __('Publier') . '</span></a>';\r
+                                       $del = '<a class="ajax suppr btbook" rel="collectionVersionDelete/' . $r->collection_id . '/' . $r->compile_date . '" href="#" title="' . __('Êtes-vous certain de vouloir supprimer cette version ?') . '"><div></div><span>' . __('Effacer') . '</span></a>';\r
+                               } else {\r
+                                       $publish = '';\r
+                                       $del = '';\r
+                               }\r
+                               $res.='<tr><td>' . date('Y-m-d H:i:s', $r->compile_date) . '</td><td>' . ($r->online ? __('Oui') : __('Non')) . '</td><td class="min nowrap">' . $publish . '</td><td class="min nowrap">' . $del . '</td></tr>';\r
+                       }\r
+                       $res.='</table>';\r
+               }\r
+               $res.='<br /><a href="#" class="right ajax" rel="publishCollection/' . $collection->collection_id . '">' . $core->typo->Ajouter(__('Publier et notifier les utilisateurs')) . '</a>';\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
index cc332282449863ccbdbbd9bbc2bab014d2a44b84..2180570a017ecdaa5693508170127ad12ea1ddce 100644 (file)
@@ -16,17 +16,81 @@ class wsExporter {
 
        public function exportCollection($collectionId, $os) {
                global $core;
-               $compiler = new wsHTML5AppCompiler($collectionId, $os, 'collection');
-               $dir = $compiler->compile();
+               $compiler = new wsHTML5AppCompiler($collectionId);
+               $dir = $compiler->compile($os, 'collection');
 
                $collection = $compiler->collection;
                $d = str_replace('.', '/', $collection->settings['namespace']);
                $dest = $d . '/www/';
 
                $this->_createProject($os, $collection->nom, $collection->settings['namespace']);
+               $this->_collectionAssets($os, $compiler);
                $this->_transfertPhonegap($os, $dir, $dest);
        }
 
+       /**
+        * 
+        * @param string $os
+        * @param wsHTML5AppCompiler $compiler
+        */
+       protected function _collectionAssets($os, $compiler) {
+               if ($os == 'ios') {
+                       $collection = $compiler->collection;
+                       $src = $compiler->wdir . '/' . $collection->theme['icon'];
+                       // icones
+                       $icons = array(57 => 'icon', 72 => 'icon-72', 114 => 'icon@2x', 144 => 'icon-72@2x');
+                       $d = WS_COLLECTIONS . '/resources/' . $collection->collection_id . '/' . $os . '/icons/';
+                       if (!file_exists($d)) {
+                               mkdir($d, 0777, true);
+                       }
+                       foreach ($icons as $s => $n) {
+
+                               $dest = $d . $n . '.png';
+                               if (!$this->_testFile($src, $dest)) {
+                                       wsPackagerPhonegap::__makeIcon($src, $dest, $s);
+                               }
+                       }
+
+                       // splashs
+                       $splashs = array('320x480' => 'Default~iphone', '640x960' => 'Default@2x~iphone', '1024x748' => 'Default-Landscape~ipad', '768x1004' => 'Default-Portrait~ipad', '2048x1496' => 'Default-Landscape@2x~ipad', '1536x2008' => 'Default-Portrait@2x~ipad', '640x1136' => 'Default-568h@2x~iphone');
+
+                       $d = WS_COLLECTIONS . '/resources/' . $collection->collection_id . '/' . $os . '/splash/';
+                       if (!file_exists($d)) {
+                               mkdir($d, 0777, true);
+                       }
+
+                       $src = $compiler->wdir . '/' . $collection->theme['splash'];
+                       foreach ($splashs as $size => $name) {
+                               list($width, $height) = explode('x', $size);
+
+                               $dest = $d . $name . '.png';
+
+                               if (!$this->_testFile($src, $dest)) {
+                                       $it = new cubeImageTools();
+                                       $it->loadImage($src);
+                                       $it->resize($width, $height, 'crop', false, 'C', 'M', 'transparent');
+                                       $it->output('png', $dest);
+                               }
+                       }
+
+
+                       // Transfert
+                       `sudo /usr/local/bin/remountmac`;
+
+                       $this->_rsync(WS_COLLECTIONS . '/resources/' . $collection->collection_id . '/' . $os, "/mnt/macbox" . $this->_iosProjectDir($collection->settings['namespace']) . '/' . CubeIT_Text::str2URL($collection->nom) . '/Resources', false);
+               }
+       }
+
+       protected function _testFile($ref, $dest) {
+               if (!file_exists($dest)) {
+                       return false;
+               }
+               if (filemtime($ref) > filemtime($dest)) {
+                       return false;
+               }
+               return true;
+       }
+
        protected function _createProject($os, $name, $ns) {
                if ($os == 'ios') {
                        $dir = $this->_iosProjectDir($ns);
@@ -101,6 +165,8 @@ class wsExporter {
                        $this->_phonegap();
                } else if ($this->metaAction == 'install') {
                        $this->_install();
+               } else if ($this->metaAction == 'phonegapcollection') {
+                       $this->_phonegapcollection();
                }
        }
 
@@ -109,6 +175,14 @@ class wsExporter {
                return in_array($this->version, $yes);
        }
 
+       protected function _phonegapcollection() {
+               $d = '/' . $this->destinationDir;
+
+               $packager = new wsPackagerPhonegap($this->book_id, $d, true, false, $this->version);
+               $packager->ignoreCache = false;
+               return $packager->makePackage(false);
+       }
+
        protected function _install() {
                $package = wsPackager::package($this->book_id, $this->version, $this->_haveToZip());
 
@@ -155,6 +229,7 @@ class wsExporter {
                }
 
                $packager = new wsPackagerPhonegap($this->book_id, null, true, false, $os);
+               $packager->cleanOnDestruct = false;
                $package = $packager->makePackage(false);
 
                $this->_transfertPhonegap($os, $package, $this->destinationDir);
@@ -232,7 +307,6 @@ class wsExporter {
                        list($distServer, $distDir) = explode(':', $dest);
                }
 
-
                if (!file_exists($dest)) {
                        if (!$destDistant) {
                                mkdir($dest, 0777, true);
index 97644c5183e76f8a35e8377f330efc9a115f3d34..2e930b9490df844d7604c206c778f469879b15c2 100644 (file)
@@ -8,24 +8,42 @@ class wsHTML5AppCompiler {
        public $os;
        public $phonegapVersion;
 
-       public function __construct($collectionId, $os, $phonegapVersion = 'latest') {
+       public function __construct($collectionId) {
 
                global $core;
 
                $this->collectionId = $collectionId;
                $dao = new wsDAOCollection($core->con);
                $this->collection = $dao->selectById($this->collectionId);
+       }
 
-               if ($phonegapVersion == 'collection') {
-                       $phonegapVersion = $this->collection->settings['phonegap'];
+       public function createVersion() {
+               $os = array('ios', 'android');
+               $time = time();
+
+               $dir = WS_COLLECTIONS . '/versions/' . $this->collectionId . '/' . $time . '/';
+
+               $books = array();
+               foreach ($this->collection->datas as $group) {
+                       foreach ($group['publications'] as $p) {
+                               $books[] = $p['id'];
+                       }
                }
 
-               $this->phonegapVersion = wsHTML5Compiler::getPhonegapVersion($phonegapVersion);
-               $this->os = $os;
+               $exporter = new wsExporter();
+               foreach ($os as $o) {
+                       $d = $dir . $o . '/';
+                       foreach ($books as $bid) {
+                               $dd = $d . $bid;
 
-               $this->vdir = $this->dir = WS_COLLECTIONS . '/app/' . $this->collectionId . '/';
-               $this->wdir = WS_COLLECTIONS . '/working/' . $this->collectionId;
-               $this->sdir = WS_COMPILE_ASSETS . '/_html5app/';
+                               if (!file_exists($dd)) {
+                                       mkdir($dd, 0777, true);
+                               }
+                               $exporter->export($bid, $x, 'phonegapcollection', $o, $dd);
+                       }
+               }
+
+               return $time;
        }
 
        protected function copy($s, $t) {
@@ -64,7 +82,18 @@ class wsHTML5AppCompiler {
                }
        }
 
-       function compile() {
+       function compile($os, $phonegapVersion = 'latest') {
+               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/';
+
                $this->copyRecursive($this->sdir, $this->vdir);
 
                $this->writeStyle();
@@ -88,7 +117,15 @@ class wsHTML5AppCompiler {
 
        function writeStyle() {
                $c = array();
-               $c[] = 'body{background-image:url("data/images/' . $this->collection->theme['back'] . '");}';
+
+               $imagesdir = $this->vdir . '/data/images/';
+               if (!file_exists($imagesdir)) {
+                       mkdir($imagesdir, 0777, true);
+               }
+
+               $this->copy($this->wdir . '/' . $this->collection->theme['back'], $imagesdir . '/' . $this->collection->theme['back']);
+
+               $c[] = 'body{background-image:url("images/' . $this->collection->theme['back'] . '");}';
                file_put_contents($this->vdir . '/data/app.css', implode("\n", $c));
        }
 
index 406c36c730997b78d6db822a0b7ba2839d3b5e64..9df43eb9398ddb469dbee005f4cfc7dfc4cc327d 100644 (file)
@@ -2,7 +2,7 @@
 
 class wsHTML5Compiler {
 
-       public static function factory($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false) {
+       public static function factory($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false) {
                if (is_null($version)) {
                        global $core;
                        $dao = new wsDAOBook($core->con);
@@ -11,9 +11,9 @@ class wsHTML5Compiler {
                }
 
                if ($version == 'stable') {
-                       return new wsHTML5Compiler($book_id, 'stable', $phonegap, $phonegapVersion, $dir, $standalone);
+                       return new wsHTML5Compiler($book_id, 'stable', $phonegap, $phonegapVersion, $dir, $standalone, $appcache);
                } else {
-                       return new wsHTML5CompilerDev($book_id, 'dev', $phonegap, $phonegapVersion, $dir, $standalone);
+                       return new wsHTML5CompilerDev($book_id, 'dev', $phonegap, $phonegapVersion, $dir, $standalone, $appcache);
                }
        }
 
@@ -139,11 +139,13 @@ class wsHTML5Compiler {
        protected $phonegapVersion;
        protected $standalone = false;
        protected $hiddenContents = array();
+       protected $appcache;
 
-       function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false) {
+       function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false) {
                global $core;
 
                $this->phonegapVersion = self::getPhonegapVersion($phonegapVersion);
+               $this->appcache = $appcache;
 
                if ($version == 'stable') {
                        $this->assets = WS_COMPILE_ASSETS . '/_html5prod';
@@ -153,6 +155,7 @@ class wsHTML5Compiler {
                }
                $this->phonegap = $phonegap;
                $this->standalone = $standalone || $this->phonegap;
+               $this->appcache = $appcache;
 
                cubePHP::set_memory('4G');
 
@@ -344,7 +347,7 @@ class wsHTML5Compiler {
        }
 
        protected function writeCache() {
-               if ($this->phonegap) {
+               if (!$this->appcache) {
                        return;
                }
 
@@ -479,6 +482,11 @@ class wsHTML5Compiler {
 
                $pagesContents = '';
 
+               $cache = '';
+               if ($this->appcache) {
+                       $cache = ' manifest="cache.appcache"';
+               }
+
                $script = '';
                if ($this->phonegap) {
                        $script .= '<script type="text/javascript" charset="utf-8" src="data/cordova.js"></script>' . "\n";
@@ -542,7 +550,7 @@ class wsHTML5Compiler {
                        }
                }
 
-               $vars = array('titre', 'credits', 'ga', 'style', 'script', 'pagesContents', 'description', 'print', 'hiddenContents', 'splash');
+               $vars = array('titre', 'credits', 'ga', 'style', 'script', 'pagesContents', 'description', 'print', 'hiddenContents', 'splash','cache');
                foreach ($vars as $v) {
                        $html = str_replace('<!-- $' . $v . ' -->', $$v, $html);
                }
@@ -570,7 +578,7 @@ class wsHTML5Compiler {
 
                $thtml = $uhtml;
 
-               $vars = array('titre', 'credits', 'ga', 'style', 'script', 'pagesContents', 'print', 'hiddenContents', 'splash');
+               $vars = array('titre', 'credits', 'ga', 'style', 'script', 'pagesContents', 'print', 'hiddenContents', 'splash','cache');
                foreach ($vars as $v) {
                        $uhtml = str_replace('<!-- $' . $v . ' -->', $$v, $uhtml);
                }
index 34ceffbbdc3430bc9e36c0055c0cf0394bda4be8..52b5276f1c00e35836f923271a5cfc4ccd286409 100644 (file)
@@ -6,6 +6,7 @@ class wsPackagerPhonegap extends wsPackager {
        protected $makeResources = true;
        protected $os = 'all';
        protected $supportedOS = array('ios', 'android');
+       public $ignoreCache = true;
 
        public function __construct($book_id, $vdir = null, $whole = true, $makeResources = true, $os = 'all') {
                $this->makeResources = $makeResources;
@@ -29,13 +30,12 @@ class wsPackagerPhonegap extends wsPackager {
                                $vdir.='/' . $os;
                        }
 
-                       $compiler = wsHTML5Compiler::factory($this->book_id, null, $os, 'latest', $vdir);
+                       $compiler = wsHTML5Compiler::factory($this->book_id, null, $os, 'latest', $vdir,false,!$this->ignoreCache);
                        $compiler->compile();
 
                        unlink($vdir . '/indext.html');
                        unlink($vdir . '/indexu.html');
                        unlink($vdir . '/widget.html');
-                       unlink($vdir . '/cache.appcache');
 
                        if ($this->makeResources) {
                                $this->makeScreenshots();
@@ -156,7 +156,7 @@ class wsPackagerPhonegap extends wsPackager {
                if (!file_exists($resources . '/splash')) {
                        mkdir($resources . '/splash', 0777, true);
                }
-               if (!file_exists($this->resources . '/icons')) {
+               if (!file_exists($resources . '/icons')) {
                        mkdir($resources . '/icons', 0777, true);
                }
 
@@ -203,10 +203,14 @@ class wsPackagerPhonegap extends wsPackager {
                        $base = WS_COMPILE_ASSETS . '/_ico/phonegap.png';
                }
 
+               self::__makeIcon($base, $dir . '/' . $name . '.png', $size);
+       }
+
+       public static function __makeIcon($src, $dest, $size) {
                $it = new cubeImageTools();
-               $it->loadImage($base);
+               $it->loadImage($src);
                $it->resize($size, $size, 'ratio', false, 'C', 'M', 'transparent');
-               $it->output('png', $dir . '/' . $name . '.png');
+               $it->output('png', $dest);
        }
 
        protected function _drawBackImage($im, $width, $height) {
index 9b959dd98d4ba1120232bf4cac7ce387159ba724..398c5c3061a953526d71fe5d984fac0f21dc3081 100644 (file)
@@ -14,6 +14,7 @@ class wsPackager {
        protected $zip;\r
        protected $workingDir;\r
        protected $whole = true;\r
+       public $cleanOnDestruct = true;\r
 \r
        public static function package($book_id, $version, $zip = true) {\r
                global $packager;\r
@@ -189,6 +190,7 @@ class wsPackager {
 \r
        protected function cleanVdir() {\r
                if (file_exists($this->vdir)) {\r
+                       return;\r
                        // Suppression du répertoire si il existe\r
                        $rm = new cubeCommandLine('rm');\r
                        $rm->setArg('r');\r
@@ -212,13 +214,13 @@ class wsPackager {
        }\r
 \r
        public function __destruct() {\r
-               if ($this->whole) {\r
+               if ($this->whole && $this->cleanOnDestruct) {\r
                        $this->cleanVdir();\r
                }\r
        }\r
 \r
        public function copy($source, $dest) {\r
-               if(!file_exists($source)){\r
+               if (!file_exists($source)) {\r
                        return;\r
                }\r
                copy($source, $dest);\r
index b56a7c697ef2d7d9b3ae815e57e14ee273a9c393..484c33d662d565fcc9f69bf19ac8577f202c118a 100644 (file)
@@ -68,6 +68,8 @@ function load_common_extranet() {
                });\r
        });\r
 \r
+\r
+\r
        $("#dash .toggle").click(function() {\r
                var rel = $(this).attr('rel');\r
                var div = $(this).parents('.dashboard').get(0);\r
@@ -150,6 +152,16 @@ function load_common_extranet() {
                return true;\r
        });\r
 \r
+       $("#copywsassets").off('change blur').on('change blur', "#source", function() {\r
+               $.ajax({\r
+                       url: SITE_PATH + 'ajax/fluidbookAssets/' + $(this).val(),\r
+                       success: function(data) {\r
+                               MyAjax(data);\r
+                       }\r
+               });\r
+       });\r
+\r
+\r
        $(window).resize(function() {\r
                resize();\r
        });\r
index d5b869c1f1a1a531dd4d196ba89331512906db1f..c2237326ced275a0641673d0f837824c6866b812 100644 (file)
--- a/js/ws.js
+++ b/js/ws.js
@@ -3,7 +3,7 @@ TO_LOAD_ONCE[TO_LOAD_ONCE.length] = 'load_ws_once();';
 FIRST_LOAD = true;\r
 \r
 function load_ws_once() {\r
-       $(document).on('change', 'form[action="exportbook"] select, form[action="exportbookExe"] select', function() {\r
+               $(document).on('change', 'form[action="exportbook"] select, form[action="exportbookExe"] select', function() {\r
                var form = $(this).parents('form');\r
                $(form).find('#changed').val($(this).attr('name'));\r
                $(form).attr('action', 'exportbook').submit().attr('action', 'exportbookExe');\r
index 0bcf1ad5e6aa53279bb73acd226ff62873334849..14dca5dfcb049730d6b8998b71819341328b4168 100644 (file)
@@ -550,7 +550,7 @@ a.btbook{
 a.btbook>div{\r
        display:inline-block;\r
        width:16px;\r
-       height:16px;\r
+       height:16px !important;\r
        background-position: 0 0;\r
 }\r
 \r