diff options
-rw-r--r-- | lib/plugins/revert/admin.php | 40 | ||||
-rw-r--r-- | lib/plugins/revert/lang/en/lang.php | 5 | ||||
-rw-r--r-- | lib/plugins/revert/lang/fr/lang.php | 2 | ||||
-rw-r--r-- | lib/plugins/revert/lang/pl/lang.php | 2 | ||||
-rw-r--r-- | lib/plugins/revert/lang/sv/lang.php | 2 |
5 files changed, 34 insertions, 17 deletions
diff --git a/lib/plugins/revert/admin.php b/lib/plugins/revert/admin.php index 5c5d98ab6..c7c371bfa 100644 --- a/lib/plugins/revert/admin.php +++ b/lib/plugins/revert/admin.php @@ -9,7 +9,11 @@ require_once(DOKU_INC.'inc/changelog.php'); * need to inherit from this class */ class admin_plugin_revert extends DokuWiki_Admin_Plugin { - var $cmd; + var $cmd; + // some vars which might need tuning later + var $max_lines = 800; // lines to read from changelog + var $max_revs = 20; // numer of old revisions to check + /** * Constructor @@ -25,7 +29,7 @@ class admin_plugin_revert extends DokuWiki_Admin_Plugin { return array( 'author' => 'Andreas Gohr', 'email' => 'andi@splitbrain.org', - 'date' => '2005-11-10', + 'date' => '2007-04-22', 'name' => 'Revert Manager', 'desc' => 'Allows you to mass revert recent edits', 'url' => 'http://wiki.splitbrain.org/plugin:revert', @@ -62,7 +66,7 @@ class admin_plugin_revert extends DokuWiki_Admin_Plugin { $this->_searchform(); if(is_array($_REQUEST['revert'])){ - $this->_revert($_REQUEST['revert']); + $this->_revert($_REQUEST['revert'],$_REQUEST['filter']); }elseif(isset($_REQUEST['filter'])){ $this->_list($_REQUEST['filter']); } @@ -77,14 +81,14 @@ class admin_plugin_revert extends DokuWiki_Admin_Plugin { echo '<label>'.$this->getLang('filter').': </label>'; echo '<input type="text" name="filter" class="edit" value="'.hsc($_REQUEST['filter']).'" />'; echo '<input type="submit" class="button" value="'.$lang['btn_search'].'" />'; - echo ' <span>'.$this->getLang('note').'</span>'; + echo ' <span>'.$this->getLang('note1').'</span>'; echo '</form><br /><br />'; } /** * Start the reversion process */ - function _revert($revert){ + function _revert($revert,$filter){ global $conf; echo '<hr /><br />'; @@ -93,14 +97,23 @@ class admin_plugin_revert extends DokuWiki_Admin_Plugin { echo '<ul>'; foreach($revert as $id){ global $REV; - $old = getRevisions($id, 0, 1); - $REV = $old[0]; - if($REV){ - saveWikiText($id,rawWiki($id,$REV),'old revision restored',false); + + // find the last non-spammy revision + $data = ''; + $old = getRevisions($id, 0, $this->max_revs); + if(count($old)){ + foreach($old as $REV){ + $data = rawWiki($id,$REV); + if(strpos($data,$filter) === false) break; + } + } + + if($data){ + saveWikiText($id,$data,'old revision restored',false); printf('<li><div class="li">'.$this->getLang('reverted').'</div></li>',$id,$REV); }else{ saveWikiText($id,'','',false); - printf('<li><div class="li">'.$this->getLang('removed').'</div></li>',$id,$REV); + printf('<li><div class="li">'.$this->getLang('removed').'</div></li>',$id); } @set_time_limit(10); flush(); @@ -119,7 +132,7 @@ class admin_plugin_revert extends DokuWiki_Admin_Plugin { echo '<form action="" method="post">'; echo '<input type="hidden" name="filter" value="'.hsc($filter).'" />'; - $recents = getRecents(0,800); + $recents = getRecents(0,$this->max_lines); echo '<ul>'; @@ -174,7 +187,10 @@ class admin_plugin_revert extends DokuWiki_Admin_Plugin { } echo '</ul>'; - echo '<input type="submit" class="button" value="'.$this->getLang('revert').'" />'; + echo '<p>'; + echo '<input type="submit" class="button" value="'.$this->getLang('revert').'" /> '; + printf($this->getLang('note2'),hsc($filter)); + echo '</p>'; echo '</form>'; } diff --git a/lib/plugins/revert/lang/en/lang.php b/lib/plugins/revert/lang/en/lang.php index 064ffb60e..fdbf7775d 100644 --- a/lib/plugins/revert/lang/en/lang.php +++ b/lib/plugins/revert/lang/en/lang.php @@ -14,13 +14,14 @@ $lang['menu'] = 'Revert Manager'; // custom language strings for the plugin $lang['filter'] = 'Search spammy pages'; -$lang['note'] = 'Note: this search is case sensitive'; -$lang['revert'] = 'Revert selected edits'; +$lang['revert'] = 'Revert selected pages'; $lang['reverted'] = '%s reverted to revision %s'; $lang['removed'] = '%s removed'; $lang['revstart'] = 'Reversion process started. This can take a long time. If the script times out before finishing, you need to revert in smaller chunks.'; $lang['revstop'] = 'Reversion process finished successfully.'; +$lang['note1'] = 'Note: this search is case sensitive'; +$lang['note2'] = 'Note: the page will be reverted to the last version not containing the given spam term <i>%s</i>.'; //Setup VIM: ex: et ts=4 enc=utf-8 : diff --git a/lib/plugins/revert/lang/fr/lang.php b/lib/plugins/revert/lang/fr/lang.php index 09c8387d9..959388ceb 100644 --- a/lib/plugins/revert/lang/fr/lang.php +++ b/lib/plugins/revert/lang/fr/lang.php @@ -14,7 +14,7 @@ $lang['menu'] = 'Gestionnaire de réversion'; // custom language strings for the plugin $lang['filter'] = 'Trouver les pages spammées '; -$lang['note'] = 'Note : cette recherche est insensible à la casse'; +$lang['note1'] = 'Note : cette recherche est insensible à la casse'; $lang['revert'] = 'Annuler les éditions sélectionnées'; $lang['reverted'] = '%s restauré à la révision %s'; $lang['removed'] = '%s supprimé'; diff --git a/lib/plugins/revert/lang/pl/lang.php b/lib/plugins/revert/lang/pl/lang.php index ddeea8fce..67d02487d 100644 --- a/lib/plugins/revert/lang/pl/lang.php +++ b/lib/plugins/revert/lang/pl/lang.php @@ -14,7 +14,7 @@ $lang['menu'] = 'Menadżer przywracania'; // custom language strings for the plugin $lang['filter'] = 'Wyszukaj uszkodzone strony'; -$lang['note'] = 'Uwaga: duże i małe litery są rozróżniane'; +$lang['note1'] = 'Uwaga: duże i małe litery są rozróżniane'; $lang['revert'] = 'Napraw zaznaczone strony'; $lang['reverted'] = 'Stronę %s zastąpiono wersją %s'; $lang['removed'] = 'Stronę %s usunięto'; diff --git a/lib/plugins/revert/lang/sv/lang.php b/lib/plugins/revert/lang/sv/lang.php index 873cc46ef..7a3465399 100644 --- a/lib/plugins/revert/lang/sv/lang.php +++ b/lib/plugins/revert/lang/sv/lang.php @@ -16,7 +16,7 @@ $lang['menu'] = 'Hantera återställningar'; // custom language strings for the plugin $lang['filter'] = 'Sök efter spamsidor'; -$lang['note'] = 'OBS: sökningen skiljer på stora och små bokstäver'; +$lang['note1'] = 'OBS: sökningen skiljer på stora och små bokstäver'; $lang['revert'] = 'Återställ markerade redigeringar'; $lang['reverted'] = '%s återställd till version %s'; $lang['removed'] = '%s borttagen'; |