r102418 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102417‎ | r102418 | r102419 >
Date:18:02, 8 November 2011
Author:ialex
Status:ok
Tags:
Comment:
Fix for r102417: commiting OutputPage.php is actually a good idea
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -67,7 +67,7 @@
6868 * Contains the page subtitle. Special pages usually have some links here.
6969 * Don't confuse with site subtitle added by skins.
7070 */
71 - var $mSubtitle = '';
 71+ private $mSubtitle = array();
7272
7373 var $mRedirect = '';
7474 var $mStatusCode;
@@ -820,28 +820,63 @@
821821 /**
822822 * Replace the subtile with $str
823823 *
824 - * @param $str String: new value of the subtitle
 824+ * @param $str String|Message: new value of the subtitle
825825 */
826826 public function setSubtitle( $str ) {
827 - $this->mSubtitle = /*$this->parse(*/ $str /*)*/; // @bug 2514
 827+ $this->clearSubtitle();
 828+ $this->addSubtitle( $str );
828829 }
829830
830831 /**
831832 * Add $str to the subtitle
832833 *
833 - * @param $str String to add to the subtitle
 834+ * @deprecated in 1.19; use addSubtitle() instead
 835+ * @param $str String|Message to add to the subtitle
834836 */
835837 public function appendSubtitle( $str ) {
836 - $this->mSubtitle .= /*$this->parse(*/ $str /*)*/; // @bug 2514
 838+ $this->addSubtitle( $str );
837839 }
838840
839841 /**
 842+ * Add $str to the subtitle
 843+ *
 844+ * @param $str String|Message to add to the subtitle
 845+ */
 846+ public function addSubtitle( $str ) {
 847+ if ( $str instanceof Message ) {
 848+ $this->mSubtitle[] = $str->setContext( $this->getContext() )->parse();
 849+ } else {
 850+ $this->mSubtitle[] = $str;
 851+ }
 852+ }
 853+
 854+ /**
 855+ * Add a subtitle containing a backlink to a page
 856+ *
 857+ * @param $title Title to link to
 858+ */
 859+ public function addBacklinkSubtitle( Title $title ) {
 860+ $query = array();
 861+ if ( $title->isRedirect() ) {
 862+ $query['redirect'] = 'no';
 863+ }
 864+ $this->addSubtitle( $this->msg( 'backlinksubtitle' )->rawParams( Linker::link( $title, null, array(), $query ) ) );
 865+ }
 866+
 867+ /**
 868+ * Clear the subtitles
 869+ */
 870+ public function clearSubtitle() {
 871+ $this->mSubtitle = array();
 872+ }
 873+
 874+ /**
840875 * Get the subtitle
841876 *
842877 * @return String
843878 */
844879 public function getSubtitle() {
845 - return $this->mSubtitle;
 880+ return implode( "<br />\n\t\t\t\t", $this->mSubtitle );
846881 }
847882
848883 /**
@@ -1947,6 +1982,7 @@
19481983 $this->setArticleRelated( false );
19491984 $this->enableClientCache( false );
19501985 $this->mRedirect = '';
 1986+ $this->clearSubtitle();
19511987 $this->clearHTML();
19521988 }
19531989
@@ -2140,10 +2176,8 @@
21412177 if ( !empty( $reasons ) ) {
21422178 // Permissions error
21432179 if( $source ) {
2144 - $this->setPageTitle( $this->msg( 'viewsource' ) );
2145 - $this->setSubtitle(
2146 - $this->msg( 'viewsourcefor', Linker::linkKnown( $this->getTitle() ) )->text()
2147 - );
 2180+ $this->setPageTitle( $this->msg( 'viewsource-title', $this->getTitle()->getPrefixedText() ) );
 2181+ $this->addBacklinkSubtitle( $this->getTitle() );
21482182 } else {
21492183 $this->setPageTitle( $this->msg( 'badaccess' ) );
21502184 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102417* Changed OutputPage's handling of subtitles to use an array and implode it w...ialex18:01, 8 November 2011

Status & tagging log