Merge "(bug 43915) Implement deleteEqualMessages.php"
[lhc/web/wiklou.git] / includes / specials / SpecialNewpages.php
index 1798e8f..053c015 100644 (file)
@@ -105,7 +105,7 @@ class SpecialNewpages extends IncludableSpecialPage {
                        }
                        // PG offsets not just digits!
                        if ( preg_match( '/^offset=([^=]+)$/', $bit, $m ) ) {
-                               $this->opts->setValue( 'offset',  intval( $m[1] ) );
+                               $this->opts->setValue( 'offset', intval( $m[1] ) );
                        }
                        if ( preg_match( '/^username=(.*)$/', $bit, $m ) ) {
                                $this->opts->setValue( 'username', $m[1] );
@@ -113,7 +113,7 @@ class SpecialNewpages extends IncludableSpecialPage {
                        if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
                                $ns = $this->getLanguage()->getNsIndex( $m[1] );
                                if( $ns !== false ) {
-                                       $this->opts->setValue( 'namespace',  $ns );
+                                       $this->opts->setValue( 'namespace', $ns );
                                }
                        }
                }
@@ -140,12 +140,13 @@ class SpecialNewpages extends IncludableSpecialPage {
 
                        $feedType = $this->opts->getValue( 'feed' );
                        if( $feedType ) {
-                               return $this->feed( $feedType );
+                               $this->feed( $feedType );
+                               return;
                        }
 
                        $allValues = $this->opts->getAllValues();
                        unset( $allValues['feed'] );
-                       $out->setFeedAppendQuery( wfArrayToCGI( $allValues ) );
+                       $out->setFeedAppendQuery( wfArrayToCgi( $allValues ) );
                }
 
                $pager = new NewPagesPager( $this, $this->opts );
@@ -164,8 +165,6 @@ class SpecialNewpages extends IncludableSpecialPage {
        }
 
        protected function filterLinks() {
-               global $wgGroupPermissions;
-
                // show/hide links
                $showhide = array( $this->msg( 'show' )->escaped(), $this->msg( 'hide' )->escaped() );
 
@@ -181,8 +180,7 @@ class SpecialNewpages extends IncludableSpecialPage {
                }
 
                // Disable some if needed
-               # @todo FIXME: Throws E_NOTICEs if not set; and doesn't obey hooks etc.
-               if ( $wgGroupPermissions['*']['createpage'] !== true ) {
+               if ( !User::groupHasPermission( '*', 'createpage' ) ) {
                        unset( $filters['hideliu'] );
                }
                if ( !$this->getUser()->useNPPatrol() ) {
@@ -328,12 +326,13 @@ class SpecialNewpages extends IncludableSpecialPage {
                        $query['rcid'] = $result->rc_id;
                }
 
-               $plink = Linker::linkKnown(
+               // Linker::linkKnown() uses 'known' and 'noclasses' options. This breaks the colouration for stubs.
+               $plink = Linker::link(
                        $title,
                        null,
                        array( 'class' => 'mw-newpages-pagename' ),
                        $query,
-                       array( 'known' ) // Set explicitly to avoid the default of 'known','noclasses'. This breaks the colouration for stubs
+                       array( 'known' )
                );
                $histLink = Linker::linkKnown(
                        $title,
@@ -360,8 +359,8 @@ class SpecialNewpages extends IncludableSpecialPage {
                        $classes[] = 'mw-newpages-zero-byte-page';
                }
 
-               # Tags, if any. check for including due to bug 23293
-               if ( !$this->including() ) {
+               # Tags, if any.
+               if( isset( $result->ts_tags ) ) {
                        list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow( $result->ts_tags, 'newpages' );
                        $classes = array_merge( $classes, $newClasses );
                } else {
@@ -459,11 +458,12 @@ class SpecialNewpages extends IncludableSpecialPage {
        protected function feedItemDesc( $row ) {
                $revision = Revision::newFromId( $row->rev_id );
                if( $revision ) {
+                       //XXX: include content model/type in feed item?
                        return '<p>' . htmlspecialchars( $revision->getUserText() ) .
                                $this->msg( 'colon-separator' )->inContentLanguage()->escaped() .
                                htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
                                "</p>\n<hr />\n<div>" .
-                               nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
+                               nl2br( htmlspecialchars( $revision->getContent()->serialize() ) ) . "</div>";
                }
                return '';
        }
@@ -488,7 +488,7 @@ class NewPagesPager extends ReverseChronologicalPager {
        }
 
        function getQueryInfo() {
-               global $wgEnableNewpagesUserFilter, $wgGroupPermissions;
+               global $wgEnableNewpagesUserFilter;
                $conds = array();
                $conds['rc_new'] = 1;
 
@@ -510,7 +510,7 @@ class NewPagesPager extends ReverseChronologicalPager {
                        $conds['rc_user_text'] = $user->getText();
                        $rcIndexes = 'rc_user_text';
                # If anons cannot make new pages, don't "exclude logged in users"!
-               } elseif( $wgGroupPermissions['*']['createpage'] && $this->opts->getValue( 'hideliu' ) ) {
+               } elseif( User::groupHasPermission( '*', 'createpage' ) && $this->opts->getValue( 'hideliu' ) ) {
                        $conds['rc_user'] = 0;
                }
                # If this user cannot see patrolled edits or they are off, don't do dumb queries!
@@ -530,7 +530,7 @@ class NewPagesPager extends ReverseChronologicalPager {
                $fields = array(
                        'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user', 'rc_user_text',
                        'rc_comment', 'rc_timestamp', 'rc_patrolled','rc_id', 'rc_deleted',
-                       'page_len AS length', 'page_latest AS rev_id', 'ts_tags', 'rc_this_oldid',
+                       'length' => 'page_len', 'rev_id' => 'page_latest', 'rc_this_oldid',
                        'page_namespace', 'page_title'
                );
                $join_conds = array( 'page' => array( 'INNER JOIN', 'page_id=rc_cur_id' ) );
@@ -546,13 +546,10 @@ class NewPagesPager extends ReverseChronologicalPager {
                        'join_conds' => $join_conds
                );
 
-               // Empty array for fields, it'll be set by us anyway.
-               $fields = array();
-
                // Modify query for tags
                ChangeTags::modifyDisplayQuery(
                        $info['tables'],
-                       $fields,
+                       $info['fields'],
                        $info['conds'],
                        $info['join_conds'],
                        $info['options'],