1<?php
2
3use dokuwiki\Form\Form;
4
5/**
6 * DokuWiki Plugin deletehistory (Admin Component)
7 *
8 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
9 * @author  Anna Dabrowska <dokuwiki@cosmocode.de>
10 */
11
12class admin_plugin_deletehistory extends DokuWiki_Admin_Plugin
13{
14    /**
15     * @return int sort number in admin menu
16     */
17    public function getMenuSort()
18    {
19        return 200;
20    }
21
22    /**
23     * Should carry out any processing required by the plugin.
24     */
25    public function handle()
26    {
27        if (isset($_REQUEST['cmd']) && key($_REQUEST['cmd']) === 'delete' && checkSecurityToken()) {
28            /** @var helper_plugin_deletehistory $helper */
29            $helper = $this->loadHelper('deletehistory');
30            $helper->deleteAllHistory();
31            msg($this->getLang('done'));
32        }
33    }
34
35    /**
36     * Render HTML output
37     */
38    public function html()
39    {
40        ptln('<h1>' . $this->getLang('menu') . '</h1>');
41        echo $this->locale_xhtml('intro');
42
43        $form = new Form();
44        $form->setHiddenField('do', 'admin');
45        $form->setHiddenField('page', $this->getPluginName());
46        $form->addButton('cmd[delete]', $this->getLang('buttonDelete'));
47        echo $form->toHTML();
48    }
49}
50
51