2018-05-14 00:00:10 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
|
|
|
// $_GET
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// (string) $_GET['query']
|
|
|
|
$query = isset($_GET['query']) ? Text::lowercase($_GET['query']) : false;
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
if ($query===false) {
|
|
|
|
exit (json_encode(array(
|
|
|
|
'status'=>1,
|
|
|
|
'files'=>'Invalid query.'
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
2018-12-31 10:31:51 +01:00
|
|
|
$tmp = array();
|
2018-10-07 23:11:49 +02:00
|
|
|
$published = $pages->getPublishedDB();
|
|
|
|
$statics = $pages->getStaticDB();
|
|
|
|
$pagesKey = array_merge($published, $statics);
|
|
|
|
foreach ($pagesKey as $pageKey) {
|
|
|
|
try {
|
|
|
|
$page = new Page($pageKey);
|
|
|
|
if ($page->isParent()) {
|
|
|
|
$lowerTitle = Text::lowercase($page->title());
|
|
|
|
if (Text::stringContains($lowerTitle, $query)) {
|
|
|
|
$tmp[$page->title()] = $page->key();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
|
|
// continue
|
2018-05-14 00:00:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit (json_encode($tmp));
|
|
|
|
|
2018-12-31 10:31:51 +01:00
|
|
|
?>
|