aboutsummaryrefslogtreecommitdiffstats
path: root/includes/SpecialLongpages.php
diff options
context:
space:
mode:
authorEvan Prodromou <evanprodromou@users.mediawiki.org>2003-12-01 16:04:35 +0000
committerEvan Prodromou <evanprodromou@users.mediawiki.org>2003-12-01 16:04:35 +0000
commitf5d4ebe686269f9c825d3881a08d966d79ad6059 (patch)
treea652b42553b6fec5ca69855c1d79093468dc7a90 /includes/SpecialLongpages.php
parent25065219b32ffcf92a64259873593e3535cee423 (diff)
downloadmediawikicore-f5d4ebe686269f9c825d3881a08d966d79ad6059.tar.gz
mediawikicore-f5d4ebe686269f9c825d3881a08d966d79ad6059.zip
I was adding a special page (dead-end pages), and I realized that almost all
the special query pages were pretty much identical. I copy-and-pasted one to make the one I was working on, and I realized that that was Wrong. So, I took the common elements and made them into a class, QueryPage.php. Then, I derived each of the existing special pages from QueryPage, and overrode places where they differed. This is a Recipe pattern, btw, for those of you following along at home. Anyways, the upshot is that the query pages are a lot shorter, with just the essentials that make them different from other query pages, and there's one place to make big UI changes for all queries.
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/2120
Diffstat (limited to 'includes/SpecialLongpages.php')
-rw-r--r--includes/SpecialLongpages.php68
1 files changed, 27 insertions, 41 deletions
diff --git a/includes/SpecialLongpages.php b/includes/SpecialLongpages.php
index 0ebcb7e3c95f..44fa88afd9e1 100644
--- a/includes/SpecialLongpages.php
+++ b/includes/SpecialLongpages.php
@@ -1,51 +1,37 @@
<?
-function wfSpecialLongpages()
-{
- global $wgUser, $wgOut, $wgLang, $wgTitle;
- $fname = "wfSpecialLongpages";
-
- # Cache
- $vsp = $wgLang->getValidSpecialPages();
- $log = new LogPage( $vsp["Longpages"] );
- $log->mUpdateRecentChanges = false;
-
- global $wgMiserMode;
- if ( $wgMiserMode ) {
- $log->showAsDisabledPage();
- return;
- }
-
- list( $limit, $offset ) = wfCheckLimits();
-
- $sql = "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " .
+include_once( "QueryPage.php" );
+
+class LongPagesPage extends QueryPage {
+
+ function getName() {
+ return "Longpages";
+ }
+
+ function isExpensive() {
+ return 1;
+ }
+
+ function getSQL( $offset, $limit ) {
+ return "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " .
"WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
"LENGTH(cur_text) DESC LIMIT {$offset}, {$limit}";
- $res = wfQuery( $sql, DB_READ, $fname );
+ }
- $sk = $wgUser->getSkin();
-
- $top = wfShowingResults( $offset, $limit );
- $wgOut->addHTML( "<p>{$top}\n" );
-
- $sl = wfViewPrevNext( $offset, $limit,
- $wgLang->specialPage( "Longpages" ) );
- $wgOut->addHTML( "<br>{$sl}\n" );
+ function formatResult( $skin, $result ) {
+ $nb = wfMsg( "nbytes", $result->len );
+ $link = $skin->makeKnownLink( $result->cur_title, "" );
+ return "{$link} ({$nb})";
+ }
+}
- $s = "<ol start=" . ( $offset + 1 ) . ">";
- while ( $obj = wfFetchObject( $res ) ) {
- $nb = wfMsg( "nbytes", $obj->len );
- $link = $sk->makeKnownLink( $obj->cur_title, "" );
- $s .= "<li>{$link} ({$nb})</li>\n";
- }
- wfFreeResult( $res );
- $s .= "</ol>";
- $wgOut->addHTML( $s );
- $wgOut->addHTML( "<p>{$sl}\n" );
+function wfSpecialLongpages()
+{
+ list( $limit, $offset ) = wfCheckLimits();
- # Saving cache
- if ( $offset > 0 OR $limit < 50 ) return ; #Not suitable
- $log->replaceContent( $s );
+ $lpp = new LongPagesPage( );
+
+ $lpp->doQuery( $offset, $limit );
}
?>