r23290 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23289‎ | r23290 | r23291 >
Date:10:56, 23 June 2007
Author:robchurch
Status:old
Tags:
Comment:
Provide a mechanism to vary the title depending upon the namespace selected, and do so for the uncategorised report variants
Modified paths:
  • /branches/robchurch/reports/includes/reports/Report.php (modified) (history)
  • /branches/robchurch/reports/includes/reports/UncategorisedPagesReport.php (modified) (history)

Diff [purge]

Index: branches/robchurch/reports/includes/reports/Report.php
@@ -80,6 +80,18 @@
8181 }
8282
8383 /**
 84+ * Is there a more appropriate title to show when
 85+ * a particular namespace is selected? Return the
 86+ * message name here
 87+ *
 88+ * @param int $namespace
 89+ * @return string
 90+ */
 91+ public function getNamespaceTitleVariant( $namespace ) {
 92+ return false;
 93+ }
 94+
 95+ /**
8496 * Return base SQL for the report
8597 *
8698 * @param Database $dbr Database object being queried
@@ -169,6 +181,12 @@
170182 public function execute( $par = false ) {
171183 global $wgOut, $wgRequest, $wgLang;
172184 $this->setHeaders();
 185+ # Per-namespace title variants
 186+ if( ( $ns = $wgRequest->getVal( 'namespace', false ) ) !== false ) {
 187+ if( ( $msg = $this->getNamespaceTitleVariant( $ns ) ) !== false )
 188+ $wgOut->setPageTitle( wfMsg( $msg ) );
 189+ }
 190+ # Cache information, etc.
173191 $pager = $this->getPager();
174192 if( $this->isDisabled() ) {
175193 $wgOut->addHtml( '<div class="mw-report-disabled">' . wfMsgExt( 'report-disabled', 'parse' ) . '</div>' );
Index: branches/robchurch/reports/includes/reports/UncategorisedPagesReport.php
@@ -48,6 +48,27 @@
4949 NS_CATEGORY
5050 );
5151 }
 52+
 53+ /**
 54+ * Is there a more appropriate title to show when
 55+ * a particular namespace is selected? Return the
 56+ * message name here
 57+ *
 58+ * @param int $namespace
 59+ * @return string
 60+ */
 61+ public function getNamespaceTitleVariant( $namespace ) {
 62+ switch( $namespace ) {
 63+ case NS_IMAGE:
 64+ return 'uncategorizedimages';
 65+ case NS_TEMPLATE:
 66+ return 'uncategorizedtemplates';
 67+ case NS_CATEGORY:
 68+ return 'uncategorizedcategories';
 69+ default:
 70+ return false;
 71+ }
 72+ }
5273
5374 /**
5475 * Return base SQL for the report

Status & tagging log