r1347 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r1346‎ | r1347 | r1348 >
Date:04:26, 23 May 2003
Author:eloquence
Status:old
Tags:
Comment:
Deletion feature improved:

If an article with less than 500 characters is to be deleted, at most the
first 150 characters are automatically suggested as a deletion reason. This
should automate the frequent practice of pasting the text of nonsense
articles into the deletion reason.

If an article with a history is to be deleted, a warning is inserted,
linking to the article history (so as to avoid accidentally deleting a
vandalized page with a valid history).

If a blanked article with a history is to be deleted, and the next earlier
revision contains less than 500 characters, at most the first 150 characters
are automatically suggested as a deletion reason. Nonsense pages are often
blanked, just checking the current revision for nonsense is not good enough.

New texts in Language.php for this feature:
- excontent, exblank, exbeforeblank, historywarning
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -540,7 +540,6 @@
541541 $wgOut->addHTML( "
542542 <form id=\"editform\" name=\"editform\" method=\"post\" action=\"$action\"
543543 enctype=\"application/x-www-form-urlencoded\">
544 -<br clear=\"all\" />
545544 <textarea tabindex=1 name=\"wpTextbox1\" rows={$rows}
546545 cols={$cols}{$ew} wrap=\"virtual\">" .
547546 $wgLang->recodeForEdit( $wpTextbox1 ) .
@@ -1003,15 +1002,73 @@
10041003 $wgOut->fatalError( wfMsg( "cannotdelete" ) );
10051004 return;
10061005 }
1007 - $sub = str_replace( "$1", $image, wfMsg( "deletesub" ) );
 1006+ $sub = str_replace( "$1", $image, wfMsg( "deletesub" ) );
10081007 } else {
 1008+
10091009 if ( ( "" == trim( $wgTitle->getText() ) )
10101010 or ( $wgTitle->getArticleId() == 0 ) ) {
10111011 $wgOut->fatalError( wfMsg( "cannotdelete" ) );
10121012 return;
10131013 }
10141014 $sub = str_replace( "$1", $wgTitle->getPrefixedText(),
1015 - wfMsg( "deletesub" ) );
 1015+ wfMsg( "deletesub" ) );
 1016+
 1017+ # determine whether this page has earlier revisions
 1018+ # and insert a warning if it does
 1019+ # we select the text because it might be useful below
 1020+ $sql="SELECT old_text FROM old WHERE old_namespace=0 and old_title='" . wfStrencode($wgTitle->getPrefixedDBkey())."' ORDER BY inverse_timestamp LIMIT 1";
 1021+ $res=wfQuery($sql,$fname);
 1022+ if( $old=wfFetchObject($res)) {
 1023+
 1024+ $skin=new Skin();
 1025+ $wgOut->addHTML("<B>".wfMsg("historywarning"));
 1026+ $wgOut->addHTML( $skin->historyLink() ."</B><P>");
 1027+ }
 1028+
 1029+ $sql="SELECT cur_text FROM cur WHERE cur_namespace=0 and cur_title='" . wfStrencode($wgTitle->getPrefixedDBkey())."'";
 1030+ $res=wfQuery($sql,$fname);
 1031+ if( ($s=wfFetchObject($res))) {
 1032+
 1033+ # if this is a mini-text, we can paste part of it into the deletion reason
 1034+
 1035+ #if this is empty, an earlier revision may contain "useful" text
 1036+ if($s->cur_text!="") {
 1037+ $text=$s->cur_text;
 1038+ } else {
 1039+ if($old) {
 1040+ $text=$old->old_text;
 1041+ $blanked=1;
 1042+ }
 1043+
 1044+ }
 1045+
 1046+ $length=strlen($text);
 1047+
 1048+ # this should not happen, since it is not possible to store an empty, new
 1049+ # page. Let's insert a standard text in case it does, though
 1050+ if($length==0) { $wpreason=wfmsg("exblank");}
 1051+
 1052+
 1053+ if($length < 500) {
 1054+
 1055+ # comment field=255, let's grep the first 150 to have some user
 1056+ # space left
 1057+ $text=substr($text,0,150);
 1058+ # let's strip out newlines and HTML tags
 1059+ $text=preg_replace("/\"/","'",$text);
 1060+ $text=preg_replace("/\</","&lt;",$text);
 1061+ $text=preg_replace("/\>/","&gt;",$text);
 1062+ $text=preg_replace("/[\n\r]/","",$text);
 1063+ if(!$blanked) {
 1064+ $wpReason=wfMsg("excontent"). " '".$text;
 1065+ } else {
 1066+ $wpReason=wfMsg("exbeforeblank") . " '".$text;
 1067+ }
 1068+ if($length>150) { $wpReason .= "..."; } # we've only pasted part of the text
 1069+ $wpReason.="'";
 1070+ }
 1071+ }
 1072+
10161073 }
10171074
10181075 # Likewise, deleting old images doesn't require confirmation
@@ -1043,7 +1100,7 @@
10441101 <form id=\"deleteconfirm\" method=\"post\" action=\"{$formaction}\">
10451102 <table border=0><tr><td align=right>
10461103 {$delcom}:</td><td align=left>
1047 -<input type=text size=20 name=\"wpReason\" value=\"{$wpReason}\">
 1104+<input type=text size=60 name=\"wpReason\" value=\"{$wpReason}\">
10481105 </td></tr><tr><td>&nbsp;</td></tr>
10491106 <tr><td align=right>
10501107 <input type=checkbox name=\"wpConfirm\" value='1'>
@@ -1558,7 +1615,7 @@
15591616
15601617 wfDebug(" saveToFileCache()\n");
15611618 $filename=$this->fileCacheName();
1562 - $mydir2=substr($filename,0,strrpos($filename,"/")); # subdirectory level 2
 1619+ $mydir2=substr($filename,0,strrpos($filename,"/")); # subdirectory level 2
15631620 $mydir1=substr($mydir2,0,strrpos($mydir2,"/")); # subdirectory level 1
15641621 if(!file_exists($mydir1)) { mkdir($mydir1,0777); } # create if necessary
15651622 if(!file_exists($mydir2)) { mkdir($mydir2,0777); }
Index: trunk/phase3/languages/Language.php
@@ -888,8 +888,12 @@
889889 #
890890 "deletepage" => "Delete page",
891891 "confirm" => "Confirm",
 892+"excontent" => "content was:",
 893+"exbeforeblank" => "content before blanking was:",
 894+"exblank" => "page was empty",
892895 "confirmdelete" => "Confirm delete",
893896 "deletesub" => "(Deleting \"$1\")",
 897+"historywarning" => "Warning: The page you are about to delete has a history: ",
894898 "confirmdeletetext" => "You are about to permanently delete a page
895899 or image along with all of its history from the database.
896900 Please confirm that you intend to do this, that you understand the

Status & tagging log