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 /** @var string message to show */ 12 private $message; 13 14 public function __construct() { 15 $this->hlp = plugin_load('helper', 'tagging'); 16 } 17 18 /** 19 * We allow use by managers 20 * 21 * @return bool always false 22 */ 23 function forAdminOnly() { 24 return false; 25 } 26 27 /** 28 * Handle tag renames 29 */ 30 function handle() { 31 global $INPUT; 32 if ($INPUT->post->has('old') && $INPUT->post->has('new') && checkSecurityToken()) { 33 $this->hlp->renameTag($INPUT->post->str('old'), $INPUT->post->str('new')); 34 } 35 } 36 37 /** 38 * Draw the interface 39 */ 40 function html() { 41 echo $this->locale_xhtml('intro'); 42 $this->html_form(); 43 echo '<br />'; 44 $this->html_table(); 45 } 46 47 /** 48 * Show form for renaming tags 49 */ 50 protected function html_form() { 51 global $ID; 52 53 $form = new Doku_Form(array('action' => script(), 'method' => 'post', 'class' => 'plugin_tagging')); 54 $form->addHidden('do', 'admin'); 55 $form->addHidden('page', 'tagging'); 56 $form->addHidden('id', $ID); 57 58 $form->startFieldset($this->getLang('admin rename tag')); 59 $form->addElement(form_makeTextField('old', '', $this->getLang('admin find tag'), '', 'block')); 60 $form->addElement(form_makeTextField('new', '', $this->getLang('admin new name'), '', 'block')); 61 $form->addElement(form_makeButton('submit', 'admin', $this->getLang('admin save'))); 62 63 $form->printForm(); 64 } 65 66 /** 67 * Display ALL the tags! 68 */ 69 protected function html_table() { 70 $tags = $this->hlp->getAllTags(); 71 72 echo '<table class="inline plugin_tagging">'; 73 echo '<tr>'; 74 echo '<th>' . $this->getLang('admin tag') . '</th>'; 75 echo '<th>' . $this->getLang('admin occurrence') . '</th>'; 76 echo '<th>' . $this->getLang('admin writtenas') . '</th>'; 77 echo '<th>' . $this->getLang('admin taggers') . '</th>'; 78 echo '</tr>'; 79 80 foreach ($tags as $tagname => $taginfo) { 81 $taggers = array_unique($taginfo['tagger']); 82 sort($taggers); 83 $written = array_unique($taginfo['orig']); 84 $taggers = join(', ', $taggers); 85 $written = join(', ', $written); 86 87 echo '<tr>'; 88 echo '<td><a class="tagslist" href="' . $this->hlp->getTagSearchURL($tagname) . '">' . hsc($tagname) . '</a></td>'; 89 echo '<td>' . $taginfo['count'] . '</td>'; 90 echo '<td>' . hsc($written) . '</td>'; 91 echo '<td>' . hsc($taggers) . '</td>'; 92 echo '</tr>'; 93 } 94 95 echo '</table>'; 96 } 97} 98