devel:admin_plugin_skeleton
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
devel:admin_plugin_skeleton [2010-01-11 02:38] – 70.131.57.199 | devel:admin_plugin_skeleton [2023-09-01 22:43] (current) – Klap-in | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Admin Plugin | + | ====== Admin Plugin |
- | This skeleton has a little more meat than the one list on the admin plugins page. In particular it shows a bare bones form with hidden controls to generate values to return to the plugin and all displayed text is retrieved from the localised | + | This Hello World example show an admin plugin. In particular it shows a bare bones form with hidden controls to generate values to return to the plugin and all displayed text is retrieved from the localized |
- | Two files are shown here | + | Three files are needed |
- | * [[# | + | * [[# |
- | * [[# | + | * [[# |
+ | * [[#lang/en/lang.php]], an English language file with [[localization|localized]] strings used for this plugin. | ||
+ | |||
+ | ===== plugin.info.txt ===== | ||
+ | |||
+ | '' | ||
+ | |||
+ | <code - plugin.info.txt> | ||
+ | base | ||
+ | author me | ||
+ | email me@somesite.com | ||
+ | date | ||
+ | name Hello World Plugin | ||
+ | desc | ||
+ | url https:// | ||
+ | </ | ||
===== admin.php ===== | ===== admin.php ===== | ||
Line 11: | Line 26: | ||
'' | '' | ||
- | <code php> | + | < |
<?php | <?php | ||
+ | |||
+ | use dokuwiki\Extension\AdminPlugin; | ||
+ | |||
/** | /** | ||
* Plugin Skeleton: Displays "Hello World!" | * Plugin Skeleton: Displays "Hello World!" | ||
Line 20: | Line 38: | ||
*/ | */ | ||
- | if(!defined(' | ||
- | if(!defined(' | ||
- | require_once(DOKU_PLUGIN.' | ||
/** | /** | ||
Line 28: | Line 43: | ||
* need to inherit from this class | * need to inherit from this class | ||
*/ | */ | ||
- | class admin_plugin_skeleton extends | + | class admin_plugin_skeleton extends |
- | | + | |
- | + | | |
- | /** | + | |
- | * return some info | + | |
- | */ | + | |
- | function getInfo(){ | + | |
- | return array( | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ); | + | |
- | } | + | |
- | + | ||
- | /** | + | |
- | * return sort order for position in admin menu | + | |
- | */ | + | |
- | function getMenuSort() { | + | |
- | return 999; | + | |
- | } | + | |
- | + | ||
- | /** | + | |
- | | + | |
- | | + | |
- | | + | |
- | */ | + | |
- | // function getMenuText() { | + | |
- | // return 'a menu prompt'; | + | |
- | // } | + | |
- | + | ||
/** | /** | ||
* handle user request | * handle user request | ||
*/ | */ | ||
- | function handle() { | + | |
- | + | | |
- | if (!isset($_REQUEST[' | + | |
+ | | ||
- | | + | |
- | + | | |
- | if (!is_array($_REQUEST[' | + | if (!checkSecurityToken()) return; |
+ | | ||
| | ||
- | | + | |
- | switch (key($_REQUEST[' | + | $cmd = $INPUT-> |
- | case ' | + | |
- | case ' | + | case ' |
- | } | + | |
+ | | ||
+ | case ' | ||
+ | | ||
+ | | ||
+ | } | ||
} | } | ||
Line 83: | Line 75: | ||
* output appropriate html | * output appropriate html | ||
*/ | */ | ||
- | function html() { | + | |
- | ptln('< | + | |
| | ||
- | ptln('< | + | echo '< |
| | ||
- | | + | |
- | ptln(' | + | |
- | ptln(' | + | |
- | + | | |
- | ptln(' | + | formSecurityToken(); |
- | ptln(' | + | |
- | ptln('</ | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
} | } | ||
Line 100: | Line 96: | ||
</ | </ | ||
- | ===== lang.php ===== | + | ===== lang/en/lang.php ===== |
- | lib/ | + | '' |
- | <code php> | + | < |
<?php | <?php | ||
/** | /** | ||
- | | + | |
* | * | ||
* @license | * @license | ||
* @author | * @author | ||
*/ | */ | ||
- | |||
- | // settings must be present and set appropriately for the language | ||
- | $lang[' | ||
- | $lang[' | ||
// for admin plugins, the menu prompt to be displayed in the admin menu | // for admin plugins, the menu prompt to be displayed in the admin menu | ||
Line 129: | Line 121: | ||
$lang[' | $lang[' | ||
</ | </ | ||
- | ---- | ||
- | |||
devel/admin_plugin_skeleton.1263173909.txt.gz · Last modified: 2010-01-11 02:38 by 70.131.57.199