r21770 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21769‎ | r21770 | r21771 >
Date:20:22, 1 May 2007
Author:aaron
Status:old
Tags:
Comment:
*Improve size option, "group by" page_namespace,page_title,pr_type only per pr_page,pr_type key
Modified paths:
  • /trunk/phase3/includes/SpecialProtectedpages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialProtectedpages.php
@@ -24,12 +24,13 @@
2525
2626 $type = $wgRequest->getVal( 'type' );
2727 $level = $wgRequest->getVal( 'level' );
28 - $minsize = $wgRequest->getIntOrNull( 'minsize' );
 28+ $sizetype = $wgRequest->getVal( 'sizetype' );
 29+ $size = $wgRequest->getIntOrNull( 'size' );
2930 $NS = $wgRequest->getIntOrNull( 'namespace' );
3031
31 - $pager = new ProtectedPagesPager( $this, array(), $type, $level, $NS, $minsize );
 32+ $pager = new ProtectedPagesPager( $this, array(), $type, $level, $NS, $sizetype, $size );
3233
33 - $wgOut->addHTML( $this->showOptions( $NS, $type, $level, $minsize ) );
 34+ $wgOut->addHTML( $this->showOptions( $NS, $type, $level, $sizetype, $size ) );
3435
3536 if ( $pager->getNumRows() ) {
3637 $s = $pager->getNavigationBar();
@@ -93,7 +94,7 @@
9495 * @param $minsize int
9596 * @private
9697 */
97 - function showOptions( $namespace, $type='edit', $level, $minsize ) {
 98+ function showOptions( $namespace, $type='edit', $level, $sizetype, $size ) {
9899 global $wgScript;
99100 $action = htmlspecialchars( $wgScript );
100101 $title = SpecialPage::getTitleFor( 'ProtectedPages' );
@@ -101,12 +102,12 @@
102103 return "<form action=\"$action\" method=\"get\">\n" .
103104 '<fieldset>' .
104105 Xml::element( 'legend', array(), wfMsg( 'protectedpages' ) ) .
105 - Xml::hidden( 'title', $special ) . "\n" .
106 - $this->getNamespaceMenu( $namespace ) . "\n" .
107 - $this->getTypeMenu( $type ) . "\n" .
 106+ Xml::hidden( 'title', $special ) . "&nbsp\n" .
 107+ $this->getNamespaceMenu( $namespace ) . "&nbsp\n" .
 108+ $this->getTypeMenu( $type ) . "&nbsp\n" .
108109 $this->getLevelMenu( $level ) . "<br/>\n" .
109 - $this->getSizeLimit( $minsize ) . "\n" .
110 - Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
 110+ $this->getSizeLimit( $sizetype, $size ) . "\n" .
 111+ "&nbsp" . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
111112 "</fieldset></form>";
112113 }
113114
@@ -118,9 +119,14 @@
119120 * @return string Formatted HTML
120121 * @private
121122 */
122 - function getSizeLimit( $minsize=0 ) {
123 - $out = Xml::input('minsize', 9, $minsize, array( 'id' => 'minsize' ) );
124 - return "<label for='minsize'>" . wfMsgHtml('minimum-size') . "</label>: " . $out;
 123+ function getSizeLimit( $sizetype, $size ) {
 124+ $out = Xml::radio( 'sizetype', 'min', ($sizetype=='min'), array('id' => 'wpmin') );
 125+ $out .= Xml::label( wfMsgHtml("minimum-size"), 'wpmin' );
 126+ $out .= "&nbsp".Xml::radio( 'sizetype', 'max', ($sizetype=='max'), array('id' => 'wpmax') );
 127+ $out .= Xml::label( wfMsgHtml("maximum-size"), 'wpmax' );
 128+ $out .= "&nbsp".Xml::input('size', 9, $size, array( 'id' => 'wpsize' ) );
 129+ $out .= ' '.wfMsg('pagesize');
 130+ return $out;
125131 }
126132
127133 /**
@@ -188,16 +194,17 @@
189195 * @todo document
190196 * @addtogroup Pager
191197 */
192 -class ProtectedPagesPager extends ReverseChronologicalPager {
 198+class ProtectedPagesPager extends AlphabeticPager {
193199 public $mForm, $mConds;
194200
195 - function __construct( $form, $conds = array(), $type, $level, $namespace, $minsize ) {
 201+ function __construct( $form, $conds = array(), $type, $level, $namespace, $sizetype='', $size=0 ) {
196202 $this->mForm = $form;
197203 $this->mConds = $conds;
198204 $this->type = ( $type ) ? $type : 'edit';
199205 $this->level = $level;
200206 $this->namespace = $namespace;
201 - $this->minsize = intval($minsize);
 207+ $this->sizetype = $sizetype;
 208+ $this->size = intval($size);
202209 parent::__construct();
203210 }
204211
@@ -226,17 +233,22 @@
227234 $conds = $this->mConds;
228235 $conds[] = 'pr_expiry>' . $this->mDb->addQuotes( $this->mDb->timestamp() );
229236 $conds[] = 'page_id=pr_page';
230 - $conds[] = 'page_len>=' . $this->minsize;
231237 $conds[] = 'pr_type=' . $this->mDb->addQuotes( $this->type );
232 - if ( $this->level )
 238+
 239+ if( $this->sizetype=='min' )
 240+ $conds[] = 'page_len>=' . $this->size;
 241+ else if( $this->sizetype=='max' )
 242+ $conds[] = 'page_len<=' . $this->size;
 243+
 244+ if( $this->level )
233245 $conds[] = 'pr_level=' . $this->mDb->addQuotes( $this->level );
234 - if ( !is_null($this->namespace) )
 246+ if( !is_null($this->namespace) )
235247 $conds[] = 'page_namespace=' . $this->mDb->addQuotes( $this->namespace );
236248 return array(
237249 'tables' => array( 'page_restrictions', 'page' ),
238250 'fields' => 'max(pr_id) AS pr_id,page_namespace,page_title,page_len,pr_type,pr_level,pr_expiry',
239251 'conds' => $conds,
240 - 'options' => array( 'GROUP BY' => 'page_namespace,page_title,pr_level,pr_expiry,page_len,pr_type' ),
 252+ 'options' => array( 'GROUP BY' => 'page_namespace,page_title,pr_type' ),
241253 );
242254 }
243255