Convert SpecialListusers to subclass SpecialPage. Only two left now!
[lhc/web/wiklou.git] / includes / specials / SpecialAllpages.php
index 3f52f47..64c1db5 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 /**
+ * Implements Special:Allpages
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
  */
+
 /**
- * implements Special:Allpages
+ * Implements Special:Allpages
+ *
  * @ingroup SpecialPage
  */
 class SpecialAllpages extends IncludableSpecialPage {
@@ -57,6 +62,7 @@ class SpecialAllpages extends IncludableSpecialPage {
 
                $this->setHeaders();
                $this->outputHeader();
+               $wgOut->allowClickjacking();
 
                # GET values
                $from = $wgRequest->getVal( 'from', null );
@@ -65,11 +71,12 @@ class SpecialAllpages extends IncludableSpecialPage {
 
                $namespaces = $wgContLang->getNamespaces();
 
-               $wgOut->setPagetitle( 
+               $wgOut->setPagetitle(
                        ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces) ) ) ?
                        wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) :
                        wfMsg( 'allarticles' )
                );
+               $wgOut->addModuleStyles( 'mediawiki.special' );
 
                if( isset($par) ) {
                        $this->showChunk( $namespace, $par, $to );
@@ -90,10 +97,10 @@ class SpecialAllpages extends IncludableSpecialPage {
        function namespaceForm( $namespace = NS_MAIN, $from = '', $to = '' ) {
                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 .= 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' ) );
@@ -183,7 +190,8 @@ class SpecialAllpages extends IncludableSpecialPage {
                                        array ('LIMIT' => 2, 'OFFSET' => $maxPerSubpage - 1, 'ORDER BY' => 'page_title ASC')
                                );
 
-                               if( $s = $dbr->fetchObject( $res ) ) {
+                               $s = $dbr->fetchObject( $res );
+                               if( $s ) {
                                        array_push( $lines, $s->page_title );
                                } else {
                                        // Final chunk, but ended prematurely. Go back and find the end.
@@ -193,7 +201,8 @@ class SpecialAllpages extends IncludableSpecialPage {
                                        array_push( $lines, $endTitle );
                                        $done = true;
                                }
-                               if( $s = $res->fetchObject() ) {
+                               $s = $res->fetchObject();
+                               if( $s ) {
                                        array_push( $lines, $s->page_title );
                                        $lastTitle = $s->page_title;
                                } else {
@@ -293,14 +302,14 @@ class SpecialAllpages extends IncludableSpecialPage {
                $n = 0;
 
                if ( !$fromList || !$toList ) {
-                       $out = wfMsgWikiHtml( 'allpagesbadtitle' );
+                       $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, $fromKey, $from ) = $fromList;
-                       list( $namespace2, $toKey, $to ) = $toList;
+                       list( , $toKey, $to ) = $toList;
 
                        $dbr = wfGetDB( DB_SLAVE );
                        $conds = array(
@@ -312,7 +321,7 @@ class SpecialAllpages extends IncludableSpecialPage {
                        }
 
                        $res = $dbr->select( 'page',
-                               array( 'page_namespace', 'page_title', 'page_is_redirect' ),
+                               array( 'page_namespace', 'page_title', 'page_is_redirect', 'page_id' ),
                                $conds,
                                __METHOD__,
                                array(
@@ -325,10 +334,10 @@ class SpecialAllpages extends IncludableSpecialPage {
                        if( $res->numRows() > 0 ) {
                                $out = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-chunk' ) );
                                while( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
-                                       $t = Title::makeTitle( $s->page_namespace, $s->page_title );
+                                       $t = Title::newFromRow( $s );
                                        if( $t ) {
                                                $link = ( $s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
-                                                       $sk->linkKnown( $t, htmlspecialchars( $t->getText() ) ) .
+                                                       $sk->link( $t ) .
                                                        ($s->page_is_redirect ? '</div>' : '' );
                                        } else {
                                                $link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
@@ -365,7 +374,7 @@ class SpecialAllpages extends IncludableSpecialPage {
                                        'page_title',
                                        array( 'page_namespace' => $namespace, 'page_title < '.$dbr->addQuotes($from) ),
                                        __METHOD__,
-                                       array( 'ORDER BY' => 'page_title DESC', 
+                                       array( 'ORDER BY' => 'page_title DESC',
                                                'LIMIT' => $this->maxPerPage, 'OFFSET' => ($this->maxPerPage - 1 )
                                        )
                                );
@@ -401,7 +410,7 @@ class SpecialAllpages extends IncludableSpecialPage {
                                                                $nsForm .
                                                        '</td>
                                                        <td class="mw-allpages-nav">' .
-                                                               $sk->link( $self, wfMsgHtml ( 'allpages' ), array(), array(), 'known' );
+                                                               $sk->link( $self, wfMsgHtml ( 'allpages' ) );
 
                        # Do we put a previous link ?
                        if( isset( $prevTitle ) &&  $pt = $prevTitle->getText() ) {
@@ -412,7 +421,7 @@ class SpecialAllpages extends IncludableSpecialPage {
 
                                $prevLink = $sk->linkKnown(
                                        $self,
-                                       htmlspecialchars( wfMsg( 'prevpage', $pt ) ),
+                                       wfMessage( 'prevpage', $pt )->escaped(),
                                        array(),
                                        $query
                                );
@@ -429,7 +438,7 @@ class SpecialAllpages extends IncludableSpecialPage {
 
                                $nextLink = $sk->linkKnown(
                                        $self,
-                                       htmlspecialchars( wfMsg( 'nextpage', $t->getText() ) ),
+                                       wfMessage( 'nextpage', $t->getText() )->escaped(),
                                        array(),
                                        $query
                                );
@@ -439,19 +448,17 @@ class SpecialAllpages extends IncludableSpecialPage {
                }
 
                $wgOut->addHTML( $out2 . $out );
-               if( isset($prevLink) or isset($nextLink) ) {
-                       $wgOut->addHTML( '<hr /><p class="mw-allpages-nav">' );
-                       if( isset( $prevLink ) ) {
-                               $wgOut->addHTML( $prevLink );
-                       }
-                       if( isset( $prevLink ) && isset( $nextLink ) ) {
-                               $wgOut->addHTML( wfMsgExt( 'pipe-separator' , 'escapenoentities' ) );
-                       }
-                       if( isset( $nextLink ) ) {
-                               $wgOut->addHTML( $nextLink );
-                       }
-                       $wgOut->addHTML( '</p>' );
 
+               $links = array();
+               if ( isset( $prevLink ) ) $links[] = $prevLink;
+               if ( isset( $nextLink ) ) $links[] = $nextLink;
+
+               if ( count( $links ) ) {
+                       $wgOut->addHTML(
+                               Html::element( 'hr' ) .
+                               Html::rawElement( 'div', array( 'class' => 'mw-allpages-nav' ),
+                                       $wgLang->pipeList( $links )
+                               ) );
                }
 
        }