Translations of this page?:

Common Plugin Functions

Each of the currently implemented DokuWiki plugin classes, syntax, admin, action, helper and renderer provide a common set of methods and properties enabling standard configuration, introspection, localisation and output facilities. These functions produce their results taking into account local installation settings and specific DokuWiki requirements.

These functions are declared in the foundation plugin class, DokuWiki_Plugin, defined in inc/plugin.php.

A summary of the functions and properties are shown below. For full and up-to-date details refer to base.php in the API Reference and the source itself in the Source Repository

Configuration

  • $conf — An array containing the plugin's configuration settings, setting ⇒ value. It is empty until populated by loadConfig()
  • $configloaded — bool, set to true by loadConfig() after it has established the current settings
  • getConf($setting) — return the value of $setting, will call loadConfig() if required.
  • loadConfig() — merges local settings with the plugin's default settings and populates $this→conf array.
  • readDefaultSettings() — reads the default settings file, lib/plugins/<plugin_name>/conf/default.php

The plugin's configuration settings are stored in the installation local settings file, local.php and in the plugin specific file, default.php (refer plugin plugin file structure).

If a plugin handles its configuration through these functions, the wiki admin will be able to manage the settings interactively through the Configuration Manager. See Configuration Metadata to learn more about how to tell the Configuration Manager what to do with your settings.

Introspection

  • getPluginType() — return the plugin type, e.g. syntax, admin or action.
  • getPluginName() — return the plugin name
  • getPluginComponent() — return the plugin component name

Localisation

For information on where the localised strings and files are stored see plugin plugin_file_structure.

  • $lang — An array containing the plugin's localised strings, id ⇒ localised string, may contain English strings where a localised version doesn't exist. It is empty until populated by setupLocale().
  • $localised — bool, set to true by setupLocale() after it has populated $this→lang.
  • getLang($id) — return the localised string for $id, or English string if localised version doesn't exist. Will call setupLocale() if required.
  • locale_xhtml($id) — uses DokuWiki's rendering engine to return xhtml created from the localised file, $id, containing DokuWiki markup.
  • setupLocale() — populates $this→lang with strings based on localisation settings

Output

  • email() — output an email link using the installation's email obfuscation settings.
  • external_link() — output an external link using the installation's target settings.
  • render() — uses the parser to parse and output a string containing wiki markup.
 
devel/common_plugin_functions.txt · Last modified: 2008/11/07 21:44 by 70.103.232.219
 

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported

Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsTranslate