From 64fa0d6ea689154355fdd35d5fc1608796e5f8d6 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 9 Jul 2010 13:42:34 +0000 Subject: [PATCH] --- inc/ws/Controlleur/class.ws.flash.php | 27 ++++++++++++-- inc/ws/Controlleur/class.ws.url.php | 32 ++-------------- inc/ws/DAO/class.ws.dao.book.php | 54 ++++++++++++++++++++++++++- 3 files changed, 80 insertions(+), 33 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index 37a0f95d8..639f53270 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -103,7 +103,7 @@ class wsFlash extends cubeFlashGateway { } $docs = array_unique($docs); $p->addAttribute('documents', implode(',', $docs)); - if (is_null($book->numerotation) || !$book->numerotation || $book->numerotation=='null') { + if (is_null($book->numerotation) || !$book->numerotation || $book->numerotation == 'null') { $this->xml->addChild('numerotation', implode(',', $defaultNum)); } else { $this->xml->addChild('numerotation', $book->numerotation); @@ -372,14 +372,35 @@ class wsFlash extends cubeFlashGateway { global $core; $dao = new wsDAOBook($core->con); $book = $dao->selectById($this->args['book_id']); - $this->xml->addChild('extras', htmlspecialchars(cubeXML::tidy($book->extras->asXML()))); + + if ($book->extras != '') { + $tidy = cubeXML::tidy('' . $book->extras . ''); + $tidy = str_replace('', '', $tidy); + $tidy = str_replace('', '', $tidy); + $tidy = str_replace('', '', $tidy); + $tidy = trim($tidy); + $e = explode("\n", $tidy); + foreach($e as $k => $v) { + if (substr($v, 0, 2) == ' ') { + $v = substr($v, 2); + } + $e[$k] = $v; + } + + $extras = implode("\n", $e); + } else { + $extras = ''; + } + + $this->xml->addChild('extras', $extras); } public function saveExtras() { global $core; $dao = new wsDAOBook($core->con); - $dao->setExtras($this->args['book_id'], $this->args['extras']); + $res = $dao->setExtras($this->args['book_id'], $this->args['extras']); + $this->xml->addChild('ok', $res?'1':'0'); } public function getBookInfos() diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 2f95c2b99..1a55cf315 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -123,36 +123,10 @@ html{height:100%}' . "\n"; public static function testAS() { global $core; - $dao = new wsDAOBook($core->con); - $book = $dao->selectById(2963); - $pages = $dao->getPagesOfBook(2963); - - $daoTheme = new wsDAOTheme($core->con); - $theme = $daoTheme->getThemeOfBook(2963); - - $flex = new cubeFlexCompiler('FluidbookDatas', ROOT . '/books/datasCompiler/test', 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH); - $flex->addVariable('links', $book->links); - $flex->addVariable('datas', $book->parametres->toStandardObject()); - $flex->addVariable('traductions', wsLang::getTraductionWithId($book->traductions)); - $flex->addVariable('chapters', $book->chapters); - $flex->addVariable('extras', $book->extras); - $flex->addVariable('numerotation', $book->numerotation); - $flex->addVariable('theme', $theme->parametres->toStandardObject()); - $flex->addVariable('pages', count($pages)); - foreach($pages as $i => $infos) { - $flex->addBitmap(ROOT . '/docs/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', 'thumb' . $i); - } - $themeRoot = ROOT . '/themes/' . $theme->theme_id . '/'; - if ($theme->parametres->useBackgroundImage) { - $flex->addBitmap($themeRoot . $theme->parametres->backgroundImage, 'background'); - } - if ($theme->parametres->useMenuImage) { - $flex->addBitmap($themeRoot . $theme->parametres->menuImage, 'menu'); - } - $flex->addBitmap($themeRoot . $theme->parametres->logo, 'logo'); - + $dao=new wsDAOBook($core->con); + header('Content-type: text/plain'); ob_clean(); - $flex->compile(); + echo $dao->compile(2963,3); exit; } } diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index e60e61cd4..6bedc633b 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -157,7 +157,7 @@ class wsDAOBook extends extranetDAO { $pages = array(); $r = $this->con->select('SELECT b.*,d.numberSections AS num FROM book_pages b LEFT JOIN documents d ON d.document_id=b.document_id WHERE b.book_id=\'' . $this->con->escape($book_id) . '\' ORDER BY book_page'); while ($r->fetch()) { - $n = explode(',',$r->num); + $n = explode(',', $r->num); $pages[$r->book_page] = array('document_id' => $r->document_id, 'document_page' => $r->document_page, 'defaultNum' => $n[$r->document_page-1]); } fb($pages); @@ -286,9 +286,23 @@ class wsDAOBook extends extranetDAO { public function setExtras($book_id, $extras) { + if ($extras != '') { + // Valide le XML + $x = simplexml_load_string('' . $extras . ''); + if (!$x) { + return false; + } + $extras = $x->asXML(); + $extras = str_replace('', '', $extras); + $extras = str_replace('', '', $extras); + $extras = str_replace('', '', $extras); + $extras = trim($extras); + } + $c = $this->con->openCursor('books'); $c->extras = $extras; $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); + return true; } public function setLang($book_id, $base, $traductions) @@ -390,6 +404,44 @@ class wsDAOBook extends extranetDAO { { $pages = $this->getPagesOfBook($book_id); } + + public function compile($book_id, $version = 3) + { + if ($version == 3) { + return $this->compile3($book_id); + } + } + + public function compile3($book_id) + { + $book = $this->selectById($book_id); + $pages = $this->getPagesOfBook($book_id); + + $daoTheme = new wsDAOTheme($this->con); + $theme = $daoTheme->getThemeOfBook($book_id); + + $flex = new cubeFlexCompiler('FluidbookDatas', ROOT . '/books/datasCompiler/' . $book_id, 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH); + $flex->addVariable('links', $book->links); + $flex->addVariable('datas', $book->parametres->toStandardObject()); + $flex->addVariable('traductions', wsLang::getTraductionWithId($book->traductions)); + $flex->addVariable('chapters', $book->chapters); + $flex->addVariable('extras', '' . $book->extras . '', false, true, 'XML'); + $flex->addVariable('numerotation', $book->numerotation); + $flex->addVariable('theme', $theme->parametres->toStandardObject()); + $flex->addVariable('pages', count($pages)); + foreach($pages as $i => $infos) { + $flex->addBitmap(ROOT . '/docs/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', 'thumb' . $i); + } + $themeRoot = ROOT . '/themes/' . $theme->theme_id . '/'; + if ($theme->parametres->useBackgroundImage) { + $flex->addBitmap($themeRoot . $theme->parametres->backgroundImage, 'background'); + } + if ($theme->parametres->useMenuImage) { + $flex->addBitmap($themeRoot . $theme->parametres->menuImage, 'menu'); + } + $flex->addBitmap($themeRoot . $theme->parametres->logo, 'logo'); + return $flex->compile(); + } } ?> \ No newline at end of file -- 2.39.5