diff options
author | ArthurHoaro <arthur@hoa.ro> | 2021-01-20 15:59:00 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2021-02-04 11:02:50 +0100 |
commit | bcba6bd353161fab456b423e93571ab027d5423c (patch) | |
tree | 97a618b77d327a5f963c91522988e24db5a9e158 /doc | |
parent | 8997ae6c8e24286f7d47981eaf905e80d2481c10 (diff) | |
download | Shaarli-bcba6bd353161fab456b423e93571ab027d5423c.tar.gz Shaarli-bcba6bd353161fab456b423e93571ab027d5423c.tar.zst Shaarli-bcba6bd353161fab456b423e93571ab027d5423c.zip |
New plugin hook: ability to add custom filters to Shaarli search engine
A new plugin hook has been added: hook_test_filter_search_entry
This hook allows to filter out bookmark with custom plugin code when a search is performed.
Related to #143
Diffstat (limited to 'doc')
-rw-r--r-- | doc/md/dev/Plugin-system.md | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/doc/md/dev/Plugin-system.md b/doc/md/dev/Plugin-system.md index 79654011..0ada57ea 100644 --- a/doc/md/dev/Plugin-system.md +++ b/doc/md/dev/Plugin-system.md | |||
@@ -27,7 +27,6 @@ You should have the following tree view: | |||
27 | | |---| demo_plugin.php | 27 | | |---| demo_plugin.php |
28 | ``` | 28 | ``` |
29 | 29 | ||
30 | |||
31 | ### Plugin initialization | 30 | ### Plugin initialization |
32 | 31 | ||
33 | At the beginning of Shaarli execution, all enabled plugins are loaded. At this point, the plugin system looks for an `init()` function in the <plugin_name>.php to execute and run it if it exists. This function must be named this way, and takes the `ConfigManager` as parameter. | 32 | At the beginning of Shaarli execution, all enabled plugins are loaded. At this point, the plugin system looks for an `init()` function in the <plugin_name>.php to execute and run it if it exists. This function must be named this way, and takes the `ConfigManager` as parameter. |
@@ -209,6 +208,7 @@ If it's still not working, please [open an issue](https://github.com/shaarli/Sha | |||
209 | | [save_link](#save_link) | Allow to alter the link being saved in the datastore. | | 208 | | [save_link](#save_link) | Allow to alter the link being saved in the datastore. | |
210 | | [delete_link](#delete_link) | Allow to do an action before a link is deleted from the datastore. | | 209 | | [delete_link](#delete_link) | Allow to do an action before a link is deleted from the datastore. | |
211 | | [save_plugin_parameters](#save_plugin_parameters) | Allow to manipulate plugin parameters before they're saved. | | 210 | | [save_plugin_parameters](#save_plugin_parameters) | Allow to manipulate plugin parameters before they're saved. | |
211 | | [filter_search_entry](#filter_search_entry) | Add custom filters to Shaarli search engine | | ||
212 | 212 | ||
213 | 213 | ||
214 | #### render_header | 214 | #### render_header |
@@ -565,6 +565,23 @@ the array will contain an entry with `MYPLUGIN_PARAMETER` as a key. | |||
565 | 565 | ||
566 | Also [special data](#special-data). | 566 | Also [special data](#special-data). |
567 | 567 | ||
568 | #### filter_search_entry | ||
569 | |||
570 | Triggered for *every* bookmark when Shaarli's BookmarkService method `search()` is used. | ||
571 | Any custom filter can be added to filter out bookmarks from search results. | ||
572 | |||
573 | The hook **must** return either: | ||
574 | - `true` to keep bookmark entry in search result set | ||
575 | - `false` to discard bookmark entry in result set | ||
576 | |||
577 | > Note: custom filters are called *before* default filters are applied. | ||
578 | |||
579 | ##### Parameters | ||
580 | |||
581 | - `Shaarli\Bookmark\Bookmark` object: entry to evaluate | ||
582 | - $context `array`: additional information provided depending on what search is currently used, | ||
583 | the user request, etc. | ||
584 | |||
568 | ## Guide for template designers | 585 | ## Guide for template designers |
569 | 586 | ||
570 | ### Plugin administration | 587 | ### Plugin administration |