FWSTK::lastUpdate() . '$$$' .
$this->fluidbookSettings->search_mode . '=+='
);
+
+ $doIndex = $this->fluidbookSettings->search_mode !== 'robust';
+
$cacheDir = Files::mkdir(protected_path('fluidbookpublication/index/' . $this->book_id . '/' . $cache . '/'));
- $indexFile = $cacheDir . '/search.index.js';
+ if ($doIndex) {
+ $indexFile = $cacheDir . '/search.index.js';
+ }
$textFile = $cacheDir . '/search.texts.js';
$hightlightsFile = $cacheDir . '/search.highlight.js';
- if (!file_exists($indexFile) || !file_exists($textFile)) {
- SearchIndex::makeTextsIndexes($this, $cacheDir, $index, $texts, true);
- file_put_contents($indexFile, 'var INDEX=' . $index . ';' . "\r");
+ if (($doIndex && !file_exists($indexFile)) || !file_exists($textFile)) {
+ if ($doIndex) {
+ SearchIndex::makeTextsIndexes($this, $cacheDir, $index, $texts, true);
+ file_put_contents($indexFile, 'var INDEX=' . $index . ';' . "\r");
+ } else {
+ SearchIndex::makeTexts($this, $cacheDir, $texts, true);
+ }
file_put_contents($textFile, 'var TEXTS=' . $texts . ";\r");
}
+
if ($this->fluidbookSettings->highlightResults && !file_exists($hightlightsFile)) {
file_put_contents($hightlightsFile, 'var HIGHLIGHTS=' . json_encode(SearchIndex::makeHighlightIndex($this)) . ";\r");
}
- $this->vdir->copy($cacheDir . '/search.index.js', 'data/search.index.js');
+ if ($doIndex) {
+ $this->vdir->copy($cacheDir . '/search.index.js', 'data/search.index.js');
+ }
if ($this->fluidbookSettings->highlightResults) {
$this->vdir->copy($cacheDir . '/search.highlight.js', 'data/search.highlight.js');
}
} else {
$secure = file_get_contents($this->assets . '/_secure.html');
}
+
+ if (!stristr($secure, 'data/noaccents.js')) {
+ $secure = str_replace('<script src="data/forge.js"></script>', '<script src="data/noaccents.js"></script><script src="data/forge.js"></script>', $secure);
+ }
+
if ($this->fluidbookSettings->secureClientSideBackgroundImage) {
$this->vdir->copy($this->wdir . '/' . $this->fluidbookSettings->secureClientSideBackgroundImage, 'data/secure/' . $this->fluidbookSettings->secureClientSideBackgroundImage);
$variables['BACKGROUND_IMAGE'] = 'data/secure/' . $this->fluidbookSettings->secureClientSideBackgroundImage;
*/
public static function makeTextsIndexes($compiler, $dir, &$index, &$textes, bool $simple = false, bool $force = false)
{
+ self::makeTexts($compiler, $dir, $textes, $force);
+
if ($simple) {
$ifilec = $dir . '/sindex.json';
} else {
$ifilec = $dir . '/index.json';
}
- $tfilec = $dir . '/textes.json';
+ $index = [];
- $index = array();
- $textes = array();
foreach ($compiler->pages as $page => $infos) {
- $tfile = $compiler->getFluidbook()->getTextFile($page, FluidbookDocument::TEXT_PLAIN);
$ifile = $compiler->getFluidbook()->getTextFile($page, FluidbookDocument::TEXT_INDEX);;
-
-
- $text = PHP::retryOnError(function () use ($tfile) {
- Gzip::compressIfNotCompressed($tfile);
- return Gzip::file_get_contents($tfile);
- }, 3, 0.5);
-
$ipage = PHP::retryOnError(function () use ($ifile) {
Gzip::compressIfNotCompressed($ifile);
return Gzip::file_get_contents($ifile);
} else {
self::fillIndexWithWords($index, $page, $ipage);
}
- $textes[$page] = $text;
+
}
ksort($index);
- $textes = json_encode($textes);
$index = json_encode($index);
+ Gzip::file_put_contents($ifilec, $index);
+ }
+ public static function makeTexts($compiler, $dir, &$textes, bool $force = false)
+ {
+ $tfilec = $dir . '/textes.json';
+ $textes = [];
+ foreach ($compiler->pages as $page => $infos) {
+ $tfile = $compiler->getFluidbook()->getTextFile($page, FluidbookDocument::TEXT_PLAIN);
+ $text = PHP::retryOnError(function () use ($tfile) {
+ Gzip::compressIfNotCompressed($tfile);
+ return Gzip::file_get_contents($tfile);
+ }, 3, 0.5);
+ $textes[$page] = $text;
+ }
+ $textes = json_encode($textes);
Gzip::file_put_contents($tfilec, $textes);
- Gzip::file_put_contents($ifilec, $index);
}
/**