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