From: vincent@cubedesigners.com Date: Fri, 8 Feb 2013 17:45:28 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=38917f3776e1d4f7c42ee65e42e526d2b19a7286;p=cubeextranet.git --- diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index cf0bcea6d..107d06fdf 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -355,7 +355,7 @@ class commonCore extends cubeCore { $db->document_links_versions->index('idx_document_links_version_update', 'BTREE', 'update'); // Table Books $db->books->book_id('integer', 0, false); - $db->books->cid('varchar', 6, false); + $db->books->cid('varchar', 8, false); $db->books->nom('varchar', 256, false); $db->books->lang('varchar', 20, false); $db->books->theme('integer', 0, false); @@ -396,6 +396,7 @@ class commonCore extends cubeCore { $db->books->index('index_books_theme', 'BTREE', 'theme'); $db->books->index('index_books_demo_counter', 'BTREE', 'demo_counter'); $db->books->index('index_books_lang', 'BTREE', 'lang'); + $db->books->index('index_books_cid', 'BTREE', 'cid'); // . // Table pages des publications $db->book_pages->book_id('integer', 0, false); diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 61b28997f..ae4447de9 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -21,6 +21,18 @@ class wsMaintenance { } } + public static function setCID() { + global $core; + $dao = new wsDAOBook($core->con); + + $r = $core->con->select('SELECT book_id FROM books WHERE cid=\'\''); + $c = $core->con->openCursor('books'); + while ($r->fetch()) { + $c->cid = $dao->generateCID(); + $c->update('WHERE book_id=\'' . $core->con->escape($r->book_id) . '\''); + } + } + public static function compactLinks() { global $core; $r = $core->con->select('SELECT * FROM `document_links_versions` GROUP BY document_id,links,rulers'); diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index 6207dd2dd..3b62e137b 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -263,12 +263,10 @@ class wsServices extends cubeFlashGateway { $this->exportpdf(true); } - protected function getPDFComplex($book_id, $range) { + protected function getPDFComplex($book, $range) { global $core; $daoBook = new wsDAOBook($core->con); - $book = $daoBook->selectById($book_id); - if (is_null($book)) { return; @@ -292,13 +290,13 @@ class wsServices extends cubeFlashGateway { if (!file_exists($baseDocument)) { return; } - $destDir = WS_CACHE . '/exportpdf/' . $book->book_id; + $destDir = WS_CACHE . '/exportpdf/' . $book->cid; if (!file_exists($destDir)) { mkdir($destDir, 0777, true); } $fname = md5(implode(',%ù', $range)) . '.pdf'; $destFile = $destDir . '/' . $fname; - $destURL = '/fluidbook/cache/exportpdf/' . $book->book_id . '/' . $fname; + $destURL = '/fluidbook/cache/exportpdf/' . $book->cid . '/' . $fname; // If result exists, don't make the pdf again if (file_exists($destFile) && filemtime($destFile) > filemtime($baseDocument)) { @@ -326,20 +324,35 @@ class wsServices extends cubeFlashGateway { } public function e() { - $this->args['id'] = $this->callArgs[0]; + $this->args['cid'] = $this->callArgs[0]; $this->args['range'] = $this->callArgs[1]; return $this->exportpdf(); } + public function p() { + $this->args['cid'] = $this->callArgs[0]; + $this->args['range'] = $this->callArgs[1]; + return $this->exportpdf(true); + } + public function exportpdf($print = false) { global $core; - $dest = $this->getPDFComplex($this->args['id'], $this->args['range']); + + $dao = new wsDAOBook($core->con); + if (isset($this->args['cid'])) { + $book = $dao->selectByCid($this->args['cid']); + } else if ($this->args['id'] >= 11202) { + $book = $dao->selectById($this->args['id']); + } + + $dest = $this->getPDFComplex($book, $this->args['range']); if (!$print) { // Return the url of the resulting pdf http::redirect($dest['url']); exit; } else { + $this->outputXML = false; $res = ' diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 9f1dd5e78..630e541a9 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -11,6 +11,7 @@ class wsDAOBook extends commonDAO { protected function singleton($r) { $book = new wsBook(); $book->book_id = $r->book_id; + $book->cid = $r->cid; $book->nom = $r->nom; $book->lang = $r->lang; $book->theme = $r->theme; @@ -57,6 +58,7 @@ class wsDAOBook extends commonDAO { $book = new wsBook(); $book->book_id = 'new'; $book->nom = ''; + $book->cid = null; $book->lang = 'fr'; $book->theme = 1; $book->proprietaire = ''; @@ -121,6 +123,18 @@ class wsDAOBook extends commonDAO { return $this->singleton($r); } + public function selectByCid($cid = null, $simple = false) { + if ($simple) { + $table = 'books'; + } else { + $table = 'books_vue'; + } + + $sql = 'SELECT * FROM ' . $table . ' WHERE cid LIKE BINARY \'' . $this->con->escape($cid) . '\' LIMIT 1'; + $r = $this->con->select($sql); + return $this->singleton($r); + } + public function selectLuceneToDo() { $sql = 'SELECT * FROM books_vue WHERE lucene_timecon->select($sql); @@ -186,6 +200,7 @@ class wsDAOBook extends commonDAO { $c->proprietaire = $createur; $c->date = TIME; $c->hash = md5(rand(0, 1234567893)); + $c->cid = $this->generateCID(); $c->compteur_visites = 20; $c->status = -1; $c->date_status = TIME; @@ -219,6 +234,7 @@ class wsDAOBook extends commonDAO { $parametres->title = $nom; $c->proprietaire = $createur; + $c->cid = $this->generateCID(); $c->nom = $nom; $c->date = TIME; $c->hash = md5(rand(0, 1234567893)); @@ -1092,6 +1108,7 @@ class wsDAOBook extends commonDAO { $flex->addVariable('signature', $exportSignature, false, true, 'JSONObject'); $flexLight->addVariable('datas', $book->parametres->toStandardObject(), false, true, 'JSONObject'); $flexLight->addVariable('id', $book_id, false, true, 'uint'); + $flexLight->addVariable('cid', $book->cid, false, true, 'String'); $traductions = (!count($book->traductions)) ? $lang->traductions : $book->traductions; $allTraductions = array(); @@ -1541,6 +1558,33 @@ class wsDAOBook extends commonDAO { } } + public function generateCID() { + + do { + $res = ''; + for ($i = 0; $i < 8; $i++) { + $j = rand(0, 61); + $res.=$this->base62($j); + } + $r = $this->con->select('SELECT book_id FROM books WHERE cid=\'' . $res . '\''); + if ($r->count() == 0) { + return $res; + } + } while (true); + } + + protected function base62($val) { + $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $base = strlen($chars); + $str = ''; + do { + $i = $val % $base; + $str = $chars[$i] . $str; + $val = ($val - $i) / $base; + } while ($val > 0); + return $str; + } + } ?> \ No newline at end of file diff --git a/inc/ws/Metier/class.ws.book.php b/inc/ws/Metier/class.ws.book.php index 909d4977c..9b72771c2 100644 --- a/inc/ws/Metier/class.ws.book.php +++ b/inc/ws/Metier/class.ws.book.php @@ -3,6 +3,7 @@ class wsBook extends cubeMetier { protected $book_id; + protected $cid; protected $nom; protected $lang; protected $theme; diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index e413ae3b3..16850f70b 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -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;