-
Notifications
You must be signed in to change notification settings - Fork 38
/
search.php
90 lines (50 loc) · 1.74 KB
/
search.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
$parser = ucFirst($type)."Parser";
define("PARSER_URL", "parsers/autosuggest/");
require_once(PARSER_URL."classes/AutoSuggestParser.php");
require_once(PARSER_URL."classes/".$type."/".$parser.".php");
require_once('workflows.php');
$parser = new $parser;
$icon = PARSER_URL."classes/".$type."/".$parser->icon;
$data = file_get_contents(PARSER_URL."data/".$parser->data_filename);
$wf = new Workflows();
$data = json_decode($data);
if (!isset($icon)) {
$icon = "icon.png";
}
$query = strtolower($query);
$arr = get_defined_functions();
$extras = array();
$extras2 = array();
$found = array();
foreach ($data as $key => $result){
$value = strtolower(trim($result->title));
$description = utf8_decode(strip_tags(strtolower($result->description)));
$new_key = $type.$result->title;
//if ($value === "wbr") echo 23;
if (strpos($value, $query) === 0) {
if (!isset($found[$value])) {
$found[$value] = true;
$wf->result( $type.$result->title, $result->url, $result->title, $result->description,$icon );
}
}
else if (strpos($value, $query) > 0) {
if (!isset($found[$value])) {
$found[$value] = true;
$extras[$key] = $result;
}
}
else if (strpos($description, $query) !== false) {
if (!isset($found[$value])) {
$found[$value] = true;
$extras2[$key] = $result;
}
}
}
foreach ($extras as $key => $result) {
$wf->result( $type.$result->title, $result->url, $result->title, $result->description, $icon );
}
foreach ($extras2 as $key => $result) {
$wf->result( $type.$result->title, $result->url, $result->title, $result->description, $icon );
}
echo $wf->toxml();