public function saveSettings() {\r
global $core;\r
$dao = new wsDAOBook($core->con);\r
- $dao->setSettings($this->args['book_id'], $this->args['settings']);\r
+\r
+ $pages = $dao->getPagesOfBook($this->args['book_id']);\r
+ $nb_pages = count($pages);\r
+\r
+ $daoDoc = new wsDAODocument($core->con);\r
+ $firstDoc = $daoDoc->selectById($pages[1]['document_id']);\r
+ $size = $firstDoc->generalInfos['size'];\r
+\r
+ $settings = json_decode($this->args['settings'], false);\r
+ $settings->width=$size[0];\r
+ $settings->height=$size[1];\r
+\r
+ $dao->setSettings($this->args['book_id'], $settings);\r
}\r
\r
public function setChapters() {\r
$couvertures = array();\r
$vroot = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/';\r
\r
+ $publications = array();\r
+\r
foreach ($composition as $k => $g) {\r
foreach ($g->publications as $l => $p) {\r
+ $publications[] = $p->id;\r
+ }\r
+ }\r
+\r
+ $daoBook = new wsDAOBook($core->con);\r
+ $books = $daoBook->selectByIds($publications);\r
+\r
+ foreach ($composition as $k => $g) {\r
+ foreach ($g->publications as $l => $p) {\r
+ $book = $books[$p->id];\r
$root = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/' . $p->id;\r
$couv = $root . '/cover.jpg';\r
$couvertures[$p->id] = base64_encode(file_get_contents($couv));\r
- $publications[] = $p->id;\r
+ $composition[$k]->publications[$l]->width = $book->parametres->width;\r
+ $composition[$k]->publications[$l]->height = $book->parametres->height;\r
}\r
}\r
\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
+ $d = array_merge($d, $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os, $books));\r
\r
$dao = new wsDAOCollection($core->con);\r
$col = $dao->selectById($id);\r
exit;\r
}\r
\r
- protected function _getManifest($publications, $dir) {\r
+ protected function _getManifest($publications, $dir, $books) {\r
global $core;\r
$res = array();\r
$res['manifest'] = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => true);\r
$bundles = array();\r
\r
$removeFromRelative = realpath(ROOT . '/' . $dir) . '/';\r
-\r
+ $daoTheme = new wsDAOTheme($core->con);\r
\r
foreach ($publications as $p) {\r
$res['manifestPub'][$p] = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => true);\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
+ $book = $books[$p];\r
$theme = $daoTheme->selectById($book->theme);\r
$orders = $this->_getBundles($book);\r
$reg = $this->_getRegExpManifest($r, $book, $theme);\r
$b[$order][] = $path;\r
}\r
\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
public function setSettings($book_id, $settings) {\r
$book = $this->selectById($book_id);\r
$parametres = $book->parametres;\r
- $new = json_decode($settings, false);\r
+ $new =$settings;\r
foreach ($new as $k => $v) {\r
if ($k == '_empty_') {\r
continue;\r
function writeScript() {
$config = array();
$config['id'] = $this->collectionId;
- $config['couleurA']=$this->collection->settings['couleurA'];
- $config['couleurB']=$this->collection->settings['couleurB'];
- $config['couleurC']=$this->collection->settings['couleurC'];
+ $config['couleurA'] = $this->collection->settings['couleurA'];
+ $config['couleurB'] = $this->collection->settings['couleurB'];
+ $config['couleurC'] = $this->collection->settings['couleurC'];
$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 . '/data/app.js', 'DATAS = ' . CubeIT_Util_Json::encode($config) . ';');
}
$this->copy($this->wdir . '/' . $this->collection->theme['back'], $imagesdir . '/' . $this->collection->theme['back']);
+ $this->copy($this->wdir . '/' . $this->collection->theme['etagere'], $imagesdir . '/' . $this->collection->theme['etagere']);
$c[] = 'body{background-image:url("images/' . $this->collection->theme['back'] . '");}';
+ $c[] = '#shelves{background-image:url("images/' . $this->collection->theme['etagere'] . '");}';
file_put_contents($this->vdir . '/data/app.css', implode("\n", $c));
}
}
protected function writeManifest() {
- $res=array();
+ $res = array();
}
protected function writeIcons() {
$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');
+ $this->_makeCover(WS_DOCS . '/' . $infos['document_id'] . '/html/t36-' . $infos['document_page'] . '.jpg');
}
}
}
+ protected function _makeCover($orig) {
+ $size = getimagesize($orig);
+ $w = $size[0];
+ $h = $size[1];
+
+ //$tmp = cubeFiles::tempnam() . '.png';
+ $tmp = $this->vdir . '/covers.png';
+
+ $c = new cubeCommandLine('convert');
+ $c->setArg(null, ROOT . '/images/ws/shade-cover-app.png');
+ $c->setManualArg('-resize ' . round($w / 3) . 'x' . $h);
+ $c->setArg(null, $tmp);
+ $c->execute();
+
+ $convert = new cubeCommandLine('composite');
+ $cmd.= '-compose Multiply ';
+ $cmd.=$tmp . ' ' . $orig . ' ';
+ $cmd.=$this->vdir . '/cover.jpg';
+ $convert->setManualArg($cmd);
+ $convert->execute();
+
+ unlink($tmp);
+ }
+
protected function copy($s, $t) {
if (!file_exists($s)) {
fb($s . ' dont exists');