Index: trunk/extensions/InspectCache/InspectCache.php |
— | — | @@ -24,4 +24,9 @@ |
25 | 25 | $wgExtensionMessagesFiles['InspectCache'] = $dir . 'InspectCache.i18n.php'; |
26 | 26 | $wgExtensionAliasesFiles['InspectCache'] = $dir . 'InspectCache.alias.php'; |
27 | 27 | $wgAutoloadClasses['SpecialInspectCache'] = $dir . 'InspectCache_body.php'; |
| 28 | + |
28 | 29 | $wgSpecialPages['InspectCache'] = 'SpecialInspectCache'; |
| 30 | +$wgSpecialPageGroups['InspectCache'] = 'wiki'; |
| 31 | + |
| 32 | +$wgAvailableRights[] = 'inspectcache'; |
| 33 | +$wgGroupPermissions['sysop']['inspectcache'] = true; |
Index: trunk/extensions/InspectCache/InspectCache_body.php |
— | — | @@ -5,35 +5,37 @@ |
6 | 6 | exit(1); |
7 | 7 | } |
8 | 8 | |
9 | | -class SpecialInspectCache extends SpecialPage |
10 | | -{ |
| 9 | +class SpecialInspectCache extends SpecialPage { |
11 | 10 | function __construct() { |
12 | | - SpecialPage::SpecialPage( 'InspectCache' ); |
| 11 | + SpecialPage::SpecialPage( 'InspectCache', 'inspectcache' ); |
13 | 12 | } |
14 | 13 | |
15 | 14 | function execute( $par ) { |
16 | | - global $wgRequest, $wgOut, $wgTitle, $inspectcacheget, $inspectcachedelete; |
| 15 | + global $wgRequest, $wgOut, $wgUser; |
17 | 16 | |
18 | 17 | wfLoadExtensionMessages( 'InspectCache' ); |
19 | 18 | |
20 | | - $inspectcacheget = wfMsgHtml('inspectcache-get'); |
21 | | - $inspectcachedelete = wfMsgHtml('inspectcache-delete'); |
22 | | - $inspectcachelist = wfMsgHtml('inspectcache-list'); |
23 | 19 | $this->setHeaders(); |
24 | 20 | |
| 21 | + if ( !$this->userCanExecute( $wgUser ) ) { |
| 22 | + $this->displayRestrictionError(); |
| 23 | + return; |
| 24 | + } |
| 25 | + |
| 26 | + $this->outputHeader(); |
| 27 | + |
25 | 28 | $key = $wgRequest->getVal( 'key' ); |
26 | 29 | $delete = $wgRequest->getBool( 'delete' ) && $wgRequest->wasPosted(); |
27 | 30 | $list = $wgRequest->getBool( 'list' ); |
28 | 31 | $group = $wgRequest->getVal( 'group' ); |
29 | 32 | |
30 | 33 | $encQ = htmlspecialchars( $key ); |
31 | | - $action = $wgTitle->escapeLocalUrl(); |
32 | | - $ok = htmlspecialchars( wfMsg( 'inspectcache-ok' ) ); |
| 34 | + $action = $this->getTitle()->escapeLocalUrl(); |
33 | 35 | |
34 | 36 | $groups = array( |
35 | | - 'main' => array( wfMsg('inspectcache-general'), 'wfGetMainCache' ), |
36 | | - 'parser' => array( wfMsg('inspectcache-parser'), 'wfGetParserCacheStorage' ), |
37 | | - 'message' => array( wfMsg('inspectcache-message'), 'wfGetMessageCacheStorage' ), |
| 37 | + 'main' => array( wfMsg( 'inspectcache-general' ), 'wfGetMainCache' ), |
| 38 | + 'parser' => array( wfMsg( 'inspectcache-parser' ), 'wfGetParserCacheStorage' ), |
| 39 | + 'message' => array( wfMsg( 'inspectcache-message' ), 'wfGetMessageCacheStorage' ), |
38 | 40 | ); |
39 | 41 | if( !isset( $groups[$group] ) ) { |
40 | 42 | $group = 'main'; |
— | — | @@ -45,16 +47,20 @@ |
46 | 48 | list( $desc ) = $bits; |
47 | 49 | $radios .= |
48 | 50 | Xml::radioLabel( $desc, 'group', $type, "mw-cache-$type", |
49 | | - $group == $type ) . " "; |
| 51 | + $group == $type ) . ' '; |
50 | 52 | } |
51 | 53 | |
| 54 | + $inspectcacheget = wfMsgHtml( 'inspectcache-get' ); |
| 55 | + $inspectcachedelete = wfMsgHtml( 'inspectcache-delete' ); |
| 56 | + $inspectcachelist = wfMsgHtml( 'inspectcache-list' ); |
| 57 | + |
52 | 58 | $wgOut->addHTML( <<<END |
53 | 59 | <form name="ucf" method="post" action="$action"> |
54 | 60 | <input type="text" size="80" name="key" value="$encQ"/><br /> |
55 | 61 | <div>$radios</div> |
56 | | -<input type="submit" name="submit" value={$inspectcacheget} /> |
57 | | -<input type="submit" name="delete" value={$inspectcachedelete} /> |
58 | | -<input type="submit" name="list" value={$inspectcachelist} /> |
| 62 | +<input type="submit" name="submit" value="{$inspectcacheget}" /> |
| 63 | +<input type="submit" name="delete" value="{$inspectcachedelete}" /> |
| 64 | +<input type="submit" name="list" value="{$inspectcachelist}" /> |
59 | 65 | <br /><br /> |
60 | 66 | </form> |
61 | 67 | END |
— | — | @@ -62,13 +68,13 @@ |
63 | 69 | |
64 | 70 | if ( $delete && !is_null( $key ) ) { |
65 | 71 | $cache->delete( $key ); |
66 | | - $wgOut->addHTML( wfMsg('inspectcache-deleted')."\n" ); |
| 72 | + $wgOut->addWikiMsg( 'inspectcache-deleted' ); |
67 | 73 | } else if ( $list ) { |
68 | 74 | $list = $cache->keys(); |
69 | 75 | $str = "<ul>\n"; |
70 | 76 | foreach( $list as $li ) { |
71 | 77 | $keyEncoded = urlencode( $li ); |
72 | | - $url = $wgTitle->getFullUrl( "key={$keyEncoded}&group={$group}" ); |
| 78 | + $url = $this->getTitle()->getFullUrl( "key={$keyEncoded}&group={$group}" ); |
73 | 79 | $urlEncoded = htmlspecialchars( $url ); |
74 | 80 | $liEncoded = htmlspecialchars( $li ); |
75 | 81 | $str .= "<li><a href=\"{$urlEncoded}\">{$liEncoded}</a></li>\n"; |
— | — | @@ -80,7 +86,7 @@ |
81 | 87 | if ( !is_string( $value ) ) { |
82 | 88 | $value = var_export( $value, true ); |
83 | 89 | } |
84 | | - $wgOut->addHTML( "<pre>" . htmlspecialchars( $value ) . "</pre>" ); |
| 90 | + $wgOut->addHTML( '<pre>' . htmlspecialchars( $value ) . '</pre>' ); |
85 | 91 | } |
86 | 92 | } |
87 | 93 | } |
Index: trunk/extensions/InspectCache/InspectCache.i18n.php |
— | — | @@ -10,7 +10,6 @@ |
11 | 11 | $messages['en'] = array( |
12 | 12 | 'inspectcache' => 'Inspect cache', |
13 | 13 | 'inspectcache-desc' => 'A simple debugging tool to inspect the contents of the shared cache', |
14 | | - 'inspectcache-ok' => 'OK', |
15 | 14 | 'inspectcache-general' => 'General cache', |
16 | 15 | 'inspectcache-parser' => 'Parser cache', |
17 | 16 | 'inspectcache-message' => 'Message cache', |
— | — | @@ -18,6 +17,7 @@ |
19 | 18 | 'inspectcache-delete' => 'Delete', |
20 | 19 | 'inspectcache-deleted' => 'Deleted cache', |
21 | 20 | 'inspectcache-list' => 'List', |
| 21 | + 'right-inspectcache' => 'View and delete cache entries', |
22 | 22 | ); |
23 | 23 | |
24 | 24 | /** Message documentation (Message documentation) |