2018-04-13 23:32:29 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
2019-05-27 19:41:46 +02:00
|
|
|
/*
|
|
|
|
| Returns a list of pages are parent and match with the string in them titles
|
|
|
|
|
|
|
|
|
| @_POST['query'] string The string to search in the title of the pages
|
|
|
|
|
|
|
|
|
| @return array
|
|
|
|
*/
|
|
|
|
|
2018-04-13 23:32:29 +02:00
|
|
|
// $_GET
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// (string) $_GET['query']
|
|
|
|
$query = isset($_GET['query']) ? Text::lowercase($_GET['query']) : false;
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
if ($query===false) {
|
2019-01-31 20:07:59 +01:00
|
|
|
ajaxResponse(1, 'Invalid query.');
|
2018-04-13 23:32:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$tmp = array();
|
|
|
|
$parents = buildParentPages();
|
|
|
|
foreach ($parents as $parent) {
|
|
|
|
$lowerTitle = Text::lowercase($parent->title());
|
|
|
|
if (Text::stringContains($lowerTitle, $query)) {
|
|
|
|
$tmp[$parent->title()] = $parent->key();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit (json_encode($tmp));
|
|
|
|
|
|
|
|
?>
|