Update to r32375 / bug 11874 -- !important may have whitespace between ! and important
[lhc/web/wiklou.git] / includes / SpecialPrefixindex.php
index ce296b4..bfab21b 100644 (file)
@@ -1,11 +1,8 @@
 <?php
 /**
- * @package MediaWiki
- * @subpackage SpecialPage
+ * @addtogroup SpecialPage
  */
 
-require_once 'SpecialAllpages.php';
-
 /**
  * Entry point : initialise variables and call subfunctions.
  * @param $par String: becomes "FOO" when called like Special:Prefixindex/FOO (default NULL)
@@ -18,20 +15,14 @@ function wfSpecialPrefixIndex( $par=NULL, $specialPage ) {
        $from = $wgRequest->getVal( 'from' );
        $prefix = $wgRequest->getVal( 'prefix' );
        $namespace = $wgRequest->getInt( 'namespace' );
-
        $namespaces = $wgContLang->getNamespaces();
 
        $indexPage = new SpecialPrefixIndex();
 
-       if( !in_array($namespace, array_keys($namespaces)) )
-               $namespace = 0;
-
-       $wgOut->setPagetitle( $namespace > 0 ?
-               wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) :
-               wfMsg( 'allarticles' )
-               );
-
-
+       $wgOut->setPagetitle( ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) )
+               ? wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) )
+               : wfMsg( 'allarticles' )
+       );
 
        if ( isset($par) ) {
                $indexPage->showChunk( $namespace, $par, $specialPage->including(), $from );
@@ -44,12 +35,16 @@ function wfSpecialPrefixIndex( $par=NULL, $specialPage ) {
        }
 }
 
+/**
+ * implements Special:Prefixindex 
+ * @addtogroup SpecialPage
+ */
 class SpecialPrefixindex extends SpecialAllpages {
-       var $maxPerPage=960;
-       var $topLevelMax=50;
-       var $name='Prefixindex';
-       # Determines, which message describes the input field 'nsfrom', used in function namespaceForm (see superclass SpecialAllpages)
-       var $nsfromMsg='allpagesprefix';
+       // Inherit $maxPerPage
+
+       // Define other properties
+       protected $name = 'Prefixindex';
+       protected $nsfromMsg = 'allpagesprefix';
 
 /**
  * @param integer $namespace (Default NS_MAIN)
@@ -66,16 +61,22 @@ function showChunk( $namespace = NS_MAIN, $prefix, $including = false, $from = n
 
        $fromList = $this->getNamespaceKeyAndText($namespace, $from);
        $prefixList = $this->getNamespaceKeyAndText($namespace, $prefix);
+       $namespaces = $wgContLang->getNamespaces();
+       $align = $wgContLang->isRtl() ? 'left' : 'right';
 
        if ( !$prefixList || !$fromList ) {
                $out = wfMsgWikiHtml( 'allpagesbadtitle' );
+       } 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, $from ) = $fromList;
 
                ### FIXME: should complain if $fromNs != $namespace
 
-               $dbr =& wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_SLAVE );
 
                $res = $dbr->select( 'page',
                        array( 'page_namespace', 'page_title', 'page_is_redirect' ),
@@ -126,8 +127,8 @@ function showChunk( $namespace = NS_MAIN, $prefix, $including = false, $from = n
        } else {
                $nsForm = $this->namespaceForm ( $namespace, $prefix );
                $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">';
-               $out2 .= '<tr valign="top"><td align="left">' . $nsForm;
-               $out2 .= '</td><td align="right" style="font-size: smaller; margin-bottom: 1em;">' .
+               $out2 .= '<tr valign="top"><td>' . $nsForm;
+               $out2 .= '</td><td align="' . $align . '" style="font-size: smaller; margin-bottom: 1em;">' .
                                $sk->makeKnownLink( $wgContLang->specialPage( $this->name ),
                                        wfMsg ( 'allpages' ) );
                if ( isset($dbr) && $dbr && ($n == $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
@@ -145,4 +146,4 @@ function showChunk( $namespace = NS_MAIN, $prefix, $including = false, $from = n
 }
 }
 
-?>
+