]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 9 Jul 2010 13:42:34 +0000 (13:42 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 9 Jul 2010 13:42:34 +0000 (13:42 +0000)
inc/ws/Controlleur/class.ws.flash.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/DAO/class.ws.dao.book.php

index 37a0f95d845f577828810d993b55d18a56da59f4..639f532700af55a872e1a3ea72ab2ce26c0409ea 100644 (file)
@@ -103,7 +103,7 @@ class wsFlash extends cubeFlashGateway {
                }\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
@@ -372,14 +372,35 @@ class wsFlash extends cubeFlashGateway {
                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
index 2f95c2b99520afe5641a3a9315adb7b1d65e3f1a..1a55cf31550812a63a66dd7ba82ba6e4dace03c9 100644 (file)
@@ -123,36 +123,10 @@ html{height:100%}' . "\n";
        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
index e60e61cd49e238ffbc5f772f44d53dfb3cd55e0e..6bedc633b9eb871b1c03a6a25d8355f8c8ae62db 100644 (file)
@@ -157,7 +157,7 @@ class wsDAOBook extends extranetDAO {
                $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
@@ -286,9 +286,23 @@ class wsDAOBook extends extranetDAO {
 \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
@@ -390,6 +404,44 @@ class wsDAOBook extends extranetDAO {
        {\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