r110866 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110865‎ | r110866 | r110867 >
Date:19:47, 7 February 2012
Author:bsitu
Status:resolved
Tags:
Comment:
Adding a new hook - BeforeDisplayNoArticleText to core at /branches/ArticleCreationWorkflow
Modified paths:
  • /branches/ArticleCreationWorkflow/phase3/docs/hooks.txt (modified) (history)
  • /branches/ArticleCreationWorkflow/phase3/includes/Article.php (modified) (history)

Diff [purge]

Index: branches/ArticleCreationWorkflow/phase3/docs/hooks.txt
@@ -587,6 +587,15 @@
588588 Change $bad and return false to override. If an image is "bad", it is not
589589 rendered inline in wiki pages or galleries in category pages.
590590
 591+'BeforeDisplayNoArticleText': before displaying noarticletext or noarticletext-nopermission
 592+at Article::showMissingArticle()
 593+
 594+$article: article object
 595+&$text: text replacing 'noarticletext'
 596+$errors: creating/editing article error
 597+$wgUser: current user object
 598+&$wikiText: boolean for determining if $text is wikitext
 599+
591600 'BeforeInitialize': before anything is initialized in MediaWiki::performRequest()
592601 &$title: Title being used for request
593602 $unused: null
Index: branches/ArticleCreationWorkflow/phase3/includes/Article.php
@@ -988,6 +988,8 @@
989989 'msgKey' => array( 'moveddeleted-notice' ) )
990990 );
991991
 992+ $text = '';
 993+ $wikiText = true;
992994 # Show error message
993995 $oldid = $this->getOldID();
994996 if ( $oldid ) {
@@ -1002,10 +1004,13 @@
10031005 $editErrors = $this->getTitle()->getUserPermissionsErrors( 'edit', $wgUser );
10041006 $errors = array_merge( $createErrors, $editErrors );
10051007
1006 - if ( !count( $errors ) ) {
1007 - $text = wfMsgNoTrans( 'noarticletext' );
1008 - } else {
1009 - $text = wfMsgNoTrans( 'noarticletext-nopermission' );
 1008+ wfRunHooks( 'BeforeDisplayNoArticleText', array( $this, &$text, $errors, $wgUser, &$wikiText ) );
 1009+ if ( !$text ) {
 1010+ if ( !count( $errors ) ) {
 1011+ $text = wfMsgNoTrans( 'noarticletext' );
 1012+ } else {
 1013+ $text = wfMsgNoTrans( 'noarticletext-nopermission' );
 1014+ }
10101015 }
10111016 }
10121017 $text = "<div class='noarticletext'>\n$text\n</div>";
@@ -1016,7 +1021,7 @@
10171022 $wgRequest->response()->header( "HTTP/1.1 404 Not Found" );
10181023 }
10191024
1020 - $wgOut->addWikiText( $text );
 1025+ $wikiText ? $wgOut->addWikiText( $text ) : $wgOut->addHTML( $text );
10211026 }
10221027
10231028 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r110896followup to -r110866 - place the hook after $text generation so extension can...bsitu23:45, 7 February 2012
r111427Port (with changes) r110866 to trunk. Reviewed by Brion before commit.werdna22:32, 13 February 2012

Status & tagging log