foreach ($composition as $k => $g) {\r
foreach ($g->publications as $l => $p) {\r
$root = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/' . $p->id;\r
- $couv = $root . '/data/background/36/t1.jpg';\r
+ $couv = $root . '/cover.jpg';\r
$couvertures[$p->id] = base64_encode(file_get_contents($couv));\r
$publications[] = $p->id;\r
}\r
}\r
\r
- $d = array('id' => $id, 'time' => $version, 'manifest' => $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os), 'datas' => $composition, 'couvertures' => $couvertures);\r
+ $d = array('id' => $id, 'time' => $version, 'datas' => $composition, 'couvertures' => $couvertures);\r
+ $d = array_merge($d, $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os));\r
\r
$dao = new wsDAOCollection($core->con);\r
$col = $dao->selectById($id);\r
}\r
\r
protected function _getManifest($publications, $dir) {\r
+ global $core;\r
+ $res = array();\r
+ $res['manifest'] = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => true);\r
+ $res['manifestPub'] = array();\r
\r
-\r
- $res = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => false);\r
$bundles = array();\r
\r
$removeFromRelative = realpath(ROOT . '/' . $dir) . '/';\r
\r
+\r
foreach ($publications as $p) {\r
- $c = array();\r
- $c1 = array();\r
+ $res['manifestPub'][$p] = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => true);\r
+\r
$r = $p . '/';\r
$iterator = CubeIT_Files::getRecursiveDirectoryIterator(ROOT . $dir . '/' . $p);\r
+\r
+ $daoBook = new wsDAOBook($core->con);\r
+ $book = $daoBook->selectById($p);\r
+ $daoTheme = new wsDAOTheme($core->con);\r
+ $theme = $daoTheme->selectById($book->theme);\r
+ $orders = $this->_getBundles($book);\r
+ $reg = $this->_getRegExpManifest($r, $book, $theme);\r
+\r
+ $b = array();\r
+\r
foreach ($iterator as $k => $f) {\r
if ($f->isDir()) {\r
continue;\r
}\r
$path = str_replace($removeFromRelative, '', $k);\r
- $order = $this->_inFirstManifest($path, $r);\r
- if ($order === 0) {\r
- $c1[] = $path;\r
- } elseif ($order === 1) {\r
- $c[] = $path;\r
+ $order = $this->_inFirstManifest($path, $orders, $reg);\r
+\r
+ if (!isset($b[$order])) {\r
+ $b[$order] = array();\r
}\r
+\r
+ $b[$order][] = $path;\r
}\r
- //shuffle($c);\r
\r
- $bundles[] = array('name' => 'p_' . $p, 'contents' => $c1);\r
- $bundles[] = array('name' => 'p_' . $p . '_', 'contents' => $c);\r
+\r
+\r
+ $bundles[] = array('name' => 'p_' . $p, 'contents' => $b['loading']);\r
+\r
+ $res['manifestPub'][$p]['bundles'] = array();\r
+\r
+ foreach ($b as $name => $contents) {\r
+ if ($name == 'loading') {\r
+ continue;\r
+ }\r
+ $k = array_search($name, $orders);\r
+ $res['manifestPub'][$p]['bundles'][$k] = array('name' => $name, 'contents' => $contents);\r
+ }\r
+ ksort($res['manifestPub'][$p]['bundles']);\r
+ $res['manifestPub'][$p]['bundles'] = array_values($res['manifestPub'][$p]['bundles']);\r
}\r
\r
- $res['bundles'] = $bundles;\r
+ $res['manifest']['bundles'] = $bundles;\r
return $res;\r
}\r
\r
- protected function _inFirstManifest($p, $r) {\r
+ protected function _getRegExpManifest($r, $book, $theme) {\r
+ $reg = array();\r
+ $reg['loading'] = array('^' . $r . 'style/(.*).css$', '^' . $r . 'index.html$', '^' . $r . 'data/style/(.*)$', '^' . $r . 'data/(.*).js$', '^' . $r . 'data/images/' . $theme->parametres->logoLoader . '$');\r
+ $reg['extras'] = array('^' . $r . 'data/links/(.*)$', '^' . $r . 'data/(.*).pdf$', '^' . $r . 'cover.jpg$');\r
+ $reg['thumbnails'] = array('^' . $r . 'data/thumbnails/p(\d+).jpg$');\r
+ for ($i = 1; $i <= $book->parametres->pages; $i++) {\r
+ $var = 'content_' . $i;\r
+ $reg[$var] = array('^' . $r . 'data/background/150/t' . $i . '.jpg$', '^' . $r . 'data/contents/p' . $i . '.svg$');\r
+ }\r
+ $reg['urgents'] = array('^' . $r . 'images/(.*)$', '^' . $r . 'data/images/(.*)$', '^' . $r . 'style/fonts/(.*).ttf$');\r
+ return $reg;\r
+ }\r
+\r
+ protected function _inFirstManifest($p, $orders, $reg) {\r
\r
- $ok = array('^' . $r . 'style/(.*)$', '^' . $r . 'index.html$', '^' . $r . 'images/(.*)$', '^' . $r . 'data/images/(.*)$', '^' . $r . 'data/style/(.*)$', '^' . $r . 'data/(.*).js$');\r
- foreach ($ok as $v) {\r
- if (preg_match('|' . $v . '|i', $p)) {\r
- fb('ok : ' . $v, $p);\r
- return 0;\r
+\r
+ foreach ($orders as $list) {\r
+ foreach ($reg[$list] as $v) {\r
+ if (preg_match('|' . $v . '|', $p)) {\r
+ fb($p);\r
+ if ($p == '11461/data/background/150/t25.jpg') {\r
+ fb($reg[$list]);\r
+ fb($v);\r
+ }\r
+ return $list;\r
+ }\r
}\r
}\r
- return 1;\r
+ return $list;\r
+ }\r
+\r
+ protected function _getBundles($book) {\r
+ $res = array(0 => 'loading', 200001 => 'extras', 20000 => 'thumbnails', 1 => 'urgents');\r
+ for ($i = 1; $i <= $book->parametres->pages; $i++) {\r
+ $k = 2 + $i;\r
+ $res[$k] = 'content_' . $i;\r
+ }\r
+ return $res;\r
}\r
\r
public function collectionPushRegister() {\r
}
}
- protected static $resolutions = array(150, 36);
+ protected static $resolutions = array(150);
protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', '');
public $jsFiles = array(
'js/libs/fix/ios-orientation.js',
'js/libs/jquery/jquery.localscroll.js',
'js/libs/gsap/TweenMax.js',
'js/libs/gsap/jquery.gsap.js',
+ 'js/libs/gal/gal.js',
+ 'js/libs/gal/gal.filesystem.js',
'js/libs/fluidbook/fluidbook.utils.js',
'js/libs/fluidbook/fluidbook.support.js',
'js/libs/fluidbook/fluidbook.video.js',
file_put_contents($this->vdir . '/data/search.js', $js);
}
+ public function supportSVG() {
+ if (!$this->phonegap) {
+ return false;
+ } else if ($this->phonegap == 'ios') {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
protected function writeConfig() {
$this->config->numerotation = explode(',', $this->book->numerotation);
$this->config->id = $this->book->book_id;
$this->config->navOrder = $navOrder;
$this->config->standalone = $this->standalone;
+ if ($this->config->phonegap) {
+ $this->config->manifest = $this->writeManifest();
+ }
return 'var DATAS=' . json_encode($this->config) . ';' . "\n";
}
+ protected function writeManifest() {
+ $res=array();
+ }
+
protected function writeIcons() {
$res = array();
// Get the colors used to colorize graphics
);
$this->config->iconsDimensions = array();
+ $makepng = !$this->supportSVG();
foreach ($icons as $icon => $color) {
- wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/', 4, $w, $h);
+ wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/', 4, $w, $h, $makepng);
$this->config->iconsDimensions[$icon] = array($w, $h);
}
return $res;
$this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/' . $this->backgroundsPrefix . $page . '.jpg');
}
$this->copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/thumbnails/p' . $page . '.jpg');
+
+ if ($page == 1) {
+ $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/t36-' . $infos['document_page'] . '.jpg', $this->vdir . '/cover.jpg');
+ }
}
}