r48565 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48564‎ | r48565 | r48566 >
Date:02:55, 19 March 2009
Author:aaron
Status:ok
Tags:
Comment:
Tweaked level selector and removed duplication
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevsXML.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/QualityOversight_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/ReviewedPages_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/specialpages/QualityOversight_body.php
@@ -70,7 +70,7 @@
7171 '<fieldset><legend>' . wfMsgHtml('qualityoversight-legend') . '</legend><p>' .
7272 Xml::hidden( 'title', $wgTitle->getPrefixedDBKey() ) .
7373 FlaggedRevsXML::getNamespaceMenu( $this->namespace ) . '&nbsp;' .
74 - FlaggedRevsXML::getLevelMenu( $this->level ) . '&nbsp;' .
 74+ FlaggedRevsXML::getLevelMenu( $this->level, 'all', 1 ) . '&nbsp;' .
7575 Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'user', 20, $this->user ) . '<br/>' .
7676 FlaggedRevsXML::getStatusFilterMenu( $this->status ) . '&nbsp;' .
7777 FlaggedRevsXML::getAutoFilterMenu( $this->automatic ) . '&nbsp;' .
Index: trunk/extensions/FlaggedRevs/specialpages/ReviewedPages_body.php
@@ -21,8 +21,8 @@
2222 # Check if there is a featured level
2323 $maxType = FlaggedRevs::pristineVersions() ? 2 : 1;
2424 $this->namespace = $wgRequest->getInt( 'namespace' );
25 - $this->type = $wgRequest->getInt( 'level' );
26 - $this->type = $this->type <= $maxType ? $this->type : 0;
 25+ $this->type = $wgRequest->getInt( 'level', -1 );
 26+ $this->type = min($this->type,$maxType);
2727
2828 $this->showForm();
2929 $this->showPageList();
@@ -38,7 +38,7 @@
3939 if( count($wgFlaggedRevsNamespaces) > 1 ) {
4040 $form .= FlaggedRevsXML::getNamespaceMenu( $this->namespace ) . '&nbsp;';
4141 }
42 - $form .= self::getLevelMenu( $this->type );
 42+ $form .= FlaggedRevsXML::getLevelMenu( $this->type );
4343
4444 $form .= " ".Xml::submitButton( wfMsg( 'go' ) );
4545 $form .= Xml::hidden( 'title', $wgTitle->getPrefixedDBKey() );
@@ -84,21 +84,6 @@
8585
8686 return "<li>$link $stxt ($list) [$best]</li>";
8787 }
88 -
89 - /**
90 - * Get a selector of review levels
91 - * @param int $selected, selected level
92 - */
93 - public static function getLevelMenu( $selected=null ) {
94 - $form = Xml::openElement( 'select', array('name' => 'level') );
95 - $form .= Xml::option( wfMsg( "reviewedpages-lev-0" ), 0, $selected==0 );
96 - if( FlaggedRevs::qualityVersions() )
97 - $form .= Xml::option( wfMsg( "reviewedpages-lev-1" ), 1, $selected==1 );
98 - if( FlaggedRevs::pristineVersions() )
99 - $form .= Xml::option( wfMsg( "reviewedpages-lev-2" ), 2, $selected==2 );
100 - $form .= Xml::closeElement('select')."\n";
101 - return $form;
102 - }
10388 }
10489
10590 /**
@@ -131,13 +116,17 @@
132117 function getQueryInfo() {
133118 $conds = $this->mConds;
134119 $conds[] = 'page_id = fp_page_id';
135 - $conds['fp_quality'] = $this->type;
136 - $conds['page_namespace'] = $this->namespace;
 120+ $index = 'PRIMARY';
 121+ if( $this->type >= 0 ) {
 122+ $conds['fp_quality'] = $this->type;
 123+ $index = 'fp_quality_page';
 124+ }
 125+ $conds['page_namespace'] = $this->namespace; // Sanity check NS
137126 return array(
138127 'tables' => array('flaggedpages','page'),
139128 'fields' => 'page_namespace,page_title,page_len,fp_page_id',
140129 'conds' => $conds,
141 - 'options' => array( 'USE INDEX' => array('flaggedpages' => 'fp_quality_page') )
 130+ 'options' => array( 'USE INDEX' => array('flaggedpages' => $index) )
142131 );
143132 }
144133
Index: trunk/extensions/FlaggedRevs/FlaggedRevsXML.php
@@ -44,15 +44,20 @@
4545 /**
4646 * Get a selector of review levels
4747 * @param int $selected, selected level
 48+ * @param bool $all all selector?
 49+ * @param int $max max level?
4850 */
49 - public static function getLevelMenu( $selected=null ) {
 51+ public static function getLevelMenu( $selected=null, $all='all', $max=2 ) {
5052 wfLoadExtensionMessages( 'FlaggedRevs' );
5153 $s = "<label for='wpLevel'>" . wfMsgHtml('revreview-levelfilter') . "</label>&nbsp;";
5254 $s .= Xml::openElement( 'select', array('name' => 'level','id' => 'wpLevel') );
53 - $s .= Xml::option( wfMsg( "revreview-filter-all" ), -1, $selected===-1 );
 55+ if( $all === 'all' )
 56+ $s .= Xml::option( wfMsg( "revreview-filter-all" ), -1, $selected===-1 );
5457 $s .= Xml::option( wfMsg( 'revreview-lev-sighted' ), 0, $selected===0 );
5558 if( FlaggedRevs::qualityVersions() )
5659 $s .= Xml::option( wfMsg( 'revreview-lev-quality' ), 1, $selected===1 );
 60+ if( $max >= 2 && FlaggedRevs::pristineVersions() )
 61+ $s .= Xml::option( wfMsg( 'revreview-lev-pristine' ), 2, $selected===2 );
5762 # Note: Pristine not tracked at sp:QualityOversight (counts as quality)
5863 $s .= Xml::closeElement('select')."\n";
5964 return $s;

Status & tagging log