Bug 6031 (feature request for __NOGALLERY__ on category pages) fixed
[lhc/web/wiklou.git] / includes / QueryPage.php
index 9488751..515e458 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
  */
@@ -23,6 +18,7 @@ $wgQueryPages = array(
        array( 'DisambiguationsPage',           'Disambiguations'               ),
        array( 'DoubleRedirectsPage',           'DoubleRedirects'               ),
        array( 'ListUsersPage',                 'Listusers'                     ),
+       array( 'ListredirectsPage', 'Listredirects' ),
        array( 'LonelyPagesPage',               'Lonelypages'                   ),
        array( 'LongPagesPage',                 'Longpages'                     ),
        array( 'MostcategoriesPage',            'Mostcategories'                ),
@@ -38,15 +34,14 @@ $wgQueryPages = array(
        array( 'UnusedimagesPage',              'Unusedimages'                  ),
        array( 'WantedCategoriesPage',          'Wantedcategories'              ),
        array( 'WantedPagesPage',               'Wantedpages'                   ),
+       array( 'UnwatchedPagesPage',            'Unwatchedpages'                ),
+       array( 'UnusedtemplatesPage', 'Unusedtemplates' ),
 );
 wfRunHooks( 'wgQueryPages', array( &$wgQueryPages ) );
 
 global $wgDisableCounters;
 if ( !$wgDisableCounters )
        $wgQueryPages[] = array( 'PopularPagesPage',            'Popularpages'          );
-global $wgEnableUnwatchedpages;
-if ( $wgEnableUnwatchedpages )
-       $wgQueryPages[] = array( 'UnwatchedPagesPage',          'Unwatchedpages'        );
 
 
 /**
@@ -63,6 +58,14 @@ class QueryPage {
         * @var bool
         */
        var $listoutput = false;
+       
+       /**
+        * The offset and limit in use, as passed to the query() function
+        *
+        * @var integer
+        */
+       var $offset = 0;
+       var $limit = 0;
 
        /**
         * A mutator for $this->listoutput;
@@ -82,6 +85,15 @@ class QueryPage {
                return '';
        }
 
+       /**
+        * Return title object representing this page
+        *
+        * @return Title
+        */
+       function getTitle() {
+               return Title::makeTitle( NS_SPECIAL, $this->getName() );
+       }
+
        /**
         * Subclasses return an SQL query here.
         *
@@ -131,7 +143,7 @@ class QueryPage {
         */
        function isCached() {
                global $wgMiserMode;
-               
+
                return $this->isExpensive() && $wgMiserMode;
        }
 
@@ -244,6 +256,11 @@ class QueryPage {
                                $dbw->ignoreErrors( $ignoreW );
                                $dbr->ignoreErrors( $ignoreR );
                        }
+
+                       # Update the querycache_info record for the page
+                       $dbw->delete( 'querycache_info', array( 'qci_type' => $this->getName() ), $fname );
+                       $dbw->insert( 'querycache_info', array( 'qci_type' => $this->getName(), 'qci_timestamp' => $dbw->timestamp() ), $fname );
+
                }
                return $num;
        }
@@ -257,8 +274,11 @@ class QueryPage {
         * @param $shownavigation show navigation like "next 200"?
         */
        function doQuery( $offset, $limit, $shownavigation=true ) {
-               global $wgUser, $wgOut, $wgContLang;
-               
+               global $wgUser, $wgOut, $wgLang, $wgContLang;
+
+               $this->offset = $offset;
+               $this->limit = $limit;
+
                $sname = $this->getName();
                $fname = get_class($this) . '::doQuery';
                $sql = $this->getSQL();
@@ -272,8 +292,25 @@ class QueryPage {
                        $sql =
                                "SELECT qc_type as type, qc_namespace as namespace,qc_title as title, qc_value as value
                                 FROM $querycache WHERE qc_type='$type'";
-                       if ( ! $this->listoutput )
-                               $wgOut->addWikiText( wfMsg( 'perfcached' ) );
+
+                       if( !$this->listoutput ) {
+
+                               # Fetch the timestamp of this update
+                               $tRes = $dbr->select( 'querycache_info', array( 'qci_timestamp' ), array( 'qci_type' => $type ), $fname );
+                               $tRow = $dbr->fetchObject( $tRes );
+                               
+                               if( $tRow ) {
+                                       $updated = $wgLang->timeAndDate( $tRow->qci_timestamp, true, true );
+                                       $cacheNotice = wfMsg( 'perfcachedts', $updated );
+                                       $wgOut->addMeta( 'Data-Cache-Time', $tRow->qci_timestamp );
+                                       $wgOut->addScript( '<script language="JavaScript">var dataCacheTime = \'' . $tRow->qci_timestamp . '\';</script>' );
+                               } else {
+                                       $cacheNotice = wfMsg( 'perfcached' );
+                               }
+       
+                               $wgOut->addWikiText( $cacheNotice );
+                       }
+
                }
 
                $sql .= $this->getOrder();
@@ -345,9 +382,9 @@ class QueryPage {
        /**
         * Similar to above, but packaging in a syndicated feed instead of a web page
         */
-       function doFeed( $class = '' ) {
+       function doFeed( $class = '', $limit = 50 ) {
                global $wgFeedClasses;
-               
+
                if( isset($wgFeedClasses[$class]) ) {
                        $feed = new $wgFeedClasses[$class](
                                $this->feedTitle(),
@@ -357,7 +394,7 @@ class QueryPage {
 
                        $dbr =& wfGetDB( DB_SLAVE );
                        $sql = $this->getSQL() . $this->getOrder();
-                       $sql = $dbr->limitResult( $sql, 50, 0 );
+                       $sql = $dbr->limitResult( $sql, $limit, 0 );
                        $res = $dbr->query( $sql, 'QueryPage::doFeed' );
                        while( $obj = $dbr->fetchObject( $res ) ) {
                                $item = $this->feedResult( $obj );