1<?php 2if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/'); 3if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 4require_once(DOKU_PLUGIN.'admin.php'); 5require_once(DOKU_INC.'inc/changelog.php'); 6 7/** 8 * All DokuWiki plugins to extend the admin function 9 * need to inherit from this class 10 */ 11class admin_plugin_revert extends DokuWiki_Admin_Plugin { 12 var $cmd; 13 14 /** 15 * Constructor 16 */ 17 function admin_plugin_revert(){ 18 $this->setupLocale(); 19 } 20 21 /** 22 * return some info 23 */ 24 function getInfo(){ 25 return array( 26 'author' => 'Andreas Gohr', 27 'email' => 'andi@splitbrain.org', 28 'date' => '2005-09-04', 29 'name' => 'Revert Manager', 30 'desc' => 'Allows you to mass revert recent edits', 31 'url' => 'http://wiki.splitbrain.org/plugin:revert', 32 ); 33 } 34 35 /** 36 * return sort order for position in admin menu 37 */ 38 function getMenuSort() { 39 return 40; 40 } 41 42 /** 43 * handle user request 44 */ 45 function handle() { 46 } 47 48 /** 49 * output appropriate html 50 */ 51 function html() { 52 print $this->plugin_locale_xhtml('intro'); 53 54 if(is_array($_REQUEST['revert'])) $this->_revert($_REQUEST['revert']); 55 56 57 echo '<form method="post">'; 58 echo '<input type="text" name="filter" class="edit" />'; 59 echo '<input type="submit" class="button" />'; 60 echo '</form>'; 61 62 $this->_list($_REQUEST['filter']); 63 } 64 65 function _revert($revert){ 66 global $conf; 67 echo '<hr /><div>'; 68 foreach($revert as $id){ 69 global $REV; 70 $old = getRevisions($id, 0, 1); 71 $REV = $old[0]; 72 if($REV){ 73 saveWikiText($id,rawWiki($id,$REV),'old revision restored',false); 74 echo "$id reverted to $REV<br />"; 75 }else{ 76 saveWikiText($id,'','',false); 77 echo "$id removed<br />"; 78 } 79 @set_time_limit(10); 80 flush(); 81 } 82 echo '</div><hr />'; 83 } 84 85 function _list($filter){ 86 global $conf; 87 echo '<form method="post">'; 88 89 $recents = getRecents(0,800); 90 print '<ul>'; 91 92 foreach($recents as $recent){ 93 if($filter){ 94 if(strpos(rawWiki($recent['id']),$filter) === false) continue; 95 } 96 97 98 $date = date($conf['dformat'],$recent['date']); 99 100 print ($recent['type']==='e') ? '<li class="minor">' : '<li>'; 101 print '<div class="li">'; 102 103 print '<input type="checkbox" name="revert[]" value="'.hsc($recent['id']).'" checked=checked />'; 104 105 106 print $date.' '; 107 108 print '<a href="'.wl($recent['id'],"do=diff").'">'; 109 $p = array(); 110 $p['src'] = DOKU_BASE.'lib/images/diff.png'; 111 $p['width'] = 15; 112 $p['height'] = 11; 113 $p['title'] = $lang['diff']; 114 $p['alt'] = $lang['diff']; 115 $att = buildAttributes($p); 116 print "<img $att />"; 117 print '</a> '; 118 119 print '<a href="'.wl($recent['id'],"do=revisions").'">'; 120 $p = array(); 121 $p['src'] = DOKU_BASE.'lib/images/history.png'; 122 $p['width'] = 12; 123 $p['height'] = 14; 124 $p['title'] = $lang['btn_revs']; 125 $p['alt'] = $lang['btn_revs']; 126 $att = buildAttributes($p); 127 print "<img $att />"; 128 print '</a> '; 129 130 print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']); 131 print ' – '.htmlspecialchars($recent['sum']); 132 133 print ' <span class="user">'; 134 print $recent['user'].' '.$recent['ip']; 135 print '</span>'; 136 137 print '</div>'; 138 print '</li>'; 139 140 @set_time_limit(10); 141 flush(); 142 } 143 print '</ul>'; 144 145 echo '<input type="submit">'; 146 echo '</form>'; 147 } 148 149} 150//Setup VIM: ex: et ts=4 enc=utf-8 : 151