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