This commit is contained in:
Alan
2026-02-14 19:34:54 +03:00
commit 5c3329238b
867 changed files with 214778 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
<?php
function showRes($res)
{
header("Content-type: application/json; charset=UTF-8");
header("Cache-Control: must-revalidate");
header("Pragma: no-cache");
header("Expires: -1");
print json_encode($res);
exit();
}
chdir('../..');
require_once('api/Simpla.php');
$simpla = new Simpla();
$limit = 100;
$keyword = $simpla->request->get('query', 'string');
//function buildFlatServiceTree($serviceId, $main = true)
//{
// global $simpla;
// $simpla->db->query("SELECT * FROM __pages WHERE parent = ? ORDER BY name", $serviceId);
// $services = $simpla->db->results();
// $res = [];
// foreach ($services as $service) {
//// $res = array_merge($res, buildFlatServiceTree($service->id));
// if ($main && $service->show_service != 1) continue;
// $res[] = [
// 'id' => $service->id,
// 'name' => $service->name,
// ];
// }
// return $res;
//}
$simpla->db->query("SELECT * FROM __pages WHERE show_service = 1 ORDER BY name");
$services = $simpla->db->results();
//$services = buildFlatServiceTree(28);
if ($keyword) {
$services = array_filter($services, function ($service) use ($keyword) {
return strpos(mb_strtolower($service->name), mb_strtolower($keyword)) !== false;
});
}
foreach ($services as $service) {
$service_name[] = $service->name;
$services_data[] = $service;
}
$res->query = $keyword;
$res->suggestions = $service_name;
$res->data = $services_data;
showRes($res);