X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FQueryPage.php;h=27c6927bdd98188a9fdca236cb3d4e535b0d0f68;hb=d35ccbc6f1872a27df32596c62a29238101945e5;hp=f7b9d1a585d8c46401681231f1cdd0efe09083e3;hpb=fa239349f2d5d4456c45efae16d1673d6472e165;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/QueryPage.php b/includes/QueryPage.php index f7b9d1a585..27c6927bdd 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -1,42 +1,45 @@ getName(), 'QueryPage::recache', 'vslow' ) ); + $dbw = wfGetDB( DB_MASTER ); + $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), 'QueryPage::recache', 'vslow' ) ); if ( !$dbw || !$dbr ) { return false; } @@ -274,20 +277,22 @@ class QueryPage { * @param $shownavigation show navigation like "next 200"? */ function doQuery( $offset, $limit, $shownavigation=true ) { - global $wgOut, $wgLang, $wgContLang; + global $wgUser, $wgOut, $wgLang, $wgContLang; $this->offset = $offset; $this->limit = $limit; $sname = $this->getName(); $fname = get_class($this) . '::doQuery'; - $sql = $this->getSQL(); - $dbr =& wfGetDB( DB_SLAVE ); - $querycache = $dbr->tableName( 'querycache' ); + $dbr = wfGetDB( DB_SLAVE ); $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 @@ -303,12 +308,20 @@ class QueryPage { $updated = $wgLang->timeAndDate( $tRow->qci_timestamp, true, true ); $cacheNotice = wfMsg( 'perfcachedts', $updated ); $wgOut->addMeta( 'Data-Cache-Time', $tRow->qci_timestamp ); - $wgOut->addScript( '' ); + $wgOut->addInlineScript( "var dataCacheTime = '{$tRow->qci_timestamp}';" ); } else { $cacheNotice = wfMsg( 'perfcached' ); } $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' ) ); + } + } } @@ -319,63 +332,114 @@ class QueryPage { $num = $dbr->numRows($res); $this->preprocessResults( $dbr, $res ); - - if($shownavigation) { - $wgOut->addHTML( $this->getPageHeader() ); - $top = wfShowingResults( $offset, $num); - $wgOut->addHTML( "
{$top}\n" );
-
- # often disable 'next' link when we reach the end
- $atend = $num < $limit;
-
- $sl = wfViewPrevNext( $offset, $limit ,
- $wgContLang->specialPage( $sname ),
- wfArrayToCGI( $this->linkParameters() ), $atend );
- $wgOut->addHTML( "
{$sl}
' . wfShowingResults( $offset, $num ) . '
' ); + # Disable the "next" link when we reach the end + $paging = wfViewPrevNext( $offset, $limit, $wgContLang->specialPage( $sname ), + wfArrayToCGI( $this->linkParameters() ), ( $num < $limit ) ); + $wgOut->addHtml( '' . $paging . '
' ); + } else { + # No results to show, so don't bother with "showing X of Y" etc. + # -- just let the user know and give up now + $wgOut->addHtml( '' . wfMsgHtml( 'specialpage-empty' ) . '
' ); + return; + } + } + + # The actual results; specialist subclasses will want to handle this + # with more than a straight list, so we hand them the info, plus + # an OutputPage, and let them get on with it + $this->outputResults( $wgOut, + $wgUser->getSkin(), + $dbr, # Should use a ResultWrapper for this + $res, + $dbr->numRows( $res ), + $offset ); + + # Repeat the paging links at the bottom + if( $shownavigation ) { + $wgOut->addHtml( '' . $paging . '
' ); } - if ( $num > 0 ) { - $s = array(); - if ( ! $this->listoutput ) - $s[] = "{$sl}
\n" ); - } - return $num; + } + + function openList( $offset ) { + return "