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 | /** |
||
100 | * The search function to handle the different search engines. |
||
101 | * |
||
102 | * @param string $searchTerm Text/Number (solution id) |
||
103 | * @param bool $allLanguages true to search over all languages |
||
104 | * |
||
105 | * @return array |
||
106 | */ |
||
107 | public function search($searchTerm, $allLanguages = true) |
||
115 | |||
116 | /** |
||
117 | * The search function for the database powered full text search. |
||
118 | * |
||
119 | * @param string $searchTerm Text/Number (solution id) |
||
120 | * @param bool $allLanguages true to search over all languages |
||
121 | * |
||
122 | * @return array |
||
123 | */ |
||
124 | public function searchDatabase($searchTerm, $allLanguages = true) |
||
179 | |||
180 | /** |
||
181 | * The search function for the Elasticsearch powered full text search. |
||
182 | * |
||
183 | * @param string $searchTerm Text/Number (solution id) |
||
184 | * @param bool $allLanguages true to search over all languages |
||
185 | * |
||
186 | * @return array |
||
187 | */ |
||
188 | public function searchElasticsearch($searchTerm, $allLanguages = true) |
||
210 | |||
211 | /** |
||
212 | * Logging of search terms for improvements. |
||
213 | * |
||
214 | * @param string $searchTerm Search term |
||
215 | */ |
||
216 | public function logSearchTerm($searchTerm) |
||
238 | |||
239 | /** |
||
240 | * Deletes a search term. |
||
241 | * |
||
242 | * @param string $searchTerm |
||
243 | * |
||
244 | * @return bool |
||
245 | */ |
||
246 | public function deleteSearchTerm($searchTerm) |
||
259 | |||
260 | /** |
||
261 | * Deletes all search terms. |
||
262 | * |
||
263 | * @return bool |
||
264 | */ |
||
265 | public function deleteAllSearchTerms() |
||
271 | |||
272 | /** |
||
273 | * Returns the most popular searches. |
||
274 | * |
||
275 | * @param int $numResults Number of Results, default: 7 |
||
276 | * @param bool $withLang Should the language be included in the result? |
||
277 | * |
||
278 | * @return array |
||
279 | */ |
||
280 | public function getMostPopularSearches($numResults = 7, $withLang = false) |
||
314 | |||
315 | /** |
||
316 | * Returns row count from the "faqsearches" table. |
||
317 | * |
||
318 | * @return int |
||
319 | */ |
||
320 | public function getSearchesCount() |
||
331 | |||
332 | /** |
||
333 | * Sets the Category object. |
||
334 | * |
||
335 | * @param PMF_Category $category |
||
336 | */ |
||
337 | public function setCategory($category) |
||
341 | |||
342 | /** |
||
343 | * Returns the Category object. |
||
344 | * |
||
345 | * @return PMF_Category |
||
346 | */ |
||
347 | public function getCategory() |
||
351 | } |
||
352 |