r62431 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62430‎ | r62431 | r62432 >
Date:14:29, 13 February 2010
Author:siebrand
Status:deferred
Tags:
Comment:
Update code formatting, run stylize.php, whitespace updates
Modified paths:
  • /trunk/extensions/AdminLinks/AdminLinks.php (modified) (history)
  • /trunk/extensions/AdminLinks/AdminLinks_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AdminLinks/AdminLinks.php
@@ -5,7 +5,7 @@
66 * @author Yaron Koren
77 */
88
9 -if (!defined('MEDIAWIKI')) die();
 9+if ( !defined( 'MEDIAWIKI' ) ) die();
1010
1111 // credits
1212 $wgExtensionCredits['specialpage'][] = array(
@@ -18,7 +18,7 @@
1919 'descriptionmsg' => 'adminlinks-desc',
2020 );
2121
22 -$wgAdminLinksIP = dirname(__FILE__) . '/';
 22+$wgAdminLinksIP = dirname( __FILE__ ) . '/';
2323 $wgExtensionMessagesFiles['AdminLinks'] = $wgAdminLinksIP . 'AdminLinks.i18n.php';
2424 $wgSpecialPages['AdminLinks'] = 'AdminLinks';
2525 $wgHooks['PersonalUrls'][] = 'AdminLinks::addURLToUserLinks';
Index: trunk/extensions/AdminLinks/AdminLinks_body.php
@@ -5,72 +5,71 @@
66 * @author Yaron Koren
77 */
88
9 -if (!defined('MEDIAWIKI')) die();
 9+if ( !defined( 'MEDIAWIKI' ) ) die();
1010
1111 class AdminLinks extends SpecialPage {
12 -
1312 var $skin;
1413
1514 /**
1615 * Constructor
1716 */
1817 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();
2322 }
2423
2524 function createInitialTree() {
2625 $tree = new ALTree();
2726
2827 // '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 );
3837
3938 // '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 );
4948
5049 // '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 );
5756
5857 // '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 );
6564
6665 return $tree;
6766 }
6867
69 - function execute($query) {
 68+ function execute( $query ) {
7069 $this->setHeaders();
7170 $admin_links_tree = $this->createInitialTree();
7271 wfRunHooks( 'AdminLinks', array( &$admin_links_tree ) );
7372 global $wgOut;
74 - $wgOut->addHTML($admin_links_tree->toString());
 73+ $wgOut->addHTML( $admin_links_tree->toString() );
7574 }
7675
7776 /**
@@ -78,15 +77,15 @@
7978 * among the user's "personal URLs" at the top, if they have
8079 * the 'adminlinks' permission
8180 */
82 - public static function addURLToUserLinks(&$personal_urls, &$title) {
 81+ public static function addURLToUserLinks( &$personal_urls, &$title ) {
8382 global $wgUser;
8483 // if user is a sysop, add link
85 - if ($wgUser->isAllowed('adminlinks')) {
86 - wfLoadExtensionMessages('AdminLinks');
 84+ if ( $wgUser->isAllowed( 'adminlinks' ) ) {
 85+ wfLoadExtensionMessages( 'AdminLinks' );
8786 $al = SpecialPage::getTitleFor( 'AdminLinks' );
8887 $href = $al->getLocalURL();
8988 $admin_links_vals = array(
90 - 'text' => wfMsg('adminlinks'),
 89+ 'text' => wfMsg( 'adminlinks' ),
9190 'href' => $href,
9291 'active' => ( $href == $title->getLocalURL() )
9392 );
@@ -96,13 +95,13 @@
9796 // keys and the values of the array, by editing them
9897 // separately and then rebuilding the array.
9998 // 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 ) );
105104 $personal_urls = array();
106 - for ($i = 0; $i < count($tab_keys); $i++)
 105+ for ( $i = 0; $i < count( $tab_keys ); $i++ )
107106 $personal_urls[$tab_keys[$i]] = $tab_values[$i];
108107
109108 }
@@ -121,23 +120,23 @@
122121 $this->sections = array();
123122 }
124123
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 ) {
128127 return $cur_section;
129128 }
130129 }
131130 return null;
132131 }
133132
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 ) {
136135 $this->sections[] = $section;
137136 return;
138137 }
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 ) );
142141 return;
143142 }
144143 }
@@ -146,7 +145,7 @@
147146
148147 function toString() {
149148 $text = "";
150 - foreach ($this->sections as $section) {
 149+ foreach ( $this->sections as $section ) {
151150 $text .= $section->toString();
152151 }
153152 return $text;
@@ -160,28 +159,28 @@
161160 var $header;
162161 var $rows;
163162
164 - function ALSection($header) {
 163+ function ALSection( $header ) {
165164 $this->header = $header;
166165 $this->rows = array();
167166 }
168167
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 ) {
172171 return $cur_row;
173172 }
174173 }
175174 return null;
176175 }
177176
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 ) {
180179 $this->rows[] = $row;
181180 return;
182181 }
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 ) );
186185 return;
187186 }
188187 }
@@ -190,7 +189,7 @@
191190
192191 function toString() {
193192 $text = ' <h4 class="mw-specialpagesgroup">' . $this->header . "</h4>\n";
194 - foreach ($this->rows as $row) {
 193+ foreach ( $this->rows as $row ) {
195194 $text .= $row->toString();
196195 }
197196 return $text;
@@ -205,19 +204,19 @@
206205 var $name;
207206 var $items;
208207
209 - function ALRow($name) {
 208+ function ALRow( $name ) {
210209 $this->name = $name;
211210 $this->items = array();
212211 }
213212
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 ) {
216215 $this->items[] = $item;
217216 return;
218217 }
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 ) );
222221 return;
223222 }
224223 }
@@ -226,8 +225,8 @@
227226
228227 function toString() {
229228 $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 )
232231 $text .= " &middot;\n";
233232 $text .= ' ' . $item->text;
234233 }
@@ -244,36 +243,36 @@
245244 var $text;
246245 var $label;
247246
248 - static function newFromPage($page_name, $desc = null, $params = null) {
 247+ static function newFromPage( $page_name, $desc = null, $params = null ) {
249248 $item = new ALItem();
250249 $item->label = $desc;
251 - if ($params != null) {
 250+ if ( $params != null ) {
252251 global $wgUser;
253 - $item->text = $wgUser->getSkin()->makeKnownLinkObj($page_name, $desc, $params);
 252+ $item->text = $wgUser->getSkin()->makeKnownLinkObj( $page_name, $desc, $params );
254253 } else
255254 $item->text = "[[$page_name|$desc]]";
256255 return $item;
257256 }
258257
259 - static function newFromSpecialPage($page_name) {
 258+ static function newFromSpecialPage( $page_name ) {
260259 $item = new ALItem();
261260 $item->label = $page_name;
262 - $page = SpecialPage::getPage($page_name);
 261+ $page = SpecialPage::getPage( $page_name );
263262 global $wgUser;
264 - $item->text = $wgUser->getSkin()->makeKnownLinkObj($page->getTitle(), $page->getDescription());
 263+ $item->text = $wgUser->getSkin()->makeKnownLinkObj( $page->getTitle(), $page->getDescription() );
265264 return $item;
266265 }
267266
268 - static function newFromEditLink($page_name, $desc) {
 267+ static function newFromEditLink( $page_name, $desc ) {
269268 $item = new ALItem();
270269 $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' );
273272 $item->text = "<a href=\"$edit_link\">$desc</a>";
274273 return $item;
275274 }
276275
277 - static function newFromExternalLink($url, $label) {
 276+ static function newFromExternalLink( $url, $label ) {
278277 $item = new ALItem();
279278 $item->label = $label;
280279 $item->text = "<a class=\"external text\" rel=\"nofollow\" href=\"$url\">$label</a>";

Status & tagging log