hlp = plugin_load('helper', 'tagging'); } /** * We allow use by managers * * @return bool always false */ function forAdminOnly() { return false; } /** * Handle tag actions */ function handle() { global $INPUT; if (!$INPUT->has('fn')) return false; if (!checkSecurityToken()) return false; // extract the command and any specific parameters // submit button name is of the form - fn[cmd][param(s)] $fn = $INPUT->param('fn'); if (is_array($fn)) { $cmd = key($fn); $param = is_array($fn[$cmd]) ? key($fn[$cmd]) : null; } else { $cmd = $fn; $param = null; } switch ($cmd) { case 'rename' : $this->_renameTag(); break; case 'delete' : $this->_deleteTags(); break; } } /** * Draw the interface */ function html() { echo $this->locale_xhtml('intro'); $this->html_form(); echo '
'; $this->html_table(); } /** * Show form for renaming tags */ protected function html_form() { global $ID; $form = new Doku_Form(array('action' => script(), 'method' => 'post', 'class' => 'plugin_tagging')); $form->addHidden('do', 'admin'); $form->addHidden('page', 'tagging'); $form->addHidden('id', $ID); $form->addHidden('fn', 'rename'); $form->startFieldset($this->getLang('admin rename tag')); $form->addElement(form_makeTextField('old', '', $this->getLang('admin find tag'), '', 'block')); $form->addElement(form_makeTextField('new', '', $this->getLang('admin new name'), '', 'block')); $form->addElement(form_makeButton('submit', 'admin', $this->getLang('admin save'))); $form->printForm(); } /** * Display ALL the tags! */ protected function html_table() { global $ID; $tags = $this->hlp->getAllTags(); echo '
'; formSecurityToken(); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; foreach ($tags as $tagname => $taginfo) { $taggers = array_unique($taginfo['tagger']); sort($taggers); $written = array_unique($taginfo['orig']); $taggers = join(', ', $taggers); $written = join(', ', $written); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo ''; echo ''; echo '
 ' . $this->getLang('admin tag') . '' . $this->getLang('admin occurrence') . '' . $this->getLang('admin writtenas') . '' . $this->getLang('admin taggers') . '
' . hsc($tagname) . '' . $taginfo['count'] . '' . hsc($written) . '' . hsc($taggers) . '
'; echo ''; echo ''; echo '
'; echo '
'; } /** * Rename a tag * */ protected function _renameTag() { global $INPUT; if ($INPUT->post->has('old') && $INPUT->post->has('new')) { $this->hlp->renameTag($INPUT->post->str('old'), $INPUT->post->str('new')); } } /** * Delete tags * */ protected function _deleteTags() { global $INPUT; if ($INPUT->post->has('tags')) { $this->hlp->deleteTags(array_keys($INPUT->post->arr('tags'))); } } }