From 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Mon, 12 Aug 2013 09:28:15 +0200 Subject: Update to MediaWiki 1.21.1 --- includes/specials/SpecialAllpages.php | 96 ++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 46 deletions(-) (limited to 'includes/specials/SpecialAllpages.php') diff --git a/includes/specials/SpecialAllpages.php b/includes/specials/SpecialAllpages.php index 0f8b2557..f9cb5cd8 100644 --- a/includes/specials/SpecialAllpages.php +++ b/includes/specials/SpecialAllpages.php @@ -59,16 +59,16 @@ class SpecialAllpages extends IncludableSpecialPage { /** * Constructor * - * @param $name string: name of the special page, as seen in links and URLs (default: 'Allpages') + * @param string $name name of the special page, as seen in links and URLs (default: 'Allpages') */ - function __construct( $name = 'Allpages' ){ + function __construct( $name = 'Allpages' ) { parent::__construct( $name ); } /** * Entry point : initialise variables and call subfunctions. * - * @param $par String: becomes "FOO" when called like Special:Allpages/FOO (default NULL) + * @param string $par becomes "FOO" when called like Special:Allpages/FOO (default NULL) */ function execute( $par ) { global $wgContLang; @@ -107,16 +107,16 @@ class SpecialAllpages extends IncludableSpecialPage { * HTML for the top form * * @param $namespace Integer: a namespace constant (default NS_MAIN). - * @param $from String: dbKey we are starting listing at. - * @param $to String: dbKey we are ending listing at. - * @param $hideredirects Bool: dont show redirects (default FALSE) + * @param string $from dbKey we are starting listing at. + * @param string $to dbKey we are ending listing at. + * @param bool $hideredirects dont show redirects (default FALSE) * @return string */ function namespaceForm( $namespace = NS_MAIN, $from = '', $to = '', $hideredirects = false ) { global $wgScript; $t = $this->getTitle(); - $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) ); + $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) ); $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); $out .= Html::hidden( 'title', $t->getPrefixedText() ); $out .= Xml::openElement( 'fieldset' ); @@ -127,7 +127,7 @@ class SpecialAllpages extends IncludableSpecialPage { Xml::label( $this->msg( 'allpagesfrom' )->text(), 'nsfrom' ) . " " . - Xml::input( 'from', 30, str_replace('_',' ',$from), array( 'id' => 'nsfrom' ) ) . + Xml::input( 'from', 30, str_replace( '_', ' ', $from ), array( 'id' => 'nsfrom' ) ) . " @@ -135,7 +135,7 @@ class SpecialAllpages extends IncludableSpecialPage { Xml::label( $this->msg( 'allpagesto' )->text(), 'nsto' ) . " " . - Xml::input( 'to', 30, str_replace('_',' ',$to), array( 'id' => 'nsto' ) ) . + Xml::input( 'to', 30, str_replace( '_', ' ', $to ), array( 'id' => 'nsto' ) ) . " @@ -165,9 +165,9 @@ class SpecialAllpages extends IncludableSpecialPage { /** * @param $namespace Integer (default NS_MAIN) - * @param $from String: list all pages from this name - * @param $to String: list all pages to this name - * @param $hideredirects Bool: dont show redirects (default FALSE) + * @param string $from list all pages from this name + * @param string $to list all pages to this name + * @param bool $hideredirects dont show redirects (default FALSE) */ function showToplevel( $namespace = NS_MAIN, $from = '', $to = '', $hideredirects = false ) { $output = $this->getOutput(); @@ -180,7 +180,7 @@ class SpecialAllpages extends IncludableSpecialPage { $where = array( 'page_namespace' => $namespace ); if ( $hideredirects ) { - $where[ 'page_is_redirect' ] = 0; + $where['page_is_redirect'] = 0; } $from = Title::makeTitleSafe( $namespace, $from ); @@ -188,18 +188,18 @@ class SpecialAllpages extends IncludableSpecialPage { $from = ( $from && $from->isLocal() ) ? $from->getDBkey() : null; $to = ( $to && $to->isLocal() ) ? $to->getDBkey() : null; - if( isset($from) ) - $where[] = 'page_title >= '.$dbr->addQuotes( $from ); - if( isset($to) ) - $where[] = 'page_title <= '.$dbr->addQuotes( $to ); + if( isset( $from ) ) + $where[] = 'page_title >= ' . $dbr->addQuotes( $from ); + if( isset( $to ) ) + $where[] = 'page_title <= ' . $dbr->addQuotes( $to ); global $wgMemc; - $key = wfMemcKey( 'allpages', 'ns', $namespace, $from, $to ); + $key = wfMemcKey( 'allpages', 'ns', $namespace, sha1( $from ), sha1( $to ) ); $lines = $wgMemc->get( $key ); $count = $dbr->estimateRowCount( 'page', '*', $where, __METHOD__ ); - $maxPerSubpage = intval($count/$this->maxLineCount); - $maxPerSubpage = max($maxPerSubpage,$this->maxPerPage); + $maxPerSubpage = intval( $count / $this->maxLineCount ); + $maxPerSubpage = max( $maxPerSubpage, $this->maxPerPage ); if( !is_array( $lines ) ) { $options = array( 'LIMIT' => 1 ); @@ -217,9 +217,9 @@ class SpecialAllpages extends IncludableSpecialPage { : array( 'page_title >= ' . $dbr->addQuotes( $lastTitle ) ); $res = $dbr->select( 'page', /* FROM */ 'page_title', /* WHAT */ - array_merge($where,$chunk), + array_merge( $where, $chunk ), __METHOD__, - array ('LIMIT' => 2, 'OFFSET' => $maxPerSubpage - 1, 'ORDER BY' => 'page_title ASC') + array( 'LIMIT' => 2, 'OFFSET' => $maxPerSubpage - 1, 'ORDER BY' => 'page_title ASC' ) ); $s = $dbr->fetchObject( $res ); @@ -228,7 +228,7 @@ class SpecialAllpages extends IncludableSpecialPage { } else { // Final chunk, but ended prematurely. Go back and find the end. $endTitle = $dbr->selectField( 'page', 'MAX(page_title)', - array_merge($where,$chunk), + array_merge( $where, $chunk ), __METHOD__ ); array_push( $lines, $endTitle ); $done = true; @@ -250,7 +250,7 @@ class SpecialAllpages extends IncludableSpecialPage { // If there are only two or less sections, don't even display them. // Instead, display the first section directly. if( count( $lines ) <= 2 ) { - if( !empty($lines) ) { + if( !empty( $lines ) ) { $this->showChunk( $namespace, $from, $to, $hideredirects ); } else { $output->addHTML( $this->namespaceForm( $namespace, $from, $to, $hideredirects ) ); @@ -272,7 +272,7 @@ class SpecialAllpages extends IncludableSpecialPage { if( $this->including() ) { $out2 = ''; } else { - if( isset($from) || isset($to) ) { + if( isset( $from ) || isset( $to ) ) { $out2 = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-form' ) ). ' ' . @@ -294,10 +294,10 @@ class SpecialAllpages extends IncludableSpecialPage { /** * Show a line of "ABC to DEF" ranges of articles * - * @param $inpoint String: lower limit of pagenames - * @param $outpoint String: upper limit of pagenames + * @param string $inpoint lower limit of pagenames + * @param string $outpoint upper limit of pagenames * @param $namespace Integer (Default NS_MAIN) - * @param $hideredirects Bool: dont show redirects (default FALSE) + * @param bool $hideredirects dont show redirects (default FALSE) * @return string */ function showline( $inpoint, $outpoint, $namespace = NS_MAIN, $hideredirects ) { @@ -311,12 +311,12 @@ class SpecialAllpages extends IncludableSpecialPage { $queryparams = $namespace ? "namespace=$namespace&" : ''; $queryhideredirects = array(); - if ($hideredirects) { - $queryhideredirects[ 'hideredirects' ] = 1; + if ( $hideredirects ) { + $queryhideredirects['hideredirects'] = 1; } $special = $this->getTitle(); - $link = htmlspecialchars( $special->getLocalUrl( $queryparams . 'from=' . urlencode($inpoint) . '&to=' . urlencode($outpoint), $queryhideredirects ) ); + $link = htmlspecialchars( $special->getLocalUrl( $queryparams . 'from=' . urlencode( $inpoint ) . '&to=' . urlencode( $outpoint ), $queryhideredirects ) ); $out = $this->msg( 'alphaindexline' )->rawParams( "$inpointf", @@ -327,15 +327,15 @@ class SpecialAllpages extends IncludableSpecialPage { /** * @param $namespace Integer (Default NS_MAIN) - * @param $from String: list all pages from this name (default FALSE) - * @param $to String: list all pages to this name (default FALSE) - * @param $hideredirects Bool: dont show redirects (default FALSE) + * @param string $from list all pages from this name (default FALSE) + * @param string $to list all pages to this name (default FALSE) + * @param bool $hideredirects dont show redirects (default FALSE) */ function showChunk( $namespace = NS_MAIN, $from = false, $to = false, $hideredirects = false ) { global $wgContLang; $output = $this->getOutput(); - $fromList = $this->getNamespaceKeyAndText($namespace, $from); + $fromList = $this->getNamespaceKeyAndText( $namespace, $from ); $toList = $this->getNamespaceKeyAndText( $namespace, $to ); $namespaces = $wgContLang->getNamespaces(); $n = 0; @@ -357,7 +357,7 @@ class SpecialAllpages extends IncludableSpecialPage { ); if ( $hideredirects ) { - $conds[ 'page_is_redirect' ] = 0; + $conds['page_is_redirect'] = 0; } if( $toKey !== "" ) { @@ -416,10 +416,10 @@ class SpecialAllpages extends IncludableSpecialPage { $res_prev = $dbr->select( 'page', 'page_title', - array( 'page_namespace' => $namespace, 'page_title < '.$dbr->addQuotes($from) ), + array( 'page_namespace' => $namespace, 'page_title < ' . $dbr->addQuotes( $from ) ), __METHOD__, array( 'ORDER BY' => 'page_title DESC', - 'LIMIT' => $this->maxPerPage, 'OFFSET' => ($this->maxPerPage - 1 ) + 'LIMIT' => $this->maxPerPage, 'OFFSET' => ( $this->maxPerPage - 1 ) ) ); @@ -438,7 +438,7 @@ class SpecialAllpages extends IncludableSpecialPage { array( 'page_namespace' => $namespace ), __METHOD__, $options ); # Show the previous link if it s not the current requested chunk if( $from != $reallyFirstPage_title ) { - $prevTitle = Title::makeTitle( $namespace, $reallyFirstPage_title ); + $prevTitle = Title::makeTitle( $namespace, $reallyFirstPage_title ); } else { $prevTitle = null; } @@ -457,7 +457,7 @@ class SpecialAllpages extends IncludableSpecialPage { Linker::link( $self, $this->msg( 'allpages' )->escaped() ); # Do we put a previous link ? - if( isset( $prevTitle ) && $pt = $prevTitle->getText() ) { + if( isset( $prevTitle ) && $pt = $prevTitle->getText() ) { $query = array( 'from' => $prevTitle->getText() ); if( $namespace ) @@ -477,7 +477,7 @@ class SpecialAllpages extends IncludableSpecialPage { if( $n == $this->maxPerPage && $s = $res->fetchObject() ) { # $s is the first link of the next chunk - $t = Title::makeTitle($namespace, $s->page_title); + $t = Title::makeTitle( $namespace, $s->page_title ); $query = array( 'from' => $t->getText() ); if( $namespace ) @@ -515,14 +515,14 @@ class SpecialAllpages extends IncludableSpecialPage { /** * @param $ns Integer: the namespace of the article - * @param $text String: the name of the article + * @param string $text the name of the article * @return array( int namespace, string dbkey, string pagename ) or NULL on error */ - protected function getNamespaceKeyAndText($ns, $text) { + protected function getNamespaceKeyAndText( $ns, $text ) { if ( $text == '' ) return array( $ns, '', '' ); # shortcut for common case - $t = Title::makeTitleSafe($ns, $text); + $t = Title::makeTitleSafe( $ns, $text ); if ( $t && $t->isLocal() ) { return array( $t->getNamespace(), $t->getDBkey(), $t->getText() ); } elseif ( $t ) { @@ -530,12 +530,16 @@ class SpecialAllpages extends IncludableSpecialPage { } # try again, in case the problem was an empty pagename - $text = preg_replace('/(#|$)/', 'X$1', $text); - $t = Title::makeTitleSafe($ns, $text); + $text = preg_replace( '/(#|$)/', 'X$1', $text ); + $t = Title::makeTitleSafe( $ns, $text ); if ( $t && $t->isLocal() ) { return array( $t->getNamespace(), '', '' ); } else { return null; } } + + protected function getGroupName() { + return 'pages'; + } } -- cgit v1.2.2