1 | <?php |
||
55 | class BookmarksProvider implements IFullTextSearchProvider { |
||
56 | |||
57 | |||
58 | const BOOKMARKS_PROVIDER_ID = 'bookmarks'; |
||
59 | |||
60 | |||
61 | /** @var IL10N */ |
||
62 | private $l10n; |
||
63 | |||
64 | /** @var ConfigService */ |
||
65 | private $configService; |
||
66 | |||
67 | /** @var BookmarksService */ |
||
68 | private $bookmarksService; |
||
69 | |||
70 | /** @var TagsService */ |
||
71 | private $tagsService; |
||
72 | |||
73 | /** @var SearchService */ |
||
74 | private $searchService; |
||
75 | |||
76 | /** @var MiscService */ |
||
77 | private $miscService; |
||
78 | |||
79 | |||
80 | /** @var IRunner */ |
||
81 | private $runner; |
||
82 | |||
83 | /** @var IIndexOptions */ |
||
84 | private $indexOptions; |
||
85 | |||
86 | |||
87 | public function __construct( |
||
98 | |||
99 | |||
100 | /** |
||
101 | * return unique id of the provider |
||
102 | */ |
||
103 | public function getId(): string { |
||
106 | |||
107 | |||
108 | /** |
||
109 | * return name of the provider |
||
110 | */ |
||
111 | public function getName(): string { |
||
114 | |||
115 | |||
116 | // /** |
||
117 | // * @return string |
||
118 | // */ |
||
119 | // public function getVersion() { |
||
120 | // return $this->configService->getAppValue('installed_version'); |
||
121 | // } |
||
122 | // |
||
123 | // |
||
124 | // /** |
||
125 | // * @return string |
||
126 | // */ |
||
127 | // public function getAppId() { |
||
128 | // return Application::APP_NAME; |
||
129 | // } |
||
130 | // |
||
131 | |||
132 | /** |
||
133 | * @return array |
||
134 | */ |
||
135 | public function getConfiguration(): array { |
||
138 | |||
139 | |||
140 | /** |
||
141 | * @param IRunner $runner |
||
142 | */ |
||
143 | public function setRunner(IRunner $runner) { |
||
146 | |||
147 | |||
148 | /** |
||
149 | * @param IIndexOptions $options |
||
150 | */ |
||
151 | public function setIndexOptions(IIndexOptions $options) { |
||
154 | |||
155 | |||
156 | public function getSearchTemplate(): SearchTemplate { |
||
224 | |||
225 | |||
226 | |||
227 | // /** |
||
228 | // * @return array |
||
229 | // */ |
||
230 | // public function getOptionsTemplate() { |
||
231 | // return [ |
||
232 | // 'navigation' => [ |
||
233 | // 'icon' => 'icon-fts-bookmarks', |
||
234 | // // 'options' => [ |
||
235 | // // [ |
||
236 | // // 'name' => 'bookmarks_tags', |
||
237 | // // 'title' => 'Filter tags', |
||
238 | // // 'type' => 'tags', |
||
239 | // // 'list' => $this->tagsService->getAllForUser() |
||
240 | // // ] |
||
241 | // // ] |
||
242 | // ] |
||
243 | // ]; |
||
244 | // } |
||
245 | |||
246 | |||
247 | /** |
||
248 | * called when loading all providers. |
||
249 | * |
||
250 | * Loading some containers. |
||
251 | * |
||
252 | * @throws QueryException |
||
253 | */ |
||
254 | public function loadProvider() { |
||
260 | |||
261 | |||
262 | /** |
||
263 | * returns all indexable document for a user. |
||
264 | * There is no need to fill the document with content at this point. |
||
265 | * |
||
266 | * $platform is provided if the mapping needs to be changed. |
||
267 | * |
||
268 | * @param string $userId |
||
269 | * |
||
270 | * @return IndexDocument[] |
||
271 | */ |
||
272 | public function generateIndexableDocuments(string $userId): array { |
||
277 | |||
278 | |||
279 | /** |
||
280 | * @param IndexDocument $document |
||
281 | */ |
||
282 | public function fillIndexDocument(IndexDocument $document) { |
||
300 | |||
301 | |||
302 | // /** |
||
303 | // * @param IndexDocument $document |
||
304 | // */ |
||
305 | // public function fillIndexDocument(IndexDocument $document) { |
||
306 | // try { |
||
307 | // $this->updateRunnerInfo('info', $document->getSource()); |
||
308 | // |
||
309 | // /** @var BookmarksDocument $document */ |
||
310 | // $this->bookmarksService->updateDocumentFromBookmarksDocument($document); |
||
311 | // |
||
312 | // } catch (Exception $e) { |
||
313 | // $this->manageErrorException($document, $e); |
||
314 | // } |
||
315 | // } |
||
316 | |||
317 | |||
318 | /** |
||
319 | * @param IndexDocument $document |
||
320 | * |
||
321 | * @return bool |
||
322 | */ |
||
323 | public function isDocumentUpToDate(IndexDocument $document): bool { |
||
326 | |||
327 | |||
328 | /** |
||
329 | * @param IIndex $index |
||
330 | * |
||
331 | * @return IndexDocument |
||
332 | * @throws WebpageIsNotIndexableException |
||
333 | */ |
||
334 | public function updateDocument(IIndex $index): IndexDocument { |
||
341 | |||
342 | |||
343 | /** |
||
344 | * @param IFullTextSearchPlatform $platform |
||
345 | */ |
||
346 | public function onInitializingIndex(IFullTextSearchPlatform $platform) { |
||
348 | |||
349 | |||
350 | /** |
||
351 | * @param IFullTextSearchPlatform $platform |
||
352 | */ |
||
353 | public function onResettingIndex(IFullTextSearchPlatform $platform) { |
||
355 | |||
356 | |||
357 | /** |
||
358 | * not used yet |
||
359 | */ |
||
360 | public function unloadProvider() { |
||
362 | |||
363 | |||
364 | /** |
||
365 | * before a search, improve the request |
||
366 | * |
||
367 | * @param ISearchRequest $request |
||
368 | */ |
||
369 | public function improveSearchRequest(ISearchRequest $request) { |
||
372 | |||
373 | |||
374 | /** |
||
375 | * after a search, improve results |
||
376 | * |
||
377 | * @param ISearchResult $searchResult |
||
378 | */ |
||
379 | public function improveSearchResult(ISearchResult $searchResult) { |
||
386 | |||
387 | |||
388 | /** |
||
389 | * @param IndexDocument $document |
||
390 | * @param Exception $e |
||
391 | */ |
||
392 | private function manageErrorException(IndexDocument $document, Exception $e) { |
||
399 | |||
400 | |||
401 | /** |
||
402 | * @param IIndex $index |
||
403 | * @param string $message |
||
404 | * @param string $exception |
||
405 | * @param int $sev |
||
406 | */ |
||
407 | private function updateNewIndexError(IIndex $index, string $message, string $exception, int $sev |
||
415 | |||
416 | |||
417 | /** |
||
418 | * @param string $info |
||
419 | * @param string $value |
||
420 | */ |
||
421 | private function updateRunnerInfo(string $info, string $value) { |
||
428 | |||
429 | |||
430 | /** |
||
431 | * @param array $data |
||
432 | */ |
||
433 | private function updateRunnerInfoArray(array $data) { |
||
440 | |||
441 | } |
||
442 | |||
443 |