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) {
$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() {
$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);
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() {