1<?php 2/** 3 * Admin Plugin Prototype 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Christopher Smith <chris@jalakai.co.uk> 7 */ 8// must be run within Dokuwiki 9if(!defined('DOKU_INC')) die(); 10 11/** 12 * All DokuWiki plugins to extend the admin function 13 * need to inherit from this class 14 */ 15class DokuWiki_Admin_Plugin extends DokuWiki_Plugin { 16 17 /** 18 * Return the text that is displayed at the main admin menu 19 * (Default localized language string 'menu' is returned, override this function for setting another name) 20 * 21 * @param string $language language code 22 * @return string menu string 23 */ 24 public function getMenuText($language) { 25 $menutext = $this->getLang('menu'); 26 if (!$menutext) { 27 $info = $this->getInfo(); 28 $menutext = $info['name'].' ...'; 29 } 30 return $menutext; 31 } 32 33 /** 34 * Return the path to the icon being displayed in the main admin menu. 35 * Default means, there won't be any icon. 36 * (Override this function for setting another image) 37 * 38 * CAUTION: 39 * Only svg-files are allowed 40 * 41 */ 42 public function getMenuIcon(){ 43 return ''; 44 } 45 46 /** 47 * Return the path to the icon being displayed in the main admin menu. 48 * In case of file mime-type not being SVG, an empty string will be returned. 49 * @return string menu icon url or empty 50 */ 51 public function getMenuIconSvgOnly(){ 52 $returnValue = ''; 53 54 if(strlen($this->getMenuIcon()) != '' && is_file(DOKU_INC.substr($this->getMenuIcon(), strlen(DOKU_BASE)))){ 55 $calculated = mimetype(DOKU_INC.substr($this->getMenuIcon(), strlen(DOKU_BASE)), false); 56 if(is_array($calculated) && $calculated[0] == 'svg') { 57 $returnValue = $this->getMenuIcon(); 58 } 59 } 60 return $returnValue; 61 } 62 63 /** 64 * Determine position in list in admin window 65 * Lower values are sorted up 66 * 67 * @return int 68 */ 69 public function getMenuSort() { 70 return 1000; 71 } 72 73 /** 74 * Carry out required processing 75 */ 76 public function handle() { 77 trigger_error('handle() not implemented in '.get_class($this), E_USER_WARNING); 78 } 79 80 /** 81 * Output html of the admin page 82 */ 83 public function html() { 84 trigger_error('html() not implemented in '.get_class($this), E_USER_WARNING); 85 } 86 87 /** 88 * Return true for access only by admins (config:superuser) or false if managers are allowed as well 89 * 90 * @return bool 91 */ 92 public function forAdminOnly() { 93 return true; 94 } 95 96 /** 97 * Return array with ToC items. Items can be created with the html_mktocitem() 98 * 99 * @see html_mktocitem() 100 * @see tpl_toc() 101 * 102 * @return array 103 */ 104 public function getTOC(){ 105 return array(); 106 } 107} 108//Setup VIM: ex: et ts=4 : 109