]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 8 Feb 2013 17:45:28 +0000 (17:45 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 8 Feb 2013 17:45:28 +0000 (17:45 +0000)
inc/commons/class.common.core.php
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Controlleur/class.ws.services.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Metier/class.ws.book.php
inc/ws/Util/html5/class.ws.html5.compiler.php

index cf0bcea6d8df077d6ad29fa286fdbc48ea016e95..107d06fdf8518801d717e11d0efa188417990a9a 100644 (file)
@@ -355,7 +355,7 @@ class commonCore extends cubeCore {
                $db->document_links_versions->index('idx_document_links_version_update', 'BTREE', 'update');\r
                // Table Books\r
                $db->books->book_id('integer', 0, false);\r
-               $db->books->cid('varchar', 6, false);\r
+               $db->books->cid('varchar', 8, false);\r
                $db->books->nom('varchar', 256, false);\r
                $db->books->lang('varchar', 20, false);\r
                $db->books->theme('integer', 0, false);\r
@@ -396,6 +396,7 @@ class commonCore extends cubeCore {
                $db->books->index('index_books_theme', 'BTREE', 'theme');\r
                $db->books->index('index_books_demo_counter', 'BTREE', 'demo_counter');\r
                $db->books->index('index_books_lang', 'BTREE', 'lang');\r
+               $db->books->index('index_books_cid', 'BTREE', 'cid');\r
                // .\r
                // Table pages des publications\r
                $db->book_pages->book_id('integer', 0, false);\r
index 61b28997fd25b385dbcb1af85447987df2ece980..ae4447de9ef62be0ebfb9ef684f03fc9495aac4d 100644 (file)
@@ -21,6 +21,18 @@ class wsMaintenance {
                }\r
        }\r
 \r
+       public static function setCID() {\r
+               global $core;\r
+               $dao = new wsDAOBook($core->con);\r
+\r
+               $r = $core->con->select('SELECT book_id FROM books WHERE cid=\'\'');\r
+               $c = $core->con->openCursor('books');\r
+               while ($r->fetch()) {\r
+                       $c->cid = $dao->generateCID();\r
+                       $c->update('WHERE book_id=\'' . $core->con->escape($r->book_id) . '\'');\r
+               }\r
+       }\r
+\r
        public static function compactLinks() {\r
                global $core;\r
                $r = $core->con->select('SELECT * FROM `document_links_versions` GROUP BY document_id,links,rulers');\r
index 6207dd2ddd5933ef879f2fc8627657471a69339e..3b62e137bed63912f88b49203b7b07f7a23dc3b8 100644 (file)
@@ -263,12 +263,10 @@ class wsServices extends cubeFlashGateway {
                $this->exportpdf(true);\r
        }\r
 \r
-       protected function getPDFComplex($book_id, $range) {\r
+       protected function getPDFComplex($book, $range) {\r
                global $core;\r
 \r
                $daoBook = new wsDAOBook($core->con);\r
-               $book = $daoBook->selectById($book_id);\r
-\r
 \r
                if (is_null($book)) {\r
                        return;\r
@@ -292,13 +290,13 @@ class wsServices extends cubeFlashGateway {
                if (!file_exists($baseDocument)) {\r
                        return;\r
                }\r
-               $destDir = WS_CACHE . '/exportpdf/' . $book->book_id;\r
+               $destDir = WS_CACHE . '/exportpdf/' . $book->cid;\r
                if (!file_exists($destDir)) {\r
                        mkdir($destDir, 0777, true);\r
                }\r
                $fname = md5(implode(',%ù', $range)) . '.pdf';\r
                $destFile = $destDir . '/' . $fname;\r
-               $destURL = '/fluidbook/cache/exportpdf/' . $book->book_id . '/' . $fname;\r
+               $destURL = '/fluidbook/cache/exportpdf/' . $book->cid . '/' . $fname;\r
                // If result exists, don't make the pdf again\r
                if (file_exists($destFile) && filemtime($destFile) > filemtime($baseDocument)) {\r
                        \r
@@ -326,20 +324,35 @@ class wsServices extends cubeFlashGateway {
        }\r
 \r
        public function e() {\r
-               $this->args['id'] = $this->callArgs[0];\r
+               $this->args['cid'] = $this->callArgs[0];\r
                $this->args['range'] = $this->callArgs[1];\r
                return $this->exportpdf();\r
        }\r
 \r
+       public function p() {\r
+               $this->args['cid'] = $this->callArgs[0];\r
+               $this->args['range'] = $this->callArgs[1];\r
+               return $this->exportpdf(true);\r
+       }\r
+\r
        public function exportpdf($print = false) {\r
                global $core;\r
-               $dest = $this->getPDFComplex($this->args['id'], $this->args['range']);\r
+\r
+               $dao = new wsDAOBook($core->con);\r
+               if (isset($this->args['cid'])) {\r
+                       $book = $dao->selectByCid($this->args['cid']);\r
+               } else if ($this->args['id'] >= 11202) {\r
+                       $book = $dao->selectById($this->args['id']);\r
+               }\r
+\r
+               $dest = $this->getPDFComplex($book, $this->args['range']);\r
 \r
                if (!$print) {\r
                        // Return the url of the resulting pdf\r
                        http::redirect($dest['url']);\r
                        exit;\r
                } else {\r
+                       $this->outputXML = false;\r
                        $res = '<!DOCTYPE html><html><head>\r
                                <meta http-equiv="X-UA-Compatible" content="IE=8" />                            \r
                                <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>\r
index 9f1dd5e7869cb925967fabc2088d303b2e97f0ec..630e541a9d3c90f8feeeee87e4c7f9b75cfc936d 100644 (file)
@@ -11,6 +11,7 @@ class wsDAOBook extends commonDAO {
        protected function singleton($r) {\r
                $book = new wsBook();\r
                $book->book_id = $r->book_id;\r
+               $book->cid = $r->cid;\r
                $book->nom = $r->nom;\r
                $book->lang = $r->lang;\r
                $book->theme = $r->theme;\r
@@ -57,6 +58,7 @@ class wsDAOBook extends commonDAO {
                $book = new wsBook();\r
                $book->book_id = 'new';\r
                $book->nom = '';\r
+               $book->cid = null;\r
                $book->lang = 'fr';\r
                $book->theme = 1;\r
                $book->proprietaire = '';\r
@@ -121,6 +123,18 @@ class wsDAOBook extends commonDAO {
                return $this->singleton($r);\r
        }\r
 \r
+       public function selectByCid($cid = null, $simple = false) {\r
+               if ($simple) {\r
+                       $table = 'books';\r
+               } else {\r
+                       $table = 'books_vue';\r
+               }\r
+\r
+               $sql = 'SELECT * FROM ' . $table . ' WHERE cid LIKE BINARY \'' . $this->con->escape($cid) . '\' LIMIT 1';\r
+               $r = $this->con->select($sql);\r
+               return $this->singleton($r);\r
+       }\r
+\r
        public function selectLuceneToDo() {\r
                $sql = 'SELECT * FROM books_vue WHERE lucene_time<composition_update AND version=2 ORDER BY book_id ASC LIMIT 1';\r
                $r = $this->con->select($sql);\r
@@ -186,6 +200,7 @@ class wsDAOBook extends commonDAO {
                $c->proprietaire = $createur;\r
                $c->date = TIME;\r
                $c->hash = md5(rand(0, 1234567893));\r
+               $c->cid = $this->generateCID();\r
                $c->compteur_visites = 20;\r
                $c->status = -1;\r
                $c->date_status = TIME;\r
@@ -219,6 +234,7 @@ class wsDAOBook extends commonDAO {
                $parametres->title = $nom;\r
 \r
                $c->proprietaire = $createur;\r
+               $c->cid = $this->generateCID();\r
                $c->nom = $nom;\r
                $c->date = TIME;\r
                $c->hash = md5(rand(0, 1234567893));\r
@@ -1092,6 +1108,7 @@ class wsDAOBook extends commonDAO {
                $flex->addVariable('signature', $exportSignature, false, true, 'JSONObject');\r
                $flexLight->addVariable('datas', $book->parametres->toStandardObject(), false, true, 'JSONObject');\r
                $flexLight->addVariable('id', $book_id, false, true, 'uint');\r
+               $flexLight->addVariable('cid', $book->cid, false, true, 'String');\r
 \r
                $traductions = (!count($book->traductions)) ? $lang->traductions : $book->traductions;\r
                $allTraductions = array();\r
@@ -1541,6 +1558,33 @@ class wsDAOBook extends commonDAO {
                }\r
        }\r
 \r
+       public function generateCID() {\r
+\r
+               do {\r
+                       $res = '';\r
+                       for ($i = 0; $i < 8; $i++) {\r
+                               $j = rand(0, 61);\r
+                               $res.=$this->base62($j);\r
+                       }\r
+                       $r = $this->con->select('SELECT book_id FROM books WHERE cid=\'' . $res . '\'');\r
+                       if ($r->count() == 0) {\r
+                               return $res;\r
+                       }\r
+               } while (true);\r
+       }\r
+\r
+       protected function base62($val) {\r
+               $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\r
+               $base = strlen($chars);\r
+               $str = '';\r
+               do {\r
+                       $i = $val % $base;\r
+                       $str = $chars[$i] . $str;\r
+                       $val = ($val - $i) / $base;\r
+               } while ($val > 0);\r
+               return $str;\r
+       }\r
+\r
 }\r
 \r
 ?>
\ No newline at end of file
index 909d4977cc2caf8fae25f0ddaa9cb3746115da02..9b72771c23a048b28aa2bafc2a86361f690527e8 100644 (file)
@@ -3,6 +3,7 @@
 class wsBook extends cubeMetier {\r
 \r
        protected $book_id;\r
+       protected $cid;\r
        protected $nom;\r
        protected $lang;\r
        protected $theme;\r
index e413ae3b3e5f5c9344d339551276f07523d97bee..16850f70b359a8f038a4f45ea8b511cdaf7166fe 100644 (file)
@@ -731,6 +731,7 @@ class wsHTML5Compiler {
        protected function writeConfig() {
                $this->config->numerotation = explode(',', $this->book->numerotation);
                $this->config->id = $this->book->book_id;
+               $this->config->cid = $this->book->cid;
                $this->config->cacheDate = TIME;
                $this->config->width = $this->cssWidth;
                $this->config->height = $this->cssHeight;