]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 26 Dec 2011 12:41:48 +0000 (12:41 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 26 Dec 2011 12:41:48 +0000 (12:41 +0000)
inc/commons/class.common.core.php
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Util/html5/class.ws.html5.compiler.php

index b201fc487d098e50ea5a5dbaf22d8382c027ae87..e1890bb8dd0bc5ad0d64ff5a5c9ecbb4fc9ca20c 100644 (file)
@@ -375,6 +375,7 @@ class commonCore extends cubeCore {
                $db->books->composition_update('integer', 0, false);\r
                $db->books->dir_references('varchar', 256, false);\r
                $db->books->dir_hosting('varchar', 256, false);\r
+               $db->books->lucene_time('integer',0,false);\r
                // Clés\r
                $db->books->primary('pk_books', 'book_id');\r
                $db->books->index('index_books_nom', 'BTREE', 'nom');\r
index 1fd6e251c5cac5a6a74fae40ff628552873eae37..71380f5aa5b1e6e4547bce6f339b2cc89b693c4f 100644 (file)
@@ -572,6 +572,47 @@ class wsMaintenance {
                $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
index 22587e2e6238cf9aaac54a5978d2cad2250ee316..0d77dd91f286e85d5595d1bf57d021350efcd0b4 100644 (file)
@@ -83,6 +83,18 @@ class wsDAOBook extends commonDAO {
                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
@@ -123,7 +135,7 @@ class wsDAOBook extends commonDAO {
                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
@@ -443,7 +455,7 @@ class wsDAOBook extends commonDAO {
                $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
@@ -532,7 +544,7 @@ class wsDAOBook extends commonDAO {
                $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
@@ -704,17 +716,20 @@ class wsDAOBook extends commonDAO {
 \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
@@ -822,7 +837,7 @@ class wsDAOBook extends commonDAO {
                                        $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
@@ -1052,10 +1067,6 @@ class wsDAOBook extends commonDAO {
        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
@@ -1069,6 +1080,10 @@ class wsDAOBook extends commonDAO {
                        $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
@@ -1103,7 +1118,13 @@ class wsDAOBook extends commonDAO {
                $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
@@ -1114,7 +1135,19 @@ class wsDAOBook extends commonDAO {
                                $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
index ba929d7b0802ef72c0b8e84047a219d1d9b598db..ed949aead97c7bfc39c17282a1f9eafab7007f72 100644 (file)
@@ -73,6 +73,8 @@ class wsHTML5Compiler {
 
        function __construct($book_id) {
                global $core;
+               
+               cubePHP::set_memory('4G');
 
                if (trim($book_id) == '') {
                        return;
@@ -914,8 +916,6 @@ class wsHTML5Compiler {
                }
                $this->fontDocs[$font][$document_id] = true;
 
-               
-               
                $idx= $this->getIndex($font, $this->cssFont, array('oblique' => $oblique));
                
                return $idx;