devel:common_plugin_functions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
devel:common_plugin_functions [2008-10-28 00:34] – 70.103.232.219 | devel:common_plugin_functions [2023-02-28 22:24] – Aleksandr | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Common Plugin Functions ====== | ||
+ | |||
+ | Each of the currently implemented [[: | ||
+ | |||
+ | These functions are declared in the foundation plugin class, '' | ||
+ | |||
+ | A summary of the functions and properties are shown below. For full and up-to-date details refer to [[xref> | ||
+ | |||
+ | |||
+ | **Inherited methods** available in all plugins (also see [[xref> | ||
+ | |||
+ | ^Name ^Description ^ | ||
+ | |[[xref> | ||
+ | |[[xref> | ||
+ | |[[xref> | ||
+ | |[[xref> | ||
+ | |[[xref> | ||
+ | |[[xref> | ||
+ | |[[xref> | ||
+ | |[[xref> | ||
+ | |[[xref> | ||
+ | |[[xref> | ||
+ | |[[xref> | ||
+ | |||
+ | The following additional methods can be **overridden** when required: | ||
+ | |||
+ | ^Name ^Description ^ | ||
+ | |[[xref> | ||
+ | |||
+ | |||
+ | ===== Configuration ===== | ||
+ | |||
+ | Please refer to [[Configuration]] for more info. The additional files used by plugins are: | ||
+ | * ''< | ||
+ | * '' | ||
+ | * contains the [[configuration# | ||
+ | * accessible via '' | ||
+ | * :!: modified settings (configuration changes) are stored within DokuWiki' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | > Use '' | ||
+ | |||
+ | If a plugin complies to the above structure the wiki admin will be able to manage the settings interactively through the [[plugin: | ||
+ | |||
+ | |||
+ | ===Example=== | ||
+ | Read setting ' | ||
+ | <code php> | ||
+ | $sort = $this-> | ||
+ | </ | ||
+ | ===== Introspection ===== | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | |||
+ | ===== Localization ===== | ||
+ | |||
+ | Localizations are stored in the plugin folder. The next files can be provided: | ||
+ | * ''< | ||
+ | * '' | ||
+ | * accessible via '' | ||
+ | * '' | ||
+ | * Shows up in the [[plugin: | ||
+ | * '' | ||
+ | * accessible via '' | ||
+ | |||
+ | Please see the developer info about [[devel: | ||
+ | |||
+ | |||
+ | ===== Instantiating ===== | ||
+ | Default DokuWiki reuses instances of plugins. This can be prevented by adding the function '' | ||
+ | <code php> | ||
+ | /** | ||
+ | * Return false to prevent DokuWiki reusing instances of the plugin | ||
+ | | ||
+ | * @return bool | ||
+ | */ | ||
+ | public function isSingleton() { | ||
+ | return false; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | =====Load Helper plugins===== | ||
+ | In all plugins Helper plugins can be loaded by '' | ||
+ | |||
+ | It loads a given helper plugin if the plugin is enabled. Details and examples in [[helper plugins]]. | ||
+ | |||
+ | ===Example=== | ||
+ | Load helper of the tag plugin: | ||
+ | <code php> | ||
+ | //get the instance of Tag Helper | ||
+ | $tag = $this-> | ||
+ | |||
+ | if($tag) { | ||
+ | $entries = $tag-> | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Load other plugins ===== | ||
+ | If you want to use another plugin in your plugin you have to use the '' | ||
+ | |||
+ | It will return a plugin object. Default this object is the unique plugin instance stored by the plugin controller, but when the requested plugin is marked as not singleton by '' | ||
+ | |||
+ | Or use instead the additional parameter options of [[xref> | ||
+ | |||
+ | Load helper plugin component from Tag plugin, which has only one helper component: | ||
+ | <code php> | ||
+ | if(!plugin_isdisabled(' | ||
+ | $tag =& plugin_load(' | ||
+ | if($tag) { | ||
+ | $entries = $tag-> | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Or load syntax plugin component from Data plugin, which has several syntax components, so specifying of the component needed: | ||
+ | <code php> | ||
+ | if(!plugin_isdisabled(' | ||
+ | $table =& plugin_load(' | ||
+ | if($table) { | ||
+ | $hasfilter = $table-> | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | ===== Output ==== | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | |||
+ | |||
+ | ===== See also ===== | ||
+ | * [[Plugin file structure]] | ||
+ | * [[Plugin file structure# | ||
+ | * [[Plugin programming tips]] | ||
+ | * [[devel: | ||
+ | |||
devel/common_plugin_functions.txt · Last modified: 2023-09-01 13:56 by Klap-in