Had a bash at cleaning up the horrendous-looking deletion log on the edit page:
authorRob Church <robchurch@users.mediawiki.org>
Mon, 4 Jun 2007 23:43:08 +0000 (23:43 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Mon, 4 Jun 2007 23:43:08 +0000 (23:43 +0000)
* Suppress if no deletion log entries
* Provide a message to explain what it is
* Allow the whole thing to be dismissed
* Remove the mess in Article
* Some prettification

RELEASE-NOTES
includes/Article.php
includes/DefaultSettings.php
includes/EditPage.php
includes/SpecialLog.php
languages/messages/MessagesEn.php
skins/common/wikibits.js
skins/monobook/main.css

index 4271333..b3d8a8b 100644 (file)
@@ -51,9 +51,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Added $wgArticleRobotPolicies
 * (bug 10076) Additional parameter $7 added to MediaWiki:Blockedtext 
   containing, the ip, ip range, or username whose block is affecting the
-* (bug 7691) Deletion log now shown when creating a new article, following
-  MediaWiki:Noarticletext(anon) or MediaWiki:Newarticletext(anon).
-  current user.
+* (bug 7691) Show relevant lines from the deletion log when viewing
+  a non-existent article or re-creating a previously-deleted article
 * Added variables 'wgRestrictionEdit' and 'wgRestrictionMove' for JS to header
 
 == Bugfixes since 1.10 ==
index fa7d239..0c92a3a 100644 (file)
@@ -852,13 +852,11 @@ class Article {
                         );
                }
 
-               /** 
-                * If it's a non-existant page, stick the deletion log after the "noarticle" message.
-                * This won't appear when editing a new page, but will when viewing a nonexistant one.
+               /**
+                * Show the deletion log when viewing a non-existent page
                 */
-               if ( 0 == $this->getID() ) {
-                       $this->showLogExtract( $wgOut, 'view' );
-               }
+               if( $this->getId() == 0 )
+                       $this->showLogExtract( $wgOut );
                
                # Trackbacks
                if ($wgUseTrackbacks)
@@ -2006,23 +2004,21 @@ class Article {
 
                $wgOut->returnToMain( false );
 
-               $this->showLogExtract( $wgOut, 'delete' );
+               $this->showLogExtract( $wgOut );
        }
 
 
        /**
-        * Fetch deletion log
+        * Show relevant lines from the deletion log
         */
-       function showLogExtract( &$out, $type = '' ) {
-               # Show relevant lines from the deletion log:
-               $out->addHTML( "<div id='mw-article-$type-deletionlog'><h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
+       function showLogExtract( $out ) {
+               $out->addHtml( '<h2>' . htmlspecialchars( LogPage::logName( 'delete' ) ) . '</h2>' );
                $logViewer = new LogViewer(
                        new LogReader(
                                new FauxRequest(
                                        array( 'page' => $this->mTitle->getPrefixedText(),
                                               'type' => 'delete' ) ) ) );
                $logViewer->showList( $out );
-               $out->addHTML( "</div>" );
        }
 
 
index 79cfd63..cc5fa25 100644 (file)
@@ -1176,7 +1176,7 @@ $wgCacheEpoch = '20030516000000';
  * to ensure that client-side caches don't keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '73';
+$wgStyleVersion = '74';
 
 
 # Server-side caching:
index 155530c..7428684 100644 (file)
@@ -604,8 +604,8 @@ class EditPage {
                                $wgOut->addWikiText( wfMsg( 'newarticletext' ) );
                        else
                                $wgOut->addWikiText( wfMsg( 'newarticletextanon' ) );
-                               // Show deletion log when editing new article.
-                               $this->mArticle->showLogExtract( $wgOut, 'create' );
+                               # Let the user know about previous deletions if applicable
+                               $this->showDeletionLog( $wgOut );
                }
        }
 
@@ -2038,6 +2038,46 @@ END
                $wgOut->setPageTitle( wfMsg( 'nocreatetitle' ) );
                $wgOut->addWikiText( wfMsg( 'nocreatetext' ) );
        }
+       
+       /**
+        * If there are rows in the deletion log for this page, show them,
+        * along with a nice little note for the user
+        *
+        * @param OutputPage $out
+        */
+       private function showDeletionLog( $out ) {
+               $title = $this->mArticle->getTitle();
+               $reader = new LogReader(
+                       new FauxRequest(
+                               array(
+                                       'page' => $title->getPrefixedText(),
+                                       'type' => 'delete',
+                                       )
+                       )
+               );
+               if( $reader->hasRows() ) {
+                       $out->addHtml( '<div id="mw-recreate-deleted-warn">' );
+                       $out->addHtml( $this->buildWarningDismisser() );
+                       $out->addWikiText( wfMsg( 'recreate-deleted-warn' ) );
+                       $viewer = new LogViewer( $reader );
+                       $viewer->showList( $out );
+                       $out->addHtml( '</div>' );                      
+               }                               
+       }
+       
+       /**
+        * Builds a JavaScript fragment that injects a link to dismiss the
+        * "recreating deleted" warning
+        *
+        * @return string
+        */
+       private function buildWarningDismisser() {
+               return '<script type="text/javascript">'
+                       . 'document.write( \'<div class="mw-recreate-deleted-control">'
+                       . '<a href="javascript:dismissRecreateWarning();">'
+                       . wfMsgHtml( 'recreate-deleted-dismiss' ) . '</a></div>\' );'
+                       . '</script>';                  
+       }
 
 }
 
index 3c9d096..2fcce66 100644 (file)
@@ -74,7 +74,8 @@ class LogReader {
                
                // XXX This all needs to use Pager, ugly hack for now.
                global $wgMiserMode;
-               if ($wgMiserMode && ($this->offset >10000)) $this->offset=10000;
+               if( $wgMiserMode )
+                       $this->offset = min( $this->offset, 10000 );
        }
 
        /**
@@ -215,6 +216,23 @@ class LogReader {
                        return $this->title->getPrefixedText();
                }
        }
+       
+       /**
+        * Is there at least one row?
+        *
+        * @return bool
+        */
+       public function hasRows() {
+               # Little hack...
+               $limit = $this->limit;
+               $this->limit = 1;
+               $res = $this->db->query( $this->getQuery() );
+               $this->limit = $limit;
+               $ret = $this->db->numRows( $res ) > 0;
+               $this->db->freeResult( $res );
+               return $ret;
+       }
+       
 }
 
 /**
index f5e2972..d7cf94d 100644 (file)
@@ -1049,6 +1049,11 @@ the text into a text file and save it for later.</strong>',
 'nocreatetitle' => 'Page creation limited',
 'nocreatetext' => 'This site has restricted the ability to create new pages.
 You can go back and edit an existing page, or [[Special:Userlogin|log in or create an account]].',
+'recreate-deleted-warn' => "'''Warning: You are recreating a page that was previously deleted.'''
+
+You should consider whether it is appropriate to continue editing this page.
+The deletion log for this page is provided here for convenience:",
+'recreate-deleted-dismiss' => '(dismiss)',
 
 # "Undo" feature
 'undo-success' => 'The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.',
index 6299e5f..3ed9832 100644 (file)
@@ -1213,6 +1213,17 @@ function ts_alternate(table) {
 /*
  * End of table sorting code
  */
+/**
+ * Allows the "recreating-deleted-page" warning to be expanded
+ * and collapsed
+ */
+function dismissRecreateWarning() {
+       var warning = document.getElementById( "mw-recreate-deleted-warn" );
+       if( warning != undefined ) {
+               warning.parentNode.removeChild( warning );
+       }
+}
 
 function runOnloadHook() {
        // don't run anything below this for non-dom browsers
@@ -1243,4 +1254,4 @@ function runOnloadHook() {
 //      so the below should be redundant. It's there just in case.
 hookEvent("load", runOnloadHook);
 
-hookEvent("load", mwSetupToolbar);
+hookEvent("load", mwSetupToolbar);
\ No newline at end of file
index db312a2..d729adf 100644 (file)
@@ -1613,6 +1613,19 @@ div.mw-lag-warn-high {
        background-color: #CC9999;
 }
 
+/* Recreating-deleted-page warning and log entries */
+div#mw-recreate-deleted-warn {
+       padding: 3px;
+       margin-bottom: 3px;
+       border: 2px solid #993333;
+}
+div#mw-recreate-deleted-warn ul li {
+       font-size: 95%;
+}
+div.mw-recreate-deleted-control {
+       float: right;
+       font-size: 90%;
+}
 /**
  * Here is some stuff that's ACTUALLY COMMON TO ALL SKINS.
  * When the day comes, it can be moved to a *real* common.css.