Gold/Docs/Anatomy of a Search Plugin: Difference between revisions
From Mahara Wiki
< User:Gold | Docs
(Initial WIP on documenting a search plugin.) |
|||
Line 28: | Line 28: | ||
=== Configuration === | === Configuration === | ||
Adding a configuration form is just a matter of implementing the following methods. | |||
* <code>has_config()</code> : Tells the system there is a config form. Shows the config cog on the Plugin Administration screen. | |||
* <code>get_config_options()</code> : Return a Pieform array. | |||
* <code>validate_config_options(Pieform $form, $values)</code> : Validate the user input from your config form. | |||
* <code>save_config_options(Pieform $form, $values)</code> : Save config options and react to any values entered. |
Latest revision as of 12:10, 20 Mayıs 2021
tl;dr;
This is intended to become a developer reference.
How to get your plugin seen by the system
The Plugin will live in the htdocs/search
directory and needs to extend the PluginSearch
class. As with all Mahara plugins the class is loaded from/lives in the lib.php
file in the plugin directory.
htdocs/search/Mysearch ├── lib │ └── PluginSearchMysearch.php ├── lib.php └── version.php
To keep things tidy we are adding a lib
directory where the class files will live. This isn't strictly needed, but if your plugin is going to create multiple classes this is a way to keep the line count per file down to a manageable level. If you are only going to need one class though, skip this and just add it to the lib.php
file.
The following methods need to be implemented by your Plugin.
search_user()
:search_group()
:group_search_user()
:self_search()
:
Extras
- Implement
get_plugin_display_name()
to give your plugin a human readable name.
Configuration
Adding a configuration form is just a matter of implementing the following methods.
has_config()
: Tells the system there is a config form. Shows the config cog on the Plugin Administration screen.get_config_options()
: Return a Pieform array.validate_config_options(Pieform $form, $values)
: Validate the user input from your config form.save_config_options(Pieform $form, $values)
: Save config options and react to any values entered.