]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - pgsrc/Help%2FWikiPlugin
Update PHP Doc
[SourceForge/phpwiki.git] / pgsrc / Help%2FWikiPlugin
1 Date: Fri, 11 Jan 2013 11:16:51 +0000
2 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0)
3 Content-Type: application/x-phpwiki;
4   pagename=Help%2FWikiPlugin;
5   flags=PAGE_LOCKED%2CEXTERNAL_PAGE;
6   charset=UTF-8
7 Content-Transfer-Encoding: binary
8
9 A **plugin** is some PHP code that:
10 * lives in ##phpwiki/lib/plugin/<pluginname>.php##
11 * implements the ~WikiPlugin interface by extending that class.
12
13 There are many plugins already distributed with ~PhpWiki. Simply look
14 in the ##lib/plugin## directory or see the [[PluginManager]] list or see all the
15 [[phpwiki:TitleSearch?s=Help/*Plugin|Help/*Plugin pages]].
16
17 To write your own, look at the [[Help:HelloWorldPlugin]] (~HelloWorld.php
18 in that directory), which is a minimal example of a plugin.
19
20 A ~WikiPlugin allows one to easily add new types of dynamic
21 content (as well as other functionality) to wiki pages within ~PhpWiki.
22 In this very wiki all actions which are not entirely lowercased
23 are implemented using plugins, and some lowercased convenience
24 actions also.
25 (rename, revert, setacl, diff, ...)
26
27 Note that you can NOT extend the markup syntax with a plugin, as in other wiki engines.
28
29 (The old-style [[Help:MagicPhpWikiURLs|MagicPhpWikiURLs]] have been replaced by plugins
30 entirely.)
31
32 == Example ==
33
34 Currently, one invokes a plugin by putting something like:
35
36 {{{
37 <<AllPages limit=20 cols=3>>
38 }}}
39
40 into a regular wiki-page.  That particular example produces a list
41 of the first 20 existing pages in 3 columns, via the [[Help:PageList|PageList]]
42 library.
43
44 <<AllPages limit=20 cols=3>>
45
46 == Details ==
47
48 Plugins can take certain named arguments, most do.  The values of
49 these arguments can be determined four different ways.  In order of
50 precedence:
51
52 # The plugin invocation can specify the value for an argument, like so:
53   {{{
54   <?plugin BackLinks page=OtherPage ?>
55   }}}
56
57 # The argument can be specified via an HTTP query argument.  This
58   doesn't happen (is not allowed) unless the argument is mentioned in
59   the plugin invocation:
60
61   {{{
62   <?plugin BackLinks page ?>
63   }}}
64
65 # Default values specified in the plugin invocation:
66
67   {{{
68   <?plugin BackLinks page||=OtherPage ?>
69   }}}
70
71 # The plugin must supply default values for each argument it uses.
72   Such default args may be overriden by URL arguments like so:
73   {{{
74     BackLinks?page=ThisPage&sortby=-mtime
75   }}}
76   (The BackLinks plugin uses the current page as the default value for
77   the *page* argument.)
78
79   Most plugins using the [[Help:PageList|PageList]] library inherit their
80   default arguments from the ~PageList.
81
82 === Standard Arguments ===
83
84 Most plugins display a list of pages, via the [[Help:PageList|PageList]]
85 library. ~PageList provides automatic support for those arguments.
86
87   info, exclude, author, owner, creator, sortby, limit, paging, cols, azhead,
88   comma, commasep, ordered
89
90   For details see the [[Help:PageList|PageList]] library documentation.
91
92 *exclude* and *pages* accept a list of pages. Either as comma-separated list,
93 supporting glob-style wildcards, or via the ##<!plugin-list pluginname ~[args~] !>##
94 invocation syntax, where pluginname might be any plugin returning a [[Help:PageList|PageList]].
95 See PhpWiki:PluginList.
96
97 Since most plugins return a ~PageList, this ~PageList is also a common
98 input parameter for other plugins, actions or formats.
99
100 === Basic Plugin Types ===
101
102 All these plugins derive from the ##~WikiPlugin## class extending the
103 run method,
104 which returns a object tree of HTML objects, and may react on any
105 provided arguments from the ~WikiPage (see the args below) or
106 optionally overridden by arguments from the url (GET or POST args),
107 if defined via '||='.
108
109 A basic plugin just needs the run() method, and optionally getName,
110 getDescription, getDefaultArguments. See the
111 [[Help:HelloWorldPlugin]] for a short introduction.
112
113   **plugin** reacts on its arguments and the request and displays
114   arbitrary HTML.
115
116   **plugin-form** is used to display a input type=text box for the
117   default argument **s**.
118
119   **plugin-list** is used as argument to provide a dynamic list of
120   pagenames.
121
122   {{{
123     <?plugin PluginName [args...] ?>
124   }}}
125
126   {{{
127     <?plugin-form PluginName [args...] ?>
128   }}}
129
130   {{{
131     <?plugin PluginName args=<!plugin-list pluginname [args...] !> ?>
132   }}}
133
134 ==== The box Method ====
135
136 Themes based on the "sidebar" theme may use the box method of any
137 plugin, which displays a **title**
138 and a condensed **content** in a box.
139
140 ==== ~WikiPluginCached ====
141
142 Plugins deriving from the class ~WikiPluginCached must also define
143 the methods getPluginType(),
144 optionally getExpire(), managesValidators(), and dependent of the
145 getPluginType the methods to display the **possibly cached** result.
146
147   getImage(), getMap() or getHtml(),
148
149 optionally also
150
151   getAlt(), getImageType(), embedMap(), embedImg(), embedObject()
152
153 See the config.ini PLUGIN_CACHED_* settings and PhpWiki:WikiPluginCached
154
155 === Action Pages ===
156
157 The term **[[Help:ActionPage|ActionPage]]** refers to a page containing a plugin
158 invocation with the same or translated pluginname as the pagename.
159 An **action** is together with the **pagename** argument the basic
160 ~PhpWiki argument.
161 It can both be GET or POST actions. Actions are untranslated, always
162 English, pagenames can be localized.
163 Basic (and old) actions are all lowercase, like edit, browse, remove, ...
164 Newer actions in [[PhpWiki:CamelCase]] are invoked via plugins on their
165 specific action page.
166
167 We decoupled actions from plugins via action pages for the following
168 reasons:
169
170 # Support translated action buttons and customizable action descriptions.
171 # Customize standard actions by tuning the plugin invocation arguments.
172   Override or add plugin defaults.
173 # Split simple plugins into multiple actions, like RecentChanges/RecentEdits,
174   MostPopular/LeastPopular, AllPages/AllPagesCreatedByMe/AllPagesLastEditedByMe/
175   AllPagesOwnedByMe which differ only in one argument.
176 # Simplify the syntax for actions on another actions using a ~PageList
177   as result of an actionpage as input parameter for another action or
178   format.
179
180 * Those actions which have buttons or links in the theme or are
181   referenced in the standard pgsrc pageset require their
182   (possibly localized) actionpages, otherwise the actions will not work.
183 * If the localized actionpage is not found the english version is
184   used.
185 * If no actionpage is found, it is recommended to do action=upgrade,
186   which imports all missing and required action pages into the database.
187
188 So for a hypothetical new ~MyActionPage plugin ~MyActionPage will
189 invoke the plugin and ~Help:~MyActionPagePlugin should be the description page.
190
191 == Existing Plugins ==
192
193 See [[PluginManager]] for a detailed list. Most plugins should have their
194 own description page as subpage of **Help/** with the name **Plugin**
195 appended.
196
197 ----
198 [[PhpWikiDocumentation]]