}\r
$docs = array_unique($docs);\r
$p->addAttribute('documents', implode(',', $docs));\r
- if (is_null($book->numerotation) || !$book->numerotation || $book->numerotation=='null') {\r
+ if (is_null($book->numerotation) || !$book->numerotation || $book->numerotation == 'null') {\r
$this->xml->addChild('numerotation', implode(',', $defaultNum));\r
} else {\r
$this->xml->addChild('numerotation', $book->numerotation);\r
global $core;\r
$dao = new wsDAOBook($core->con);\r
$book = $dao->selectById($this->args['book_id']);\r
- $this->xml->addChild('extras', htmlspecialchars(cubeXML::tidy($book->extras->asXML())));\r
+\r
+ if ($book->extras != '') {\r
+ $tidy = cubeXML::tidy('<extras>' . $book->extras . '</extras>');\r
+ $tidy = str_replace('<extras>', '', $tidy);\r
+ $tidy = str_replace('</extras>', '', $tidy);\r
+ $tidy = str_replace('<?xml version="1.0"?>', '', $tidy);\r
+ $tidy = trim($tidy);\r
+ $e = explode("\n", $tidy);\r
+ foreach($e as $k => $v) {\r
+ if (substr($v, 0, 2) == ' ') {\r
+ $v = substr($v, 2);\r
+ }\r
+ $e[$k] = $v;\r
+ }\r
+\r
+ $extras = implode("\n", $e);\r
+ } else {\r
+ $extras = '';\r
+ }\r
+\r
+ $this->xml->addChild('extras', $extras);\r
}\r
\r
public function saveExtras()\r
{\r
global $core;\r
$dao = new wsDAOBook($core->con);\r
- $dao->setExtras($this->args['book_id'], $this->args['extras']);\r
+ $res = $dao->setExtras($this->args['book_id'], $this->args['extras']);\r
+ $this->xml->addChild('ok', $res?'1':'0');\r
}\r
\r
public function getBookInfos()\r
public static function testAS()\r
{\r
global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->selectById(2963);\r
- $pages = $dao->getPagesOfBook(2963);\r
-\r
- $daoTheme = new wsDAOTheme($core->con);\r
- $theme = $daoTheme->getThemeOfBook(2963);\r
-\r
- $flex = new cubeFlexCompiler('FluidbookDatas', ROOT . '/books/datasCompiler/test', 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH);\r
- $flex->addVariable('links', $book->links);\r
- $flex->addVariable('datas', $book->parametres->toStandardObject());\r
- $flex->addVariable('traductions', wsLang::getTraductionWithId($book->traductions));\r
- $flex->addVariable('chapters', $book->chapters);\r
- $flex->addVariable('extras', $book->extras);\r
- $flex->addVariable('numerotation', $book->numerotation);\r
- $flex->addVariable('theme', $theme->parametres->toStandardObject());\r
- $flex->addVariable('pages', count($pages));\r
- foreach($pages as $i => $infos) {\r
- $flex->addBitmap(ROOT . '/docs/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', 'thumb' . $i);\r
- }\r
- $themeRoot = ROOT . '/themes/' . $theme->theme_id . '/';\r
- if ($theme->parametres->useBackgroundImage) {\r
- $flex->addBitmap($themeRoot . $theme->parametres->backgroundImage, 'background');\r
- }\r
- if ($theme->parametres->useMenuImage) {\r
- $flex->addBitmap($themeRoot . $theme->parametres->menuImage, 'menu');\r
- }\r
- $flex->addBitmap($themeRoot . $theme->parametres->logo, 'logo');\r
-\r
+ $dao=new wsDAOBook($core->con);\r
+ header('Content-type: text/plain');\r
ob_clean();\r
- $flex->compile();\r
+ echo $dao->compile(2963,3);\r
exit;\r
}\r
}\r
$pages = array();\r
$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');\r
while ($r->fetch()) {\r
- $n = explode(',',$r->num);\r
+ $n = explode(',', $r->num);\r
$pages[$r->book_page] = array('document_id' => $r->document_id, 'document_page' => $r->document_page, 'defaultNum' => $n[$r->document_page-1]);\r
}\r
fb($pages);\r
\r
public function setExtras($book_id, $extras)\r
{\r
+ if ($extras != '') {\r
+ // Valide le XML\r
+ $x = simplexml_load_string('<extras>' . $extras . '</extras>');\r
+ if (!$x) {\r
+ return false;\r
+ }\r
+ $extras = $x->asXML();\r
+ $extras = str_replace('<?xml version="1.0"?>', '', $extras);\r
+ $extras = str_replace('<extras>', '', $extras);\r
+ $extras = str_replace('</extras>', '', $extras);\r
+ $extras = trim($extras);\r
+ }\r
+\r
$c = $this->con->openCursor('books');\r
$c->extras = $extras;\r
$c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
+ return true;\r
}\r
\r
public function setLang($book_id, $base, $traductions)\r
{\r
$pages = $this->getPagesOfBook($book_id);\r
}\r
+\r
+ public function compile($book_id, $version = 3)\r
+ {\r
+ if ($version == 3) {\r
+ return $this->compile3($book_id);\r
+ }\r
+ }\r
+\r
+ public function compile3($book_id)\r
+ {\r
+ $book = $this->selectById($book_id);\r
+ $pages = $this->getPagesOfBook($book_id);\r
+\r
+ $daoTheme = new wsDAOTheme($this->con);\r
+ $theme = $daoTheme->getThemeOfBook($book_id);\r
+\r
+ $flex = new cubeFlexCompiler('FluidbookDatas', ROOT . '/books/datasCompiler/' . $book_id, 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH);\r
+ $flex->addVariable('links', $book->links);\r
+ $flex->addVariable('datas', $book->parametres->toStandardObject());\r
+ $flex->addVariable('traductions', wsLang::getTraductionWithId($book->traductions));\r
+ $flex->addVariable('chapters', $book->chapters);\r
+ $flex->addVariable('extras', '<extras>' . $book->extras . '</extras>', false, true, 'XML');\r
+ $flex->addVariable('numerotation', $book->numerotation);\r
+ $flex->addVariable('theme', $theme->parametres->toStandardObject());\r
+ $flex->addVariable('pages', count($pages));\r
+ foreach($pages as $i => $infos) {\r
+ $flex->addBitmap(ROOT . '/docs/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', 'thumb' . $i);\r
+ }\r
+ $themeRoot = ROOT . '/themes/' . $theme->theme_id . '/';\r
+ if ($theme->parametres->useBackgroundImage) {\r
+ $flex->addBitmap($themeRoot . $theme->parametres->backgroundImage, 'background');\r
+ }\r
+ if ($theme->parametres->useMenuImage) {\r
+ $flex->addBitmap($themeRoot . $theme->parametres->menuImage, 'menu');\r
+ }\r
+ $flex->addBitmap($themeRoot . $theme->parametres->logo, 'logo');\r
+ return $flex->compile();\r
+ }\r
}\r
\r
?>
\ No newline at end of file