Introduce Language::getMessageKeysFor() and use it in ApiQueryAllmessages
[lhc/web/wiklou.git] / includes / specials / SpecialPrefixindex.php
index ff66cbe..3b64ee9 100644 (file)
@@ -38,36 +38,43 @@ class SpecialPrefixindex extends SpecialAllpages {
         * @param $par String: becomes "FOO" when called like Special:Prefixindex/FOO (default null)
         */
        function execute( $par ) {
-               global $wgRequest, $wgOut, $wgContLang;
+               global $wgContLang;
 
                $this->setHeaders();
                $this->outputHeader();
-               $wgOut->addModuleStyles( 'mediawiki.special' );
+
+               $out = $this->getOutput();
+               $out->addModuleStyles( 'mediawiki.special' );
 
                # GET values
-               $from = $wgRequest->getVal( 'from', '' );
-               $prefix = $wgRequest->getVal( 'prefix', '' );
-               $namespace = $wgRequest->getInt( 'namespace' );
-               $namespaces = $wgContLang->getNamespaces();
+               $request = $this->getRequest();
+               $from = $request->getVal( 'from', '' );
+               $prefix = $request->getVal( 'prefix', '' );
+               $ns = $request->getIntOrNull( 'namespace' );
+               $namespace = (int)$ns; // if no namespace given, use 0 (NS_MAIN).
 
-               $wgOut->setPagetitle( ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) )
-                       ? wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) )
-                       : wfMsg( 'prefixindex' )
+               $namespaces = $wgContLang->getNamespaces();
+               $out->setPagetitle(
+                       ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) )
+                               ? wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) )
+                               : wfMsg( 'prefixindex' )
                );
 
                $showme = '';
-               if( isset( $par ) ){
+               if( isset( $par ) ) {
                        $showme = $par;
-               } elseif( $prefix != '' ){
+               } elseif( $prefix != '' ) {
                        $showme = $prefix;
-               } elseif( $from != '' ){
+               } elseif( $from != '' ) {
                        // For back-compat with Special:Allpages
                        $showme = $from;
                }
-               if ($showme != '' || $namespace) {
+
+               // Bug 27864: if transcluded, show all pages instead of the form.
+               if ( $this->including() || $showme != '' || $ns !== null ) {
                        $this->showPrefixChunk( $namespace, $showme, $from );
                } else {
-                       $wgOut->addHTML( $this->namespacePrefixForm( $namespace, null ) );
+                       $out->addHTML( $this->namespacePrefixForm( $namespace, null ) );
                }
        }
 
@@ -78,11 +85,10 @@ class SpecialPrefixindex extends SpecialAllpages {
        */
        function namespacePrefixForm( $namespace = NS_MAIN, $from = '' ) {
                global $wgScript;
-               $t = $this->getTitle();
 
                $out  = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
                $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
-               $out .= Html::hidden( 'title', $t->getPrefixedText() );
+               $out .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() );
                $out .= Xml::openElement( 'fieldset' );
                $out .= Xml::element( 'legend', null, wfMsg( 'allpages' ) );
                $out .= Xml::openElement( 'table', array( 'id' => 'nsselect', 'class' => 'allpages' ) );
@@ -116,11 +122,11 @@ class SpecialPrefixindex extends SpecialAllpages {
         * @param $from String: list all pages from this name (default FALSE)
         */
        function showPrefixChunk( $namespace = NS_MAIN, $prefix, $from = null ) {
-               global $wgOut, $wgUser, $wgContLang, $wgLang;
-
-               $sk = $wgUser->getSkin();
+               global $wgContLang;
 
-               if (!isset($from)) $from = $prefix;
+               if ( $from === null ) {
+                       $from = $prefix;
+               }
 
                $fromList = $this->getNamespaceKeyAndText($namespace, $from);
                $prefixList = $this->getNamespaceKeyAndText($namespace, $prefix);
@@ -136,7 +142,7 @@ class SpecialPrefixindex extends SpecialAllpages {
                        list( $namespace, $prefixKey, $prefix ) = $prefixList;
                        list( /* $fromNS */, $fromKey, ) = $fromList;
 
-                       ### FIXME: should complain if $fromNs != $namespace
+                       ### @todo FIXME: Should complain if $fromNs != $namespace
 
                        $dbr = wfGetDB( DB_SLAVE );
 
@@ -155,7 +161,7 @@ class SpecialPrefixindex extends SpecialAllpages {
                                )
                        );
 
-                       ### FIXME: side link to previous
+                       ### @todo FIXME: Side link to previous
 
                        $n = 0;
                        if( $res->numRows() > 0 ) {
@@ -165,7 +171,7 @@ class SpecialPrefixindex extends SpecialAllpages {
                                        $t = Title::makeTitle( $s->page_namespace, $s->page_title );
                                        if( $t ) {
                                                $link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
-                                                       $sk->linkKnown(
+                                                       Linker::linkKnown(
                                                                $t,
                                                                htmlspecialchars( $t->getText() )
                                                        ) .
@@ -201,8 +207,7 @@ class SpecialPrefixindex extends SpecialAllpages {
                                        <td>' .
                                                $nsForm .
                                        '</td>
-                                       <td id="mw-prefixindex-nav-form">' .
-                                               $sk->linkKnown( $self, wfMsgHtml( 'allpages' ) );
+                                       <td id="mw-prefixindex-nav-form">';
 
                        if( isset( $res ) && $res && ( $n == $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
                                $query = array(
@@ -214,9 +219,9 @@ class SpecialPrefixindex extends SpecialAllpages {
                                        $query['namespace'] = $namespace;
                                }
 
-                               $out2 = $wgLang->pipeList( array(
+                               $out2 = $this->getLang()->pipeList( array(
                                        $out2,
-                                       $sk->linkKnown(
+                                       Linker::linkKnown(
                                                $self,
                                                wfMsgHtml( 'nextpage', str_replace( '_',' ', htmlspecialchars( $s->page_title ) ) ),
                                                array(),
@@ -228,6 +233,6 @@ class SpecialPrefixindex extends SpecialAllpages {
                                Xml::closeElement( 'table' );
                }
 
-               $wgOut->addHTML( $out2 . $out );
+               $this->getOutput()->addHTML( $out2 . $out );
        }
 }