1 | <?php |
||
37 | class PMF_Search |
||
38 | { |
||
39 | /** |
||
40 | * @var PMF_Configuration |
||
41 | */ |
||
42 | private $_config; |
||
43 | |||
44 | /** |
||
45 | * Category ID. |
||
46 | * |
||
47 | * @var int |
||
48 | */ |
||
49 | private $categoryId = null; |
||
50 | |||
51 | /** |
||
52 | * Category object. |
||
53 | * |
||
54 | * @var PMF_Category |
||
55 | */ |
||
56 | private $category = null; |
||
57 | |||
58 | /** |
||
59 | * Search table. |
||
60 | * |
||
61 | * @var string |
||
62 | */ |
||
63 | private $_table = null; |
||
64 | |||
65 | /** |
||
66 | * Constructor. |
||
67 | * |
||
68 | * @param PMF_Configuration $config |
||
69 | * |
||
70 | * @return PMF_Search |
||
71 | */ |
||
72 | public function __construct(PMF_Configuration $config) |
||
77 | |||
78 | /** |
||
79 | * Setter for category. |
||
80 | * |
||
81 | * @param int $categoryId Category ID |
||
82 | */ |
||
83 | public function setCategoryId($categoryId) |
||
87 | |||
88 | /** |
||
89 | * Getter for category. |
||
90 | * |
||
91 | * @return int |
||
92 | */ |
||
93 | public function getCategoryId() |
||
97 | |||
98 | /** |
||
99 | * The search function to handle the different search engines. |
||
100 | * |
||
101 | * @param string $searchTerm Text/Number (solution id) |
||
102 | * @param bool $allLanguages true to search over all languages |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | public function search($searchTerm, $allLanguages = true) |
||
114 | |||
115 | /** |
||
116 | * The autocomplete function to handle the different search engines. |
||
117 | * |
||
118 | * @param string $searchTerm Text to auto complete |
||
119 | * |
||
120 | * @return array |
||
121 | */ |
||
122 | public function autocomplete($searchTerm) |
||
140 | |||
141 | /** |
||
142 | * The search function for the database powered full text search. |
||
143 | * |
||
144 | * @param string $searchTerm Text/Number (solution id) |
||
145 | * @param bool $allLanguages true to search over all languages |
||
146 | * |
||
147 | * @return array |
||
148 | */ |
||
149 | public function searchDatabase($searchTerm, $allLanguages = true) |
||
204 | |||
205 | /** |
||
206 | * The search function for the Elasticsearch powered full text search. |
||
207 | * |
||
208 | * @param string $searchTerm Text/Number (solution id) |
||
209 | * @param bool $allLanguages true to search over all languages |
||
210 | * |
||
211 | * @return array |
||
212 | */ |
||
213 | public function searchElasticsearch($searchTerm, $allLanguages = true) |
||
235 | |||
236 | /** |
||
237 | * Logging of search terms for improvements. |
||
238 | * |
||
239 | * @param string $searchTerm Search term |
||
240 | */ |
||
241 | public function logSearchTerm($searchTerm) |
||
263 | |||
264 | /** |
||
265 | * Deletes a search term. |
||
266 | * |
||
267 | * @param string $searchTerm |
||
268 | * |
||
269 | * @return bool |
||
270 | */ |
||
271 | public function deleteSearchTerm($searchTerm) |
||
284 | |||
285 | /** |
||
286 | * Deletes all search terms. |
||
287 | * |
||
288 | * @return bool |
||
289 | */ |
||
290 | public function deleteAllSearchTerms() |
||
296 | |||
297 | /** |
||
298 | * Returns the most popular searches. |
||
299 | * |
||
300 | * @param int $numResults Number of Results, default: 7 |
||
301 | * @param bool $withLang Should the language be included in the result? |
||
302 | * |
||
303 | * @return array |
||
304 | */ |
||
305 | public function getMostPopularSearches($numResults = 7, $withLang = false) |
||
339 | |||
340 | /** |
||
341 | * Returns row count from the "faqsearches" table. |
||
342 | * |
||
343 | * @return int |
||
344 | */ |
||
345 | public function getSearchesCount() |
||
356 | |||
357 | /** |
||
358 | * Sets the Category object. |
||
359 | * |
||
360 | * @param PMF_Category $category |
||
361 | */ |
||
362 | public function setCategory($category) |
||
366 | |||
367 | /** |
||
368 | * Returns the Category object. |
||
369 | * |
||
370 | * @return PMF_Category |
||
371 | */ |
||
372 | public function getCategory() |
||
376 | } |
||
377 |