-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
init.php
56 lines (47 loc) · 1.42 KB
/
init.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
if (!isset($login)) {
$login = new Login();
}
if (!isset($helper)) {
include(THEME_DIR_PHP.'lib/helper.php');
$helper = new Helper($useCdn=false); //set $useCDN to true for image CDN
}
//create or update bltsearch.json
$pubList = $pages->getDB(false);
foreach ($pubList as $key=>$fields) {
if ($fields['type']!='published' && $fields['type']!='sticky') {
unset($pubList[$key]);
}
}
$pubList = array_keys($pubList);
$jsonFile = PATH_UPLOADS . 'bltsearch.json';
if (!isset($searchJson)) {
include(THEME_DIR_PHP.'lib/jsondb.php');
$searchJson = new jsonDB($jsonFile);
}
if(count($pubList) != $searchJson->count() ){
$searchJson->truncate();
foreach ($pubList as $pageKey) {
try {
$tpage = buildPage($pageKey);
// Process $ clean content
$tcont = str_replace('<', ' <', $tpage->content(false));
$tcont = html_entity_decode($tcont, ENT_QUOTES, "UTF-8");
$tcont = Text::removeHTMLTags($tcont);
$tcont = $helper->limit_text_words($tcont, 300, '');
$tcont = trim($tcont);
$tcont = htmlentities($tcont, ENT_QUOTES|ENT_IGNORE, "UTF-8");
$ttitle = html_entity_decode($tpage->title(), ENT_QUOTES, "UTF-8");
$ttitle = htmlentities($ttitle, ENT_QUOTES|ENT_IGNORE, "UTF-8");
$searchJson->db[] = array(
'title' => $ttitle,
'content' => $tcont,
'slug' => $pageKey
);
}
catch (Exception $e) {
// Continue
}
}
$searchJson->save();
}