$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
$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
}\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
$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
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
}\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
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
$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
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
$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
$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
$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
}\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
class wsBook extends cubeMetier {\r
\r
protected $book_id;\r
+ protected $cid;\r
protected $nom;\r
protected $lang;\r
protected $theme;\r
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;