devel:action_plugins
Различия
Показаны различия между двумя версиями страницы.
| devel:action_plugins [2023/09/02 17:38] – создано vladpolskiy | devel:action_plugins [Дата неизвестна] (текущий) – удалено - внешнее изменение (Дата неизвестна) 127.0.0.1 | ||
|---|---|---|---|
| Строка 1: | Строка 1: | ||
| - | ====== Action Plugins ====== | ||
| - | [[ru: | ||
| - | |||
| - | ===== Описание ===== | ||
| - | |||
| - | Action plugins загружаются до того, как вики делает что-либо значительное. Сразу же после загрузки, | ||
| - | |||
| - | ===== Техническое описание ===== | ||
| - | |||
| - | Action plugins используют такой же основной формат и правила наименоваения, | ||
| - | |||
| - | * каждый плагин должен располагаться в собственной директории внутри каталога '' | ||
| - | * скрипт плагина должен называться '' | ||
| - | * плагин должен содержать один класс '' | ||
| - | * плагин поддерживает стандартные introspection, | ||
| - | * плагин должен иметь два метода, | ||
| - | * внешние библиотеки могут быть загружены в тот момент, | ||
| - | |||
| - | ==== getInfo() ==== | ||
| - | |||
| - | **!!! Теперь вместо неё прилагается отдельный файл plugin.info.txt !!!** | ||
| - | |||
| - | **обязательный** | ||
| - | <code php> | ||
| - | function getInfo(){ | ||
| - | return array( | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ); | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | ==== register() ==== | ||
| - | **обязательный** | ||
| - | <code php> | ||
| - | /** | ||
| - | * plugin should use this method to register its handlers with the dokuwiki' | ||
| - | * | ||
| - | * @param | ||
| - | * | ||
| - | * @return | ||
| - | */ | ||
| - | function register(Doku_Event_Handler $controller) { | ||
| - | $controller-> | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | ==== <event handler> | ||
| - | **необязательный** их может быть любое количество; | ||
| - | <code php> | ||
| - | /** | ||
| - | * custom event handler | ||
| - | * | ||
| - | * @param | ||
| - | * @param | ||
| - | * | ||
| - | * @return | ||
| - | */ | ||
| - | function < | ||
| - | // custom script statements ... | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | ===== Examples ===== | ||
| - | |||
| - | Action plugins are a way to modify many aspects of how DokuWiki behaves in certain cases independent of a page's syntax. To be able to modify a DokuWiki internal behavior it needs to trigger an event. Your action plugin can register as a handler for such an event and then work with the given event data. | ||
| - | |||
| - | To learn more about events, read the following pages: | ||
| - | |||
| - | |||
| - | * [[events]] | ||
| - | * [[events list]] | ||
| - | * [[event handlers]] | ||
| - | |||
| - | |||
| - | ==== Sample action plugin 1 ==== | ||
| - | |||
| - | Insert a javascript script link in all pages. | ||
| - | * Register the [[events_list# | ||
| - | * Add javascript information to " | ||
| - | |||
| - | <file php action.php> | ||
| - | <?php | ||
| - | /** | ||
| - | * Example Action Plugin: | ||
| - | | ||
| - | * @author | ||
| - | */ | ||
| - | |||
| - | if(!defined(' | ||
| - | if(!defined(' | ||
| - | require_once(DOKU_PLUGIN.' | ||
| - | |||
| - | class action_plugin_example extends DokuWiki_Action_Plugin { | ||
| - | |||
| - | /** | ||
| - | * return some info | ||
| - | */ | ||
| - | function getInfo(){ | ||
| - | return array( | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ); | ||
| - | } | ||
| - | | ||
| - | /** | ||
| - | * Register its handlers with the dokuwiki' | ||
| - | */ | ||
| - | function register(Doku_Event_Handler $controller) { | ||
| - | $controller-> | ||
| - | } | ||
| - | | ||
| - | /** | ||
| - | * Hook js script into page headers. | ||
| - | * | ||
| - | * @author Samuele Tognini < | ||
| - | */ | ||
| - | function _hookjs(& | ||
| - | $event-> | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | ); | ||
| - | } | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | ==== Sample Action Plugin 2 ==== | ||
| - | |||
| - | Inserts a button into the editor toolbar: | ||
| - | * registers as handler for the [[events_list# | ||
| - | * adds a button definition to the event' | ||
| - | |||
| - | <file php action.php> | ||
| - | <?php | ||
| - | /** | ||
| - | * Example Action Plugin: Inserts a button into the toolbar | ||
| - | * | ||
| - | * @author Gina Haeussge < | ||
| - | */ | ||
| - | |||
| - | if (!defined(' | ||
| - | if (!defined(' | ||
| - | require_once (DOKU_PLUGIN . ' | ||
| - | |||
| - | class action_plugin_actionexample extends DokuWiki_Action_Plugin { | ||
| - | |||
| - | /** | ||
| - | * Return some info | ||
| - | */ | ||
| - | function getInfo() { | ||
| - | return array ( | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ); | ||
| - | } | ||
| - | |||
| - | /** | ||
| - | * Register the eventhandlers | ||
| - | */ | ||
| - | function register(Doku_Event_Handler $controller) { | ||
| - | $controller-> | ||
| - | } | ||
| - | |||
| - | /** | ||
| - | * Inserts the toolbar button | ||
| - | */ | ||
| - | function insert_button(& | ||
| - | global $lang; | ||
| - | global $conf; | ||
| - | include_once (dirname(__FILE__) . '/ | ||
| - | @ include_once (dirname(__FILE__) . '/ | ||
| - | |||
| - | $event-> | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ); | ||
| - | } | ||
| - | |||
| - | } | ||
| - | </ | ||
| - | https:// | ||
devel/action_plugins.1693665538.txt.gz · Последнее изменение: — vladpolskiy
