Index: trunk/extensions/ApprovedRevs/ApprovedRevs_body.php |
— | — | @@ -1,4 +1,5 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * Main class for the Approved Revs extension. |
5 | 6 | * |
— | — | @@ -7,7 +8,6 @@ |
8 | 9 | * |
9 | 10 | * @author Yaron Koren |
10 | 11 | */ |
11 | | - |
12 | 12 | class ApprovedRevs { |
13 | 13 | /** |
14 | 14 | * Gets the approved revision ID for this page, or null if there isn't |
Index: trunk/extensions/ApprovedRevs/ApprovedRevs.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | * @author Yaron Koren |
11 | 11 | */ |
12 | 12 | |
13 | | -define( 'APPROVED_REVS_VERSION', '0.5.5' ); |
| 13 | +define( 'APPROVED_REVS_VERSION', '0.5.6 alpha' ); |
14 | 14 | |
15 | 15 | // credits |
16 | 16 | $wgExtensionCredits['other'][] = array( |
Index: trunk/extensions/ApprovedRevs/SpecialApprovedRevs.php |
— | — | @@ -1,13 +1,11 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * Special page that displays various lists of pages that either do or do |
5 | 6 | * not have an approved revision. |
6 | 7 | * |
7 | 8 | * @author Yaron Koren |
8 | 9 | */ |
9 | | - |
10 | | -if ( !defined( 'MEDIAWIKI' ) ) die(); |
11 | | - |
12 | 10 | class SpecialApprovedRevs extends SpecialPage { |
13 | 11 | |
14 | 12 | /** |
— | — | @@ -45,7 +43,7 @@ |
46 | 44 | } |
47 | 45 | |
48 | 46 | function getName() { |
49 | | - return "ApprovedRevs"; |
| 47 | + return 'ApprovedRevs'; |
50 | 48 | } |
51 | 49 | |
52 | 50 | function isExpensive() { return false; } |
— | — | @@ -114,10 +112,25 @@ |
115 | 113 | function getPageFooter() { |
116 | 114 | } |
117 | 115 | |
| 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 | + */ |
118 | 126 | function getSQL() { |
| 127 | + global $egApprovedRevsNamespaces; |
| 128 | + |
| 129 | + $nsCond = '(' . implode( ' OR ', array_map( array( __CLASS__, 'getNsConditionPart' ), $egApprovedRevsNamespaces ) ) . ')'; |
| 130 | + |
119 | 131 | $dbr = wfGetDB( DB_SLAVE ); |
120 | 132 | $approved_revs = $dbr->tableName( 'approved_revs' ); |
121 | 133 | $page = $dbr->tableName( 'page' ); |
| 134 | + |
122 | 135 | if ( $this->mMode == 'notlatest' ) { |
123 | 136 | return "SELECT 'Page' AS type, |
124 | 137 | p.page_id AS id, |
— | — | @@ -125,24 +138,32 @@ |
126 | 139 | p.page_latest AS latest_id |
127 | 140 | FROM $approved_revs ar JOIN $page p |
128 | 141 | 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"; |
130 | 143 | } elseif ( $this->mMode == 'unapproved' ) { |
131 | 144 | return "SELECT 'Page' AS type, |
132 | 145 | p.page_id AS id |
133 | 146 | FROM $approved_revs ar RIGHT OUTER JOIN $page p |
134 | 147 | ON ar.page_id = p.page_id |
135 | | - WHERE ar.page_id IS NULL"; |
| 148 | + WHERE ar.page_id IS NULL AND $nsCond"; |
136 | 149 | } else { // all approved pages |
137 | 150 | return "SELECT 'Page' AS type, |
138 | 151 | p.page_id AS id, |
139 | 152 | ar.rev_id AS rev_id, |
140 | 153 | p.page_latest AS latest_id |
141 | 154 | 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"; |
143 | 156 | } |
144 | 157 | } |
145 | 158 | |
| 159 | + /** |
| 160 | + * Used as of MW 1.17. |
| 161 | + * |
| 162 | + * (non-PHPdoc) |
| 163 | + * @see QueryPage::getSQL() |
| 164 | + */ |
146 | 165 | function getQueryInfo() { |
| 166 | + global $egApprovedRevsNamespaces; |
| 167 | + |
147 | 168 | if ( $this->mMode == 'notlatest' ) { |
148 | 169 | return array( |
149 | 170 | 'tables' => array( 'ar' => 'approved_revs', 'p' => 'page' ), |
— | — | @@ -156,7 +177,10 @@ |
157 | 178 | 'JOIN', 'ar.page_id=p.page_id' |
158 | 179 | ) |
159 | 180 | ), |
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 | + ) |
161 | 185 | ); |
162 | 186 | } elseif ( $this->mMode == 'unapproved' ) { |
163 | 187 | return array( |
— | — | @@ -167,7 +191,10 @@ |
168 | 192 | 'RIGHT OUTER JOIN', 'ar.page_id=p.page_id' |
169 | 193 | ) |
170 | 194 | ), |
171 | | - 'conds' => array( "ar.page_id IS NULL" ) |
| 195 | + 'conds' => array( |
| 196 | + 'ar.page_id IS NULL', |
| 197 | + 'p.page_namespace' => $egApprovedRevsNamespaces |
| 198 | + ) |
172 | 199 | ); |
173 | 200 | } else { // all approved pages |
174 | 201 | return array( |
— | — | @@ -179,7 +206,8 @@ |
180 | 207 | ), |
181 | 208 | 'join_conds' => array( |
182 | 209 | 'p' => array( |
183 | | - 'JOIN', 'ar.page_id=p.page_id' |
| 210 | + 'JOIN', 'ar.page_id=p.page_id', |
| 211 | + 'p.page_namespace' => $egApprovedRevsNamespaces |
184 | 212 | ) |
185 | 213 | ), |
186 | 214 | ); |
— | — | @@ -197,6 +225,7 @@ |
198 | 226 | function formatResult( $skin, $result ) { |
199 | 227 | $title = Title::newFromId( $result->id ); |
200 | 228 | $pageLink = $skin->makeLinkObj( $title ); |
| 229 | + |
201 | 230 | if ( $this->mMode == 'unapproved' ) { |
202 | 231 | return $pageLink; |
203 | 232 | } elseif ( $this->mMode == 'notlatest' ) { |
— | — | @@ -209,14 +238,17 @@ |
210 | 239 | ) ), |
211 | 240 | wfMsg( 'approvedrevs-difffromlatest' ) |
212 | 241 | ); |
| 242 | + |
213 | 243 | return "$pageLink ($diffLink)"; |
214 | 244 | } else { |
215 | 245 | global $wgUser, $wgOut, $wgLang; |
| 246 | + |
216 | 247 | if ( $result->rev_id == $result->latest_id ) { |
217 | 248 | $class = "approvedRevIsLatest"; |
218 | 249 | } else { |
219 | 250 | $class = "approvedRevNotLatest"; |
220 | 251 | } |
| 252 | + |
221 | 253 | $additionalInfo = Xml::element( 'span', |
222 | 254 | array ( 'class' => $class ), |
223 | 255 | wfMsg( 'approvedrevs-revisionnumber', $result->rev_id ) |
— | — | @@ -230,12 +262,15 @@ |
231 | 263 | $pager->mLimit = 1; |
232 | 264 | $pager->doQuery(); |
233 | 265 | $row = $pager->mResult->fetchObject(); |
| 266 | + |
234 | 267 | if ( !empty( $row ) ) { |
235 | 268 | $time = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->log_timestamp ), true ); |
236 | 269 | $userLink = $sk->userLink( $row->log_user, $row->user_name ); |
237 | 270 | $additionalInfo .= ', ' . wfMsg( 'approvedrevs-approvedby', $userLink, $time ); |
238 | 271 | } |
| 272 | + |
239 | 273 | return "$pageLink ($additionalInfo)"; |
240 | 274 | } |
241 | 275 | } |
| 276 | + |
242 | 277 | } |
Index: trunk/extensions/ApprovedRevs/ApprovedRevs.hooks.php |
— | — | @@ -9,7 +9,6 @@ |
10 | 10 | * |
11 | 11 | * @author Yaron Koren |
12 | 12 | */ |
13 | | - |
14 | 13 | class ApprovedRevsHooks { |
15 | 14 | |
16 | 15 | /** |
Index: trunk/extensions/ApprovedRevs/README |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | Approved Revs Extension |
3 | 3 | |
4 | | - Version 0.5.5 |
| 4 | + Version 0.5.6 |
5 | 5 | Yaron Koren |
6 | 6 | |
7 | 7 | This is free software licensed under the GNU General Public License. Please |