From 903130f48e7a535c7ec76032333b13c06e9a93cf Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Thu, 14 Nov 2013 10:43:12 +0000 Subject: [PATCH] --- inc/ws/Controlleur/class.ws.url.php | 6 ++++ inc/ws/Util/class.ws.exporter.php | 35 ++++++++++++++++--- .../html5/app/class.ws.html5.app.compiler.php | 22 +++++++----- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index ec97bf9f6..af535e621 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -312,6 +312,12 @@ class wsUrl { $res.='' . __('Certificat APNS') . ' Prod (' . __('Fichier .pem') . ')'; $res.=''; + $res.='

' . __('Applications offline') . '

'; + $res.=''; + $res.=''; + $res.=''; + $res.='
' . __("Filtres d'exclusion") . '' . form::textarea(array('settings[offline_exclude]', 'offline_exclude'), 30, 3, $collection->settings['offline_exclude']) . '
' . __("Synchronisations supplémentaires") . '' . form::textarea(array('settings[offline_syncs]', 'offline_syncs'), 30, 3, $collection->settings['offline_syncs']) . '
'; + $res.='

' . __('Thème') . '

'; $res.=''; $images = array('back' => __('Image de fond'), 'etagere' => __("Image de l'étagère"), 'icon' => __("Icône de l'application") . ' (1024x1024px)'); diff --git a/inc/ws/Util/class.ws.exporter.php b/inc/ws/Util/class.ws.exporter.php index 23f38e67b..a49f1d695 100644 --- a/inc/ws/Util/class.ws.exporter.php +++ b/inc/ws/Util/class.ws.exporter.php @@ -61,8 +61,37 @@ class wsExporter { ) ); + $allpub = $compiler->books; + if (isset($collection->settings['offline']) && $collection->settings['offline']) { - $phonegap->addAdditionalSource('publications', $compiler->getPublishedVersionPath($os)); + $p = $compiler->getPublishedVersionPath($os); + $phonegap->addAdditionalSource('publications', $p); + + $exs = explode("\n", $collection->settings['offline_exclude']); + foreach ($exs as $e) { + $e = trim($e); + if ($e == '') { + continue; + } + + if (stristr($e, '$id$')) { + foreach ($allpub as $i) { + $phonegap->addExclude('"' . str_replace('$id$', $i, $e) . '"'); + } + } else { + $phonegap->addExclude('"' . $e . '"'); + } + } + + $add = explode("\n", $collection->settings['offline_syncs']); + foreach ($add as $a) { + $a = trim($a); + if ($a == '') { + continue; + } + list($to, $source) = explode(':', $a); + $phonegap->addAdditionalSource('publications' . '/' . $to, $p . $source); + } } $ctrl = isset($_GET['ctrl']) && $_GET['ctrl'] == 'true'; @@ -77,10 +106,6 @@ class wsExporter { } $phonegap->run($run); - - /* $this->_createProject($os, $collection->nom, $collection->settings['namespace']); - $this->_collectionAssets($os, $compiler); - $this->_transfertPhonegap($os, $dir, $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 index cacaf46dd..99dff1fdc 100644 --- a/inc/ws/Util/html5/app/class.ws.html5.app.compiler.php +++ b/inc/ws/Util/html5/app/class.ws.html5.app.compiler.php @@ -8,6 +8,7 @@ class wsHTML5AppCompiler { public $os; public $phonegapVersion; public $langs; + public $books=array(); public function __construct($collectionId) { @@ -19,12 +20,12 @@ class wsHTML5AppCompiler { foreach ($this->collection->datas as $group) { foreach ($group['publications'] as $p) { - $books[] = $p['id']; + $this->books[] = $p['id']; } } $daoBook = new wsDAOBook($core->con); - $allbooks = $daoBook->selectByIds($books); + $allbooks = $daoBook->selectByIds($this->books); $this->langs = array(); foreach ($allbooks as $b) { @@ -40,12 +41,7 @@ class wsHTML5AppCompiler { $dir = WS_COLLECTIONS . '/versions/' . $this->collectionId . '/' . $time . '/'; - $books = array(); - foreach ($this->collection->datas as $group) { - foreach ($group['publications'] as $p) { - $books[] = $p['id']; - } - } + $books = $this->getPublicationsIds(); $exporter = new wsExporter(); foreach ($os as $o) { @@ -63,6 +59,16 @@ class wsHTML5AppCompiler { return $time; } + protected function getPublicationsIds() { + $books = array(); + foreach ($this->collection->datas as $group) { + foreach ($group['publications'] as $p) { + $books[] = $p['id']; + } + } + return $books; + } + protected function copy($s, $t) { if (!file_exists($s)) { return; -- 2.39.5