Fix NS_PROJECT_TALK (bug #7792)
[lhc/web/wiklou.git] / includes / QueryPage.php
index cd16576..ff6355e 100644 (file)
@@ -4,11 +4,6 @@
  * @package MediaWiki
  */
 
-/**
- *
- */
-require_once 'Feed.php';
-
 /**
  * List of query page classes and their associated special pages, for periodic update purposes
  */
@@ -35,6 +30,7 @@ $wgQueryPages = array(
        array( 'ShortPagesPage',                'Shortpages'                    ),
        array( 'UncategorizedCategoriesPage',   'Uncategorizedcategories'       ),
        array( 'UncategorizedPagesPage',        'Uncategorizedpages'            ),
+       array( 'UncategorizedImagesPage', 'Uncategorizedimages' ),
        array( 'UnusedCategoriesPage',          'Unusedcategories'              ),
        array( 'UnusedimagesPage',              'Unusedimages'                  ),
        array( 'WantedCategoriesPage',          'Wantedcategories'              ),
@@ -56,7 +52,7 @@ if ( !$wgDisableCounters )
  *
  * @package MediaWiki
  */
-abstract class QueryPage {
+class QueryPage {
        /**
         * Whether or not we want plain listoutput rather than an ordered list
         *
@@ -96,7 +92,7 @@ abstract class QueryPage {
         * @return Title
         */
        function getTitle() {
-               return Title::makeTitle( NS_SPECIAL, $this->getName() );
+               return SpecialPage::getTitleFor( $this->getName() );
        }
 
        /**
@@ -286,13 +282,15 @@ abstract class QueryPage {
 
                $sname = $this->getName();
                $fname = get_class($this) . '::doQuery';
-               $sql = $this->getSQL();
                $dbr =& wfGetDB( DB_SLAVE );
-               $querycache = $dbr->tableName( 'querycache' );
 
                $wgOut->setSyndicated( $this->isSyndicated() );
 
-               if ( $this->isCached() ) {
+               if ( !$this->isCached() ) {
+                       $sql = $this->getSQL();
+               } else {
+                       # Get the cached result
+                       $querycache = $dbr->tableName( 'querycache' );
                        $type = $dbr->strencode( $sname );
                        $sql =
                                "SELECT qc_type as type, qc_namespace as namespace,qc_title as title, qc_value as value
@@ -314,6 +312,14 @@ abstract class QueryPage {
                                }
        
                                $wgOut->addWikiText( $cacheNotice );
+                               
+                               # If updates on this page have been disabled, let the user know
+                               # that the data set won't be refreshed for now
+                               global $wgDisableQueryPageUpdate;
+                               if( is_array( $wgDisableQueryPageUpdate ) && in_array( $this->getName(), $wgDisableQueryPageUpdate ) ) {
+                                       $wgOut->addWikiText( wfMsg( 'querypage-no-updates' ) );
+                               }
+                               
                        }
 
                }
@@ -343,7 +349,7 @@ abstract class QueryPage {
                if ( $num > 0 ) {
                        $s = array();
                        if ( ! $this->listoutput )
-                               $s[] = "<ol start='" . ( $offset + 1 ) . "' class='special'>";
+                               $s[] = $this->openList( $offset );
 
                        # Only read at most $num rows, because $res may contain the whole 1000
                        for ( $i = 0; $i < $num && $obj = $dbr->fetchObject( $res ); $i++ ) {
@@ -368,7 +374,7 @@ abstract class QueryPage {
 
                        $dbr->freeResult( $res );
                        if ( ! $this->listoutput )
-                               $s[] = '</ol>';
+                               $s[] = $this->closeList();
                        $str = $this->listoutput ? $wgContLang->listToText( $s ) : implode( '', $s );
                        $wgOut->addHTML( $str );
                }
@@ -377,12 +383,20 @@ abstract class QueryPage {
                }
                return $num;
        }
+       
+       function openList( $offset ) {
+               return "<ol start='" . ( $offset + 1 ) . "' class='special'>";
+       }
+       
+       function closeList() {
+               return '</ol>';
+       }
 
        /**
         * Do any necessary preprocessing of the result object.
-        * You should pass this by reference: &$db , &$res
+        * You should pass this by reference: &$db , &$res  [although probably no longer necessary in PHP5]
         */
-       function preprocessResults( $db, $res ) {}
+       function preprocessResults( &$db, &$res ) {}
 
        /**
         * Similar to above, but packaging in a syndicated feed instead of a web page
@@ -452,10 +466,10 @@ abstract class QueryPage {
        }
 
        function feedTitle() {
-               global $wgLanguageCode, $wgSitename;
+               global $wgContLanguageCode, $wgSitename;
                $page = SpecialPage::getPage( $this->getName() );
                $desc = $page->getDescription();
-               return "$wgSitename - $desc [$wgLanguageCode]";
+               return "$wgSitename - $desc [$wgContLanguageCode]";
        }
 
        function feedDesc() {
@@ -463,7 +477,7 @@ abstract class QueryPage {
        }
 
        function feedUrl() {
-               $title = Title::MakeTitle( NS_SPECIAL, $this->getName() );
+               $title = SpecialPage::getTitleFor( $this->getName() );
                return $title->getFullURL();
        }
 }