Merge pull request #2515 from Innovailable/master
[dokuwiki.git] / inc / PluginInterface.php
blob60898909642891801d47d433b568cf87c9629fa3
1 <?php
2 /**
3 * DokuWiki Plugin Interface
5 * Defines the public contract all DokuWiki plugins will adhere to. The actual code
6 * to do so is defined in DokuWiki_PluginTrait
8 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
9 * @author Christopher Smith <chris@jalakai.co.uk>
11 interface DokuWiki_PluginInterface {
12 /**
13 * General Info
15 * Needs to return a associative array with the following values:
17 * base - the plugin's base name (eg. the directory it needs to be installed in)
18 * author - Author of the plugin
19 * email - Email address to contact the author
20 * date - Last modified date of the plugin in YYYY-MM-DD format
21 * name - Name of the plugin
22 * desc - Short description of the plugin (Text only)
23 * url - Website with more information on the plugin (eg. syntax description)
25 public function getInfo();
27 /**
28 * The type of the plugin inferred from the class name
30 * @return string plugin type
32 public function getPluginType();
34 /**
35 * The name of the plugin inferred from the class name
37 * @return string plugin name
39 public function getPluginName();
41 /**
42 * The component part of the plugin inferred from the class name
44 * @return string component name
46 public function getPluginComponent();
48 /**
49 * Access plugin language strings
51 * to try to minimise unnecessary loading of the strings when the plugin doesn't require them
52 * e.g. when info plugin is querying plugins for information about themselves.
54 * @param string $id id of the string to be retrieved
55 * @return string in appropriate language or english if not available
57 public function getLang($id);
59 /**
60 * retrieve a language dependent file and pass to xhtml renderer for display
61 * plugin equivalent of p_locale_xhtml()
63 * @param string $id id of language dependent wiki page
64 * @return string parsed contents of the wiki page in xhtml format
66 public function locale_xhtml($id);
68 /**
69 * Prepends appropriate path for a language dependent filename
70 * plugin equivalent of localFN()
72 * @param string $id id of localization file
73 * @param string $ext The file extension (usually txt)
74 * @return string wiki text
76 public function localFN($id, $ext = 'txt');
78 /**
79 * Reads all the plugins language dependent strings into $this->lang
80 * this function is automatically called by getLang()
82 * @todo this could be made protected and be moved to the trait only
84 public function setupLocale();
86 /**
87 * use this function to access plugin configuration variables
89 * @param string $setting the setting to access
90 * @param mixed $notset what to return if the setting is not available
91 * @return mixed
93 public function getConf($setting, $notset = false);
95 /**
96 * merges the plugin's default settings with any local settings
97 * this function is automatically called through getConf()
99 * @todo this could be made protected and be moved to the trait only
101 public function loadConfig();
104 * Loads a given helper plugin (if enabled)
106 * @author Esther Brunner <wikidesign@gmail.com>
108 * @param string $name name of plugin to load
109 * @param bool $msg if a message should be displayed in case the plugin is not available
110 * @return DokuWiki_PluginInterface|null helper plugin object
112 public function loadHelper($name, $msg = true);
115 * email
116 * standardised function to generate an email link according to obfuscation settings
118 * @param string $email
119 * @param string $name
120 * @param string $class
121 * @param string $more
122 * @return string html
124 public function email($email, $name = '', $class = '', $more = '');
127 * external_link
128 * standardised function to generate an external link according to conf settings
130 * @param string $link
131 * @param string $title
132 * @param string $class
133 * @param string $target
134 * @param string $more
135 * @return string
137 public function external_link($link, $title = '', $class = '', $target = '', $more = '');
140 * output text string through the parser, allows dokuwiki markup to be used
141 * very ineffecient for small pieces of data - try not to use
143 * @param string $text wiki markup to parse
144 * @param string $format output format
145 * @return null|string
147 public function render_text($text, $format = 'xhtml');
150 * Allow the plugin to prevent DokuWiki from reusing an instance
152 * @return bool false if the plugin has to be instantiated
154 public function isSingleton();