<?php
/**
- * @package MediaWiki
- * @subpackage SpecialPage
+ * @addtogroup SpecialPage
*/
/**
* Entry point : initialise variables and call subfunctions.
* @param $par String: becomes "FOO" when called like Special:Allpages/FOO (default NULL)
- * @param $specialPage @see SpecialPage object.
+ * @param $specialPage See the SpecialPage object.
*/
function wfSpecialAllpages( $par=NULL, $specialPage ) {
global $wgRequest, $wgOut, $wgContLang;
}
}
+/**
+ * Implements Special:Allpages
+ * @addtogroup SpecialPage
+ */
class SpecialAllpages {
var $maxPerPage=960;
var $topLevelMax=50;
# TODO: Either make this *much* faster or cache the title index points
# in the querycache table.
- $dbr =& wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_SLAVE );
$out = "";
$where = array( 'page_namespace' => $namespace );
$sk = $wgUser->getSkin();
$fromList = $this->getNamespaceKeyAndText($namespace, $from);
-
+ $n = 0;
+
if ( !$fromList ) {
$out = wfMsgWikiHtml( 'allpagesbadtitle' );
} else {
list( $namespace, $fromKey, $from ) = $fromList;
- $dbr =& wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'page',
array( 'page_namespace', 'page_title', 'page_is_redirect' ),
array(
)
);
- ### FIXME: side link to previous
-
- $n = 0;
$out = '<table style="background: inherit;" border="0" width="100%">';
while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
if ( $including ) {
$out2 = '';
} else {
+ if( $from == '' ) {
+ // First chunk; no previous link.
+ $prevTitle = null;
+ } else {
+ # Get the last title from previous chunk
+ $dbr = wfGetDB( DB_SLAVE );
+ $res_prev = $dbr->select(
+ 'page',
+ 'page_title',
+ array( 'page_namespace' => $namespace, 'page_title < '.$dbr->addQuotes($from) ),
+ $fname,
+ array( 'ORDER BY' => 'page_title DESC', 'LIMIT' => $this->maxPerPage, 'OFFSET' => ($this->maxPerPage - 1 ) )
+ );
+
+ # Get first title of previous complete chunk
+ if( $dbr->numrows( $res_prev ) >= $this->maxPerPage ) {
+ $pt = $dbr->fetchObject( $res_prev );
+ $prevTitle = Title::makeTitle( $namespace, $pt->page_title );
+ } else {
+ # The previous chunk is not complete, need to link to the very first title
+ # available in the database
+ $reallyFirstPage_title = $dbr->selectField( 'page', 'page_title', array( 'page_namespace' => $namespace ), $fname, array( 'LIMIT' => 1) );
+
+ # Show the previous link if it s not the current requested chunk
+ if( $from != $reallyFirstPage_title ) {
+ $prevTitle = Title::makeTitle( $namespace, $reallyFirstPage_title );
+ } else {
+ $prevTitle = null;
+ }
+ }
+ }
+
$nsForm = $this->namespaceForm ( $namespace, $from );
$out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">';
$out2 .= '<tr valign="top"><td align="left">' . $nsForm;
$out2 .= '</td><td align="right" style="font-size: smaller; margin-bottom: 1em;">' .
$sk->makeKnownLink( $wgContLang->specialPage( "Allpages" ),
wfMsgHtml ( 'allpages' ) );
- if ( isset($dbr) && $dbr && ($n == $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
- $t = Title::MakeTitle( $s->page_namespace, $s->page_title );
- $self = SpecialPage::getTitleFor( 'Allpages' );
+
+ $self = SpecialPage::getTitleFor( 'Allpages' );
+
+ # Do we put a previous link ?
+ if( isset( $prevTitle ) && $pt = $prevTitle->getText() ) {
+ $q = 'from=' . $prevTitle->getPartialUrl() . ( $namespace ? '&namespace=' . $namespace : '' );
+ $prevLink = $sk->makeKnownLinkObj( $self, wfMsgHTML( 'prevpage', $pt ), $q );
+ $out2 .= ' | ' . $prevLink;
+ }
+
+ if( $n == $this->maxPerPage && $s = $dbr->fetchObject($res) ) {
+ # $s is the first link of the next chunk
+ $t = Title::MakeTitle($namespace, $s->page_title);
$q = 'from=' . $t->getPartialUrl() . ( $namespace ? '&namespace=' . $namespace : '' );
$nextLink = $sk->makeKnownLinkObj( $self, wfMsgHtml( 'nextpage', $t->getText() ), $q );
$out2 .= ' | ' . $nextLink;
}
$wgOut->addHtml( $out2 . $out );
- if( isset( $nextLink ) )
- $wgOut->addHtml( '<p style="font-size: smaller; float: right;">' . $nextLink . '</p>' );
+ if( isset($prevLink) or isset($nextLink) ) {
+ $wgOut->addHtml( '<hr/><p style="font-size: smaller; float: right;">' );
+ if( isset( $prevLink ) )
+ $wgOut->addHTML( $prevLink . ' | ');
+ if( isset( $nextLink ) )
+ $wgOut->addHTML( $nextLink );
+ $wgOut->addHTML( '</p>' );
+
+ }
}