Index: trunk/extensions/RefreshSpecial/RefreshSpecial.body.php |
— | — | @@ -13,9 +13,8 @@ |
14 | 14 | /** |
15 | 15 | * Constructor |
16 | 16 | */ |
17 | | - function __construct() { |
18 | | - parent::__construct( 'RefreshSpecial', 'refreshspecial', true, 'execute', false ); |
19 | | - wfLoadExtensionMessages('RefreshSpecial'); |
| 17 | + public function __construct() { |
| 18 | + parent::__construct( 'RefreshSpecial'/*class*/, 'refreshspecial'/*restriction*/ ); |
20 | 19 | } |
21 | 20 | |
22 | 21 | /** |
— | — | @@ -23,17 +22,19 @@ |
24 | 23 | * |
25 | 24 | * @param $par Mixed: parameter passed to the page or null |
26 | 25 | */ |
27 | | - function execute( $par ) { |
| 26 | + public function execute( $par ) { |
28 | 27 | global $wgOut, $wgUser, $wgRequest; |
| 28 | + wfLoadExtensionMessages('RefreshSpecial'); |
| 29 | + |
29 | 30 | $wgOut->setPageTitle( wfMsg('refreshspecial-title') ); |
30 | 31 | $cSF = new RefreshSpecialForm(); |
31 | 32 | |
32 | | - $action = $wgRequest->getVal('action'); |
33 | | - if ('success' == $action) { |
| 33 | + $action = $wgRequest->getVal( 'action' ); |
| 34 | + if( 'success' == $action ) { |
34 | 35 | /* do something */ |
35 | | - } else if ('failure' == $action) { |
| 36 | + } else if( 'failure' == $action ) { |
36 | 37 | $cSF->showForm( wfMsg('refreshspecial-fail') ); |
37 | | - } else if ( $wgRequest->wasPosted() && 'submit' == $action && |
| 38 | + } else if( $wgRequest->wasPosted() && 'submit' == $action && |
38 | 39 | $wgUser->matchEditToken( $wgRequest->getVal('wpEditToken') ) ) { |
39 | 40 | $cSF->doSubmit(); |
40 | 41 | } else { |
— | — | @@ -50,13 +51,6 @@ |
51 | 52 | var $mMode, $mLink; |
52 | 53 | |
53 | 54 | /** |
54 | | - * Constructor |
55 | | - */ |
56 | | - function RefreshSpecialForm() { |
57 | | - global $wgRequest; |
58 | | - } |
59 | | - |
60 | | - /** |
61 | 55 | * Show the actual form |
62 | 56 | * |
63 | 57 | * @param $err string Error message if there was an error, otherwise null |
— | — | @@ -65,19 +59,19 @@ |
66 | 60 | global $wgOut, $wgUser, $wgRequest, $wgQueryPages; |
67 | 61 | |
68 | 62 | $token = htmlspecialchars( $wgUser->editToken() ); |
69 | | - $titleObj = Title::makeTitle( NS_SPECIAL, 'RefreshSpecial' ); |
| 63 | + $titleObj = SpecialPage::getTitleFor( 'RefreshSpecial' ); |
70 | 64 | $action = $titleObj->escapeLocalURL( "action=submit" ); |
71 | 65 | |
72 | | - if ( "" != $err ) { |
| 66 | + if ( '' != $err ) { |
73 | 67 | $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) ); |
74 | 68 | $wgOut->addHTML( "<p class='error'>{$err}</p>\n" ); |
75 | 69 | } |
76 | 70 | |
77 | | - $wgOut->addWikiText( wfMsg('refreshspecial-help') ); |
| 71 | + $wgOut->addWikiMsg( 'refreshspecial-help' ); |
78 | 72 | |
79 | | - ( 'submit' == $wgRequest->getVal( 'action' )) ? $scLink = htmlspecialchars ($this->mLink) : $scLink = ''; |
| 73 | + ( 'submit' == $wgRequest->getVal( 'action' ) ) ? $scLink = htmlspecialchars($this->mLink) : $scLink = ''; |
80 | 74 | |
81 | | - $wgOut->addHTML("<form name=\"RefreshSpecial\" method=\"post\" action=\"{$action}\"><ul>"); |
| 75 | + $wgOut->addHTML("<form name=\"RefreshSpecial\" method=\"post\" action=\"{$action}\"><ul>"); |
82 | 76 | |
83 | 77 | /** |
84 | 78 | * List pages right here |
— | — | @@ -91,7 +85,7 @@ |
92 | 86 | |
93 | 87 | $specialObj = SpecialPage::getPage( $special ); |
94 | 88 | if ( !$specialObj ) { |
95 | | - $wgOut->addWikiText( wfMsg('refreshspecial-no-page') . " $special\n"); |
| 89 | + $wgOut->addWikiText( wfMsg('refreshspecial-no-page') . " $special\n" ); |
96 | 90 | exit; |
97 | 91 | } |
98 | 92 | $file = $specialObj->getFile(); |
— | — | @@ -116,10 +110,10 @@ |
117 | 111 | $wgOut->addHTML("</label> |
118 | 112 | </li> |
119 | 113 | <script type=\"text/javascript\"> |
120 | | - function refreshSpecialCheck (form) { |
121 | | - pattern = document.getElementById ('refreshSpecialCheckAll').checked; |
122 | | - for (i=0; i<form.elements.length; i++) { |
123 | | - if (form.elements[i].type == 'checkbox' && form.elements[i].name != 'check_all') { |
| 114 | + function refreshSpecialCheck( form ) { |
| 115 | + pattern = document.getElementById('refreshSpecialCheckAll').checked; |
| 116 | + for( i = 0; i < form.elements.length; i++ ) { |
| 117 | + if( form.elements[i].type == 'checkbox' && form.elements[i].name != 'check_all' ) { |
124 | 118 | form.elements[i].checked = pattern; |
125 | 119 | } |
126 | 120 | } |
— | — | @@ -152,7 +146,7 @@ |
153 | 147 | * @param $message mixed Message displayed to the user containing the elapsed time |
154 | 148 | * @return true |
155 | 149 | */ |
156 | | - function format_time_message($time, &$message) { |
| 150 | + function format_time_message( $time, &$message ) { |
157 | 151 | if ( $time['hours'] ) { |
158 | 152 | $message .= $time['hours'] . 'h '; |
159 | 153 | } |
— | — | @@ -170,7 +164,7 @@ |
171 | 165 | function refreshSpecial() { |
172 | 166 | global $wgRequest, $wgQueryPages, $wgOut; |
173 | 167 | $dbw = wfGetDB( DB_MASTER ); |
174 | | - $to_refresh = $wgRequest->getArray('wpSpecial'); |
| 168 | + $to_refresh = $wgRequest->getArray( 'wpSpecial' ); |
175 | 169 | $total = array ( |
176 | 170 | 'pages' => 0, |
177 | 171 | 'rows' => 0, |
— | — | @@ -180,13 +174,13 @@ |
181 | 175 | |
182 | 176 | foreach ( $wgQueryPages as $page ) { |
183 | 177 | @list( $class, $special, $limit ) = $page; |
184 | | - if ( !in_array($special, $to_refresh) ) { |
| 178 | + if ( !in_array( $special, $to_refresh ) ) { |
185 | 179 | continue; |
186 | 180 | } |
187 | 181 | |
188 | 182 | $specialObj = SpecialPage::getPage( $special ); |
189 | 183 | if ( !$specialObj ) { |
190 | | - $wgOut->addWikiText( wfMsg('refreshspecial-no-page').": $special\n"); |
| 184 | + $wgOut->addWikiText( wfMsg('refreshspecial-no-page').": $special\n"); |
191 | 185 | exit; |
192 | 186 | } |
193 | 187 | $file = $specialObj->getFile(); |
— | — | @@ -195,8 +189,8 @@ |
196 | 190 | } |
197 | 191 | $queryPage = new $class; |
198 | 192 | |
199 | | - $message = ""; |
200 | | - if( !(isset($options['only'])) or ($options['only'] == $queryPage->getName()) ) { |
| 193 | + $message = ''; |
| 194 | + if( !( isset( $options['only'] ) ) or ( $options['only'] == $queryPage->getName() ) ) { |
201 | 195 | $wgOut->addHTML("<b>$special</b>: "); |
202 | 196 | |
203 | 197 | if ( $queryPage->isExpensive() ) { |
— | — | @@ -206,7 +200,7 @@ |
207 | 201 | $t2 = explode( ' ', microtime() ); |
208 | 202 | |
209 | 203 | if ( $num === false ) { |
210 | | - $wgOut->addHTML( wfMsg('refreshspecial-db-error') . "<br />"); |
| 204 | + $wgOut->addHTML( wfMsg('refreshspecial-db-error') . "<br />" ); |
211 | 205 | } else { |
212 | 206 | $message = "got $num rows in "; |
213 | 207 | $elapsed = ($t2[0] - $t1[0]) + ($t2[1] - $t1[1]); |
— | — | @@ -222,26 +216,26 @@ |
223 | 217 | if ( !wfGetLB()->pingAll() ) { |
224 | 218 | $wgOut->addHTML("<br />"); |
225 | 219 | do { |
226 | | - $wgOut->addHTML( wfMsg('refreshspecial-reconnecting') ."<br />"); |
| 220 | + $wgOut->addHTML( wfMsg('refreshspecial-reconnecting') ."<br />" ); |
227 | 221 | sleep(REFRESHSPECIAL_RECONNECTION_SLEEP); |
228 | 222 | } while ( !wfGetLB()->pingAll() ); |
229 | | - $wgOut->addHTML( wfMsg('refreshspecial-reconnected') . "<br /><br />"); |
| 223 | + $wgOut->addHTML( wfMsg('refreshspecial-reconnected') . "<br /><br />" ); |
230 | 224 | } else { |
231 | 225 | # Commit the results |
232 | | - $dbw->immediateCommit(); |
| 226 | + $dbw->commit(); |
233 | 227 | } |
234 | 228 | |
235 | 229 | # Wait for the slave to catch up |
236 | | - $slaveDB = wfGetDB( DB_SLAVE, array('QueryPage::recache', 'vslow' ) ); |
| 230 | + $slaveDB = wfGetDB( DB_SLAVE, array( 'QueryPage::recache', 'vslow' ) ); |
237 | 231 | while( $slaveDB->getLag() > REFRESHSPECIAL_SLAVE_LAG_LIMIT ) { |
238 | | - $wgOut->addHTML(wfMsg('refreshspecial-slave-lagged') ."<br />"); |
| 232 | + $wgOut->addHTML( wfMsg('refreshspecial-slave-lagged') ."<br />" ); |
239 | 233 | sleep(REFRESHSPECIAL_SLAVE_LAG_SLEEP); |
240 | 234 | } |
241 | 235 | $t2 = explode( ' ', microtime() ); |
242 | 236 | $elapsed_total = ($t2[0] - $t1[0]) + ($t2[1] - $t1[1]); |
243 | 237 | $total['total_elapsed'] += $elapsed + $elapsed_total; |
244 | 238 | } else { |
245 | | - $wgOut->addHTML(wfMsg('refreshspecial-skipped')."<br />"); |
| 239 | + $wgOut->addHTML( wfMsg('refreshspecial-skipped')."<br />" ); |
246 | 240 | } |
247 | 241 | } |
248 | 242 | } |
— | — | @@ -269,17 +263,17 @@ |
270 | 264 | function doSubmit() { |
271 | 265 | global $wgOut, $wgUser, $wgRequest; |
272 | 266 | /* guard against an empty array */ |
273 | | - $array = $wgRequest->getArray('wpSpecial'); |
| 267 | + $array = $wgRequest->getArray( 'wpSpecial' ); |
274 | 268 | if ( !is_array($array) || empty($array) || is_null($array) ) { |
275 | 269 | $this->showForm( wfMsg('refreshspecial-none-selected') ); |
276 | 270 | return; |
277 | 271 | } |
278 | 272 | |
279 | | - $wgOut->setSubTitle( wfMsg('refreshspecial-choice', wfMsg('refreshspecial-refreshing') ) ); |
| 273 | + $wgOut->setSubTitle( wfMsg( 'refreshspecial-choice', wfMsg('refreshspecial-refreshing') ) ); |
280 | 274 | $this->refreshSpecial(); |
281 | 275 | $sk = $wgUser->getSkin(); |
282 | | - $titleObj = Title::makeTitle( NS_SPECIAL, 'RefreshSpecial' ); |
283 | | - $link_back = $sk->makeKnownLinkObj($titleObj, wfMsg('refreshspecial-here') ); |
| 276 | + $titleObj = SpecialPage::getTitleFor( 'RefreshSpecial' ); |
| 277 | + $link_back = $sk->makeKnownLinkObj( $titleObj, wfMsg('refreshspecial-here') ); |
284 | 278 | $wgOut->addHTML("<br />".wfMsg('refreshspecial-link-back')." $link_back."); |
285 | 279 | } |
286 | 280 | } |
\ No newline at end of file |
Index: trunk/extensions/RefreshSpecial/RefreshSpecial.i18n.php |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | /** |
4 | 4 | * Internationalisation file for the RefreshSpecial extension. |
5 | 5 | * |
| 6 | + * @file |
6 | 7 | * @ingroup Extensions |
7 | 8 | */ |
8 | 9 | |
— | — | @@ -10,7 +11,7 @@ |
11 | 12 | /** English |
12 | 13 | * @author Bartek Łapiński |
13 | 14 | */ |
14 | | -$messages['en'] = array ( |
| 15 | +$messages['en'] = array( |
15 | 16 | 'refreshspecial' => 'Refresh special pages', |
16 | 17 | 'refreshspecial-desc' => 'Allows [[Special:RefreshSpecial|manual special page refresh]] of special pages', |
17 | 18 | 'refreshspecial-title' => 'Refresh special pages', |
— | — | @@ -34,18 +35,6 @@ |
35 | 36 | 'refreshspecial-total-display' => '<br />Refreshed $1 pages totaling $2 rows in time $3 (complete time of the script run is $4)', |
36 | 37 | ); |
37 | 38 | |
38 | | -/** Message documentation (Message documentation) |
39 | | - * @author Jon Harald Søby |
40 | | - * @author Purodha |
41 | | - */ |
42 | | -$messages['qqq'] = array( |
43 | | - 'refreshspecial' => '{{Identical|Refresh special pages}}', |
44 | | - 'refreshspecial-desc' => 'Shown in [[Special:Version]] as a short description of this extension. Do not translate links.', |
45 | | - 'refreshspecial-title' => '{{Identical|Refresh special pages}}', |
46 | | - 'refreshspecial-refreshing' => '{{Identical|Refreshing special pages}}', |
47 | | - 'refreshspecial-success-subtitle' => '{{Identical|Refreshing special pages}}', |
48 | | -); |
49 | | - |
50 | 39 | /** Arabic (العربية) |
51 | 40 | * @author Meno25 |
52 | 41 | */ |
Index: trunk/extensions/RefreshSpecial/RefreshSpecial.php |
— | — | @@ -2,27 +2,32 @@ |
3 | 3 | /** |
4 | 4 | * A special page providing means to manually refresh special pages |
5 | 5 | * |
| 6 | + * @file |
6 | 7 | * @ingroup Extensions |
7 | | - * @author Bartek Łapiński <bartek@wikia.com> |
8 | | - * @version 1.0 |
| 8 | + * @author Bartek Łapiński <bartek@wikia-inc.com> |
| 9 | + * @version 1.1 |
| 10 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
9 | 11 | * @link http://www.mediawiki.org/wiki/Extension:RefreshSpecial Documentation |
10 | 12 | */ |
11 | 13 | |
12 | | -if(!defined('MEDIAWIKI')) |
| 14 | +if( !defined('MEDIAWIKI') ) |
13 | 15 | die(); |
14 | 16 | |
15 | | -$wgAvailableRights[] = 'refreshspecial'; |
16 | | -$wgGroupPermissions['staff']['refreshspecial'] = true; |
17 | | - |
| 17 | +// Extension credits that will be shown on Special:Version |
18 | 18 | $wgExtensionCredits['specialpage'][] = array( |
19 | | - 'name' => 'Refresh Special', |
20 | | - 'author' => 'Bartek Łapiński', |
21 | | - 'version' => '1.1', |
22 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:RefreshSpecial', |
23 | | - 'description' => 'Allows manual special page refresh of special pages', |
| 19 | + 'name' => 'Refresh Special', |
| 20 | + 'author' => 'Bartek Łapiński', |
| 21 | + 'version' => '1.1', |
| 22 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:RefreshSpecial', |
| 23 | + 'description' => 'Allows manual special page refresh of special pages', |
24 | 24 | 'descriptionmsg' => 'refreshspecial-desc', |
25 | 25 | ); |
26 | 26 | |
| 27 | +// New user right, required to use Special:RefreshSpecial |
| 28 | +$wgAvailableRights[] = 'refreshspecial'; |
| 29 | +$wgGroupPermissions['staff']['refreshspecial'] = true; |
| 30 | + |
| 31 | +// Set up the new special page |
27 | 32 | $dir = dirname(__FILE__) . '/'; |
28 | 33 | $wgExtensionMessagesFiles['RefreshSpecial'] = $dir . 'RefreshSpecial.i18n.php'; |
29 | 34 | $wgExtensionAliasesFiles['RefreshSpecial'] = $dir . 'RefreshSpecial.alias.php'; |
— | — | @@ -36,4 +41,4 @@ |
37 | 42 | /* amount of acceptable slave lag */ |
38 | 43 | define('REFRESHSPECIAL_SLAVE_LAG_LIMIT', 600); |
39 | 44 | /* interval when slave is lagged */ |
40 | | -define('REFRESHSPECIAL_SLAVE_LAG_SLEEP', 30); |
| 45 | +define('REFRESHSPECIAL_SLAVE_LAG_SLEEP', 30); |
\ No newline at end of file |
Index: trunk/extensions/RefreshSpecial/RefreshSpecial.alias.php |
— | — | @@ -2,10 +2,13 @@ |
3 | 3 | /** |
4 | 4 | * Aliases for special pages |
5 | 5 | * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
6 | 8 | */ |
7 | 9 | |
8 | 10 | $aliases = array(); |
9 | 11 | |
| 12 | +/** English */ |
10 | 13 | $aliases['en'] = array( |
11 | 14 | 'RefreshSpecial' => array( 'RefreshSpecial' ), |
12 | 15 | ); |
— | — | @@ -31,7 +34,7 @@ |
32 | 35 | |
33 | 36 | /** Finnish (Suomi) */ |
34 | 37 | $aliases['fi'] = array( |
35 | | - 'RefreshSpecial' => array( 'Toimintosivun päivitys' ), |
| 38 | + 'RefreshSpecial' => array( 'Toimintosivujen päivitys' ), |
36 | 39 | ); |
37 | 40 | |
38 | 41 | /** Swiss German (Alemannisch) */ |
— | — | @@ -62,5 +65,4 @@ |
63 | 66 | /** Norwegian (bokmål) (Norsk (bokmål)) */ |
64 | 67 | $aliases['no'] = array( |
65 | 68 | 'RefreshSpecial' => array( 'Oppdater spesialsider' ), |
66 | | -); |
67 | | - |
| 69 | +); |
\ No newline at end of file |