r82414 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82413‎ | r82414 | r82415 >
Date:19:39, 18 February 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Only show pages in approvedrevs namespaces on the special page
Modified paths:
  • /trunk/extensions/ApprovedRevs/ApprovedRevs.hooks.php (modified) (history)
  • /trunk/extensions/ApprovedRevs/ApprovedRevs.php (modified) (history)
  • /trunk/extensions/ApprovedRevs/ApprovedRevs_body.php (modified) (history)
  • /trunk/extensions/ApprovedRevs/README (modified) (history)
  • /trunk/extensions/ApprovedRevs/SpecialApprovedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ApprovedRevs/ApprovedRevs_body.php
@@ -1,4 +1,5 @@
22 <?php
 3+
34 /**
45 * Main class for the Approved Revs extension.
56 *
@@ -7,7 +8,6 @@
89 *
910 * @author Yaron Koren
1011 */
11 -
1212 class ApprovedRevs {
1313 /**
1414 * Gets the approved revision ID for this page, or null if there isn't
Index: trunk/extensions/ApprovedRevs/ApprovedRevs.php
@@ -9,7 +9,7 @@
1010 * @author Yaron Koren
1111 */
1212
13 -define( 'APPROVED_REVS_VERSION', '0.5.5' );
 13+define( 'APPROVED_REVS_VERSION', '0.5.6 alpha' );
1414
1515 // credits
1616 $wgExtensionCredits['other'][] = array(
Index: trunk/extensions/ApprovedRevs/SpecialApprovedRevs.php
@@ -1,13 +1,11 @@
22 <?php
 3+
34 /**
45 * Special page that displays various lists of pages that either do or do
56 * not have an approved revision.
67 *
78 * @author Yaron Koren
89 */
9 -
10 -if ( !defined( 'MEDIAWIKI' ) ) die();
11 -
1210 class SpecialApprovedRevs extends SpecialPage {
1311
1412 /**
@@ -45,7 +43,7 @@
4644 }
4745
4846 function getName() {
49 - return "ApprovedRevs";
 47+ return 'ApprovedRevs';
5048 }
5149
5250 function isExpensive() { return false; }
@@ -114,10 +112,25 @@
115113 function getPageFooter() {
116114 }
117115
 116+ public static function getNsConditionPart( $ns ) {
 117+ return 'p.page_namespace = ' . $ns;
 118+ }
 119+
 120+ /**
 121+ * For compatibility with MW < 1.17.
 122+ *
 123+ * (non-PHPdoc)
 124+ * @see QueryPage::getSQL()
 125+ */
118126 function getSQL() {
 127+ global $egApprovedRevsNamespaces;
 128+
 129+ $nsCond = '(' . implode( ' OR ', array_map( array( __CLASS__, 'getNsConditionPart' ), $egApprovedRevsNamespaces ) ) . ')';
 130+
119131 $dbr = wfGetDB( DB_SLAVE );
120132 $approved_revs = $dbr->tableName( 'approved_revs' );
121133 $page = $dbr->tableName( 'page' );
 134+
122135 if ( $this->mMode == 'notlatest' ) {
123136 return "SELECT 'Page' AS type,
124137 p.page_id AS id,
@@ -125,24 +138,32 @@
126139 p.page_latest AS latest_id
127140 FROM $approved_revs ar JOIN $page p
128141 ON ar.page_id = p.page_id
129 - WHERE p.page_latest != ar.rev_id";
 142+ WHERE p.page_latest != ar.rev_id AND $nsCond";
130143 } elseif ( $this->mMode == 'unapproved' ) {
131144 return "SELECT 'Page' AS type,
132145 p.page_id AS id
133146 FROM $approved_revs ar RIGHT OUTER JOIN $page p
134147 ON ar.page_id = p.page_id
135 - WHERE ar.page_id IS NULL";
 148+ WHERE ar.page_id IS NULL AND $nsCond";
136149 } else { // all approved pages
137150 return "SELECT 'Page' AS type,
138151 p.page_id AS id,
139152 ar.rev_id AS rev_id,
140153 p.page_latest AS latest_id
141154 FROM $approved_revs ar JOIN $page p
142 - ON ar.page_id = p.page_id";
 155+ ON ar.page_id = p.page_id AND $nsCond";
143156 }
144157 }
145158
 159+ /**
 160+ * Used as of MW 1.17.
 161+ *
 162+ * (non-PHPdoc)
 163+ * @see QueryPage::getSQL()
 164+ */
146165 function getQueryInfo() {
 166+ global $egApprovedRevsNamespaces;
 167+
147168 if ( $this->mMode == 'notlatest' ) {
148169 return array(
149170 'tables' => array( 'ar' => 'approved_revs', 'p' => 'page' ),
@@ -156,7 +177,10 @@
157178 'JOIN', 'ar.page_id=p.page_id'
158179 )
159180 ),
160 - 'conds' => array( 'p.page_latest != ar.rev_id')
 181+ 'conds' => array(
 182+ 'p.page_latest != ar.rev_id',
 183+ 'p.page_namespace' => $egApprovedRevsNamespaces
 184+ )
161185 );
162186 } elseif ( $this->mMode == 'unapproved' ) {
163187 return array(
@@ -167,7 +191,10 @@
168192 'RIGHT OUTER JOIN', 'ar.page_id=p.page_id'
169193 )
170194 ),
171 - 'conds' => array( "ar.page_id IS NULL" )
 195+ 'conds' => array(
 196+ 'ar.page_id IS NULL',
 197+ 'p.page_namespace' => $egApprovedRevsNamespaces
 198+ )
172199 );
173200 } else { // all approved pages
174201 return array(
@@ -179,7 +206,8 @@
180207 ),
181208 'join_conds' => array(
182209 'p' => array(
183 - 'JOIN', 'ar.page_id=p.page_id'
 210+ 'JOIN', 'ar.page_id=p.page_id',
 211+ 'p.page_namespace' => $egApprovedRevsNamespaces
184212 )
185213 ),
186214 );
@@ -197,6 +225,7 @@
198226 function formatResult( $skin, $result ) {
199227 $title = Title::newFromId( $result->id );
200228 $pageLink = $skin->makeLinkObj( $title );
 229+
201230 if ( $this->mMode == 'unapproved' ) {
202231 return $pageLink;
203232 } elseif ( $this->mMode == 'notlatest' ) {
@@ -209,14 +238,17 @@
210239 ) ),
211240 wfMsg( 'approvedrevs-difffromlatest' )
212241 );
 242+
213243 return "$pageLink ($diffLink)";
214244 } else {
215245 global $wgUser, $wgOut, $wgLang;
 246+
216247 if ( $result->rev_id == $result->latest_id ) {
217248 $class = "approvedRevIsLatest";
218249 } else {
219250 $class = "approvedRevNotLatest";
220251 }
 252+
221253 $additionalInfo = Xml::element( 'span',
222254 array ( 'class' => $class ),
223255 wfMsg( 'approvedrevs-revisionnumber', $result->rev_id )
@@ -230,12 +262,15 @@
231263 $pager->mLimit = 1;
232264 $pager->doQuery();
233265 $row = $pager->mResult->fetchObject();
 266+
234267 if ( !empty( $row ) ) {
235268 $time = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->log_timestamp ), true );
236269 $userLink = $sk->userLink( $row->log_user, $row->user_name );
237270 $additionalInfo .= ', ' . wfMsg( 'approvedrevs-approvedby', $userLink, $time );
238271 }
 272+
239273 return "$pageLink ($additionalInfo)";
240274 }
241275 }
 276+
242277 }
Index: trunk/extensions/ApprovedRevs/ApprovedRevs.hooks.php
@@ -9,7 +9,6 @@
1010 *
1111 * @author Yaron Koren
1212 */
13 -
1413 class ApprovedRevsHooks {
1514
1615 /**
Index: trunk/extensions/ApprovedRevs/README
@@ -1,6 +1,6 @@
22 Approved Revs Extension
33
4 - Version 0.5.5
 4+ Version 0.5.6
55 Yaron Koren
66
77 This is free software licensed under the GNU General Public License. Please

Status & tagging log