summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialPrefixindex.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialPrefixindex.php')
-rw-r--r--includes/specials/SpecialPrefixindex.php139
1 files changed, 88 insertions, 51 deletions
diff --git a/includes/specials/SpecialPrefixindex.php b/includes/specials/SpecialPrefixindex.php
index 9c880349..ea0c1135 100644
--- a/includes/specials/SpecialPrefixindex.php
+++ b/includes/specials/SpecialPrefixindex.php
@@ -1,40 +1,4 @@
<?php
-/**
- * @file
- * @ingroup SpecialPage
- */
-
-/**
- * Entry point : initialise variables and call subfunctions.
- * @param $par String: becomes "FOO" when called like Special:Prefixindex/FOO (default NULL)
- * @param $specialPage SpecialPage object.
- */
-function wfSpecialPrefixIndex( $par=NULL, $specialPage ) {
- global $wgRequest, $wgOut, $wgContLang;
-
- # GET values
- $from = $wgRequest->getVal( 'from' );
- $prefix = $wgRequest->getVal( 'prefix' );
- $namespace = $wgRequest->getInt( 'namespace' );
- $namespaces = $wgContLang->getNamespaces();
-
- $indexPage = new SpecialPrefixIndex();
-
- $wgOut->setPagetitle( ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) )
- ? wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) )
- : wfMsg( 'allarticles' )
- );
-
- if ( isset($par) ) {
- $indexPage->showChunk( $namespace, $par, $specialPage->including(), $from );
- } elseif ( isset($prefix) ) {
- $indexPage->showChunk( $namespace, $prefix, $specialPage->including(), $from );
- } elseif ( isset($from) ) {
- $indexPage->showChunk( $namespace, $from, $specialPage->including(), $from );
- } else {
- $wgOut->addHtml($indexPage->namespaceForm ( $namespace, null ));
- }
-}
/**
* implements Special:Prefixindex
@@ -44,18 +8,90 @@ class SpecialPrefixindex extends SpecialAllpages {
// Inherit $maxPerPage
// Define other properties
- protected $name = 'Prefixindex';
protected $nsfromMsg = 'allpagesprefix';
+
+ function __construct(){
+ parent::__construct( 'Prefixindex' );
+ }
+
+ /**
+ * Entry point : initialise variables and call subfunctions.
+ * @param $par String: becomes "FOO" when called like Special:Prefixindex/FOO (default null)
+ */
+ function execute( $par ) {
+ global $wgRequest, $wgOut, $wgContLang;
+
+ $this->setHeaders();
+ $this->outputHeader();
+
+ # GET values
+ $from = $wgRequest->getVal( 'from' );
+ $prefix = $wgRequest->getVal( 'prefix' );
+ $namespace = $wgRequest->getInt( 'namespace' );
+ $namespaces = $wgContLang->getNamespaces();
+
+ $wgOut->setPagetitle( ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) )
+ ? wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) )
+ : wfMsg( 'prefixindex' )
+ );
+
+ if( isset( $par ) ){
+ $this->showPrefixChunk( $namespace, $par, $from );
+ } elseif( isset( $prefix ) ){
+ $this->showPrefixChunk( $namespace, $prefix, $from );
+ } elseif( isset( $from ) ){
+ $this->showPrefixChunk( $namespace, $from, $from );
+ } else {
+ $wgOut->addHTML( $this->namespacePrefixForm( $namespace, null ) );
+ }
+ }
+
+ /**
+ * HTML for the top form
+ * @param integer $namespace A namespace constant (default NS_MAIN).
+ * @param string $from dbKey we are starting listing at.
+ */
+ function namespacePrefixForm( $namespace = NS_MAIN, $from = '' ) {
+ global $wgScript;
+ $t = $this->getTitle();
+
+ $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
+ $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
+ $out .= Xml::hidden( 'title', $t->getPrefixedText() );
+ $out .= Xml::openElement( 'fieldset' );
+ $out .= Xml::element( 'legend', null, wfMsg( 'allpages' ) );
+ $out .= Xml::openElement( 'table', array( 'id' => 'nsselect', 'class' => 'allpages' ) );
+ $out .= "<tr>
+ <td class='mw-label'>" .
+ Xml::label( wfMsg( 'allpagesfrom' ), 'nsfrom' ) .
+ "</td>
+ <td class='mw-input'>" .
+ Xml::input( 'from', 30, str_replace('_',' ',$from), array( 'id' => 'nsfrom' ) ) .
+ "</td>
+ </tr>
+ <tr>
+ <td class='mw-label'>" .
+ Xml::label( wfMsg( 'namespace' ), 'namespace' ) .
+ "</td>
+ <td class='mw-input'>" .
+ Xml::namespaceSelector( $namespace, null ) . ' ' .
+ Xml::submitButton( wfMsg( 'allpagessubmit' ) ) .
+ "</td>
+ </tr>";
+ $out .= Xml::closeElement( 'table' );
+ $out .= Xml::closeElement( 'fieldset' );
+ $out .= Xml::closeElement( 'form' );
+ $out .= Xml::closeElement( 'div' );
+ return $out;
+ }
/**
* @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 ) {
+ function showPrefixChunk( $namespace = NS_MAIN, $prefix, $from = null ) {
global $wgOut, $wgUser, $wgContLang;
- $fname = 'indexShowChunk';
-
$sk = $wgUser->getSkin();
if (!isset($from)) $from = $prefix;
@@ -86,7 +122,7 @@ class SpecialPrefixindex extends SpecialAllpages {
'page_title LIKE \'' . $dbr->escapeLike( $prefixKey ) .'%\'',
'page_title >= ' . $dbr->addQuotes( $fromKey ),
),
- $fname,
+ __METHOD__,
array(
'ORDER BY' => 'page_title',
'LIMIT' => $this->maxPerPage + 1,
@@ -100,7 +136,7 @@ class SpecialPrefixindex extends SpecialAllpages {
if( $res->numRows() > 0 ) {
$out = '<table style="background: inherit;" border="0" width="100%">';
- while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
+ while( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$t = Title::makeTitle( $s->page_namespace, $s->page_title );
if( $t ) {
$link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
@@ -127,26 +163,27 @@ class SpecialPrefixindex extends SpecialAllpages {
}
}
- if ( $including ) {
+ if ( $this->including() ) {
$out2 = '';
} else {
- $nsForm = $this->namespaceForm ( $namespace, $prefix );
+ $nsForm = $this->namespacePrefixForm( $namespace, $prefix );
+ $self = $this->getTitle();
$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 ),
+ $sk->makeKnownLinkObj( $self,
wfMsg ( 'allpages' ) );
- if ( isset($dbr) && $dbr && ($n == $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
+ if( isset( $res ) && $res && ( $n == $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$namespaceparam = $namespace ? "&namespace=$namespace" : "";
- $out2 .= " | " . $sk->makeKnownLink(
- $wgContLang->specialPage( $this->name ),
+ $out2 .= " | " . $sk->makeKnownLinkObj(
+ $self,
wfMsgHtml( 'nextpage', htmlspecialchars( $s->page_title ) ),
- "from=" . wfUrlEncode ( $s->page_title ) .
- "&prefix=" . wfUrlEncode ( $prefix ) . $namespaceparam );
+ "from=" . wfUrlEncode( $s->page_title ) .
+ "&prefix=" . wfUrlEncode( $prefix ) . $namespaceparam );
}
$out2 .= "</td></tr></table><hr />";
}
- $wgOut->addHtml( $out2 . $out );
+ $wgOut->addHTML( $out2 . $out );
}
}