* Fix explicit s-maxage=0 on raw pages; should help with proxy issues in
[lhc/web/wiklou.git] / includes / SpecialAllpages.php
index 63b67af..25275a6 100644 (file)
@@ -14,7 +14,7 @@ function wfSpecialAllpages( $par=NULL, $specialPage ) {
        # GET values
        $from = $wgRequest->getVal( 'from' );
        $namespace = $wgRequest->getInt( 'namespace' );
-       
+
        $namespaces = $wgContLang->getNamespaces();
 
        $indexPage = new SpecialAllpages();
@@ -26,7 +26,7 @@ function wfSpecialAllpages( $par=NULL, $specialPage ) {
                wfMsg( 'allinnamespace', $namespaces[$namespace] ) :
                wfMsg( 'allarticles' )
                );
-       
+
        if ( isset($par) ) {
                $indexPage->showChunk( $namespace, $par, $specialPage->including() );
        } elseif ( isset($from) ) {
@@ -39,6 +39,9 @@ function wfSpecialAllpages( $par=NULL, $specialPage ) {
 class SpecialAllpages {
        var $maxPerPage=960;
        var $topLevelMax=50;
+       var $name='Allpages';
+       # Determines, which message describes the input field 'nsfrom' (->SpecialPrefixindex.php)
+       var $nsfromMsg='allpagesfrom';
 
 /**
  * HTML for the top form
@@ -47,23 +50,23 @@ class SpecialAllpages {
  */
 function namespaceForm ( $namespace = NS_MAIN, $from = '' ) {
        global $wgContLang, $wgScript;
-       $t = Title::makeTitle( NS_SPECIAL, "Allpages" );
+       $t = Title::makeTitle( NS_SPECIAL, $this->name );
 
        $namespaceselect = HTMLnamespaceselector($namespace, null);
 
        $frombox = "<input type='text' size='20' name='from' id='nsfrom' value=\""
                    . htmlspecialchars ( $from ) . '"/>';
        $submitbutton = '<input type="submit" value="' . wfMsgHtml( 'allpagessubmit' ) . '" />';
-       
+
        $out = "<div class='namespaceoptions'><form method='get' action='{$wgScript}'>";
        $out .= '<input type="hidden" name="title" value="'.$t->getPrefixedText().'" />';
        $out .= "
 <table id='nsselect' class='allpages'>
        <tr>
-               <td align='right'>" . wfMsgHtml('allpagesfrom') . "</td>
+               <td align='right'>" . wfMsgHtml($this->nsfromMsg) . "</td>
                <td align='left'><label for='nsfrom'>$frombox</label></td>
        </tr>
-       <tr>    
+       <tr>
                <td align='right'><label for='namespace'>" . wfMsgHtml('namespace') . "</label></td>
                <td align='left'>
                        $namespaceselect $submitbutton
@@ -97,14 +100,14 @@ function showToplevel ( $namespace = NS_MAIN, $including = false ) {
        global $wgMemc, $wgDBname;
        $key = "$wgDBname:allpages:ns:$namespace";
        $lines = $wgMemc->get( $key );
-       
+
        if( !is_array( $lines ) ) {
                $firstTitle = $dbr->selectField( 'page', 'page_title', $where, $fname, array( 'LIMIT' => 1 ) );
                $lastTitle = $firstTitle;
-               
+
                # This array is going to hold the page_titles in order.
                $lines = array( $firstTitle );
-               
+
                # If we are going to show n rows, we need n+1 queries to find the relevant titles.
                $done = false;
                for( $i = 0; !$done; ++$i ) {
@@ -143,11 +146,11 @@ function showToplevel ( $namespace = NS_MAIN, $including = false ) {
                }
                $wgMemc->add( $key, $lines, 3600 );
        }
-       
+
        // If there are only two or less sections, don't even display them.
        // Instead, display the first section directly.
        if( count( $lines ) <= 2 ) {
-               $this->showChunk( $namespace, '', false, $including );
+               $this->showChunk( $namespace, '', $including );
                return;
        }
 
@@ -160,7 +163,7 @@ function showToplevel ( $namespace = NS_MAIN, $including = false ) {
        }
        $out .= '</table>';
        $nsForm = $this->namespaceForm ( $namespace, '', false );
-       
+
        # Is there more?
        if ( $including ) {
                $out2 = '';
@@ -185,14 +188,14 @@ function showToplevel ( $namespace = NS_MAIN, $including = false ) {
  * @param integer $namespace (Default NS_MAIN)
  */
 function showline( $inpoint, $outpoint, $namespace = NS_MAIN ) {
-       global $wgOut, $wgLang, $wgUser;
+       global $wgOut, $wgUser;
        $sk = $wgUser->getSkin();
        $dbr =& wfGetDB( DB_SLAVE );
 
        $inpointf = htmlspecialchars( str_replace( '_', ' ', $inpoint ) );
        $outpointf = htmlspecialchars( str_replace( '_', ' ', $outpoint ) );
        $queryparams = ($namespace ? "namespace=$namespace" : '');
-       $special = Title::makeTitle( NS_SPECIAL, 'Allpages/' . $inpoint );
+       $special = Title::makeTitle( NS_SPECIAL, $this->name . '/' . $inpoint );
        $link = $special->escapeLocalUrl( $queryparams );
 
        $out = wfMsgHtml(
@@ -211,18 +214,21 @@ function showChunk( $namespace = NS_MAIN, $from, $including = false ) {
        global $wgOut, $wgUser, $wgContLang;
 
        $fname = 'indexShowChunk';
-       
+
        $sk = $wgUser->getSkin();
 
        $fromTitle = null;
        if ($from!="") {
                $fromTitle = Title::newFromURL( $from );
+               if (!$fromTitle) {
+                       return;
+               }
                $fromNS = $fromTitle->getNamespace();
                if ($namespace == NS_MAIN)
                        $namespace = $fromNS;
        }
        $fromKey = is_null( $fromTitle ) ? '' : $fromTitle->getDBkey();
-       
+
        $dbr =& wfGetDB( DB_SLAVE );
        $res = $dbr->select( 'page',
                array( 'page_namespace', 'page_title', 'page_is_redirect' ),
@@ -267,6 +273,7 @@ function showChunk( $namespace = NS_MAIN, $from, $including = false ) {
        }
        $out .= '</table>';
 
+
        if ( $including ) {
                $out2 = '';
        } else {