Reduce calls to wfTimestampNow() by using temporary variable. Inspired by CR on r88278.
[lhc/web/wiklou.git] / includes / specials / SpecialPrefixindex.php
index 20e6796..1421a61 100644 (file)
  */
 class SpecialPrefixindex extends SpecialAllpages {
        // Inherit $maxPerPage
-       
+
        function __construct(){
                parent::__construct( 'Prefixindex' );
        }
-       
+
        /**
         * Entry point : initialise variables and call subfunctions.
         * @param $par String: becomes "FOO" when called like Special:Prefixindex/FOO (default null)
@@ -42,6 +42,7 @@ class SpecialPrefixindex extends SpecialAllpages {
 
                $this->setHeaders();
                $this->outputHeader();
+               $wgOut->addModuleStyles( 'mediawiki.special' );
 
                # GET values
                $from = $wgRequest->getVal( 'from', '' );
@@ -54,17 +55,24 @@ class SpecialPrefixindex extends SpecialAllpages {
                        : wfMsg( 'prefixindex' )
                );
 
-               if( isset( $par ) ){
-                       $this->showPrefixChunk( $namespace, $par, $from );
-               } elseif( $prefix != '' ){
-                       $this->showPrefixChunk( $namespace, $prefix, $from );
-               } elseif( $from != '' ){
-                       $this->showPrefixChunk( $namespace, $from, $from );
+               $showme = '';
+               if ( $this->including() && $par == '' ) {
+                       // Bug 27864: if transcluded, show all pages instead of the form
+               } elseif( isset( $par ) ) {
+                       $showme = $par;
+               } elseif( $prefix != '' ) {
+                       $showme = $prefix;
+               } elseif( $from != '' ) {
+                       // For back-compat with Special:Allpages
+                       $showme = $from;
+               }
+               if ( $showme != '' || $namespace ) {
+                       $this->showPrefixChunk( $namespace, $showme, $from );
                } else {
                        $wgOut->addHTML( $this->namespacePrefixForm( $namespace, null ) );
                }
        }
-       
+
        /**
        * HTML for the top form
        * @param $namespace Integer: a namespace constant (default NS_MAIN).
@@ -121,16 +129,16 @@ class SpecialPrefixindex extends SpecialAllpages {
                $namespaces = $wgContLang->getNamespaces();
 
                if ( !$prefixList || !$fromList ) {
-                       $out = wfMsgWikiHtml( 'allpagesbadtitle' );
+                       $out = wfMsgExt( 'allpagesbadtitle', 'parse' );
                } elseif ( !in_array( $namespace, array_keys( $namespaces ) ) ) {
                        // Show errormessage and reset to NS_MAIN
                        $out = wfMsgExt( 'allpages-bad-ns', array( 'parseinline' ), $namespace );
                        $namespace = NS_MAIN;
                } else {
                        list( $namespace, $prefixKey, $prefix ) = $prefixList;
-                       list( /* $fromNs */, $fromKey, $from ) = $fromList;
+                       list( /* $fromNS */, $fromKey, ) = $fromList;
 
-                       ### FIXME: should complain if $fromNs != $namespace
+                       ### @todo FIXME: Should complain if $fromNs != $namespace
 
                        $dbr = wfGetDB( DB_SLAVE );
 
@@ -149,12 +157,12 @@ class SpecialPrefixindex extends SpecialAllpages {
                                )
                        );
 
-                       ### FIXME: side link to previous
+                       ### @todo FIXME: Side link to previous
 
                        $n = 0;
                        if( $res->numRows() > 0 ) {
                                $out = Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-prefixindex-list-table' ) );
-       
+
                                while( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
                                        $t = Title::makeTitle( $s->page_namespace, $s->page_title );
                                        if( $t ) {
@@ -195,8 +203,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(