getName(); $fname = get_class($this) . "::doQuery"; $wgOut->setSyndicated( true ); if ( $this->isExpensive( ) ) { $vsp = $wgLang->getValidSpecialPages(); $logpage = new LogPage( "!" . $vsp[$sname] ); $logpage->mUpdateRecentChanges = false; if ( $wgMiserMode ) { $logpage->showAsDisabledPage(); return; } } $sql = $this->getSQL( $offset, $limit ); $res = wfQuery( $sql, DB_READ, $fname ); $num = wfNumRows($res); $sk = $wgUser->getSkin( ); $top = wfShowingResults( $offset, $num); $wgOut->addHTML( "

{$top}\n" ); # often disable 'next' link when we reach the end if($num < $limit) { $atend = true; } else { $atend = false; } $sl = wfViewPrevNext( $offset, $limit , $wgLang->specialPage( $sname ), "" ,$atend ); $wgOut->addHTML( "
{$sl}

\n" ); $s = "
    "; while ( $obj = wfFetchObject( $res ) ) { $format = $this->formatResult( $sk, $obj ); $s .= "
  1. {$format}
  2. \n"; } wfFreeResult( $res ); $s .= "
"; $wgOut->addHTML( $s ); $wgOut->addHTML( "

{$sl}

\n" ); # Saving cache if ( $this->isExpensive() && $offset == 0 && $limit >= 50 ) { $logpage->replaceContent( $s ); } } # Similar to above, but packaging in a syndicated feed instead of a web page function doFeed( $class = "" ) { global $wgFeedClasses; global $wgOut, $wgLanguageCode, $wgLang; if( isset($wgFeedClasses[$class]) ) { $feed = new $wgFeedClasses[$class]( $this->feedTitle(), $this->feedDesc(), $this->feedUrl() ); $feed->outHeader(); $sql = $this->getSQL( 0, 50 ); $res = wfQuery( $sql, DB_READ, "QueryPage::doFeed" ); while( $obj = wfFetchObject( $res ) ) { $item = $this->feedResult( $obj ); if( $item ) $feed->outItem( $item ); } wfFreeResult( $res ); $feed->outFooter(); return true; } else { return false; } } # Override for custom handling. If the titles/links are ok, just do feedItemDesc() function feedResult( $row ) { if( isset( $row->cur_title ) ) { $title = Title::MakeTitle( $row->cur_namespace, $row->cur_title ); } elseif( isset( $row->old_title ) ) { $title = Title::MakeTitle( $row->old_namespace, $row->old_title ); } elseif( isset( $row->rc_title ) ) { $title = Title::MakeTitle( $row->rc_namespace, $row->rc_title ); } else { return NULL; } if( $title ) { $date = ""; if( isset( $row->cur_timestamp ) ) { $date = $row->cur_timestamp; } elseif( isset( $row->old_timestamp ) ) { $date = $row->old_timestamp; } elseif( isset( $row->rc_cur_timestamp ) ) { $date = $row->rc_cur_timestamp; } $comments = ""; if( $title ) { $talkpage = $title->getTalkPage(); $comments = $talkpage->getFullURL(); } return new FeedItem( $title->getText(), $this->feedItemDesc( $row ), $title->getFullURL(), $date, $this->feedItemAuthor( $row ), $comments); } else { return NULL; } } function feedItemDesc( $row ) { $text = ""; if( isset( $row->cur_comment ) ) { $text = $row->cur_comment; } elseif( isset( $row->old_comment ) ) { $text = $row->old_comment; } elseif( isset( $row->rc_comment ) ) { $text = $row->rc_comment; } $text = htmlspecialchars( $text ); if( isset( $row->cur_text ) ) { $text = "

" . htmlspecialchars( wfMsg( "summary" ) ) . ": " . $text . "

\n
\n
" . nl2br( $row->cur_text ) . "
";; } return $text; } function feedItemAuthor( $row ) { /* old code $fields = array( "cur_user_text", "old_user_text", "rc_user_text" ); foreach( $fields as $field ) { if( isset( $row->$field ) ) return $row->field; } new code follow, that's an ugly hack to fix things: */ if( isset( $row->cur_user_text ) ) return $row->cur_user_text; if( isset( $row->old_user_text ) ) return $row->old_user_text; if( isset( $row->rc_user_text ) ) return $row->rc_user_text; return ""; } function feedTitle() { global $wgLanguageCode, $wgSitename, $wgLang; $pages = $wgLang->getValidSpecialPages(); $title = $pages[$this->getName()]; return "$wgSitename - $title [$wgLanguageCode]"; } function feedDesc() { return wfMsg( "fromwikipedia" ); } function feedUrl() { global $wgLang; $title = Title::MakeTitle( NS_SPECIAL, $this->getName() ); return $title->getFullURL(); } } # This is a subclass for very simple queries that are just looking for page # titles that match some criteria. It formats each result item as a link to # that page. class PageQueryPage extends QueryPage { function formatResult( $skin, $result ) { return $skin->makeKnownLink( $result->cur_title, "" ); } } ?>