]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 23 Jun 2014 09:21:18 +0000 (09:21 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 23 Jun 2014 09:21:18 +0000 (09:21 +0000)
.htaccess
inc/commons/class.common.core.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/html5/app/class.ws.html5.app.compiler.php

index 1d2e185b1d9ef8ab5a7428208c473fb781c82efb..a0e56504ad0dceaab47d48a934e289d296896a3e 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -42,10 +42,16 @@ AddCharset UTF-8 log
        RewriteCond %{HTTP_HOST} fluidbook\r
        RewriteRule ^favicon.ico$ images/ws/favicon.ico [L]\r
 \r
+       # Ignore static files or directories\r
+       RewriteCond %{REQUEST_FILENAME} -s [OR]\r
+       RewriteCond %{REQUEST_FILENAME} -l [OR]\r
+       RewriteCond %{REQUEST_FILENAME} -d\r
+       RewriteRule ^.*$ - [NC,L]\r
+\r
        RewriteRule ^ajax/supprimeFichier/([0-9]+)/(.*)$ index.php/ajax/supprimeFichier/$1/$2 [L]\r
        RewriteRule ^telecharger/([0-9a-fA-F]+)/([0-9]+)/(.*)$ index.php/telecharger/$1/$2/$3 [L]\r
        RewriteRule ^telechargerr/([0-9a-fA-F]+)/([0-9]+)/(.*)$ index.php/telechargerr/$1/$2/$3 [L]\r
-       RewriteRule ^([-,_a-zA-Z0-9/]+)$ index.php/$1 [L]\r
+       RewriteRule ^([-,_a-zA-Z0-9\./]+)$ index.php/$1 [L]\r
 \r
        RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.html$ viewer/$1_$2_$3/index [L]\r
        RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.swf$ fluidbook/compile/index.swf [L]\r
index 96f2d37133bf98fb0737bb9f7e91dc70f75c4a52..853b3593d4ef0862a1a4270fa2ddef85d4bda1a3 100644 (file)
@@ -17,7 +17,7 @@ class commonCore extends cubeCore {
                try {\r
                        $this->authentifie();\r
                } catch (Exception $e) {\r
-                       \r
+\r
                }\r
 \r
                if ($this->user) {\r
@@ -444,8 +444,8 @@ class commonCore extends cubeCore {
                // Table des compilations de collection\r
                $db->book_collection_compile->collection_id('integer', 0, false);\r
                $db->book_collection_compile->compile_date('integer', 0, false);\r
-               $db->book_collection_compile->online_ios('integer', 0, false);\r
-               $db->book_collection_compile->online_android('integer', 0, false);\r
+               $db->book_collection_compile->online_ios('varchar', 10, false);\r
+               $db->book_collection_compile->online_android('varchar', 10, false);\r
                $db->book_collection_compile->primary('book_collection_compile', 'collection_id', 'compile_date');\r
 \r
                // Table des notification push\r
@@ -466,7 +466,7 @@ class commonCore extends cubeCore {
                $db->ws_users_tree->facturable_id('integer', 0, false);\r
                $db->ws_users_tree->facturable_entreprise_id('integer', 0, false);\r
                $db->ws_users_tree->administrateur_id('integer', 0, false);\r
-               // Clé \r
+               // Clé\r
                $db->ws_users_tree->primary('pk_utilisateur_id', 'utilisateur_id');\r
                // Table des entreprises\r
                $db->ws_entreprises_tree->entreprise_id('integer', 0, false);\r
index cd9adc1097861938432fd4a4fdc59b18a417b456..1064da257d03a0fcd2002f2960f9d99f9c06e64a 100644 (file)
@@ -1086,14 +1086,10 @@ class wsAjax extends cubeAjax {
                $c = $core->con->openCursor('book_collection_compile');\r
                $c->collection_id = $id;\r
                $c->compile_date = $time;\r
-               $c->online_ios = 0;\r
-               $c->online_android = 0;\r
+               $c->online_ios = '';\r
+               $c->online_android = '';\r
                $c->insert();\r
 \r
-               if ($_GET['ctrl']) {\r
-                       self::collectionVersionPublish(array('', $id, $time, 'ios'), $x);\r
-               }\r
-\r
                $x->addReload();\r
        }\r
 \r
@@ -1101,18 +1097,14 @@ class wsAjax extends cubeAjax {
                global $core;\r
 \r
                $id = $args[1];\r
-               $date = $args[2];\r
-               $os = $args[3];\r
-\r
-               $online = 'online_' . $os;\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
+               foreach ($_POST['version'] as $version => $oss) {\r
+                       $c = $core->con->openCursor('book_collection_compile');\r
+                       foreach ($oss as $os => $appver) {\r
+                               $c->{'online_' . $os} = $appver;\r
+                       }\r
+                       $c->update('WHERE collection_id=\'' . $core->con->escape($id) . '\' AND compile_date=\'' . $core->con->escape($version) . '\'');\r
+               }\r
 \r
                self::cleanCachesCollection($id, $os);\r
 \r
@@ -1120,17 +1112,8 @@ class wsAjax extends cubeAjax {
        }\r
 \r
        protected static function cleanCachesCollection($id, $os) {\r
-               $files = array('json', 'update');\r
-               $resolutions = array(150, 300);\r
-\r
-               foreach ($files as $f) {\r
-                       foreach ($resolutions as $r) {\r
-                               $ff = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $r . '.' . $f;\r
-                               if (file_exists($ff)) {\r
-                                       unlink($ff);\r
-                               }\r
-                       }\r
-               }\r
+               $ff = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.*';\r
+               `rm $ff`;\r
        }\r
 \r
        public static function collectionVersionDelete($args, &$x) {\r
index bace75d742f220bc742ecb7dd84e558f1568d38d..6720491a02db243d8c062e0a492880fe70d488e9 100644 (file)
@@ -662,7 +662,8 @@ class wsServices extends cubeFlashGateway {
                $id = $this->callArgs[0];
                $os = $this->callArgs[1];
                $resolution = $this->callArgs[2];
-               $local = (isset($this->callArgs[3])) ? $this->callArgs[3] : null;
+               $local = (isset($this->callArgs[3]) && $this->callArgs[3] != '0') ? $this->callArgs[3] : null;
+               $appver = (isset($this->callArgs[4]) && $this->callArgs[4]) ? $this->callArgs[4] : '1.0';
 
                if (is_null($resolution)) {
                        $resolution = 150;
@@ -675,8 +676,10 @@ class wsServices extends cubeFlashGateway {
                $this->outputXML = false;
                header('Content-type: application/json');
 
-               $cache = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $resolution . '.json';
-               $update = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $resolution . '.update';
+               $appverf = str_replace('.', '_', $appver);
+
+               $cache = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $resolution . '.' . $appverf . '.json';
+               $update = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $resolution . '.' . $appverf . '.update';
 
                if (file_exists($update) && filemtime(__FILE__) > filemtime($update)) {
                        unlink($update);
@@ -689,75 +692,81 @@ class wsServices extends cubeFlashGateway {
 
                $limit = TIME - 72000;
                if (!file_exists($cache) || !file_exists($update) || filemtime($cache) < $limit) {
-                       $r = $core->con->select('SELECT * FROM book_collection_compile WHERE online_' . $os . '=1 AND collection_id=\'' . $core->con->escape($id) . '\'');
-                       $r->fetch();
-                       $version = $r->compile_date;
+                       $r = $core->con->select('SELECT *,online_' . $os . ' AS v FROM book_collection_compile WHERE online_' . $os . '!=\'\' AND collection_id=\'' . $core->con->escape($id) . '\' ORDER BY compile_date DESC');
+                       while ($r->fetch()) {
+                               if (version_compare($r->v, $appver, '>')) {
+                                       continue;
+                               }
 
-                       $daoCollection = new wsDAOCollection($core->con);
-                       $collection = $daoCollection->selectById($id);
+                               $version = $r->compile_date;
 
-                       $ns = $collection->settings['namespace'];
+                               $daoCollection = new wsDAOCollection($core->con);
+                               $collection = $daoCollection->selectById($id);
 
+                               $ns = $collection->settings['namespace'];
 
-                       $vcompo = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/composition.json';
-                       $composition = json_decode(file_get_contents($vcompo));
+                               $vcompo = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/composition.json';
+                               $composition = json_decode(file_get_contents($vcompo));
 
-                       $couvertures = array();
-                       $vroot = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/';
+                               $couvertures = array();
+                               $vroot = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/';
 
-                       $publications = array();
-                       $langs = array();
+                               $publications = array();
+                               $langs = array();
 
-                       foreach ($composition as $k => $g) {
-                               foreach ($g->publications as $l => $p) {
-                                       $publications[] = $p->id;
+                               foreach ($composition as $k => $g) {
+                                       foreach ($g->publications as $l => $p) {
+                                               $publications[] = $p->id;
+                                       }
                                }
-                       }
 
-                       $daoBook = new wsDAOBook($core->con);
-                       $books = $daoBook->selectByIds($publications);
-
-                       $langsnames = array();
-                       foreach ($composition as $k => $g) {
-                               foreach ($g->publications as $l => $p) {
-                                       $book = $books[$p->id];
-                                       $root = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/' . $p->id;
-                                       $couv = $root . '/cover.jpg';
-                                       $couvertures[$p->id] = base64_encode(file_get_contents($couv));
-                                       $composition[$k]->publications[$l]->width = $book->parametres->width;
-                                       $composition[$k]->publications[$l]->height = $book->parametres->height;
-                                       $composition[$k]->publications[$l]->lang = $book->lang;
-                                       $langs[] = $book->lang;
+                               $daoBook = new wsDAOBook($core->con);
+                               $books = $daoBook->selectByIds($publications);
+
+                               $langsnames = array();
+                               foreach ($composition as $k => $g) {
+                                       foreach ($g->publications as $l => $p) {
+                                               $book = $books[$p->id];
+                                               $root = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/' . $p->id;
+                                               $couv = $root . '/cover.jpg';
+                                               $couvertures[$p->id] = base64_encode(file_get_contents($couv));
+                                               $composition[$k]->publications[$l]->width = $book->parametres->width;
+                                               $composition[$k]->publications[$l]->height = $book->parametres->height;
+                                               $composition[$k]->publications[$l]->lang = $book->lang;
+                                               $langs[] = $book->lang;
+                                       }
                                }
-                       }
 
-                       $langs = array_unique($langs);
+                               $langs = array_unique($langs);
 
-                       $w2h = new wiki2xhtml();
-                       $w2h->setOpt('active_pre', 0);
+                               $w2h = new wiki2xhtml();
+                               $w2h->setOpt('active_pre', 0);
 
-                       $contents = $collection->contents;
-                       foreach ($langs as $lang) {
-                               $langsnames[$lang] = cubeLang::getNameByCode($lang);
-                               $contents[$lang]['apropos'] = $w2h->transform($contents[$lang]['apropos']);
-                       }
+                               $contents = $collection->contents;
+                               foreach ($langs as $lang) {
+                                       $langsnames[$lang] = cubeLang::getNameByCode($lang);
+                                       $contents[$lang]['apropos'] = $w2h->transform($contents[$lang]['apropos']);
+                               }
 
 
-                       $traductions = array();
-                       $r = $core->con->select('SELECT traductions,lang_id FROM langues WHERE lang_id IN(\'' . implode('\',\'', $langs) . '\')');
-                       while ($r->fetch()) {
-                               $traductions[$r->lang_id] = json_decode($r->traductions);
-                       }
+                               $traductions = array();
+                               $r = $core->con->select('SELECT traductions,lang_id FROM langues WHERE lang_id IN(\'' . implode('\',\'', $langs) . '\')');
+                               while ($r->fetch()) {
+                                       $traductions[$r->lang_id] = json_decode($r->traductions);
+                               }
+
+                               $d = array('id' => $id, 'res' => $resolution, 'ns' => $ns, 'langs' => $langs, 'langnames' => $langsnames, 'time' => $version, 'datas' => $composition, 'couvertures' => $couvertures, 'traductions' => $traductions, 'contents' => $contents);
+                               $d = array_merge($d, $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os, $books, $resolution));
 
-                       $d = array('id' => $id, 'res' => $resolution, 'ns' => $ns, 'langs' => $langs, 'langnames' => $langsnames, 'time' => $version, 'datas' => $composition, 'couvertures' => $couvertures, 'traductions' => $traductions, 'contents' => $contents);
-                       $d = array_merge($d, $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os, $books, $resolution));
+                               $dao = new wsDAOCollection($core->con);
+                               $col = $dao->selectById($id);
 
-                       $dao = new wsDAOCollection($core->con);
-                       $col = $dao->selectById($id);
+                               $json = json_encode($d);
+                               file_put_contents($cache, $json);
+                               file_put_contents($update, $version);
 
-                       $json = json_encode($d);
-                       file_put_contents($cache, $json);
-                       file_put_contents($update, $version);
+                               break;
+                       }
                } else {
                        $d = json_decode(file_get_contents($cache), true);
                }
@@ -770,6 +779,7 @@ class wsServices extends cubeFlashGateway {
                        }
                }
 
+
                $d['forceUpdate'] = $force;
                echo json_encode($d);
                exit;
index 4e9a9c873e8cd555cd0d0a2471ad0df1b4610273..f599bfcadc58959d73e6aba206fef9c849da6b12 100644 (file)
@@ -313,6 +313,8 @@ class wsUrl {
                $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>';
                $res.='<tr><td class="min nowrap">' . __('Certificat APNS') . ' Dev (' . __('Fichier .pem') . ')</td><td><input type="file" name="apns_dev" /></td></tr>';
                $res.='<tr><td class="min nowrap">' . __('Certificat APNS') . ' Prod (' . __('Fichier .pem') . ')</td><td><input type="file" name="apns_prod" /></td></tr>';
+               $res.='<tr><td class="min nowrap">' . __('Versions iOS') . '</td><td>' . form::field(array('settings[v_ios]', 'namespace'), 64, 64, $collection->settings['v_ios']) . '</td></tr>';
+               $res.='<tr><td class="min nowrap">' . __('Versions Android') . '</td><td>' . form::field(array('settings[v_android]', 'namespace'), 64, 64, $collection->settings['v_android']) . '</td></tr>';
                $res.='</table>';
 
                $res.='<h3>' . __('Applications offline') . '</h3>';
@@ -338,8 +340,14 @@ class wsUrl {
                $res.='</form>';
                $res.='<p class="clear"></p>';
                $res.='<h3>' . __('Versions') . '</h3>';
+               $res.='<form action="collectionVersionPublish/' . $collection->collection_id . '" method="post">';
                $res.='<a href="#" class="ajax" rel="collectionVersionCreate/' . $collection->collection_id . '">' . $core->typo->Ajouter(__('Créer une version')) . '</a><br /><br />';
                $r = $core->con->select('SELECT * FROM book_collection_compile WHERE collection_id=\'' . $collection->collection_id . '\' ORDER BY compile_date DESC');
+
+               $v_ios = self::getSelectVersions($collection->settings['v_ios']);
+               $v_android = self::getSelectVersions($collection->settings['v_android']);
+
+
                if (!$r->count()) {
                        $res.=__('Aucune version de la collection n\'a été crée');
                } else {
@@ -353,22 +361,16 @@ class wsUrl {
                                        $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>';
                                }
 
-                               if ($r->online_ios) {
-                                       $pub_ios = __('Publiée');
-                               } else {
-                                       $pub_ios = '<a class="ajax download btbook" rel="collectionVersionPublish/' . $r->collection_id . '/' . $r->compile_date . '/ios" href="#"><div></div><span>' . __('Publier') . '</span></a>';
-                               }
+                               $pub_ios = form::combo('version[' . $r->compile_date . '][ios]', $v_ios, $r->online_ios);
+                               $pub_android = form::combo('version[' . $r->compile_date . '][android]', $v_android, $r->online_android);
 
-                               if ($r->online_android) {
-                                       $pub_android = __('Publiée');
-                               } else {
-                                       $pub_android = '<a class="ajax download btbook" rel="collectionVersionPublish/' . $r->collection_id . '/' . $r->compile_date . '/android" href="#"><div></div><span>' . __('Publier') . '</span></a>';
-                               }
                                $res.='<tr><td>' . date('Y-m-d H:i:s', $r->compile_date) . '</td><td>' . $pub_ios . '</td><td>' . $pub_android . '</td><td class="min nowrap">' . $del . '</td></tr>';
                        }
                        $res.='</table>';
                }
-
+               $res.='<a href="#" class="submit right">' . $core->typo->Ajouter(__('Enregistrer')) . '</a>';
+               $res.='</form>';
+               $res.='<p class="clear"></p>';
                $res.='<h3>' . __('Notifications') . '</h3>';
                $res.='<p>' . __('Indiquez le texte de la notification à envoyer aux utilisateurs') . ' (' . __('Max 200 caractères') . ').<br />' . __('Laissez vide si vous souhaitez simplement afficher un badge') . '</p>';
                $res.='<form method="post" action="publishCollection">';
@@ -386,6 +388,18 @@ class wsUrl {
                return $res;
        }
 
+       public static function getSelectVersions($versions) {
+               fb($versions);
+               $res = array('-----' => '');
+               $e = explode(',', $versions);
+
+               foreach ($e as $ee) {
+                       $ee = trim($ee);
+                       $res[$ee] = $ee;
+               }
+               return $res;
+       }
+
        public static function listeCollections($dashboard = null, $settings = null) {
                global $core;
 
index 8720cab6c2aaaa9493035205bfe4951e7ed45315..5082c6eb985f08fd13ba0a146bb5a8ed54658f2f 100644 (file)
@@ -152,7 +152,7 @@ class wsHTML5AppCompiler {
                        unset($c->manifestPub);
                        $config['collection'] = $c;
                }
-
+               $config['appver'] = $this->collection->settings['version'];
                file_put_contents($this->vdir . '/data/app.js', 'DATAS = ' . CubeIT_Util_Json::encode($config) . ';');
        }