Index: trunk/extensions/RefreshSpecial/RefreshSpecial.body.php |
— | — | @@ -3,8 +3,8 @@ |
4 | 4 | * Protect against register_globals vulnerabilities. |
5 | 5 | * This line must be present before any global variable is referenced. |
6 | 6 | */ |
7 | | -if ( ! defined( 'MEDIAWIKI' ) ) |
8 | | - die(); |
| 7 | +if ( !defined( 'MEDIAWIKI' ) ) |
| 8 | + die( "This is not a valid entry point.\n" ); |
9 | 9 | |
10 | 10 | require_once("QueryPage.php"); //sigh, this line has to be there so that the extension works |
11 | 11 | |
— | — | @@ -25,15 +25,28 @@ |
26 | 26 | public function execute( $par ) { |
27 | 27 | global $wgOut, $wgUser, $wgRequest; |
28 | 28 | |
29 | | - wfLoadExtensionMessages('RefreshSpecial'); |
| 29 | + wfLoadExtensionMessages( 'RefreshSpecial' ); |
30 | 30 | |
31 | | - $wgOut->setPageTitle( wfMsg('refreshspecial-title') ); |
| 31 | + $wgOut->setPageTitle( wfMsg( 'refreshspecial-title' ) ); |
32 | 32 | |
33 | | - if( !$wgUser->isAllowed('refreshspecial') ) { |
| 33 | + # If the user doesn't have the required permission, display an error |
| 34 | + if( !$wgUser->isAllowed( 'refreshspecial' ) ) { |
34 | 35 | $wgOut->permissionRequired( 'refreshspecial' ); |
35 | 36 | return; |
36 | 37 | } |
37 | 38 | |
| 39 | + # Show a message if the database is in read-only mode |
| 40 | + if ( wfReadOnly() ) { |
| 41 | + $wgOut->readOnlyPage(); |
| 42 | + return; |
| 43 | + } |
| 44 | + |
| 45 | + # If user is blocked, s/he doesn't need to access this page |
| 46 | + if ( $wgUser->isBlocked() ) { |
| 47 | + $wgOut->blockedPage(); |
| 48 | + return; |
| 49 | + } |
| 50 | + |
38 | 51 | $cSF = new RefreshSpecialForm(); |
39 | 52 | |
40 | 53 | $action = $wgRequest->getVal( 'action' ); |
— | — | @@ -42,10 +55,10 @@ |
43 | 56 | } else if( 'failure' == $action ) { |
44 | 57 | $cSF->showForm( wfMsg('refreshspecial-fail') ); |
45 | 58 | } else if( $wgRequest->wasPosted() && 'submit' == $action && |
46 | | - $wgUser->matchEditToken( $wgRequest->getVal('wpEditToken') ) ) { |
| 59 | + $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
47 | 60 | $cSF->doSubmit(); |
48 | 61 | } else { |
49 | | - $cSF->showForm(''); |
| 62 | + $cSF->showForm( '' ); |
50 | 63 | } |
51 | 64 | } |
52 | 65 | } |
— | — | @@ -63,11 +76,11 @@ |
64 | 77 | * @param $err string Error message if there was an error, otherwise null |
65 | 78 | */ |
66 | 79 | function showForm( $err ) { |
67 | | - global $wgOut, $wgUser, $wgRequest, $wgQueryPages; |
| 80 | + global $wgOut, $wgUser, $wgRequest, $wgScriptPath, $wgQueryPages; |
68 | 81 | |
69 | 82 | $token = htmlspecialchars( $wgUser->editToken() ); |
70 | 83 | $titleObj = SpecialPage::getTitleFor( 'RefreshSpecial' ); |
71 | | - $action = $titleObj->escapeLocalURL( "action=submit" ); |
| 84 | + $action = $titleObj->escapeLocalURL( 'action=submit' ); |
72 | 85 | |
73 | 86 | if ( '' != $err ) { |
74 | 87 | $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) ); |
— | — | @@ -76,9 +89,11 @@ |
77 | 90 | |
78 | 91 | $wgOut->addWikiMsg( 'refreshspecial-help' ); |
79 | 92 | |
80 | | - ( 'submit' == $wgRequest->getVal( 'action' ) ) ? $scLink = htmlspecialchars($this->mLink) : $scLink = ''; |
| 93 | + ( 'submit' == $wgRequest->getVal( 'action' ) ) ? $scLink = htmlspecialchars( $this->mLink ) : $scLink = ''; |
81 | 94 | |
82 | | - $wgOut->addHTML("<form name=\"RefreshSpecial\" method=\"post\" action=\"{$action}\"><ul>"); |
| 95 | + $wgOut->addScriptFile( $wgScriptPath . '/extensions/RefreshSpecial/RefreshSpecial.js' ); |
| 96 | + $wgOut->addHTML( "<form name=\"RefreshSpecial\" method=\"post\" action=\"{$action}\"> |
| 97 | + <ul>\n" ); |
83 | 98 | |
84 | 99 | /** |
85 | 100 | * List pages right here |
— | — | @@ -88,48 +103,38 @@ |
89 | 104 | * that brings up an interesting question - do we need that limit or not? |
90 | 105 | */ |
91 | 106 | foreach ( $wgQueryPages as $page ) { |
92 | | - @list( $class, $special, $limit ) = $page; |
| 107 | + @list( $class, $special, $limit ) = $page; |
93 | 108 | |
94 | | - $specialObj = SpecialPage::getPage( $special ); |
95 | | - if ( !$specialObj ) { |
96 | | - $wgOut->addWikiText( wfMsg('refreshspecial-no-page') . " $special\n" ); |
97 | | - exit; |
98 | | - } |
99 | | - $file = $specialObj->getFile(); |
100 | | - if ( $file ) { |
101 | | - require_once( $file ); |
102 | | - } |
103 | | - $queryPage = new $class; |
104 | | - $checked = ''; |
| 109 | + $specialObj = SpecialPage::getPage( $special ); |
| 110 | + if ( !$specialObj ) { |
| 111 | + $wgOut->addWikiText( wfMsg( 'refreshspecial-no-page' ) . " $special\n" ); |
| 112 | + exit; |
| 113 | + } |
| 114 | + $file = $specialObj->getFile(); |
| 115 | + if ( $file ) { |
| 116 | + require_once( $file ); |
| 117 | + } |
| 118 | + $queryPage = new $class; |
| 119 | + $checked = ''; |
105 | 120 | if ( $queryPage->isExpensive() ) { |
106 | | - $checked = "checked=\"checked\""; |
107 | | - $wgOut->addHTML("<li> |
108 | | - <input type=\"checkbox\" name=\"wpSpecial[]\" value=\"$special\" $checked /> |
| 121 | + $checked = 'checked="checked"'; |
| 122 | + $wgOut->addHTML("\t\t\t\t\t<li> |
| 123 | + <input type=\"checkbox\" name=\"wpSpecial[]\" value=\"$special\" $checked /> |
109 | 124 | <b>$special</b> |
110 | | - </li>"); |
| 125 | + </li>\n"); |
111 | 126 | } |
112 | 127 | } |
113 | 128 | |
114 | | - $wgOut->addHTML("<li> |
115 | | - <input type=\"checkbox\" name=\"check_all\" id=\"refreshSpecialCheckAll\" onclick=\"refreshSpecialCheck(this.form);\" /><label for=\"refreshSpecialCheckAll\"> " . wfMsg ( 'refreshspecial-select-all-pages' ) . " |
116 | | - <noscript>" . wfMsg ( 'refreshspecial-js-disabled' ) . " |
117 | | - </noscript>" ); |
118 | | - $wgOut->addHTML("</label> |
119 | | - </li> |
120 | | - <script type=\"text/javascript\"> |
121 | | - function refreshSpecialCheck( form ) { |
122 | | - pattern = document.getElementById('refreshSpecialCheckAll').checked; |
123 | | - for( i = 0; i < form.elements.length; i++ ) { |
124 | | - if( form.elements[i].type == 'checkbox' && form.elements[i].name != 'check_all' ) { |
125 | | - form.elements[i].checked = pattern; |
126 | | - } |
127 | | - } |
128 | | - } |
129 | | - </script> |
130 | | - </ul> |
131 | | - <input tabindex=\"5\" name=\"wpRefreshSpecialSubmit\" type=\"submit\" value=\"".wfMsg('refreshspecial-button')."\" /> |
132 | | - <input type='hidden' name='wpEditToken' value=\"{$token}\" /> |
133 | | - </form>"); |
| 129 | + $wgOut->addHTML( "\t\t\t\t\t" . '<li> |
| 130 | + <input type="checkbox" name="check_all" id="refreshSpecialCheckAll" onclick="refreshSpecialCheck(this.form);" /> |
| 131 | + <label for="refreshSpecialCheckAll"> ' . wfMsg( 'refreshspecial-select-all-pages' ) . ' |
| 132 | + <noscript>' . wfMsg( 'refreshspecial-js-disabled' ) . '</noscript> |
| 133 | + </label> |
| 134 | + </li> |
| 135 | + </ul> |
| 136 | + <input tabindex="5" name="wpRefreshSpecialSubmit" type="submit" value="'. wfMsg( 'refreshspecial-button' ). '" /> |
| 137 | + <input type="hidden" name="wpEditToken" value="'. $token .'" /> |
| 138 | + </form>' . "\n" ); |
134 | 139 | } |
135 | 140 | |
136 | 141 | /** |
— | — | @@ -138,7 +143,7 @@ |
139 | 144 | * @param $amount int |
140 | 145 | * @return array Amount of elapsed time |
141 | 146 | */ |
142 | | - function compute_time($amount) { |
| 147 | + function computeTime( $amount ) { |
143 | 148 | $return_array = array(); |
144 | 149 | $return_array['hours'] = intval( $amount / 3600 ); |
145 | 150 | $return_array['minutes'] = intval( $amount % 3600 / 60 ); |
— | — | @@ -153,7 +158,7 @@ |
154 | 159 | * @param $message mixed Message displayed to the user containing the elapsed time |
155 | 160 | * @return true |
156 | 161 | */ |
157 | | - function format_time_message( $time, &$message ) { |
| 162 | + function formatTimeMessage( $time, &$message ) { |
158 | 163 | if ( $time['hours'] ) { |
159 | 164 | $message .= $time['hours'] . 'h '; |
160 | 165 | } |
— | — | @@ -172,12 +177,12 @@ |
173 | 178 | global $wgRequest, $wgQueryPages, $wgOut; |
174 | 179 | $dbw = wfGetDB( DB_MASTER ); |
175 | 180 | $to_refresh = $wgRequest->getArray( 'wpSpecial' ); |
176 | | - $total = array ( |
177 | | - 'pages' => 0, |
178 | | - 'rows' => 0, |
179 | | - 'elapsed' => 0, |
180 | | - 'total_elapsed' => 0 |
181 | | - ); |
| 181 | + $total = array( |
| 182 | + 'pages' => 0, |
| 183 | + 'rows' => 0, |
| 184 | + 'elapsed' => 0, |
| 185 | + 'total_elapsed' => 0 |
| 186 | + ); |
182 | 187 | |
183 | 188 | foreach ( $wgQueryPages as $page ) { |
184 | 189 | @list( $class, $special, $limit ) = $page; |
— | — | @@ -187,7 +192,7 @@ |
188 | 193 | |
189 | 194 | $specialObj = SpecialPage::getPage( $special ); |
190 | 195 | if ( !$specialObj ) { |
191 | | - $wgOut->addWikiText( wfMsg('refreshspecial-no-page').": $special\n"); |
| 196 | + $wgOut->addWikiText( wfMsg( 'refreshspecial-no-page' ).": $special\n" ); |
192 | 197 | exit; |
193 | 198 | } |
194 | 199 | $file = $specialObj->getFile(); |
— | — | @@ -198,7 +203,7 @@ |
199 | 204 | |
200 | 205 | $message = ''; |
201 | 206 | if( !( isset( $options['only'] ) ) or ( $options['only'] == $queryPage->getName() ) ) { |
202 | | - $wgOut->addHTML("<b>$special</b>: "); |
| 207 | + $wgOut->addHTML( "<b>$special</b>: " ); |
203 | 208 | |
204 | 209 | if ( $queryPage->isExpensive() ) { |
205 | 210 | $t1 = explode( ' ', microtime() ); |
— | — | @@ -207,28 +212,28 @@ |
208 | 213 | $t2 = explode( ' ', microtime() ); |
209 | 214 | |
210 | 215 | if ( $num === false ) { |
211 | | - $wgOut->addHTML( wfMsg('refreshspecial-db-error') . "<br />" ); |
| 216 | + $wgOut->addHTML( wfMsg( 'refreshspecial-db-error' ) . '<br />' ); |
212 | 217 | } else { |
213 | | - $message = wfMsgExt( 'refreshspecial-page-result', array( 'escape', 'parsemag' ), $num ) . " "; |
214 | | - $elapsed = ($t2[0] - $t1[0]) + ($t2[1] - $t1[1]); |
| 218 | + $message = wfMsgExt( 'refreshspecial-page-result', array( 'escape', 'parsemag' ), $num ) . ' '; |
| 219 | + $elapsed = ( $t2[0] - $t1[0] ) + ( $t2[1] - $t1[1] ); |
215 | 220 | $total['elapsed'] += $elapsed; |
216 | 221 | $total['rows'] += $num; |
217 | 222 | $total['pages']++; |
218 | | - $ftime = $this->compute_time($elapsed); |
219 | | - $this->format_time_message($ftime, $message); |
220 | | - $wgOut->addHTML("$message<br />"); |
| 223 | + $ftime = $this->computeTime( $elapsed ); |
| 224 | + $this->formatTimeMessage( $ftime, $message ); |
| 225 | + $wgOut->addHTML( "$message<br />" ); |
221 | 226 | } |
222 | 227 | |
223 | 228 | $t1 = explode( ' ', microtime() ); |
224 | 229 | |
225 | 230 | # Reopen any connections that have closed |
226 | 231 | if ( !wfGetLB()->pingAll() ) { |
227 | | - $wgOut->addHTML("<br />"); |
| 232 | + $wgOut->addHTML( '<br />' ); |
228 | 233 | do { |
229 | | - $wgOut->addHTML( wfMsg('refreshspecial-reconnecting') ."<br />" ); |
230 | | - sleep(REFRESHSPECIAL_RECONNECTION_SLEEP); |
| 234 | + $wgOut->addHTML( wfMsg( 'refreshspecial-reconnecting' ) . '<br />' ); |
| 235 | + sleep( REFRESHSPECIAL_RECONNECTION_SLEEP ); |
231 | 236 | } while ( !wfGetLB()->pingAll() ); |
232 | | - $wgOut->addHTML( wfMsg('refreshspecial-reconnected') . "<br /><br />" ); |
| 237 | + $wgOut->addHTML( wfMsg( 'refreshspecial-reconnected' ) . '<br /><br />' ); |
233 | 238 | } else { |
234 | 239 | # Commit the results |
235 | 240 | $dbw->commit(); |
— | — | @@ -237,53 +242,52 @@ |
238 | 243 | # Wait for the slave to catch up |
239 | 244 | $slaveDB = wfGetDB( DB_SLAVE, array( 'QueryPage::recache', 'vslow' ) ); |
240 | 245 | while( $slaveDB->getLag() > REFRESHSPECIAL_SLAVE_LAG_LIMIT ) { |
241 | | - $wgOut->addHTML( wfMsg('refreshspecial-slave-lagged') ."<br />" ); |
242 | | - sleep(REFRESHSPECIAL_SLAVE_LAG_SLEEP); |
| 246 | + $wgOut->addHTML( wfMsg( 'refreshspecial-slave-lagged' ) . '<br />' ); |
| 247 | + sleep( REFRESHSPECIAL_SLAVE_LAG_SLEEP ); |
243 | 248 | } |
244 | 249 | |
245 | 250 | $t2 = explode( ' ', microtime() ); |
246 | 251 | $elapsed_total = ($t2[0] - $t1[0]) + ($t2[1] - $t1[1]); |
247 | 252 | $total['total_elapsed'] += $elapsed + $elapsed_total; |
248 | 253 | } else { |
249 | | - $wgOut->addHTML( wfMsg('refreshspecial-skipped')."<br />" ); |
| 254 | + $wgOut->addHTML( wfMsg( 'refreshspecial-skipped' ) . '<br />' ); |
250 | 255 | } |
251 | 256 | } |
252 | 257 | } |
253 | 258 | /* display all stats */ |
254 | 259 | $elapsed_message = ''; |
255 | 260 | $total_elapsed_message = ''; |
256 | | - $this->format_time_message( $this->compute_time($total['elapsed']), $elapsed_message ); |
257 | | - $this->format_time_message( $this->compute_time($total['total_elapsed']), $total_elapsed_message ); |
258 | | - $wgOut->addHTML( "<br />" . wfMsgExt('refreshspecial-total-display', array( 'escape', 'parsemag' ), $total['pages'], $total['rows'], $elapsed_message, $total_elapsed_message) ); |
259 | | - $wgOut->addHTML("</ul></form>"); |
| 261 | + $this->formatTimeMessage( $this->computeTime( $total['elapsed'] ), $elapsed_message ); |
| 262 | + $this->formatTimeMessage( $this->computeTime( $total['total_elapsed'] ), $total_elapsed_message ); |
| 263 | + $wgOut->addHTML( '<br />' . |
| 264 | + wfMsgExt( 'refreshspecial-total-display', |
| 265 | + array( 'escape', 'parsemag' ), |
| 266 | + $total['pages'], |
| 267 | + $total['rows'], |
| 268 | + $elapsed_message, |
| 269 | + $total_elapsed_message |
| 270 | + ) |
| 271 | + ); |
| 272 | + $wgOut->addHTML( '</ul></form>' ); |
260 | 273 | } |
261 | 274 | |
262 | 275 | /** |
263 | | - * On success |
264 | | - */ |
265 | | - function showSuccess() { |
266 | | - global $wgOut, $wgRequest; |
267 | | - $wgOut->setPageTitle( wfMsg('refreshspecial-title') ); |
268 | | - $wgOut->setSubTitle( wfMsg('refreshspecial-success-subtitle') ); |
269 | | - } |
270 | | - |
271 | | - /** |
272 | 276 | * On submit |
273 | 277 | */ |
274 | 278 | function doSubmit() { |
275 | 279 | global $wgOut, $wgUser, $wgRequest; |
276 | 280 | /* guard against an empty array */ |
277 | 281 | $array = $wgRequest->getArray( 'wpSpecial' ); |
278 | | - if ( !is_array($array) || empty($array) || is_null($array) ) { |
279 | | - $this->showForm( wfMsg('refreshspecial-none-selected') ); |
| 282 | + if ( !is_array( $array ) || empty( $array ) || is_null( $array ) ) { |
| 283 | + $this->showForm( wfMsg( 'refreshspecial-none-selected' ) ); |
280 | 284 | return; |
281 | 285 | } |
282 | 286 | |
283 | | - $wgOut->setSubTitle( wfMsg( 'refreshspecial-choice', wfMsg('refreshspecial-refreshing') ) ); |
| 287 | + $wgOut->setSubTitle( wfMsg( 'refreshspecial-choice', wfMsg( 'refreshspecial-refreshing' ) ) ); |
284 | 288 | $this->refreshSpecial(); |
285 | 289 | $sk = $wgUser->getSkin(); |
286 | 290 | $titleObj = SpecialPage::getTitleFor( 'RefreshSpecial' ); |
287 | | - $link_back = $sk->makeKnownLinkObj( $titleObj, wfMsg('refreshspecial-link-back') ); |
288 | | - $wgOut->addHTML("<br /><b>" . $link_back . "</b>"); |
| 291 | + $link_back = $sk->makeKnownLinkObj( $titleObj, wfMsg( 'refreshspecial-link-back' ) ); |
| 292 | + $wgOut->addHTML( '<br /><b>' . $link_back . '</b>' ); |
289 | 293 | } |
290 | | -} |
| 294 | +} |
\ No newline at end of file |
Index: trunk/extensions/RefreshSpecial/RefreshSpecial.i18n.php |
— | — | @@ -22,7 +22,6 @@ |
23 | 23 | 'refreshspecial-fail' => 'Please check at least one special page to refresh.', |
24 | 24 | 'refreshspecial-refreshing' => 'refreshing special pages', |
25 | 25 | 'refreshspecial-skipped' => 'cheap, skipped', |
26 | | - 'refreshspecial-success-subtitle' => 'refreshing special pages', |
27 | 26 | 'refreshspecial-choice' => 'refreshing special pages', |
28 | 27 | 'refreshspecial-js-disabled' => '(<i>You cannot select all pages when JavaScript is disabled</i>)', |
29 | 28 | 'refreshspecial-select-all-pages' => 'Select all pages', |
— | — | @@ -329,7 +328,7 @@ |
330 | 329 | |
331 | 330 | /** Finnish (Suomi) |
332 | 331 | * @author Crt |
333 | | - * @author Jack Phoenix |
| 332 | + * @author Jack Phoenix <jack@countervandalism.net> |
334 | 333 | * @author Mobe |
335 | 334 | * @author Nike |
336 | 335 | * @author Vililikku |
Index: trunk/extensions/RefreshSpecial/RefreshSpecial.php |
— | — | @@ -4,20 +4,22 @@ |
5 | 5 | * |
6 | 6 | * @file |
7 | 7 | * @ingroup Extensions |
| 8 | + * @version 1.2.1 |
8 | 9 | * @author Bartek Łapiński <bartek@wikia-inc.com> |
9 | | - * @version 1.1 |
| 10 | + * @author Jack Phoenix <jack@countervandalism.net> |
10 | 11 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
11 | 12 | * @link http://www.mediawiki.org/wiki/Extension:RefreshSpecial Documentation |
12 | 13 | */ |
13 | 14 | |
14 | | -if( !defined('MEDIAWIKI') ) |
15 | | - die(); |
| 15 | +if( !defined( 'MEDIAWIKI' ) ){ |
| 16 | + die( "This is not a valid entry point.\n" ); |
| 17 | +} |
16 | 18 | |
17 | 19 | // Extension credits that will be shown on Special:Version |
18 | 20 | $wgExtensionCredits['specialpage'][] = array( |
19 | 21 | 'name' => 'Refresh Special', |
20 | | - 'author' => 'Bartek Łapiński', |
21 | | - 'version' => '1.2', |
| 22 | + 'author' => array( 'Bartek Łapiński', 'Jack Phoenix' ), |
| 23 | + 'version' => '1.2.1', |
22 | 24 | 'url' => 'http://www.mediawiki.org/wiki/Extension:RefreshSpecial', |
23 | 25 | 'description' => 'Allows manual special page refresh of special pages', |
24 | 26 | 'descriptionmsg' => 'refreshspecial-desc', |
Index: trunk/extensions/RefreshSpecial/RefreshSpecial.js |
— | — | @@ -0,0 +1,11 @@ |
| 2 | +/** |
| 3 | + * JavaScript helper function for RefreshSpecial extension |
| 4 | + */ |
| 5 | +function refreshSpecialCheck( form ) { |
| 6 | + pattern = document.getElementById( 'refreshSpecialCheckAll' ).checked; |
| 7 | + for( i = 0; i < form.elements.length; i++ ) { |
| 8 | + if( form.elements[i].type == 'checkbox' && form.elements[i].name != 'check_all' ) { |
| 9 | + form.elements[i].checked = pattern; |
| 10 | + } |
| 11 | + } |
| 12 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/RefreshSpecial/RefreshSpecial.js |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 13 | + native |
Index: trunk/extensions/RefreshSpecial/RefreshSpecial.alias.php |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | |
36 | 36 | /** Finnish (Suomi) */ |
37 | 37 | $aliases['fi'] = array( |
38 | | - 'RefreshSpecial' => array( 'Toimintosivun päivitys' ), |
| 38 | + 'RefreshSpecial' => array( 'Toimintosivujen päivitys' ), |
39 | 39 | ); |
40 | 40 | |
41 | 41 | /** Galician (Galego) */ |