]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 6 Jan 2011 17:14:23 +0000 (17:14 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 6 Jan 2011 17:14:23 +0000 (17:14 +0000)
inc/extranet/Controlleur/class.extranet.core.php
inc/ws/Controlleur/class.ws.conversion.session.php
inc/ws/Controlleur/class.ws.flash.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/DAO/class.ws.dao.document.php
inc/ws/Metier/class.ws.book.php
inc/ws/Metier/class.ws.document.php

index 365ec2d0e6d517a6734d62ebe01ac3112e915cd3..374abfa2e976dbae1180159010a41c604903805a 100644 (file)
@@ -314,9 +314,7 @@ class extranetCore extends cubeCore {
                $db->documents->localInfos('text', 0, false);\r
                $db->documents->generalInfos('text', 0, false);\r
                $db->documents->conversionInfos('text', 0, false);\r
-               $db->documents->bookmarks('text', 0, false);\r
                $db->documents->numberSections('text', 0, false);\r
-               $db->documents->links('text', 0, false);\r
                $db->documents->localHash('varchar', 64, false);\r
                // Clés\r
                $db->documents->primary('pk_documents', 'document_id');\r
@@ -326,12 +324,15 @@ class extranetCore extends cubeCore {
                $db->documents->reference('fk_documents_proprietaire', 'proprietaire', 'utilisateurs', 'utilisateur_id');\r
                // .\r
                // Table pages des documents\r
-               $db->document_pages->document_id('integer', 0, false);\r
-               $db->document_pages->document_page('integer', 0, false);\r
-               $db->document_pages->text('text', 0, false);\r
-               $db->document_pages->links('text', 0, false);\r
+               $db->document_links->document_id('integer', 0, false);\r
+               $db->document_links->document_page('integer', 0, false);\r
+               $db->document_links->links('text', 0, false);\r
+               $db->document_links->rulers('text', 0, false);\r
+               $db->document_links->update('integer', 0, false);\r
                // Clés\r
-               $db->document_pages->primary('pk_document_pages', 'document_id', 'document_page');\r
+               $db->document_links->primary('pk_document_links', 'document_id', 'document_page', 'update');\r
+               $db->document_links->index('index_document_links_date', 'BTREE', 'update');\r
+               $db->document_links->index('index_document_links_document_id', 'BTREE', 'document_id');\r
                // .\r
                // Table Books\r
                $db->books->book_id('integer', 0, false);\r
@@ -346,8 +347,6 @@ class extranetCore extends cubeCore {
                $db->books->date_status('integer', 0, false);\r
                $db->books->parametres('text', 0, false);\r
                $db->books->chapters('text', 0, false);\r
-               $db->books->links('text', 0, false);\r
-               $db->books->rulers('text', 0, false);\r
                $db->books->extras('text', 0, false);\r
                $db->books->traductions('text', 0, false);\r
                $db->books->date('integer', 0, false);\r
index 933340ca895aecfe3d9a2c496f41b1adf0ccbd6d..2a2f2f36fe8fa50ef982077e3da0f1184b7944ad 100644 (file)
@@ -67,6 +67,7 @@ class wsConversionSession {
                        $this->serialize();\r
                        if (!$this->reload) {\r
                                $this->currentDoc->globalOperations();\r
+                               $dao->putLinksFromCSV($this->currentDoc->document_id);\r
                        }\r
                        if ($this->documentsPages[$doc->document_id] == 'all') {\r
                                $docPages = range(1, $doc->generalInfos['pages']);\r
index cdcb045903031b48f9e45c81e19cd70041248881..42d01d70b0eff6e484e48f080939aaa51dbe5d31 100644 (file)
@@ -425,7 +425,7 @@ class wsFlash extends cubeFlashGateway {
                global $core;\r
                $dao = new wsDAOBook($core->con);\r
                $book = $dao->selectById($this->args['book_id']);\r
-               $this->xml->addChild('links', json_encode($book->links));\r
+\r
                $pages = $dao->getPagesOfBook($this->args['book_id']);\r
                $nb_pages = count($pages);\r
                $this->xml->addChild('pages', $nb_pages);\r
@@ -434,16 +434,18 @@ class wsFlash extends cubeFlashGateway {
                $daoDoc = new wsDAODocument($core->con);\r
                $firstDoc = $daoDoc->selectById($pages[1]['document_id']);\r
                $size = $firstDoc->generalInfos['size'];\r
+               $daoDoc->getLinksAndRulers($this->args['book_id'], $links , $rulers);\r
 \r
                $this->xml->addChild('width', $size[0]);\r
                $this->xml->addChild('height', $size[1]);\r
-               $this->xml->addChild('rulers', json_encode($book->rulers));\r
+               $this->xml->addChild('links', json_encode($links));\r
+               $this->xml->addChild('rulers', json_encode($rulers));\r
        }\r
 \r
        public function saveLinks()\r
        {\r
                global $core;\r
-               $dao = new wsDAOBook($core->con);\r
+               $dao = new wsDAODocument($core->con);\r
                $dao->setLinksAndRulers($this->args['book_id'], $this->args['links'], $this->args['rulers']);\r
        }\r
 \r
index 42b6b191d090834ebee4a5700ce03c45dc83a554..71449467d95916c8a42f12ffeac08b98540c7579 100644 (file)
@@ -16,8 +16,6 @@ class wsDAOBook extends extranetDAO {
                $book->date = $r->date;\r
                $book->pages = array();\r
                $book->chapters = $r->chapters;\r
-               $book->links = $r->links;\r
-               $book->rulers = $r->rulers;\r
                $book->traductions = $r->traductions;\r
                $book->parametres = $r->parametres;\r
                $book->extras = $r->extras;\r
@@ -285,15 +283,6 @@ class wsDAOBook extends extranetDAO {
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
        }\r
 \r
-       public function setLinksAndRulers($book_id, $links, $rulers)\r
-       {\r
-               $c = $this->con->openCursor('books');\r
-               $c->links = json_encode(json_decode($links, false));\r
-               $c->rulers = json_encode(json_decode($rulers, false));\r
-               $c->changedate = TIME;\r
-               $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
-       }\r
-\r
        public function setExtras($book_id, $extras)\r
        {\r
                if ($extras != '') {\r
@@ -403,47 +392,6 @@ class wsDAOBook extends extranetDAO {
                }\r
        }\r
 \r
-       public function getLinksFromCSV($book_id)\r
-       {\r
-               $booleans = array('video_loop', 'video_auto_start', 'video_controls', 'video_sound_on');\r
-               $pages = $this->getPagesOfBook($book_id);\r
-               $res = array();\r
-               foreach($pages as $page => $p) {\r
-                       $csv = WS_DOCS . '/' . $p['document_id'] . '/p' . $p['document_page'] . '.csv';\r
-                       $fp = fopen($csv, 'rb');\r
-\r
-                       while (true) {\r
-                               $line = fgetcsv($fp, 512, ';', '"');\r
-                               // End of file\r
-                               if (!$line) {\r
-                                       break;\r
-                               }\r
-                               // Commentaire || ligne vide\r
-                               if (substr($line[0], 0, 1) == '#' || is_null($line[0])) {\r
-                                       continue;\r
-                               }\r
-                               $link = array();\r
-                               $cols = array('page' => '', 'type' => '', 'to' => '', 'left' => '', 'top' => '', 'width' => '', 'height' => '', 'target' => '_blank', 'video_loop' => true, 'video_auto_start' => true, 'video_controls' => true, 'video_sound_on' => true, 'infobulle' => '', 'numerotation' => 'physical');\r
-                               $k = 0;\r
-                               foreach($cols as $col => $default) {\r
-                                       if (isset($line[$k])) {\r
-                                               if (in_array($k, $booleans)) {\r
-                                                       $link[$col] = ($line[$k] == '1');\r
-                                               } else {\r
-                                                       $link[$col] = $line[$k];\r
-                                               }\r
-                                       } else {\r
-                                               $link[$col] = $default;\r
-                                       }\r
-                                       $k++;\r
-                               }\r
-                               $link['page'] = $page;\r
-                               $res[] = $link;\r
-                       }\r
-               }\r
-               return $res;\r
-       }\r
-\r
        public function makeTextsIndexes($book_id, &$index, &$textes)\r
        {\r
                $pages = $this->getPagesOfBook($book_id);\r
index 8e476223d3c1c346918664c8ab074f186d6be796..dece1f35c9103fa9d51e5dd858054ae675075a75 100644 (file)
@@ -18,6 +18,129 @@ class wsDAODocument extends extranetDAO {
                return $document;\r
        }\r
 \r
+       public function putLinksFromCSV($document_id)\r
+       {\r
+               $document = $this->selectById($document_id);\r
+\r
+               $booleans = array('video_loop', 'video_auto_start', 'video_controls', 'video_sound_on');\r
+\r
+               $c = $core->con->openCursor('document_links');\r
+               $c->document_id = $document->document_id;\r
+               $c->rulers = json_encode(array());\r
+               $c->links = json_encode(array());\r
+\r
+               for($page = 1;$page <= $document->generalInfos['pages'];$page++) {\r
+                       $csv = WS_DOCS . '/' . $document->document_id . '/p' . $page . '.csv';\r
+                       $c->update = filemtime($csv);\r
+                       $fp = fopen($csv, 'rb');\r
+                       $links = array();\r
+                       while (true) {\r
+                               $line = fgetcsv($fp, 512, ';', '"');\r
+                               // End of file\r
+                               if (!$line) {\r
+                                       break;\r
+                               }\r
+                               // Commentaire || ligne vide\r
+                               if (substr($line[0], 0, 1) == '#' || is_null($line[0])) {\r
+                                       continue;\r
+                               }\r
+                               $link = array();\r
+                               $cols = array('page' => '', 'type' => '', 'to' => '', 'left' => '', 'top' => '', 'width' => '', 'height' => '', 'target' => '_blank', 'video_loop' => true, 'video_auto_start' => true, 'video_controls' => true, 'video_sound_on' => true, 'infobulle' => '', 'numerotation' => 'physical');\r
+                               $k = 0;\r
+                               foreach($cols as $col => $default) {\r
+                                       if (isset($line[$k])) {\r
+                                               if (in_array($k, $booleans)) {\r
+                                                       $link[$col] = ($line[$k] == '1');\r
+                                               } else {\r
+                                                       $link[$col] = $line[$k];\r
+                                               }\r
+                                       } else {\r
+                                               $link[$col] = $default;\r
+                                       }\r
+                                       $k++;\r
+                               }\r
+                               $link['page'] = $page;\r
+                               $links[] = $link;\r
+                       }\r
+                       $c->links = json_encode($links);\r
+                       $c->insert();\r
+               }\r
+       }\r
+\r
+       public function setLinksAndRulers($book_id, $links, $rulers)\r
+       {\r
+               $daoBook = new wsDAOBook($this->con);\r
+               $pages = $daoBook->getPagesOfBook($book_id);\r
+\r
+               $links = json_decode($links, false);\r
+               $rulers = json_decode($rulers, false);\r
+\r
+               $t = array();\r
+\r
+               foreach($links as $link) {\r
+                       if (!isset($t[$link->page])) {\r
+                               $t[$link->page] = array('links' => array(), 'rulers' => array());\r
+                       }\r
+                       $t[$link->page]['links'][] = $link;\r
+               }\r
+               foreach($rulers as $ruler) {\r
+                       if (!isset($t[$ruler->page])) {\r
+                               $t[$ruler->page] = array('links' => array(), 'rulers' => array());\r
+                       }\r
+                       $t[$ruler->page]['rulers'][] = $ruler;\r
+               }\r
+\r
+               $c = $this->con->openCursor('document_links');\r
+               $c->update = TIME;\r
+\r
+               foreach($pages as $page => $infos) {\r
+                       $c->document_id = $infos['document_id'];\r
+                       $c->document_page = $infos['document_page'];\r
+                       if (isset($t[$page])) {\r
+                               $elements = $t[$page];\r
+                               $c->links = json_encode($elements['links']);\r
+                               $c->rulers = json_encode($elements['rulers']);\r
+                       } else {\r
+                               $c->links = json_encode(array());\r
+                               $c->rulers = json_encode(array());\r
+                       }\r
+                       $c->insert();\r
+               }\r
+       }\r
+\r
+       public function getLinksAndRulers($book_id, &$links, &$rulers)\r
+       {\r
+               $daoBook = new wsDAOBook($this->con);\r
+               $pages = $daoBook->getPagesOfBook($book_id);\r
+\r
+               $couples = array();\r
+               $couples_order = array();\r
+               foreach($pages as $p => $infos) {\r
+                       $couples[$p] = '(' . $infos['document_id'] . ',' . $infos['document_page'] . ')';\r
+                       $couples_order[] = "'" . $infos['document_id'] . ',' . $infos['document_page'] . "'";\r
+               }\r
+\r
+               $links = array();\r
+               $rulers = array();\r
+\r
+               $sql = 'SELECT *,CONCAT(document_id,\',\',document_page) AS doc_page FROM document_links WHERE (document_id,document_page) IN(' . implode(',', $couples) . ') ORDER BY `update` DESC, FIELD(doc_page,' . implode(',', $couples_order) . ') LIMIT ' . count($pages);\r
+               $r = $this->con->select($sql);\r
+               $i = 1;\r
+               while ($r->fetch()) {\r
+                       $l = json_decode($r->links);\r
+                       foreach($l as $link) {\r
+                               $link->page = $i;\r
+                               $links[] = $link;\r
+                       }\r
+                       $ru = json_decode($r->rulers);\r
+                       foreach($ru as $ruler) {\r
+                               $ruler->page = $i;\r
+                               $rulers[] = $ruler;\r
+                       }\r
+                       $i++;\r
+               }\r
+       }\r
+\r
        public function getNextId()\r
        {\r
                $r = $this->con->select('SELECT MAX(document_id) AS document_id FROM documents');\r
index 93df8706e5dfd5a486871d0be41904cf1e13eff0..074a879e3c86cf3583bed1d64a84dab8ce6ffd53 100644 (file)
@@ -26,8 +26,6 @@ class wsBook extends cubeMetier {
        protected $pages;\r
 \r
        protected $chapters;\r
-       protected $links;\r
-       protected $rulers;\r
        protected $extras;\r
        protected $traductions;\r
        protected $numerotation;\r
@@ -43,7 +41,7 @@ class wsBook extends cubeMetier {
                        throw new Exception($msg);\r
                }\r
 \r
-               $classic = array('chapters', 'links', 'rulers', 'traductions');\r
+               $classic = array('chapters', 'traductions');\r
 \r
                if (in_array($varname, $classic)) {\r
                        if (is_array($this->$varname) || is_object($this->$varname)) {\r
index 0737e39c8b05b2e2b9ad32a8b37446ab6ea5f286..f30a700ce21352d31248fd7c3bab61b6d13528ad 100644 (file)
@@ -20,7 +20,6 @@ class wsDocument extends cubeMetier {
        protected $conversionInfos;\r
        protected $bookmarks;\r
        protected $numberSections;\r
-       protected $links;\r
        protected $localHash;\r
        // Crop & cut\r
        protected $autocrop;\r