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;
8 Content-Transfer-Encoding: binary
10 A **plugin** is some PHP code that:
11 * lives in ##phpwiki/lib/plugin/<pluginname>.php##
12 * implements the ~WikiPlugin interface by extending that class.
14 There are many plugins already distributed with ~PhpWiki. Simply look
15 in the ##lib/plugin## directory or see the [[PluginManager]] list or see all the
16 [[phpwiki:TitleSearch?s=Help/*Plugin|Help/*Plugin pages]].
18 To write your own, look at the [[Help:HelloWorldPlugin]] (~HelloWorld.php
19 in that directory), which is a minimal example of a plugin.
21 A ~WikiPlugin allows one to easily add new types of dynamic
22 content (as well as other functionality) to wiki pages within ~PhpWiki.
23 In this very wiki all actions which are not entirely lowercased
24 are implemented using plugins, and some lowercased convenience
26 (rename, revert, setacl, diff, ...)
28 Note that you can NOT extend the markup syntax with a plugin, as in other wiki engines.
30 (The old-style [[Help:MagicPhpWikiURLs|MagicPhpWikiURLs]] have been replaced by plugins
35 Currently, one invokes a plugin by putting something like:
38 <<AllPages limit=20 cols=3>>
41 into a regular wiki-page. That particular example produces a list
42 of the first 20 existing pages in 3 columns, via the [[Help:PageList|PageList]]
45 <<AllPages limit=20 cols=3>>
49 Plugins can take certain named arguments, most do. The values of
50 these arguments can be determined four different ways. In order of
53 # The plugin invocation can specify the value for an argument, like so:
55 <?plugin BackLinks page=OtherPage ?>
58 # The argument can be specified via an HTTP query argument. This
59 doesn't happen (is not allowed) unless the argument is mentioned in
60 the plugin invocation:
63 <?plugin BackLinks page ?>
66 # Default values specified in the plugin invocation:
69 <?plugin BackLinks page||=OtherPage ?>
72 # The plugin must supply default values for each argument it uses.
73 Such default args may be overriden by URL arguments like so:
75 BackLinks?page=ThisPage&sortby=-mtime
77 (The BackLinks plugin uses the current page as the default value for
80 Most plugins using the [[Help:PageList|PageList]] library inherit their
81 default arguments from the ~PageList.
83 === Standard Arguments ===
85 Most plugins display a list of pages, via the [[Help:PageList|PageList]]
86 library. ~PageList provides automatic support for those arguments.
88 info, exclude, author, owner, creator, sortby, limit, paging, cols, azhead,
89 comma, commasep, ordered
91 For details see the [[Help:PageList|PageList]] library documentation.
93 *exclude* and *pages* accept a list of pages. Either as comma-separated list,
94 supporting glob-style wildcards, or via the ##<!plugin-list pluginname ~[args~] !>##
95 invocation syntax, where pluginname might be any plugin returning a [[Help:PageList|PageList]].
96 See PhpWiki:PluginList.
98 Since most plugins return a ~PageList, this ~PageList is also a common
99 input parameter for other plugins, actions or formats.
101 === Basic Plugin Types ===
103 All these plugins derive from the ##~WikiPlugin## class extending the
105 which returns a object tree of HTML objects, and may react on any
106 provided arguments from the ~WikiPage (see the args below) or
107 optionally overridden by arguments from the url (GET or POST args),
108 if defined via '||='.
110 A basic plugin just needs the run() method, and optionally getName,
111 getDescription, getDefaultArguments. See the
112 [[Help:HelloWorldPlugin]] for a short introduction.
114 **plugin** reacts on its arguments and the request and displays
117 **plugin-form** is used to display a input type=text box for the
118 default argument **s**.
120 **plugin-list** is used as argument to provide a dynamic list of
124 <?plugin PluginName [args...] ?>
128 <?plugin-form PluginName [args...] ?>
132 <?plugin PluginName args=<!plugin-list pluginname [args...] !> ?>
135 ==== The box Method ====
137 Themes based on the "sidebar" theme may use the box method of any
138 plugin, which displays a **title**
139 and a condensed **content** in a box.
141 ==== ~WikiPluginCached ====
143 Plugins deriving from the class ~WikiPluginCached must also define
144 the methods getPluginType(),
145 optionally getExpire(), managesValidators(), and dependent of the
146 getPluginType the methods to display the **possibly cached** result.
148 getImage(), getMap() or getHtml(),
152 getAlt(), getImageType(), embedMap(), embedImg(), embedObject()
154 See the config.ini PLUGIN_CACHED_* settings and PhpWiki:WikiPluginCached
158 The term **[[Help:ActionPage|ActionPage]]** refers to a page containing a plugin
159 invocation with the same or translated pluginname as the pagename.
160 An **action** is together with the **pagename** argument the basic
162 It can both be GET or POST actions. Actions are untranslated, always
163 English, pagenames can be localized.
164 Basic (and old) actions are all lowercase, like edit, browse, remove, ...
165 Newer actions in [[PhpWiki:CamelCase]] are invoked via plugins on their
166 specific action page.
168 We decoupled actions from plugins via action pages for the following
171 # Support translated action buttons and customizable action descriptions.
172 # Customize standard actions by tuning the plugin invocation arguments.
173 Override or add plugin defaults.
174 # Split simple plugins into multiple actions, like RecentChanges/RecentEdits,
175 MostPopular/LeastPopular, AllPages/AllPagesCreatedByMe/AllPagesLastEditedByMe/
176 AllPagesOwnedByMe which differ only in one argument.
177 # Simplify the syntax for actions on another actions using a ~PageList
178 as result of an actionpage as input parameter for another action or
181 * Those actions which have buttons or links in the theme or are
182 referenced in the standard pgsrc pageset require their
183 (possibly localized) actionpages, otherwise the actions will not work.
184 * If the localized actionpage is not found the english version is
186 * If no actionpage is found, it is recommended to do action=upgrade,
187 which imports all missing and required action pages into the database.
189 So for a hypothetical new ~MyActionPage plugin ~MyActionPage will
190 invoke the plugin and ~Help:~MyActionPagePlugin should be the description page.
192 == Existing Plugins ==
194 See [[PluginManager]] for a detailed list. Most plugins should have their
195 own description page as subpage of **Help/** with the name **Plugin**
199 [[PhpWikiDocumentation]]