From: Rob Church Date: Mon, 4 Jun 2007 23:43:08 +0000 (+0000) Subject: Had a bash at cleaning up the horrendous-looking deletion log on the edit page: X-Git-Tag: 1.31.0-rc.0~52683 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=e68b7441c9e91330777a61b15c9c09a6e7961f42;p=lhc%2Fweb%2Fwiklou.git Had a bash at cleaning up the horrendous-looking deletion log on the edit page: * 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 --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 4271333c08..b3d8a8bc2e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/Article.php b/includes/Article.php index fa7d23922a..0c92a3af65 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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( "

" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "

\n" ); + function showLogExtract( $out ) { + $out->addHtml( '

' . htmlspecialchars( LogPage::logName( 'delete' ) ) . '

' ); $logViewer = new LogViewer( new LogReader( new FauxRequest( array( 'page' => $this->mTitle->getPrefixedText(), 'type' => 'delete' ) ) ) ); $logViewer->showList( $out ); - $out->addHTML( "
" ); } diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 79cfd630f1..cc5fa2542f 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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: diff --git a/includes/EditPage.php b/includes/EditPage.php index 155530c74c..74286844e2 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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( '
' ); + $out->addHtml( $this->buildWarningDismisser() ); + $out->addWikiText( wfMsg( 'recreate-deleted-warn' ) ); + $viewer = new LogViewer( $reader ); + $viewer->showList( $out ); + $out->addHtml( '
' ); + } + } + + /** + * Builds a JavaScript fragment that injects a link to dismiss the + * "recreating deleted" warning + * + * @return string + */ + private function buildWarningDismisser() { + return ''; + } } diff --git a/includes/SpecialLog.php b/includes/SpecialLog.php index 3c9d096024..2fcce66467 100644 --- a/includes/SpecialLog.php +++ b/includes/SpecialLog.php @@ -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; + } + } /** diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index f5e2972223..d7cf94d80a 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1049,6 +1049,11 @@ the text into a text file and save it for later.', '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.', diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 6299e5fa88..3ed98320ad 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -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 diff --git a/skins/monobook/main.css b/skins/monobook/main.css index db312a2e9b..d729adf0e8 100644 --- a/skins/monobook/main.css +++ b/skins/monobook/main.css @@ -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.