$core->refreshWSUsersTree();\r
}\r
\r
+ public static function updateLuceneTime() {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $books = $dao->selectLuceneTimeNotSet();\r
+ foreach ($books as $book) {\r
+ $index = WS_BOOKS . '/search/' . $book->book_id;\r
+ if (!file_exists($index)) {\r
+ fb($book->book_id, 'Skip');\r
+ continue;\r
+ }\r
+\r
+ $mtime = 0;\r
+ $dr = opendir($index);\r
+ while ($file = readdir($dr)) {\r
+ if ($file == '.' || $file == '..') {\r
+ continue;\r
+ }\r
+ $mtime = max($mtime, filemtime($index . '/' . $file));\r
+ }\r
+\r
+ $c = $core->con->openCursor('books');\r
+ $c->lucene_time = $mtime;\r
+ $c->update('WHERE book_id=' . $book->book_id);\r
+\r
+ fb($book->book_id, 'Update : ' . $mtime);\r
+ }\r
+ }\r
+\r
+ public static function makeLuceneIndexes() {\r
+ global $core;\r
+\r
+ cubePHP::neverStop();\r
+\r
+ $dao = new wsDAOBook($core->con);\r
+ $books = $dao->selectLuceneToDo();\r
+ foreach ($books as $book) {\r
+ $pages = $dao->getPagesOfBook($book->book_id);\r
+ $dao->indexPDF($book, $pages);\r
+ }\r
+ }\r
+\r
}\r
\r
?>
\ No newline at end of file
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
+ return $this->factory($r);\r
+ }\r
+\r
+ public function selectLuceneTimeNotSet() {\r
+ $sql = 'SELECT * FROM books_vue WHERE lucene_time=0 AND version=2';\r
+ $r = $this->con->select($sql);\r
+ return $this->factory($r);\r
+ }\r
+\r
/**\r
* wsDAOBook::sauve()\r
*\r
return $this->selectById($book_id);\r
}\r
\r
- public function duplicate($book_id, $createur, $nom, $pages=false) {\r
+ public function duplicate($book_id, $createur, $nom, $pages = false) {\r
$r = $this->con->select('SELECT * FROM books_vue WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
\r
$old_id = $book_id;\r
$c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
}\r
\r
- public function saveCompositionVersion($book_id, $time=null) {\r
+ public function saveCompositionVersion($book_id, $time = null) {\r
\r
$time = is_null($time) ? TIME : $time;\r
\r
$c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
}\r
\r
- public function isUpToDate($book_id, $html=false) {\r
+ public function isUpToDate($book_id, $html = false) {\r
$r = $this->con->select('SELECT changedate,compiledate FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
if ($r->compiledate < $r->changedate) {\r
return false;\r
\r
foreach ($filesToCopy as $local => $source) {\r
$localPath = $finalDir . $local;\r
- // if (!file_exists($localPath) || filemtime($localPath) < filemtime($source) || filesize($localPath) != filesize($source)) {\r
- if (is_dir($source)) {\r
- continue;\r
+ if (!file_exists($localPath) || filemtime($localPath) < filemtime($source) || filesize($localPath) != filesize($source) || filemtime($localPath) < $book->composition_update) {\r
+ if (is_dir($source)) {\r
+ continue;\r
+ }\r
+ copy($source, $localPath);\r
}\r
- copy($source, $localPath);\r
- // }\r
}\r
\r
+\r
$this->compilePDF($book, $pages);\r
- $this->indexPDF($book, $pages);\r
- $this->compileHTML5($book_id);\r
+ //$this->indexPDF($book, $pages);\r
+ if ($book->parametres->mobileVersion != 'pdf') {\r
+ $this->compileHTML5($book_id);\r
+ }\r
$this->compileWidget($book, $pages);\r
\r
$this->touchCompile($book_id);\r
$poster = $link['to'];\r
$e = explode('.', $poster);\r
array_pop($e);\r
- array_push($e,'jpg');\r
+ array_push($e, 'jpg');\r
$poster = implode('.', $e);\r
\r
$workingFile = $workingDir . '/' . $poster;\r
public function indexPDF($book, $pages) {\r
$indexPath = WS_BOOKS . '/search/' . $book->book_id;\r
\r
- if (file_exists($indexPath) && filemtime($indexPath) > $book->composition_update) {\r
- return;\r
- }\r
-\r
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());\r
\r
if (file_exists($indexPath)) {\r
$doc->addField(Zend_Search_Lucene_Field::UnStored('contents', file_get_contents(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.txt')));\r
$index->addDocument($doc);\r
}\r
+\r
+ $c = $this->con->openCursor('books');\r
+ $c->lucene_time = TIME;\r
+ $c->update('WHERE book_id=' . $book->book_id);\r
}\r
\r
public function compilePDF($book, $pages) {\r
$nb_pages = array();\r
$j = 0;\r
$k = 0;\r
+ $original = true;\r
+\r
foreach ($pages as $i => $infos) {\r
+ if (!isset($firstDoc)) {\r
+ $firstDoc = $infos['document_id'];\r
+ }\r
+\r
$doc = WS_DOCS . '/' . $infos['document_id'] . '/crop.pdf';\r
if (!isset($pdfList[$doc])) {\r
$pdfList[$doc] = $j;\r
$k = $pdfList[$doc];\r
}\r
$pagesList[$i] = array($k, $infos['document_page']);\r
+\r
+ if ($i != $infos['document_page'] || $infos['document_id'] != $firstDoc) {\r
+ $original = false;\r
+ }\r
+ }\r
+\r
+ if ($original) {\r
+ copy(WS_DOCS . '/' . $firstDoc . '/crop.pdf', $finalPDF);\r
+ fb('Original');\r
+ return;\r
}\r
+ fb('Composite');\r
+ exit;\r
\r
$args = '';\r
foreach ($pdfList as $doc => $index) {\r