From 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Dec 2013 09:55:49 +0100 Subject: Update to MediaWiki 1.22.0 --- includes/specials/SpecialProtectedpages.php | 169 ++++++++++++++++++++-------- 1 file changed, 119 insertions(+), 50 deletions(-) (limited to 'includes/specials/SpecialProtectedpages.php') diff --git a/includes/specials/SpecialProtectedpages.php b/includes/specials/SpecialProtectedpages.php index cdf053ec..3de6ea24 100644 --- a/includes/specials/SpecialProtectedpages.php +++ b/includes/specials/SpecialProtectedpages.php @@ -40,7 +40,7 @@ class SpecialProtectedpages extends SpecialPage { $this->outputHeader(); // Purge expired entries on one in every 10 queries - if( !mt_rand( 0, 10 ) ) { + if ( !mt_rand( 0, 10 ) ) { Title::purgeExpiredRestrictions(); } @@ -49,19 +49,37 @@ class SpecialProtectedpages extends SpecialPage { $level = $request->getVal( $this->IdLevel ); $sizetype = $request->getVal( 'sizetype' ); $size = $request->getIntOrNull( 'size' ); - $NS = $request->getIntOrNull( 'namespace' ); + $ns = $request->getIntOrNull( 'namespace' ); $indefOnly = $request->getBool( 'indefonly' ) ? 1 : 0; $cascadeOnly = $request->getBool( 'cascadeonly' ) ? 1 : 0; - $pager = new ProtectedPagesPager( $this, array(), $type, $level, $NS, $sizetype, $size, $indefOnly, $cascadeOnly ); - - $this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level, $sizetype, $size, $indefOnly, $cascadeOnly ) ); + $pager = new ProtectedPagesPager( + $this, + array(), + $type, + $level, + $ns, + $sizetype, + $size, + $indefOnly, + $cascadeOnly + ); - if( $pager->getNumRows() ) { + $this->getOutput()->addHTML( $this->showOptions( + $ns, + $type, + $level, + $sizetype, + $size, + $indefOnly, + $cascadeOnly + ) ); + + if ( $pager->getNumRows() ) { $this->getOutput()->addHTML( $pager->getNavigationBar() . - '' . - $pager->getNavigationBar() + '' . + $pager->getNavigationBar() ); } else { $this->getOutput()->addWikiMsg( 'protectedpagesempty' ); @@ -78,26 +96,39 @@ class SpecialProtectedpages extends SpecialPage { static $infinity = null; - if( is_null( $infinity ) ) { + if ( is_null( $infinity ) ) { $infinity = wfGetDB( DB_SLAVE )->getInfinity(); } $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); - if( !$title ) { - return Html::rawElement( 'li', array(), - Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), - Linker::getInvalidTitleDescription( $this->getContext(), $row->page_namespace, $row->page_title ) ) ) . "\n"; + if ( !$title ) { + wfProfileOut( __METHOD__ ); + + return Html::rawElement( + 'li', + array(), + Html::element( + 'span', + array( 'class' => 'mw-invalidtitle' ), + Linker::getInvalidTitleDescription( + $this->getContext(), + $row->page_namespace, + $row->page_title + ) + ) + ) . "\n"; } $link = Linker::link( $title ); - $description_items = array (); + $description_items = array(); + // Messages: restriction-level-sysop, restriction-level-autoconfirmed $protType = $this->msg( 'restriction-level-' . $row->pr_level )->escaped(); $description_items[] = $protType; - if( $row->pr_cascade ) { + if ( $row->pr_cascade ) { $description_items[] = $this->msg( 'protect-summary-cascade' )->text(); } @@ -105,7 +136,7 @@ class SpecialProtectedpages extends SpecialPage { $lang = $this->getLanguage(); $expiry = $lang->formatExpiry( $row->pr_expiry, TS_MW ); - if( $expiry != $infinity ) { + if ( $expiry != $infinity ) { $user = $this->getUser(); $description_items[] = $this->msg( 'protect-expiring-local', @@ -115,12 +146,13 @@ class SpecialProtectedpages extends SpecialPage { )->escaped(); } - if( !is_null( $size = $row->page_len ) ) { + if ( !is_null( $size = $row->page_len ) ) { $stxt = $lang->getDirMark() . ' ' . Linker::formatRevisionSize( $size ); } - # Show a link to the change protection form for allowed users otherwise a link to the protection log - if( $this->getUser()->isAllowed( 'protect' ) ) { + // Show a link to the change protection form for allowed users otherwise + // a link to the protection log + if ( $this->getUser()->isAllowed( 'protect' ) ) { $changeProtection = Linker::linkKnown( $title, $this->msg( 'protect_change' )->escaped(), @@ -140,14 +172,17 @@ class SpecialProtectedpages extends SpecialPage { ); } - $changeProtection = ' ' . $this->msg( 'parentheses' )->rawParams( $changeProtection )->escaped(); + $changeProtection = ' ' . $this->msg( 'parentheses' )->rawParams( $changeProtection ) + ->escaped(); wfProfileOut( __METHOD__ ); return Html::rawElement( 'li', array(), - $lang->specialList( $link . $stxt, $lang->commaList( $description_items ), false ) . $changeProtection ) . "\n"; + $lang->specialList( $link . $stxt, $lang->commaList( $description_items ), false ) . + $changeProtection + ) . "\n"; } /** @@ -160,9 +195,13 @@ class SpecialProtectedpages extends SpecialPage { * @param $cascadeOnly Boolean: only cascading protection * @return String: input form */ - protected function showOptions( $namespace, $type = 'edit', $level, $sizetype, $size, $indefOnly, $cascadeOnly ) { + protected function showOptions( $namespace, $type = 'edit', $level, $sizetype, + $size, $indefOnly, $cascadeOnly + ) { global $wgScript; + $title = $this->getTitle(); + return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . Xml::openElement( 'fieldset' ) . Xml::element( 'legend', array(), $this->msg( 'protectedpages' )->text() ) . @@ -196,8 +235,8 @@ class SpecialProtectedpages extends SpecialPage { 'all' => '', 'label' => $this->msg( 'namespace' )->text() ), array( - 'name' => 'namespace', - 'id' => 'namespace', + 'name' => 'namespace', + 'id' => 'namespace', 'class' => 'namespaceselector', ) ) @@ -205,31 +244,54 @@ class SpecialProtectedpages extends SpecialPage { } /** + * @param bool $indefOnly * @return string Formatted HTML */ protected function getExpiryCheck( $indefOnly ) { - return - Xml::checkLabel( $this->msg( 'protectedpages-indef' )->text(), 'indefonly', 'indefonly', $indefOnly ) . "\n"; + return Xml::checkLabel( + $this->msg( 'protectedpages-indef' )->text(), + 'indefonly', + 'indefonly', + $indefOnly + ) . "\n"; } /** + * @param bool $cascadeOnly * @return string Formatted HTML */ protected function getCascadeCheck( $cascadeOnly ) { - return - Xml::checkLabel( $this->msg( 'protectedpages-cascade' )->text(), 'cascadeonly', 'cascadeonly', $cascadeOnly ) . "\n"; + return Xml::checkLabel( + $this->msg( 'protectedpages-cascade' )->text(), + 'cascadeonly', + 'cascadeonly', + $cascadeOnly + ) . "\n"; } /** + * @param string $sizetype "min" or "max" + * @param mixed $size * @return string Formatted HTML */ protected function getSizeLimit( $sizetype, $size ) { $max = $sizetype === 'max'; - return - Xml::radioLabel( $this->msg( 'minimum-size' )->text(), 'sizetype', 'min', 'wpmin', !$max ) . + return Xml::radioLabel( + $this->msg( 'minimum-size' )->text(), + 'sizetype', + 'min', + 'wpmin', + !$max + ) . ' ' . - Xml::radioLabel( $this->msg( 'maximum-size' )->text(), 'sizetype', 'max', 'wpmax', $max ) . + Xml::radioLabel( + $this->msg( 'maximum-size' )->text(), + 'sizetype', + 'max', + 'wpmax', + $max + ) . ' ' . Xml::input( 'size', 9, $size, array( 'id' => 'wpsize' ) ) . ' ' . @@ -246,14 +308,15 @@ class SpecialProtectedpages extends SpecialPage { $options = array(); // First pass to load the log names - foreach( Title::getFilteredRestrictionTypes( true ) as $type ) { + foreach ( Title::getFilteredRestrictionTypes( true ) as $type ) { + // Messages: restriction-edit, restriction-move, restriction-create, restriction-upload $text = $this->msg( "restriction-$type" )->text(); $m[$text] = $type; } // Third pass generates sorted XHTML content - foreach( $m as $text => $type ) { - $selected = ($type == $pr_type ); + foreach ( $m as $text => $type ) { + $selected = ( $type == $pr_type ); $options[] = Xml::option( $text, $type, $selected ) . "\n"; } @@ -272,21 +335,22 @@ class SpecialProtectedpages extends SpecialPage { protected function getLevelMenu( $pr_level ) { global $wgRestrictionLevels; - $m = array( $this->msg( 'restriction-level-all' )->text() => 0 ); // Temporary array + // Temporary array + $m = array( $this->msg( 'restriction-level-all' )->text() => 0 ); $options = array(); // First pass to load the log names - foreach( $wgRestrictionLevels as $type ) { + foreach ( $wgRestrictionLevels as $type ) { // Messages used can be 'restriction-level-sysop' and 'restriction-level-autoconfirmed' - if( $type != '' && $type != '*' ) { + if ( $type != '' && $type != '*' ) { $text = $this->msg( "restriction-level-$type" )->text(); $m[$text] = $type; } } // Third pass generates sorted XHTML content - foreach( $m as $text => $type ) { - $selected = ($type == $pr_level ); + foreach ( $m as $text => $type ) { + $selected = ( $type == $pr_level ); $options[] = Xml::option( $text, $type, $selected ); } @@ -310,9 +374,9 @@ class ProtectedPagesPager extends AlphabeticPager { public $mForm, $mConds; private $type, $level, $namespace, $sizetype, $size, $indefonly; - function __construct( $form, $conds = array(), $type, $level, $namespace, $sizetype = '', $size = 0, - $indefonly = false, $cascadeonly = false ) - { + function __construct( $form, $conds = array(), $type, $level, $namespace, + $sizetype = '', $size = 0, $indefonly = false, $cascadeonly = false + ) { $this->mForm = $form; $this->mConds = $conds; $this->type = ( $type ) ? $type : 'edit'; @@ -332,6 +396,7 @@ class ProtectedPagesPager extends AlphabeticPager { $lb->add( $row->page_namespace, $row->page_title ); } $lb->execute(); + return ''; } @@ -342,27 +407,31 @@ class ProtectedPagesPager extends AlphabeticPager { function getQueryInfo() { $conds = $this->mConds; $conds[] = '(pr_expiry>' . $this->mDb->addQuotes( $this->mDb->timestamp() ) . - 'OR pr_expiry IS NULL)'; + 'OR pr_expiry IS NULL)'; $conds[] = 'page_id=pr_page'; $conds[] = 'pr_type=' . $this->mDb->addQuotes( $this->type ); - if( $this->sizetype == 'min' ) { + if ( $this->sizetype == 'min' ) { $conds[] = 'page_len>=' . $this->size; - } elseif( $this->sizetype == 'max' ) { + } elseif ( $this->sizetype == 'max' ) { $conds[] = 'page_len<=' . $this->size; } - if( $this->indefonly ) { - $conds[] = "pr_expiry = {$this->mDb->addQuotes( $this->mDb->getInfinity() )} OR pr_expiry IS NULL"; + if ( $this->indefonly ) { + $infinity = $this->mDb->addQuotes( $this->mDb->getInfinity() ); + $conds[] = "pr_expiry = $infinity OR pr_expiry IS NULL"; } - if( $this->cascadeonly ) { + if ( $this->cascadeonly ) { $conds[] = 'pr_cascade = 1'; } - if( $this->level ) + if ( $this->level ) { $conds[] = 'pr_level=' . $this->mDb->addQuotes( $this->level ); - if( !is_null( $this->namespace ) ) + } + if ( !is_null( $this->namespace ) ) { $conds[] = 'page_namespace=' . $this->mDb->addQuotes( $this->namespace ); + } + return array( 'tables' => array( 'page_restrictions', 'page' ), 'fields' => array( 'pr_id', 'page_namespace', 'page_title', 'page_len', -- cgit v1.2.2