From: vincent@cubedesigners.com Date: Wed, 6 Sep 2017 15:39:17 +0000 (+0000) Subject: fix #1651 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=6b2cf3ee01e368573f38ba5e498301bc5196e21a;p=cubeextranet.git fix #1651 @0.25 --- diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index c319b6dc7..4c1c0cf98 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -851,7 +851,7 @@ class wsDAOBook extends commonDAO { } public function makeTextsIndexes($book, $pages, &$index, &$textes, $simple = false) { - + global $core; $prefix = ''; if ($book->parametres->textExtraction == 'poppler') { $prefix = 'p'; @@ -873,7 +873,7 @@ class wsDAOBook extends commonDAO { } $tfilec = $dir . '/' . $prefix . 'textes.json'; - if (CubeIT_Util_Gzip::file_exists($ifilec) && CubeIT_Util_Gzip::file_exists($tfilec) && (min(CubeIT_Util_Gzip::filemtime($ifilec), CubeIT_Util_Gzip::filemtime($tfilec)) >= $book->composition_update)) { + if (CubeIT_Util_Gzip::file_exists($ifilec) && CubeIT_Util_Gzip::file_exists($tfilec) && (min(CubeIT_Util_Gzip::filemtime($ifilec), CubeIT_Util_Gzip::filemtime($tfilec)) >= max($book->composition_update, filemtime(__FILE__), filemtime(WS_TOOLS . '/fwstk/out/artifacts/fwstk_jar/fwstk.jar')))) { $index = CubeIT_Util_Gzip::file_get_contents($ifilec); $textes = CubeIT_Util_Gzip::file_get_contents($tfilec); return; @@ -904,6 +904,13 @@ class wsDAOBook extends commonDAO { foreach ($pages as $book_page => $infos) { $tfile = wsDocument::getDir($infos['document_id']) . $prefix . 'p' . $infos['document_page'] . '.txt'; $ifile = wsDocument::getDir($infos['document_id']) . $prefix . 'i' . $infos['document_page'] . '.txt'; + + if (!file_exists($tfile) || !file_exists($ifile)) { + $daoDoc = new wsDAODocument($core->con); + $doc = $daoDoc->selectById($infos['document_id']); + $doc->getLinksAndTexts(); + } + CubeIT_Util_Gzip::compressIfNotCompressed($tfile); CubeIT_Util_Gzip::compressIfNotCompressed($ifile); $text = CubeIT_Util_Gzip::file_get_contents($tfile); @@ -940,18 +947,22 @@ class wsDAOBook extends commonDAO { } if (file_exists($fby)) { - $words = CubeIT_Util_Json::decode(file_get_contents($fby), CubeIT_Util_Json::TYPE_OBJECT); - - foreach ($words as $w) { - $word = $w->word; - unset($w->word); - $w->page = $book_page; - if (!isset($res->{$word})) { - $res->{$word} = array(); - } - $res->{$word}[] = $w; - } - } + $words = CubeIT_Util_Json::decode(file_get_contents($fby), CubeIT_Util_Json::TYPE_OBJECT); + + foreach ($words as $w) { + $word = $w->word; + $word = trim($word, "\0"); + if($word==''){ + continue; + } + unset($w->word); + $w->page = $book_page; + if (!isset($res->{$word})) { + $res->{$word} = array(); + } + $res->{$word}[] = $w; + } + } } return $res; }