From: vincent@cubedesigners.com Date: Mon, 29 Jul 2013 09:19:04 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=04774c67d6b361d43426def4efcdd67f259a25a4;p=cubeextranet.git --- diff --git a/fluidbook/cover.jpg b/fluidbook/cover.jpg new file mode 100644 index 000000000..d95e2a2a8 Binary files /dev/null and b/fluidbook/cover.jpg differ diff --git a/images/ws/shade-cover-app.png b/images/ws/shade-cover-app.png new file mode 100644 index 000000000..f96319b35 Binary files /dev/null and b/images/ws/shade-cover-app.png differ diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index 192b6ba32..4887b80b7 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -452,7 +452,19 @@ class wsFlash extends cubeFlashGateway { public function saveSettings() { global $core; $dao = new wsDAOBook($core->con); - $dao->setSettings($this->args['book_id'], $this->args['settings']); + + $pages = $dao->getPagesOfBook($this->args['book_id']); + $nb_pages = count($pages); + + $daoDoc = new wsDAODocument($core->con); + $firstDoc = $daoDoc->selectById($pages[1]['document_id']); + $size = $firstDoc->generalInfos['size']; + + $settings = json_decode($this->args['settings'], false); + $settings->width=$size[0]; + $settings->height=$size[1]; + + $dao->setSettings($this->args['book_id'], $settings); } public function setChapters() { diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index cf923b5d5..6642cdb28 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -586,17 +586,30 @@ class wsServices extends cubeFlashGateway { $couvertures = array(); $vroot = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/'; + $publications = array(); + foreach ($composition as $k => $g) { foreach ($g->publications as $l => $p) { + $publications[] = $p->id; + } + } + + $daoBook = new wsDAOBook($core->con); + $books = $daoBook->selectByIds($publications); + + 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)); - $publications[] = $p->id; + $composition[$k]->publications[$l]->width = $book->parametres->width; + $composition[$k]->publications[$l]->height = $book->parametres->height; } } $d = array('id' => $id, 'time' => $version, 'datas' => $composition, 'couvertures' => $couvertures); - $d = array_merge($d, $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os)); + $d = array_merge($d, $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os, $books)); $dao = new wsDAOCollection($core->con); $col = $dao->selectById($id); @@ -622,7 +635,7 @@ class wsServices extends cubeFlashGateway { exit; } - protected function _getManifest($publications, $dir) { + protected function _getManifest($publications, $dir, $books) { global $core; $res = array(); $res['manifest'] = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => true); @@ -631,7 +644,7 @@ class wsServices extends cubeFlashGateway { $bundles = array(); $removeFromRelative = realpath(ROOT . '/' . $dir) . '/'; - + $daoTheme = new wsDAOTheme($core->con); foreach ($publications as $p) { $res['manifestPub'][$p] = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => true); @@ -639,9 +652,7 @@ class wsServices extends cubeFlashGateway { $r = $p . '/'; $iterator = CubeIT_Files::getRecursiveDirectoryIterator(ROOT . $dir . '/' . $p); - $daoBook = new wsDAOBook($core->con); - $book = $daoBook->selectById($p); - $daoTheme = new wsDAOTheme($core->con); + $book = $books[$p]; $theme = $daoTheme->selectById($book->theme); $orders = $this->_getBundles($book); $reg = $this->_getRegExpManifest($r, $book, $theme); @@ -662,10 +673,7 @@ class wsServices extends cubeFlashGateway { $b[$order][] = $path; } - - $bundles[] = array('name' => 'p_' . $p, 'contents' => $b['loading']); - $res['manifestPub'][$p]['bundles'] = array(); foreach ($b as $name => $contents) { diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index b1c86855c..2aa2c0aa3 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -629,7 +629,7 @@ class wsDAOBook extends commonDAO { public function setSettings($book_id, $settings) { $book = $this->selectById($book_id); $parametres = $book->parametres; - $new = json_decode($settings, false); + $new =$settings; foreach ($new as $k => $v) { if ($k == '_empty_') { continue; 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 364f389c7..23578c514 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 @@ -106,9 +106,9 @@ class wsHTML5AppCompiler { 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) . ';'); @@ -127,8 +127,10 @@ class wsHTML5AppCompiler { } $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)); } diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 997287f68..1b04a8df4 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -845,7 +845,7 @@ class wsHTML5Compiler { } protected function writeManifest() { - $res=array(); + $res = array(); } protected function writeIcons() { @@ -910,11 +910,35 @@ class wsHTML5Compiler { $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');