setHeaders(); $this->outputHeader(); $wgOut->addModuleStyles( 'mediawiki.special' ); # GET values $from = $wgRequest->getVal( 'from', '' ); $prefix = $wgRequest->getVal( 'prefix', '' ); $ns = $wgRequest->getIntOrNull( 'namespace' ); $namespace = (int)$ns; // if no namespace given, use 0 (NS_MAIN). $namespaces = $wgContLang->getNamespaces(); $wgOut->setPagetitle( ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) ) ? wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) : wfMsg( 'prefixindex' ) ); $showme = ''; if( isset( $par ) ) { $showme = $par; } elseif( $prefix != '' ) { $showme = $prefix; } elseif( $from != '' ) { // For back-compat with Special:Allpages $showme = $from; } // Bug 27864: if transcluded, show all pages instead of the form. if ( $this->including() || $showme != '' || $ns !== null ) { $this->showPrefixChunk( $namespace, $showme, $from ); } else { $wgOut->addHTML( $this->namespacePrefixForm( $namespace, null ) ); } } /** * HTML for the top form * @param $namespace Integer: a namespace constant (default NS_MAIN). * @param $from String: 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 .= Html::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 .= " " . Xml::label( wfMsg( 'allpagesprefix' ), 'nsfrom' ) . " " . Xml::input( 'prefix', 30, str_replace('_',' ',$from), array( 'id' => 'nsfrom' ) ) . " " . Xml::label( wfMsg( 'namespace' ), 'namespace' ) . " " . Xml::namespaceSelector( $namespace, null ) . ' ' . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . " "; $out .= Xml::closeElement( 'table' ); $out .= Xml::closeElement( 'fieldset' ); $out .= Xml::closeElement( 'form' ); $out .= Xml::closeElement( 'div' ); return $out; } /** * @param $namespace Integer, default NS_MAIN * @param $prefix String * @param $from String: list all pages from this name (default FALSE) */ function showPrefixChunk( $namespace = NS_MAIN, $prefix, $from = null ) { global $wgOut, $wgContLang, $wgLang; $sk = $this->getSkin(); if (!isset($from)) $from = $prefix; $fromList = $this->getNamespaceKeyAndText($namespace, $from); $prefixList = $this->getNamespaceKeyAndText($namespace, $prefix); $namespaces = $wgContLang->getNamespaces(); if ( !$prefixList || !$fromList ) { $out = wfMsgExt( 'allpagesbadtitle', 'parse' ); } 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, ) = $fromList; ### @todo 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' . $dbr->buildLike( $prefixKey, $dbr->anyString() ), 'page_title >= ' . $dbr->addQuotes( $fromKey ), ), __METHOD__, array( 'ORDER BY' => 'page_title', 'LIMIT' => $this->maxPerPage + 1, 'USE INDEX' => 'name_title', ) ); ### @todo FIXME: Side link to previous $n = 0; if( $res->numRows() > 0 ) { $out = Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-prefixindex-list-table' ) ); while( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { $t = Title::makeTitle( $s->page_namespace, $s->page_title ); if( $t ) { $link = ($s->page_is_redirect ? '
' : '' ) . $sk->linkKnown( $t, htmlspecialchars( $t->getText() ) ) . ($s->page_is_redirect ? '
' : '' ); } else { $link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; } if( $n % 3 == 0 ) { $out .= ''; } $out .= "$link"; $n++; if( $n % 3 == 0 ) { $out .= ''; } } if( ($n % 3) != 0 ) { $out .= ''; } $out .= Xml::closeElement( 'table' ); } else { $out = ''; } } $footer = ''; if ( $this->including() ) { $out2 = ''; } else { $nsForm = $this->namespacePrefixForm( $namespace, $prefix ); $self = $this->getTitle(); $out2 = Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-prefixindex-nav-table' ) ) . ' ' . $nsForm . ' '; if( isset( $res ) && $res && ( $n == $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { $query = array( 'from' => $s->page_title, 'prefix' => $prefix ); if( $namespace ) { $query['namespace'] = $namespace; } $nextLink = Linker::linkKnown( $self, wfMsgHtml( 'nextpage', str_replace( '_',' ', htmlspecialchars( $s->page_title ) ) ), array(), $query ); $out2 .= $nextLink; $footer = "\n" . Html::element( "hr" ) . Html::rawElement( "div", array( "class" => "mw-prefixindex-nav" ), $nextLink ); } $out2 .= "" . Xml::closeElement( 'table' ); } $this->getOutput()->addHTML( $out2 . $out . $footer ); } }