Index: trunk/extensions/AdminLinks/AdminLinks.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * @author Yaron Koren |
7 | 7 | */ |
8 | 8 | |
9 | | -if (!defined('MEDIAWIKI')) die(); |
| 9 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
10 | 10 | |
11 | 11 | // credits |
12 | 12 | $wgExtensionCredits['specialpage'][] = array( |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | 'descriptionmsg' => 'adminlinks-desc', |
20 | 20 | ); |
21 | 21 | |
22 | | -$wgAdminLinksIP = dirname(__FILE__) . '/'; |
| 22 | +$wgAdminLinksIP = dirname( __FILE__ ) . '/'; |
23 | 23 | $wgExtensionMessagesFiles['AdminLinks'] = $wgAdminLinksIP . 'AdminLinks.i18n.php'; |
24 | 24 | $wgSpecialPages['AdminLinks'] = 'AdminLinks'; |
25 | 25 | $wgHooks['PersonalUrls'][] = 'AdminLinks::addURLToUserLinks'; |
Index: trunk/extensions/AdminLinks/AdminLinks_body.php |
— | — | @@ -5,72 +5,71 @@ |
6 | 6 | * @author Yaron Koren |
7 | 7 | */ |
8 | 8 | |
9 | | -if (!defined('MEDIAWIKI')) die(); |
| 9 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
10 | 10 | |
11 | 11 | class AdminLinks extends SpecialPage { |
12 | | - |
13 | 12 | var $skin; |
14 | 13 | |
15 | 14 | /** |
16 | 15 | * Constructor |
17 | 16 | */ |
18 | 17 | function AdminLinks() { |
19 | | - SpecialPage::SpecialPage('AdminLinks'); |
20 | | - wfLoadExtensionMessages('AdminLinks'); |
21 | | - global $wgUser; |
22 | | - $this->skin = $wgUser->getSkin(); |
| 18 | + SpecialPage::SpecialPage( 'AdminLinks' ); |
| 19 | + wfLoadExtensionMessages( 'AdminLinks' ); |
| 20 | + global $wgUser; |
| 21 | + $this->skin = $wgUser->getSkin(); |
23 | 22 | } |
24 | 23 | |
25 | 24 | function createInitialTree() { |
26 | 25 | $tree = new ALTree(); |
27 | 26 | |
28 | 27 | // 'general' section |
29 | | - $general_section = new ALSection(wfMsg('adminlinks_general')); |
30 | | - $main_row = new ALRow('main'); |
31 | | - $main_row->addItem(ALItem::newFromSpecialPage('Specialpages')); |
32 | | - $main_row->addItem(ALItem::newFromSpecialPage('Allmessages')); |
33 | | - $main_row->addItem(ALItem::newFromEditLink('Sidebar', wfMsg('adminlinks_editsidebar'))); |
34 | | - $main_row->addItem(ALItem::newFromEditLink('Common.css', wfMsg('adminlinks_editcss'))); |
35 | | - $main_row->addItem(ALItem::newFromEditLink('Mainpage', wfMsg('adminlinks_editmainpagename'))); |
36 | | - $general_section->addRow($main_row); |
37 | | - $tree->addSection($general_section); |
| 28 | + $general_section = new ALSection( wfMsg( 'adminlinks_general' ) ); |
| 29 | + $main_row = new ALRow( 'main' ); |
| 30 | + $main_row->addItem( ALItem::newFromSpecialPage( 'Specialpages' ) ); |
| 31 | + $main_row->addItem( ALItem::newFromSpecialPage( 'Allmessages' ) ); |
| 32 | + $main_row->addItem( ALItem::newFromEditLink( 'Sidebar', wfMsg( 'adminlinks_editsidebar' ) ) ); |
| 33 | + $main_row->addItem( ALItem::newFromEditLink( 'Common.css', wfMsg( 'adminlinks_editcss' ) ) ); |
| 34 | + $main_row->addItem( ALItem::newFromEditLink( 'Mainpage', wfMsg( 'adminlinks_editmainpagename' ) ) ); |
| 35 | + $general_section->addRow( $main_row ); |
| 36 | + $tree->addSection( $general_section ); |
38 | 37 | |
39 | 38 | // 'users' section |
40 | | - $users_section = new ALSection(wfMsg('adminlinks_users')); |
41 | | - $main_row = new ALRow('main'); |
42 | | - $main_row->addItem(ALItem::newFromSpecialPage('Listusers')); |
43 | | - $ul = SpecialPage::getTitleFor('Userlogin'); |
44 | | - $al = SpecialPage::getTitleFor('AdminLinks'); |
45 | | - $main_row->addItem(AlItem::newFromPage($ul, wfMsg('adminlinks_createuser'), "type=signup&returnto=$al")); |
46 | | - $main_row->addItem(ALItem::newFromSpecialPage('Userrights')); |
47 | | - $users_section->addRow($main_row); |
48 | | - $tree->addSection($users_section); |
| 39 | + $users_section = new ALSection( wfMsg( 'adminlinks_users' ) ); |
| 40 | + $main_row = new ALRow( 'main' ); |
| 41 | + $main_row->addItem( ALItem::newFromSpecialPage( 'Listusers' ) ); |
| 42 | + $ul = SpecialPage::getTitleFor( 'Userlogin' ); |
| 43 | + $al = SpecialPage::getTitleFor( 'AdminLinks' ); |
| 44 | + $main_row->addItem( AlItem::newFromPage( $ul, wfMsg( 'adminlinks_createuser' ), "type=signup&returnto=$al" ) ); |
| 45 | + $main_row->addItem( ALItem::newFromSpecialPage( 'Userrights' ) ); |
| 46 | + $users_section->addRow( $main_row ); |
| 47 | + $tree->addSection( $users_section ); |
49 | 48 | |
50 | 49 | // 'browsing and searching' section |
51 | | - $browse_search_section = new ALSection(wfMsg('adminlinks_browsesearch')); |
52 | | - $main_row = new ALRow('main'); |
53 | | - $main_row->addItem(ALItem::newFromSpecialPage('Allpages')); |
54 | | - $main_row->addItem(ALItem::newFromSpecialPage('Search')); |
55 | | - $browse_search_section->addRow($main_row); |
56 | | - $tree->addSection($browse_search_section); |
| 50 | + $browse_search_section = new ALSection( wfMsg( 'adminlinks_browsesearch' ) ); |
| 51 | + $main_row = new ALRow( 'main' ); |
| 52 | + $main_row->addItem( ALItem::newFromSpecialPage( 'Allpages' ) ); |
| 53 | + $main_row->addItem( ALItem::newFromSpecialPage( 'Search' ) ); |
| 54 | + $browse_search_section->addRow( $main_row ); |
| 55 | + $tree->addSection( $browse_search_section ); |
57 | 56 | |
58 | 57 | // 'importing and exporting' section |
59 | | - $import_export_section = new ALSection(wfMsg('adminlinks_importexport')); |
60 | | - $main_row = new ALRow('main'); |
61 | | - $main_row->addItem(ALItem::newFromSpecialPage('Export')); |
62 | | - $main_row->addItem(ALItem::newFromSpecialPage('Import')); |
63 | | - $import_export_section->addRow($main_row); |
64 | | - $tree->addSection($import_export_section); |
| 58 | + $import_export_section = new ALSection( wfMsg( 'adminlinks_importexport' ) ); |
| 59 | + $main_row = new ALRow( 'main' ); |
| 60 | + $main_row->addItem( ALItem::newFromSpecialPage( 'Export' ) ); |
| 61 | + $main_row->addItem( ALItem::newFromSpecialPage( 'Import' ) ); |
| 62 | + $import_export_section->addRow( $main_row ); |
| 63 | + $tree->addSection( $import_export_section ); |
65 | 64 | |
66 | 65 | return $tree; |
67 | 66 | } |
68 | 67 | |
69 | | - function execute($query) { |
| 68 | + function execute( $query ) { |
70 | 69 | $this->setHeaders(); |
71 | 70 | $admin_links_tree = $this->createInitialTree(); |
72 | 71 | wfRunHooks( 'AdminLinks', array( &$admin_links_tree ) ); |
73 | 72 | global $wgOut; |
74 | | - $wgOut->addHTML($admin_links_tree->toString()); |
| 73 | + $wgOut->addHTML( $admin_links_tree->toString() ); |
75 | 74 | } |
76 | 75 | |
77 | 76 | /** |
— | — | @@ -78,15 +77,15 @@ |
79 | 78 | * among the user's "personal URLs" at the top, if they have |
80 | 79 | * the 'adminlinks' permission |
81 | 80 | */ |
82 | | - public static function addURLToUserLinks(&$personal_urls, &$title) { |
| 81 | + public static function addURLToUserLinks( &$personal_urls, &$title ) { |
83 | 82 | global $wgUser; |
84 | 83 | // if user is a sysop, add link |
85 | | - if ($wgUser->isAllowed('adminlinks')) { |
86 | | - wfLoadExtensionMessages('AdminLinks'); |
| 84 | + if ( $wgUser->isAllowed( 'adminlinks' ) ) { |
| 85 | + wfLoadExtensionMessages( 'AdminLinks' ); |
87 | 86 | $al = SpecialPage::getTitleFor( 'AdminLinks' ); |
88 | 87 | $href = $al->getLocalURL(); |
89 | 88 | $admin_links_vals = array( |
90 | | - 'text' => wfMsg('adminlinks'), |
| 89 | + 'text' => wfMsg( 'adminlinks' ), |
91 | 90 | 'href' => $href, |
92 | 91 | 'active' => ( $href == $title->getLocalURL() ) |
93 | 92 | ); |
— | — | @@ -96,13 +95,13 @@ |
97 | 96 | // keys and the values of the array, by editing them |
98 | 97 | // separately and then rebuilding the array. |
99 | 98 | // based on the example at http://us2.php.net/manual/en/function.array-splice.php#31234 |
100 | | - $tab_keys = array_keys($personal_urls); |
101 | | - $tab_values = array_values($personal_urls); |
102 | | - $prefs_location = array_search('preferences', $tab_keys); |
103 | | - array_splice($tab_keys, $prefs_location, 0, 'adminlinks'); |
104 | | - array_splice($tab_values, $prefs_location, 0, array($admin_links_vals)); |
| 99 | + $tab_keys = array_keys( $personal_urls ); |
| 100 | + $tab_values = array_values( $personal_urls ); |
| 101 | + $prefs_location = array_search( 'preferences', $tab_keys ); |
| 102 | + array_splice( $tab_keys, $prefs_location, 0, 'adminlinks' ); |
| 103 | + array_splice( $tab_values, $prefs_location, 0, array( $admin_links_vals ) ); |
105 | 104 | $personal_urls = array(); |
106 | | - for ($i = 0; $i < count($tab_keys); $i++) |
| 105 | + for ( $i = 0; $i < count( $tab_keys ); $i++ ) |
107 | 106 | $personal_urls[$tab_keys[$i]] = $tab_values[$i]; |
108 | 107 | |
109 | 108 | } |
— | — | @@ -121,23 +120,23 @@ |
122 | 121 | $this->sections = array(); |
123 | 122 | } |
124 | 123 | |
125 | | - function getSection($section_header) { |
126 | | - foreach ($this->sections as $cur_section) { |
127 | | - if ($cur_section->header === $section_header) { |
| 124 | + function getSection( $section_header ) { |
| 125 | + foreach ( $this->sections as $cur_section ) { |
| 126 | + if ( $cur_section->header === $section_header ) { |
128 | 127 | return $cur_section; |
129 | 128 | } |
130 | 129 | } |
131 | 130 | return null; |
132 | 131 | } |
133 | 132 | |
134 | | - function addSection($section, $next_section_header = null) { |
135 | | - if ($next_section_header == null) { |
| 133 | + function addSection( $section, $next_section_header = null ) { |
| 134 | + if ( $next_section_header == null ) { |
136 | 135 | $this->sections[] = $section; |
137 | 136 | return; |
138 | 137 | } |
139 | | - foreach ($this->sections as $i => $cur_section) { |
140 | | - if ($cur_section->header === $next_section_header) { |
141 | | - array_splice($this->sections, $i, 0, array($section)); |
| 138 | + foreach ( $this->sections as $i => $cur_section ) { |
| 139 | + if ( $cur_section->header === $next_section_header ) { |
| 140 | + array_splice( $this->sections, $i, 0, array( $section ) ); |
142 | 141 | return; |
143 | 142 | } |
144 | 143 | } |
— | — | @@ -146,7 +145,7 @@ |
147 | 146 | |
148 | 147 | function toString() { |
149 | 148 | $text = ""; |
150 | | - foreach ($this->sections as $section) { |
| 149 | + foreach ( $this->sections as $section ) { |
151 | 150 | $text .= $section->toString(); |
152 | 151 | } |
153 | 152 | return $text; |
— | — | @@ -160,28 +159,28 @@ |
161 | 160 | var $header; |
162 | 161 | var $rows; |
163 | 162 | |
164 | | - function ALSection($header) { |
| 163 | + function ALSection( $header ) { |
165 | 164 | $this->header = $header; |
166 | 165 | $this->rows = array(); |
167 | 166 | } |
168 | 167 | |
169 | | - function getRow($row_name) { |
170 | | - foreach ($this->rows as $cur_row) { |
171 | | - if ($cur_row->name === $row_name) { |
| 168 | + function getRow( $row_name ) { |
| 169 | + foreach ( $this->rows as $cur_row ) { |
| 170 | + if ( $cur_row->name === $row_name ) { |
172 | 171 | return $cur_row; |
173 | 172 | } |
174 | 173 | } |
175 | 174 | return null; |
176 | 175 | } |
177 | 176 | |
178 | | - function addRow($row, $next_row_name = null) { |
179 | | - if ($next_row_name == null) { |
| 177 | + function addRow( $row, $next_row_name = null ) { |
| 178 | + if ( $next_row_name == null ) { |
180 | 179 | $this->rows[] = $row; |
181 | 180 | return; |
182 | 181 | } |
183 | | - foreach ($this->rows as $i => $cur_row) { |
184 | | - if ($cur_row->name === $next_row_name) { |
185 | | - array_splice($this->rows, $i, 0, array($row)); |
| 182 | + foreach ( $this->rows as $i => $cur_row ) { |
| 183 | + if ( $cur_row->name === $next_row_name ) { |
| 184 | + array_splice( $this->rows, $i, 0, array( $row ) ); |
186 | 185 | return; |
187 | 186 | } |
188 | 187 | } |
— | — | @@ -190,7 +189,7 @@ |
191 | 190 | |
192 | 191 | function toString() { |
193 | 192 | $text = ' <h4 class="mw-specialpagesgroup">' . $this->header . "</h4>\n"; |
194 | | - foreach ($this->rows as $row) { |
| 193 | + foreach ( $this->rows as $row ) { |
195 | 194 | $text .= $row->toString(); |
196 | 195 | } |
197 | 196 | return $text; |
— | — | @@ -205,19 +204,19 @@ |
206 | 205 | var $name; |
207 | 206 | var $items; |
208 | 207 | |
209 | | - function ALRow($name) { |
| 208 | + function ALRow( $name ) { |
210 | 209 | $this->name = $name; |
211 | 210 | $this->items = array(); |
212 | 211 | } |
213 | 212 | |
214 | | - function addItem($item, $next_item_label = null) { |
215 | | - if ($next_item_label == null) { |
| 213 | + function addItem( $item, $next_item_label = null ) { |
| 214 | + if ( $next_item_label == null ) { |
216 | 215 | $this->items[] = $item; |
217 | 216 | return; |
218 | 217 | } |
219 | | - foreach ($this->items as $i => $cur_item) { |
220 | | - if ($cur_item->label === $next_item_label) { |
221 | | - array_splice($this->items, $i, 0, array($item)); |
| 218 | + foreach ( $this->items as $i => $cur_item ) { |
| 219 | + if ( $cur_item->label === $next_item_label ) { |
| 220 | + array_splice( $this->items, $i, 0, array( $item ) ); |
222 | 221 | return; |
223 | 222 | } |
224 | 223 | } |
— | — | @@ -226,8 +225,8 @@ |
227 | 226 | |
228 | 227 | function toString() { |
229 | 228 | $text = " <p>\n"; |
230 | | - foreach ($this->items as $i => $item) { |
231 | | - if ($i > 0) |
| 229 | + foreach ( $this->items as $i => $item ) { |
| 230 | + if ( $i > 0 ) |
232 | 231 | $text .= " ·\n"; |
233 | 232 | $text .= ' ' . $item->text; |
234 | 233 | } |
— | — | @@ -244,36 +243,36 @@ |
245 | 244 | var $text; |
246 | 245 | var $label; |
247 | 246 | |
248 | | - static function newFromPage($page_name, $desc = null, $params = null) { |
| 247 | + static function newFromPage( $page_name, $desc = null, $params = null ) { |
249 | 248 | $item = new ALItem(); |
250 | 249 | $item->label = $desc; |
251 | | - if ($params != null) { |
| 250 | + if ( $params != null ) { |
252 | 251 | global $wgUser; |
253 | | - $item->text = $wgUser->getSkin()->makeKnownLinkObj($page_name, $desc, $params); |
| 252 | + $item->text = $wgUser->getSkin()->makeKnownLinkObj( $page_name, $desc, $params ); |
254 | 253 | } else |
255 | 254 | $item->text = "[[$page_name|$desc]]"; |
256 | 255 | return $item; |
257 | 256 | } |
258 | 257 | |
259 | | - static function newFromSpecialPage($page_name) { |
| 258 | + static function newFromSpecialPage( $page_name ) { |
260 | 259 | $item = new ALItem(); |
261 | 260 | $item->label = $page_name; |
262 | | - $page = SpecialPage::getPage($page_name); |
| 261 | + $page = SpecialPage::getPage( $page_name ); |
263 | 262 | global $wgUser; |
264 | | - $item->text = $wgUser->getSkin()->makeKnownLinkObj($page->getTitle(), $page->getDescription()); |
| 263 | + $item->text = $wgUser->getSkin()->makeKnownLinkObj( $page->getTitle(), $page->getDescription() ); |
265 | 264 | return $item; |
266 | 265 | } |
267 | 266 | |
268 | | - static function newFromEditLink($page_name, $desc) { |
| 267 | + static function newFromEditLink( $page_name, $desc ) { |
269 | 268 | $item = new ALItem(); |
270 | 269 | $item->label = $page_name; |
271 | | - $title = Title::makeTitleSafe(NS_MEDIAWIKI, $page_name); |
272 | | - $edit_link = $title->getFullURL('action=edit'); |
| 270 | + $title = Title::makeTitleSafe( NS_MEDIAWIKI, $page_name ); |
| 271 | + $edit_link = $title->getFullURL( 'action=edit' ); |
273 | 272 | $item->text = "<a href=\"$edit_link\">$desc</a>"; |
274 | 273 | return $item; |
275 | 274 | } |
276 | 275 | |
277 | | - static function newFromExternalLink($url, $label) { |
| 276 | + static function newFromExternalLink( $url, $label ) { |
278 | 277 | $item = new ALItem(); |
279 | 278 | $item->label = $label; |
280 | 279 | $item->text = "<a class=\"external text\" rel=\"nofollow\" href=\"$url\">$label</a>"; |