1<?php 2// must be run within Dokuwiki 3if (!defined('DOKU_INC')) { 4 die(); 5} 6 7class admin_plugin_tagging extends DokuWiki_Admin_Plugin { 8 9 /** @var helper_plugin_tagging */ 10 private $hlp; 11 12 public function __construct() { 13 $this->hlp = plugin_load('helper', 'tagging'); 14 } 15 16 /** 17 * We allow use by managers 18 * 19 * @return bool always false 20 */ 21 function forAdminOnly() { 22 return false; 23 } 24 25 /** 26 * Handle tag actions 27 * 28 * FIXME remove obsolete actions 29 */ 30 function handle() { 31 global $ID, $INPUT; 32 33 //by default sort by tag name 34 if (!$INPUT->has('sort')) { 35 $INPUT->set('sort', 'tid'); 36 } 37 38 //now starts functions handle 39 if (!$INPUT->has('fn')) { 40 return false; 41 } 42 if (!checkSecurityToken()) { 43 return false; 44 } 45 46 // extract the command and any specific parameters 47 // submit button name is of the form - fn[cmd][param(s)] 48 $fn = $INPUT->param('fn'); 49 50 if (is_array($fn)) { 51 $cmd = key($fn); 52 $param = is_array($fn[$cmd]) ? key($fn[$cmd]) : null; 53 } else { 54 $cmd = $fn; 55 $param = null; 56 } 57 58 switch ($cmd) { 59 case 'rename': 60 $this->hlp->renameTag($INPUT->str('old'), $INPUT->str('new')); 61 break; 62 case 'delete': 63 $this->hlp->deleteTags(array_keys($INPUT->arr('tags')), $INPUT->str('filter')); 64 break; 65 case 'sort': 66 $INPUT->set('sort', $param); 67 break; 68 69 } 70 } 71 72 /** 73 * Draw the interface 74 */ 75 public function html() { 76 echo $this->locale_xhtml('intro'); 77 echo $this->hlp->html_table(); 78 } 79} 80