devel:plugin_programming_tips
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
devel:plugin_programming_tips [2015-05-27 13:51] – [Disabling syntax plugins in user comments] 130.112.1.3 | devel:plugin_programming_tips [2023-09-20 23:01] – [User lists and info] Klap-in | ||
---|---|---|---|
Line 5: | Line 5: | ||
On this page are some tips (see ToC right). Useful resources elsewhere in the wiki are: | On this page are some tips (see ToC right). Useful resources elsewhere in the wiki are: | ||
* [[common plugin functions# | * [[common plugin functions# | ||
- | * [[common plugin functions#Localisation]] | + | * [[common plugin functions#Localization]] |
* Plugin [[plugin file structure|file structure]] and [[plugin file structure|name conventions]] | * Plugin [[plugin file structure|file structure]] and [[plugin file structure|name conventions]] | ||
+ | * [[devel: | ||
Line 20: | Line 20: | ||
<code php> | <code php> | ||
- | | + | global $auth; |
- | if($auth-> | + | if ($auth-> |
- | $auth-> | + | $auth-> |
- | } | + | } |
</ | </ | ||
Where '' | Where '' | ||
- | Several values in each using ' | + | Several values in each using ''|'' as a separator. |
For example, to retrieve all users in the group ' | For example, to retrieve all users in the group ' | ||
<code php> | <code php> | ||
- | | + | $filter[' |
- | $array_of_matches = retrieveUsers(0, | + | $array_of_matches = $auth->retrieveUsers(0, |
</ | </ | ||
- | Be aware that the user backend | + | Be aware that the authentication plugin |
- | See also [[devel:authentication_backends#optional_methods|authentication | + | See also [[devel:auth_plugins#retrieveusers|authentication |
===== DokuWiki Global Variables ===== | ===== DokuWiki Global Variables ===== | ||
Line 53: | Line 54: | ||
===Protect forms and action urls=== | ===Protect forms and action urls=== | ||
- | If you use forms in your plugins or urls that initiate actions, you should include a hidden form field with the session-based security token. In the current version of DokuWiki you can generate this field by calling the function | + | If you use forms in your plugins or urls that initiate actions, you should include a hidden form field with the session-based security token. In the current version of DokuWiki you can generate this field by calling the function |
// | // | ||
Line 163: | Line 164: | ||
* in PHP: | * in PHP: | ||
* set a value '' | * set a value '' | ||
- | * delete an entry '' | + | * delete an entry '' |
* and retrieve its value with '' | * and retrieve its value with '' | ||
* and in javascript: | * and in javascript: | ||
Line 177: | Line 178: | ||
setCookie(" | setCookie(" | ||
</ | </ | ||
- | and in javascript | + | and in javascript: |
<code javascript> | <code javascript> | ||
jQuery.cookie(" | jQuery.cookie(" | ||
expires: 7, //days | expires: 7, //days | ||
- | path: (typeof | + | path: DOKU_COOKIE_PARAM.path, |
- | | + | secure: DOKU_COOKIE_PARAM.secure |
}); | }); | ||
- | </ | ||
- | |||
- | As long '' | ||
- | <code php> | ||
- | public function register(Doku_Event_Handler $controller) { | ||
- | $controller-> | ||
- | } | ||
- | /** | ||
- | * Fallback cookie parameters for releases before the release 2013-12-08 " | ||
- | * | ||
- | * @deprecated 2013-12-08 Temporary fallback to JSINFO.DOKU_COOKIE_PARAM | ||
- | */ | ||
- | public function _cookiepath(Doku_Event $event, $param) { | ||
- | global $JSINFO, $conf; | ||
- | $JSINFO[' | ||
- | ' | ||
- | ' | ||
- | ); | ||
- | } | ||
</ | </ | ||
Line 209: | Line 191: | ||
===== Handle JSON ajax request ===== | ===== Handle JSON ajax request ===== | ||
- | An action plugin that register the [[devel: | + | An action plugin that register the [[devel: |
Create an [[Action Plugin]] which should contain: | Create an [[Action Plugin]] which should contain: | ||
Line 234: | Line 216: | ||
//e.g. access additional request variables | //e.g. access additional request variables | ||
global $INPUT; //available since release 2012-10-13 "Adora Belle" | global $INPUT; //available since release 2012-10-13 "Adora Belle" | ||
- | $name = $INPUT-> | + | $name = $INPUT-> |
| | ||
//data | //data | ||
Line 240: | Line 222: | ||
//json library of DokuWiki | //json library of DokuWiki | ||
- | require_once DOKU_INC . ' | ||
$json = new JSON(); | $json = new JSON(); | ||
| | ||
Line 302: | Line 283: | ||
===== Sending popularity data ===== | ===== Sending popularity data ===== | ||
- | [[devel: | + | Since release 2015-08-10 " |
- | /!\ As a plugin developer, beware: since popularity data is public, you must not send sensitive information with this feature | + | :!: As a plugin developer, beware: since popularity data is public, you must not send sensitive information with this feature. |
The [[plugin: | The [[plugin: | ||
Line 320: | Line 301: | ||
$event-> | $event-> | ||
- | //or: $event-> | + | /* or: |
+ | | ||
+ | | ||
+ | | ||
+ | ); | ||
+ | */ | ||
} | } | ||
</ | </ | ||
- | FIXME link to a plugin which uses this feature | + | A plugin which uses this feature |
devel/plugin_programming_tips.txt · Last modified: 2023-09-20 23:34 by Klap-in