2005-08-10 21:14:38 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
2007-01-20 15:09:52 +00:00
|
|
|
* @addtogroup SpecialPage
|
2005-08-10 21:14:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Entry point : initialise variables and call subfunctions.
|
2006-04-19 15:46:24 +00:00
|
|
|
* @param $par String: becomes "FOO" when called like Special:Prefixindex/FOO (default NULL)
|
|
|
|
|
* @param $specialPage SpecialPage object.
|
2005-08-10 21:14:38 +00:00
|
|
|
*/
|
|
|
|
|
function wfSpecialPrefixIndex( $par=NULL, $specialPage ) {
|
|
|
|
|
global $wgRequest, $wgOut, $wgContLang;
|
|
|
|
|
|
|
|
|
|
# GET values
|
|
|
|
|
$from = $wgRequest->getVal( 'from' );
|
2006-06-28 15:45:50 +00:00
|
|
|
$prefix = $wgRequest->getVal( 'prefix' );
|
2005-08-10 21:14:38 +00:00
|
|
|
$namespace = $wgRequest->getInt( 'namespace' );
|
|
|
|
|
$namespaces = $wgContLang->getNamespaces();
|
|
|
|
|
|
|
|
|
|
$indexPage = new SpecialPrefixIndex();
|
|
|
|
|
|
2007-06-26 07:21:28 +00:00
|
|
|
$wgOut->setPagetitle( ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) )
|
|
|
|
|
? wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) )
|
|
|
|
|
: wfMsg( 'allarticles' )
|
|
|
|
|
);
|
2006-06-28 15:45:50 +00:00
|
|
|
|
2005-08-10 21:14:38 +00:00
|
|
|
if ( isset($par) ) {
|
2006-06-28 15:45:50 +00:00
|
|
|
$indexPage->showChunk( $namespace, $par, $specialPage->including(), $from );
|
|
|
|
|
} elseif ( isset($prefix) ) {
|
|
|
|
|
$indexPage->showChunk( $namespace, $prefix, $specialPage->including(), $from );
|
2005-08-10 21:14:38 +00:00
|
|
|
} elseif ( isset($from) ) {
|
2006-06-28 15:45:50 +00:00
|
|
|
$indexPage->showChunk( $namespace, $from, $specialPage->including(), $from );
|
2005-08-10 21:14:38 +00:00
|
|
|
} else {
|
2006-06-28 15:45:50 +00:00
|
|
|
$wgOut->addHtml($indexPage->namespaceForm ( $namespace, null ));
|
2005-08-10 21:14:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-20 08:55:14 +00:00
|
|
|
/**
|
2008-04-14 07:45:50 +00:00
|
|
|
* implements Special:Prefixindex
|
2007-04-20 08:55:14 +00:00
|
|
|
* @addtogroup SpecialPage
|
|
|
|
|
*/
|
2005-08-10 21:14:38 +00:00
|
|
|
class SpecialPrefixindex extends SpecialAllpages {
|
2007-12-24 17:08:05 +00:00
|
|
|
// Inherit $maxPerPage
|
2007-12-24 11:21:37 +00:00
|
|
|
|
|
|
|
|
// Define other properties
|
|
|
|
|
protected $name = 'Prefixindex';
|
|
|
|
|
protected $nsfromMsg = 'allpagesprefix';
|
2005-08-10 21:14:38 +00:00
|
|
|
|
2008-04-14 07:45:50 +00:00
|
|
|
/**
|
|
|
|
|
* @param integer $namespace (Default NS_MAIN)
|
|
|
|
|
* @param string $from list all pages from this name (default FALSE)
|
|
|
|
|
*/
|
|
|
|
|
function showChunk( $namespace = NS_MAIN, $prefix, $including = false, $from = null ) {
|
|
|
|
|
global $wgOut, $wgUser, $wgContLang;
|
|
|
|
|
|
|
|
|
|
$fname = 'indexShowChunk';
|
|
|
|
|
|
|
|
|
|
$sk = $wgUser->getSkin();
|
|
|
|
|
|
|
|
|
|
if (!isset($from)) $from = $prefix;
|
|
|
|
|
|
|
|
|
|
$fromList = $this->getNamespaceKeyAndText($namespace, $from);
|
|
|
|
|
$prefixList = $this->getNamespaceKeyAndText($namespace, $prefix);
|
|
|
|
|
$namespaces = $wgContLang->getNamespaces();
|
|
|
|
|
$align = $wgContLang->isRtl() ? 'left' : 'right';
|
|
|
|
|
|
|
|
|
|
if ( !$prefixList || !$fromList ) {
|
|
|
|
|
$out = wfMsgWikiHtml( 'allpagesbadtitle' );
|
|
|
|
|
} elseif ( !in_array( $namespace, array_keys( $namespaces ) ) ) {
|
|
|
|
|
// Show errormessage and reset to NS_MAIN
|
|
|
|
|
$out = wfMsgExt( 'allpages-bad-ns', array( 'parseinline' ), $namespace );
|
|
|
|
|
$namespace = NS_MAIN;
|
|
|
|
|
} else {
|
|
|
|
|
list( $namespace, $prefixKey, $prefix ) = $prefixList;
|
|
|
|
|
list( /* $fromNs */, $fromKey, $from ) = $fromList;
|
|
|
|
|
|
|
|
|
|
### FIXME: should complain if $fromNs != $namespace
|
|
|
|
|
|
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
|
|
|
|
|
$res = $dbr->select( 'page',
|
|
|
|
|
array( 'page_namespace', 'page_title', 'page_is_redirect' ),
|
|
|
|
|
array(
|
|
|
|
|
'page_namespace' => $namespace,
|
|
|
|
|
'page_title LIKE \'' . $dbr->escapeLike( $prefixKey ) .'%\'',
|
|
|
|
|
'page_title >= ' . $dbr->addQuotes( $fromKey ),
|
|
|
|
|
),
|
|
|
|
|
$fname,
|
|
|
|
|
array(
|
|
|
|
|
'ORDER BY' => 'page_title',
|
|
|
|
|
'LIMIT' => $this->maxPerPage + 1,
|
|
|
|
|
'USE INDEX' => 'name_title',
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
### FIXME: side link to previous
|
|
|
|
|
|
|
|
|
|
$n = 0;
|
|
|
|
|
$out = '<table style="background: inherit;" border="0" width="100%">';
|
|
|
|
|
|
|
|
|
|
while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
|
|
|
|
|
$t = Title::makeTitle( $s->page_namespace, $s->page_title );
|
|
|
|
|
if( $t ) {
|
|
|
|
|
$link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
|
|
|
|
|
$sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) .
|
|
|
|
|
($s->page_is_redirect ? '</div>' : '' );
|
|
|
|
|
} else {
|
|
|
|
|
$link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
|
|
|
|
|
}
|
|
|
|
|
if( $n % 3 == 0 ) {
|
|
|
|
|
$out .= '<tr>';
|
|
|
|
|
}
|
|
|
|
|
$out .= "<td>$link</td>";
|
|
|
|
|
$n++;
|
|
|
|
|
if( $n % 3 == 0 ) {
|
|
|
|
|
$out .= '</tr>';
|
|
|
|
|
}
|
2006-07-02 14:39:47 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
if( ($n % 3) != 0 ) {
|
2006-07-02 14:39:47 +00:00
|
|
|
$out .= '</tr>';
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
$out .= '</table>';
|
2005-08-10 21:14:38 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2008-04-14 07:45:50 +00:00
|
|
|
if ( $including ) {
|
|
|
|
|
$out2 = '';
|
|
|
|
|
} else {
|
|
|
|
|
$nsForm = $this->namespaceForm ( $namespace, $prefix );
|
|
|
|
|
$out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">';
|
|
|
|
|
$out2 .= '<tr valign="top"><td>' . $nsForm;
|
|
|
|
|
$out2 .= '</td><td align="' . $align . '" style="font-size: smaller; margin-bottom: 1em;">' .
|
|
|
|
|
$sk->makeKnownLink( $wgContLang->specialPage( $this->name ),
|
|
|
|
|
wfMsg ( 'allpages' ) );
|
|
|
|
|
if ( isset($dbr) && $dbr && ($n == $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
|
|
|
|
|
$namespaceparam = $namespace ? "&namespace=$namespace" : "";
|
|
|
|
|
$out2 .= " | " . $sk->makeKnownLink(
|
|
|
|
|
$wgContLang->specialPage( $this->name ),
|
|
|
|
|
wfMsg ( 'nextpage', $s->page_title ),
|
|
|
|
|
"from=" . wfUrlEncode ( $s->page_title ) .
|
|
|
|
|
"&prefix=" . wfUrlEncode ( $prefix ) . $namespaceparam );
|
|
|
|
|
}
|
|
|
|
|
$out2 .= "</td></tr></table><hr />";
|
2005-08-10 21:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
2008-04-14 07:45:50 +00:00
|
|
|
$wgOut->addHtml( $out2 . $out );
|
|
|
|
|
}
|
2005-08-10 21:14:38 +00:00
|
|
|
}
|