From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- includes/specials/SpecialPrefixindex.php | 78 +++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 27 deletions(-) (limited to 'includes/specials/SpecialPrefixindex.php') diff --git a/includes/specials/SpecialPrefixindex.php b/includes/specials/SpecialPrefixindex.php index 495f15f7..7740b320 100644 --- a/includes/specials/SpecialPrefixindex.php +++ b/includes/specials/SpecialPrefixindex.php @@ -52,6 +52,7 @@ class SpecialPrefixindex extends SpecialAllpages { $prefix = $request->getVal( 'prefix', '' ); $ns = $request->getIntOrNull( 'namespace' ); $namespace = (int)$ns; // if no namespace given, use 0 (NS_MAIN). + $hideredirects = $request->getBool( 'hideredirects', false ); $namespaces = $wgContLang->getNamespaces(); $out->setPageTitle( @@ -73,29 +74,31 @@ class SpecialPrefixindex extends SpecialAllpages { // Bug 27864: if transcluded, show all pages instead of the form. if ( $this->including() || $showme != '' || $ns !== null ) { - $this->showPrefixChunk( $namespace, $showme, $from ); + $this->showPrefixChunk( $namespace, $showme, $from, $hideredirects ); } else { - $out->addHTML( $this->namespacePrefixForm( $namespace, null ) ); + $out->addHTML( $this->namespacePrefixForm( $namespace, null, $hideredirects ) ); } } /** - * HTML for the top form - * @param $namespace Integer: a namespace constant (default NS_MAIN). - * @param $from String: dbKey we are starting listing at. - */ - function namespacePrefixForm( $namespace = NS_MAIN, $from = '' ) { + * HTML for the top form + * @param $namespace Integer: a namespace constant (default NS_MAIN). + * @param $from String: dbKey we are starting listing at. + * @param $hideredirects Bool: hide redirects (default FALSE) + * @return string + */ + function namespacePrefixForm( $namespace = NS_MAIN, $from = '', $hideredirects = false ) { global $wgScript; $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) ); $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); $out .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ); $out .= Xml::openElement( 'fieldset' ); - $out .= Xml::element( 'legend', null, wfMsg( 'allpages' ) ); + $out .= Xml::element( 'legend', null, $this->msg( 'allpages' )->text() ); $out .= Xml::openElement( 'table', array( 'id' => 'nsselect', 'class' => 'allpages' ) ); $out .= " " . - Xml::label( wfMsg( 'allpagesprefix' ), 'nsfrom' ) . + Xml::label( $this->msg( 'allpagesprefix' )->text(), 'nsfrom' ) . " " . Xml::input( 'prefix', 30, str_replace('_',' ',$from), array( 'id' => 'nsfrom' ) ) . @@ -103,13 +106,25 @@ class SpecialPrefixindex extends SpecialAllpages { " . - Xml::label( wfMsg( 'namespace' ), 'namespace' ) . + Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ) . " " . - Xml::namespaceSelector( $namespace, null ) . ' ' . - Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . + Html::namespaceSelector( array( + 'selected' => $namespace, + ), array( + 'name' => 'namespace', + 'id' => 'namespace', + 'class' => 'namespaceselector', + ) ) . + Xml::checkLabel( + $this->msg( 'allpages-hide-redirects' )->text(), + 'hideredirects', + 'hideredirects', + $hideredirects + ) . ' ' . + Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . " - "; + "; $out .= Xml::closeElement( 'table' ); $out .= Xml::closeElement( 'fieldset' ); $out .= Xml::closeElement( 'form' ); @@ -121,8 +136,9 @@ class SpecialPrefixindex extends SpecialAllpages { * @param $namespace Integer, default NS_MAIN * @param $prefix String * @param $from String: list all pages from this name (default FALSE) + * @param $hideredirects Bool: hide redirects (default FALSE) */ - function showPrefixChunk( $namespace = NS_MAIN, $prefix, $from = null ) { + function showPrefixChunk( $namespace = NS_MAIN, $prefix, $from = null, $hideredirects = false ) { global $wgContLang; if ( $from === null ) { @@ -134,10 +150,10 @@ class SpecialPrefixindex extends SpecialAllpages { $namespaces = $wgContLang->getNamespaces(); if ( !$prefixList || !$fromList ) { - $out = wfMsgExt( 'allpagesbadtitle', 'parse' ); + $out = $this->msg( 'allpagesbadtitle' )->parseAsBlock(); } elseif ( !in_array( $namespace, array_keys( $namespaces ) ) ) { // Show errormessage and reset to NS_MAIN - $out = wfMsgExt( 'allpages-bad-ns', array( 'parseinline' ), $namespace ); + $out = $this->msg( 'allpages-bad-ns', $namespace )->parse(); $namespace = NS_MAIN; } else { list( $namespace, $prefixKey, $prefix ) = $prefixList; @@ -147,13 +163,19 @@ class SpecialPrefixindex extends SpecialAllpages { $dbr = wfGetDB( DB_SLAVE ); + $conds = array( + 'page_namespace' => $namespace, + 'page_title' . $dbr->buildLike( $prefixKey, $dbr->anyString() ), + 'page_title >= ' . $dbr->addQuotes( $fromKey ), + ); + + if ( $hideredirects ) { + $conds['page_is_redirect'] = 0; + } + $res = $dbr->select( 'page', array( 'page_namespace', 'page_title', 'page_is_redirect' ), - array( - 'page_namespace' => $namespace, - 'page_title' . $dbr->buildLike( $prefixKey, $dbr->anyString() ), - 'page_title >= ' . $dbr->addQuotes( $fromKey ), - ), + $conds, __METHOD__, array( 'ORDER BY' => 'page_title', @@ -166,7 +188,7 @@ class SpecialPrefixindex extends SpecialAllpages { $n = 0; if( $res->numRows() > 0 ) { - $out = Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-prefixindex-list-table' ) ); + $out = Xml::openElement( 'table', array( 'id' => 'mw-prefixindex-list-table' ) ); while( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { $t = Title::makeTitle( $s->page_namespace, $s->page_title ); @@ -174,7 +196,8 @@ class SpecialPrefixindex extends SpecialAllpages { $link = ($s->page_is_redirect ? '
' : '' ) . Linker::linkKnown( $t, - htmlspecialchars( $t->getText() ) + htmlspecialchars( $t->getText() ), + $s->page_is_redirect ? array( 'class' => 'mw-redirect' ) : array() ) . ($s->page_is_redirect ? '
' : '' ); } else { @@ -202,9 +225,9 @@ class SpecialPrefixindex extends SpecialAllpages { if ( $this->including() ) { $out2 = ''; } else { - $nsForm = $this->namespacePrefixForm( $namespace, $prefix ); + $nsForm = $this->namespacePrefixForm( $namespace, $prefix, $hideredirects ); $self = $this->getTitle(); - $out2 = Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-prefixindex-nav-table' ) ) . + $out2 = Xml::openElement( 'table', array( 'id' => 'mw-prefixindex-nav-table' ) ) . ' ' . $nsForm . @@ -214,7 +237,8 @@ class SpecialPrefixindex extends SpecialAllpages { if( isset( $res ) && $res && ( $n == $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { $query = array( 'from' => $s->page_title, - 'prefix' => $prefix + 'prefix' => $prefix, + 'hideredirects' => $hideredirects, ); if( $namespace || ($prefix == '')) { @@ -224,7 +248,7 @@ class SpecialPrefixindex extends SpecialAllpages { } $nextLink = Linker::linkKnown( $self, - wfMsgHtml( 'nextpage', str_replace( '_',' ', htmlspecialchars( $s->page_title ) ) ), + $this->msg( 'nextpage', str_replace( '_',' ', $s->page_title ) )->escaped(), array(), $query ); -- cgit v1.2.3-54-g00ecf