1<?php 2/** 3 * DokuWiki Plugin autologoff (Admin Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Andreas Gohr <gohr@cosmocode.de> 7 */ 8 9// must be run within Dokuwiki 10if(!defined('DOKU_INC')) die(); 11 12class admin_plugin_cleanup extends DokuWiki_Admin_Plugin { 13 /** @var helper_plugin_cleanup */ 14 private $helper; 15 16 public function __construct() { 17 $this->helper = $this->loadHelper('cleanup', false); 18 } 19 20 /** 21 * @return int sort number in admin menu 22 */ 23 public function getMenuSort() { 24 return 600; 25 } 26 27 /** 28 * Should carry out any processing required by the plugin. 29 */ 30 public function handle() { 31 32 } 33 34 /** 35 * Render HTML output, e.g. helpful text and a form 36 */ 37 public function html() { 38 global $ID; 39 40 echo $this->locale_xhtml('intro'); 41 tpl_flush(); 42 43 if(empty($_REQUEST['run'])) { 44 $form = new Doku_Form(array('action' => script(), 'method' => 'post')); 45 $form->addHidden('id', $ID); 46 $form->addHidden('page', 'cleanup'); 47 $form->addHidden('run', 'dry'); 48 $form->addElement(form_makeButton('submit', 'admin', $this->getLang('preview'))); 49 $form->printForm(); 50 } else { 51 if($_REQUEST['run'] == 'real') { 52 $this->helper->run(true); 53 } else { 54 $this->helper->run(); 55 } 56 57 echo '<ul class="cleanup_files">'; 58 foreach($this->helper->list as $file) { 59 echo '<li><div class="li">' . hsc($file) . '</div></li>'; 60 } 61 echo '</ul>'; 62 echo '<p>' . sprintf($this->getLang('sum'), count($this->helper->list), filesize_h($this->helper->size)) . '</p>'; 63 64 if($_REQUEST['run'] == 'dry') { 65 $form = new Doku_Form(array('action' => script(), 'method' => 'post')); 66 $form->addHidden('id', $ID); 67 $form->addHidden('page', 'cleanup'); 68 $form->addHidden('run', 'real'); 69 $form->addElement(form_makeButton('submit', 'admin', $this->getLang('execute'))); 70 $form->printForm(); 71 } else { 72 echo '<p>' . $this->getLang('done') . '</p>'; 73 } 74 } 75 76 } 77} 78 79// vim:ts=4:sw=4:et: