<?php
/**
- *
* @package MediaWiki
* @subpackage SpecialPage
*/
* Entry point : initialise variables and call subfunctions.
* @param string $par Becomes "FOO" when called like Special:Allpages/FOO (default NULL)
*/
-function wfSpecialAllpages( $par=NULL ) {
+function wfSpecialAllpages( $par=NULL, $specialPage ) {
global $indexMaxperpage, $toplevelMaxperpage, $wgRequest, $wgOut, $wgContLang;
# Config
$indexMaxperpage = 480;
$namespace = $wgRequest->getInt( 'namespace' );
$invert = $wgRequest->getBool( 'invert' );
- $names = $wgContLang->getNamespaces();
+ $namespaces = $wgContLang->getNamespaces();
- if( !isset( $names[$namespace] ) ) {
+ if( !in_array($namespace, array_keys($namespaces)) )
$namespace = 0;
- }
if ($invert) {
$wgOut->setPagetitle( $namespace > 0 ?
- wfMsg( 'allnotinnamespace', $names[$namespace] ) :
+ wfMsg( 'allnotinnamespace', $namespaces[$namespace] ) :
wfMsg( 'allnonarticles' )
);
} else {
$wgOut->setPagetitle( $namespace > 0 ?
- wfMsg( 'allinnamespace', $names[$namespace] ) :
+ wfMsg( 'allinnamespace', $namespaces[$namespace] ) :
wfMsg( 'allarticles' )
);
}
- if ( $par ) {
- indexShowChunk( $namespace, $par, $invert );
- } elseif ( $from ) {
- indexShowChunk( $namespace, $from, $invert );
+ if ( isset($par) ) {
+ indexShowChunk( $namespace, $par, $invert, $specialPage->including() );
+ } elseif ( isset($from) ) {
+ indexShowChunk( $namespace, $from, $invert, $specialPage->including() );
} else {
- indexShowToplevel ( $namespace, $invert );
+ indexShowToplevel ( $namespace, $invert, $specialPage->including() );
}
}
* @param string $from Article name we are starting listing at.
* @param bool $invert true if we want the namespaces inverted (default false)
*/
-function namespaceForm ( $namespace = NS_MAIN, $from = '', $invert ) {
+function indexNamespaceForm ( $namespace = NS_MAIN, $from = '', $invert = false ) {
global $wgContLang, $wgScript;
$t = Title::makeTitle( NS_SPECIAL, "Allpages" );
- $namespaceselect = '<select name="namespace">';
- $arr = $wgContLang->getNamespaces();
+ $namespaceselect = "<select name='namespace' id='nsselectbox'>";
+ $arr = $wgContLang->getFormattedNamespaces();
foreach ( $arr as $ns => $name ) {
- if ( $ns < NS_MAIN ) continue;
- $namespacename = str_replace ( '_', ' ', $name);
- $n = ($ns == 0) ? wfMsg ( 'articlenamespace' ) : $namespacename;
- $sel = ($ns == $namespace) ? ' selected="selected"' : '';
- $namespaceselect .= "<option value='{$ns}'{$sel}>{$n}</option>";
+ if ($ns < NS_MAIN)
+ continue;
+ $n = $ns == 0 ? wfMsg ( 'blanknamespace' ) : $name;
+ $sel = $ns == $namespace ? ' selected="selected"' : '';
+ $namespaceselect .= "<option value='$ns'$sel>$n</option>";
}
$namespaceselect .= '</select>';
- $frombox = '<input type="text" size="20" name="from" value="'
+ $frombox = "<input type='text' size='20' name='from' id='nsfrom' value=\""
. htmlspecialchars ( $from ) . '"/>';
$submitbutton = '<input type="submit" value="' . wfMsg( 'allpagessubmit' ) . '" />';
- $invertbox = "<input type='checkbox' name='invert' value='1'" . ( $invert ? ' checked="checked"' : '' ) . ' />';
+ $invertbox = "<input type='checkbox' name='invert' value='1' id='nsinvert'" . ( $invert ? ' checked="checked"' : '' ) . ' />';
$out = "<div class='namespaceselector'><form method='get' action='{$wgScript}'>";
$out .= '<input type="hidden" name="title" value="'.$t->getPrefixedText().'" />';
- $out .= wfMsg ( 'allpagesformtext', $frombox, $namespaceselect, $submitbutton, $invertbox );
+ $out .= "
+<table id='nsselect' class='allpages'>
+ <tr>
+ <td align='right'>" . wfMsg('allpagesfrom') . "</td>
+ <td align='left'><label for='nsfrom'>$frombox</label></td>
+ </tr>
+ <tr>
+ <td align='right'><label for='nsselectbox'>" . wfMsg('namespace') . "</label></td>
+ <td align='left'>
+ $namespaceselect $submitbutton $invertbox
+ <label for='nsinvert'>" . wfMsg('invert') . "</label>
+ </td>
+ </tr>
+</table>
+";
$out .= '</form></div>';
- return $out;
+ return $out;
}
/**
* @param integer $namespace (default NS_MAIN)
* @param bool $invert true if we want the namespaces inverted (default false)
*/
-function indexShowToplevel ( $namespace = NS_MAIN, $invert ) {
+function indexShowToplevel ( $namespace = NS_MAIN, $invert = false, $including = false ) {
global $wgOut, $indexMaxperpage, $toplevelMaxperpage, $wgContLang, $wgRequest, $wgUser;
$sk = $wgUser->getSkin();
$fname = "indexShowToplevel";
if ( $sections < 3 ) {
# If there are only two or less sections, don't even display them.
# Instead, display the first section directly.
- indexShowChunk( $namespace, '', $invert );
+ indexShowChunk( $namespace, '', $invert, $including );
return;
}
$limit = ( $i == $offset || $i == $stopat ) ? 1 : 2;
$sql = "SELECT page_title $fromwhere $order_str " . $dbr->limitResult ( $limit, $from );
$res = $dbr->query( $sql, $fname );
- $s = $dbr->fetchObject( $res );
- array_push ( $lines, $s->page_title );
if ( $s = $dbr->fetchObject( $res ) ) {
array_push ( $lines, $s->page_title );
+ if ( $s = $dbr->fetchObject( $res ) ) {
+ array_push ( $lines, $s->page_title );
+ }
}
$dbr->freeResult( $res );
}
}
$out .= '</table>';
- $nsForm = namespaceForm ( $namespace, '', $invert );
-
+ $nsForm = indexNamespaceForm ( $namespace, '', $invert );
+
# Is there more?
- $morelinks = '';
- if ( $offset > 0 ) {
- $morelinks = $sk->makeKnownLink (
- $wgContLang->specialPage ( 'Allpages' ),
- wfMsg ( 'allpagesprev' ),
- ( $offset > $toplevelMaxperpage ) ? 'offset='.($offset-$toplevelMaxperpage) : ''
- );
- }
- if ( $stopat < $sections-1 ) {
- if ( $morelinks != '' ) { $morelinks .= " | "; }
- $morelinks .= $sk->makeKnownLink (
- $wgContLang->specialPage ( 'Allpages' ),
- wfMsg ( 'allpagesnext' ),
- 'offset=' . ($offset + $toplevelMaxperpage)
- );
- }
-
- if ( $morelinks != '' ) {
- $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;">';
- $out2 .= $morelinks . '</td></tr></table><hr />';
+ if ( $including ) {
+ $out2 = '';
} else {
- $out2 = $nsForm . '<hr />';
+ $morelinks = '';
+ if ( $offset > 0 ) {
+ $morelinks = $sk->makeKnownLink (
+ $wgContLang->specialPage ( 'Allpages' ),
+ wfMsg ( 'allpagesprev' ),
+ ( $offset > $toplevelMaxperpage ) ? 'offset='.($offset-$toplevelMaxperpage) : ''
+ );
+ }
+ if ( $stopat < $sections-1 ) {
+ if ( $morelinks != '' ) { $morelinks .= " | "; }
+ $morelinks .= $sk->makeKnownLink (
+ $wgContLang->specialPage ( 'Allpages' ),
+ wfMsg ( 'allpagesnext' ),
+ 'offset=' . ($offset + $toplevelMaxperpage)
+ );
+ }
+
+ if ( $morelinks != '' ) {
+ $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;">';
+ $out2 .= $morelinks . '</td></tr></table><hr />';
+ } else {
+ $out2 = $nsForm . '<hr />';
+ }
}
$wgOut->addHtml( $out2 . $out );
* @param string $from list all pages from this name (default FALSE)
* @param bool $invert true if we want the namespaces inverted (default false)
*/
-function indexShowChunk( $namespace = NS_MAIN, $from, $invert ) {
+function indexShowChunk( $namespace = NS_MAIN, $from, $invert = false, $including = false ) {
global $wgOut, $wgUser, $indexMaxperpage, $wgContLang;
$sk = $wgUser->getSkin();
$maxPlusOne = $indexMaxperpage + 1;
$fromTitle = Title::newFromURL( $from );
$fromKey = is_null( $fromTitle ) ? '' : $fromTitle->getDBkey();
- $sql = "SELECT page_namespace, page_title FROM $page WHERE page_namespace" .
+ $sql = "SELECT page_namespace,page_title FROM $page WHERE page_namespace" .
($invert ? '!' : '') . "=$namespace" .
" AND page_title >= ". $dbr->addQuotes( $fromKey ) .
" ORDER BY page_title LIMIT " . $maxPlusOne;
$n = 0;
$out = '<table style="background: inherit;" border="0" width="100%">';
+
+ $namespaces = $wgContLang->getFormattedNamespaces();
while( ($n < $indexMaxperpage) && ($s = $dbr->fetchObject( $res )) ) {
$t = Title::makeTitle( $s->page_namespace, $s->page_title );
if( $t ) {
- $link = $sk->makeKnownLinkObj( $t, $t->getText() );
+ $ns = $s->page_namespace;
+ $prefix = $invert ? $namespaces[$ns] : '';
+ $prefix .= $invert && $namespaces[$ns] != $wgContLang->getNsText(NS_MAIN) ? ':' : '';
+ $link = $sk->makeKnownLinkObj( $t, $t->getText(), false, false, $prefix );
} else {
$link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
}
}
$out .= '</table>';
- $nsForm = namespaceForm ( $namespace, $from, $invert );
- $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" ),
- wfMsg ( 'allpages' ) );
- if ( ($n == $indexMaxperpage) && ($s = $dbr->fetchObject( $res )) ) {
- $namespaceparam = $namespace ? "&namespace=$namespace" : "";
- $invertparam = $invert ? "&invert=$invert" : '';
- $out2 .= " | " . $sk->makeKnownLink(
- $wgContLang->specialPage( "Allpages" ),
- wfMsg ( 'nextpage', $s->page_title ),
- "from=" . wfUrlEncode ( $s->page_title ) . $namespaceparam . $invertparam );
+ if ( $including ) {
+ $out2 = '';
+ } else {
+ $nsForm = indexNamespaceForm ( $namespace, $from, $invert );
+ $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" ),
+ wfMsg ( 'allpages' ) );
+ if ( ($n == $indexMaxperpage) && ($s = $dbr->fetchObject( $res )) ) {
+ $namespaceparam = $namespace ? "&namespace=$namespace" : "";
+ $invertparam = $invert ? "&invert=$invert" : '';
+ $out2 .= " | " . $sk->makeKnownLink(
+ $wgContLang->specialPage( "Allpages" ),
+ wfMsg ( 'nextpage', $s->page_title ),
+ "from=" . wfUrlEncode ( $s->page_title ) . $namespaceparam . $invertparam );
+ }
+ $out2 .= "</td></tr></table><hr />";
}
- $out2 .= "</td></tr></table><hr />";
$wgOut->addHtml( $out2 . $out );
}