]> _ Git - cubeextranet.git/commitdiff
#811
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 23 Aug 2017 16:35:16 +0000 (16:35 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 23 Aug 2017 16:35:16 +0000 (16:35 +0000)
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Metier/class.ws.book.php
inc/ws/Metier/class.ws.document.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 8f86c0fb2caec1a920ee1d133aad8451fd1fc15a..550db638555c0ef64f415411fb8053f3eb4e5672 100644 (file)
@@ -925,6 +925,33 @@ class wsDAOBook extends commonDAO {
                CubeIT_Util_Gzip::file_put_contents($ifilec, $index);
        }
 
+       public function makeHighlightIndex($book, $pages) {
+               $jar = WS_TOOLS . '/fwstk/out/artifacts/fwstk_jar/fwstk.jar';
+
+
+               $daoDoc = new wsDAODocument($this->con);
+               $res = array();
+               foreach ($pages as $book_page => $infos) {
+                       $fby = wsDocument::getDir($infos['document_id']) . 'html/p' . $infos['document_page'] . '.fby';
+                       // Refresh highlight data if fby file doesn't exists or if fwstk has been updated
+                       if (!file_exists($fby) || filemtime($jar) > filemtime($fby)) {
+                               $doc = $daoDoc->selectById($infos['document_id']);
+                               $doc->getHighlightTextsData();
+                       }
+                       $words = CubeIT_Util_Json::decode(file_get_contents($fby), CubeIT_Util_Json::TYPE_ARRAY);
+                       foreach ($words as $w) {
+                               $word = $w['word'];
+                               unset($w['word']);
+                               $w['page'] = $book_page;
+                               if (!isset($res[$word])) {
+                                       $res[$word] = array();
+                               }
+                               $res[$word][] = $w;
+                       }
+               }
+               return $res;
+       }
+
        protected function _escapeIndex($str) {
                $todelete = array('\ufffd');
                foreach ($todelete as $d) {
index 9b72771c23a048b28aa2bafc2a86361f690527e8..8077d9f6c4ec4afb31d0e62664e26525e00d483d 100644 (file)
@@ -80,6 +80,4 @@ class wsBook extends cubeMetier {
                return $this->$varname;\r
        }\r
 \r
-}\r
-\r
-?>
\ No newline at end of file
+}
\ No newline at end of file
index b032c1ed9f7bb46dff7e04110c7eb6ace2770cdc..0aaebbef6ac9aa637983cfc612a2ed9db668f66e 100644 (file)
@@ -361,15 +361,17 @@ class wsDocument extends cubeMetier {
                $fwstk->setArg('--threads 1');
                $fwstk->execute();
                $this->addToLog($fwstk);
+       }
 
-               /* $fwstk = new cubeCommandLine('fwstk');
-                 $fwstk->setPath(CONVERTER_PATH);
-                 $fwstk->setArg('--input ' . $this->cropped);
-                 $fwstk->setArg('--layout ' . $this->html . 'p%d.layout');
-                 $fwstk->setArg('--cmaps ' . $this->html);
-                 $fwstk->setArg('--fonts' . $this->out . 'fonts/web/');
-                 $fwstk->execute();
-                 $this->addToLog($fwstk); */
+       public function getHighlightTextsData(){
+               $fwstk = new cubeCommandLine('fwstk.sh');
+               $fwstk->setPath(CONVERTER_PATH);
+               $fwstk->setArg('--input ' . $this->cropped);
+               $fwstk->setArg('--layout ' . $this->html . 'p%d.fby');
+               $fwstk->setArg('--cmaps ' . $this->html);
+               $fwstk->setArg('--fonts' . $this->out . 'fonts/web/');
+               $fwstk->execute();
+               $this->addToLog($fwstk);
        }
 
        public function getResolutionRatio() {
@@ -617,10 +619,10 @@ class wsDocument extends cubeMetier {
                $this->_cleanSVG($svgFile, $page);
        }
 
-       public static function cleanSVG($svgFile,$debug=false) {
+       public static function cleanSVG($svgFile, $debug = false) {
                $svg = new DOMDocument();
                $svg->preserveWhiteSpace = false;
-               $svg->load($svgFile,LIBXML_PARSEHUGE);
+               $svg->load($svgFile, LIBXML_PARSEHUGE);
 
                // Operations to delete
                $xpath = new DOMXPath($svg);
index e9f8fdc224e1a99c4dc9e5937a84c992fdb92f5e..871a2ff1228434da8d7ade9796da18bf8941f298 100644 (file)
@@ -979,6 +979,7 @@ class wsHTML5Compiler {
 
                file_put_contents($this->vdir . '/data/search.index.js', $jsindex);
                file_put_contents($this->vdir . '/data/search.texts.js', $jstexts);
+               file_put_contents($this->vdir . '/data/search.highlight.js', 'var HIGHLIGHTS=' . json_encode($this->daoBook->makeHighlightIndex($this->book, $this->pages)) . ";\r");
        }
 
        public function supportSVG() {