$book->facturable = $r->facturable;\r
$book->facturable_id = $r->facturable_id;\r
$book->tache = $r->tache;\r
- $book->projet = $r->projet;\r
+ if (isset($r->projet)) {\r
+ $book->projet = $r->projet;\r
+ }\r
$book->version = $r->version;\r
$book->composition_update = $r->composition_update;\r
$book->dir_references = $r->dir_references;\r
return $this->cree();\r
}\r
$sql = 'SELECT * FROM books_vue WHERE book_id=\'' . $this->con->escape($book_id) . '\' LIMIT 1';\r
- $r = $this->con->select('SELECT * FROM books_vue WHERE book_id=\'' . $this->con->escape($book_id) . '\' LIMIT 1');\r
+ $r = $this->con->select($sql);\r
return $this->singleton($r);\r
}\r
\r
}\r
\r
public function setChapters($book_id, $json) {\r
+ $chapters = json_decode($json,TRUE);\r
+ $res = array();\r
+\r
+ foreach ($chapters as $c) {\r
+ $c['label'] = trim($c['label']);\r
+ $n = (string) $c['page'];\r
+ $c['label'] = trim(preg_replace('|' . $n . '$|', '', $c['label']));\r
+ $res[] = $c;\r
+ }\r
+\r
$c = $this->con->openCursor('books');\r
- $c->chapters = json_encode(json_decode($json, false));\r
+ $c->chapters = json_encode($res);\r
$c->changedate = TIME;\r
$c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
}\r
\r
public function makeTextsIndexes($book, $pages, &$index, &$textes) {\r
\r
+ $dir = WS_BOOKS . '/index/' . $book->book_id;\r
+ if ($book->parametres->ignoreSearchSeparators != '') {\r
+ $dir.='/' . sha1($book->parametres->ignoreSearchSeparators);\r
+ }\r
+ if (!file_exists($dir)) {\r
+ mkdir($dir, 0777, true);\r
+ }\r
+\r
+ $ifilec = $dir . '/index.json';\r
+ $tfilec = $dir . '/textes.json';\r
+\r
+ if (file_exists($ifilec) && file_exists($tfilec) && (min(filemtime($ifilec), filemtime($tfilec)) >= $book->composition_update)) {\r
+ $index = file_get_contents($ifilec);\r
+ $textes = file_get_contents($tfilec);\r
+ return;\r
+ }\r
+\r
if ($book->parametres->ignoreSearchSeparators != "") {\r
$docs = array();\r
foreach ($pages as $p => $i) {\r
$textes[$book_page] = $text;\r
}\r
ksort($index);\r
+\r
+\r
+ $textes = json_encode($textes);\r
+ $index = json_encode($index);\r
+\r
+ file_put_contents($tfilec, $textes);\r
+ file_put_contents($ifilec, $index);\r
}\r
\r
protected function fillIndexWithWords(&$index, $page, $ipage) {\r
continue;\r
}\r
list($woa, $worddata) = $w1;\r
- list($total, $wordslist) = explode("\t", $worddata, 2);\r
+ $e = explode("\t", $worddata, 2);\r
+ if (count($e) < 2) {\r
+ continue;\r
+ }\r
+ list($total, $wordslist) = $e;\r
\r
if ($woa == '') {\r
continue;\r
$packager->makePackage(false);\r
}\r
\r
- public function compile3($book_id, $complete) {\r
+ public function compile3($book_id, $complete, &$book) {\r
$res = '';\r
\r
$compilerDir = WS_BOOKS . '/datasCompiler/' . $book_id . '/';\r