r58725 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58724‎ | r58725 | r58726 >
Date:18:03, 7 November 2009
Author:ashley
Status:deferred
Tags:
Comment:
DataCenter: coding style cleanup for UI/Widgets
Modified paths:
  • /trunk/extensions/DataCenter/UI/Widgets/Actions.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/Body.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/Details.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/Export.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/FieldLinks.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/Form.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/Gallery.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/Heading.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/History.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/Map.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/Model.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/Plan.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/Search.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/SearchResults.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/Space.php (modified) (history)
  • /trunk/extensions/DataCenter/UI/Widgets/Table.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DataCenter/UI/Widgets/Plan.php
@@ -75,9 +75,7 @@
7676
7777 /* Static Functions */
7878
79 - public static function render(
80 - array $parameters
81 - ) {
 79+ public static function render( array $parameters ) {
8280 // Adds script to UI
8381 DataCenterUI::addScript(
8482 '/extensions/DataCenter/Resources/Widgets/Plan/Plan.js'
@@ -125,9 +123,7 @@
126124 return $xmlOutput;
127125 }
128126
129 - private static function addPlanJsFunction(
130 - array $parameters
131 - ) {
 127+ private static function addPlanJsFunction( array $parameters ) {
132128 // Adds script to add plan to scene
133129 $jsOutput = DataCenterJs::callFunction(
134130 'scene.setModule',
@@ -148,9 +144,7 @@
149145 return DataCenterJs::buildFunction( array( 'scene' ), $jsOutput );
150146 }
151147
152 - private static function buildStateJsObject(
153 - $parameters
154 - ) {
 148+ private static function buildStateJsObject( $parameters ) {
155149 // Builds array for state
156150 $state = array(
157151 'focus' => array(
@@ -170,11 +164,11 @@
171165 $state['focus']['id'] = $parameters['look-at-rack'];
172166 $state['focus']['progress'] = 1;
173167 $state['focus']['inc'] = true;
174 - } else if ( $parameters['zoom-to-rack'] !== null ) {
 168+ } elseif ( $parameters['zoom-to-rack'] !== null ) {
175169 $state['focus']['id'] = $parameters['zoom-to-rack'];
176170 $state['focus']['progress'] = 0;
177171 $state['focus']['inc'] = true;
178 - } else if ( $parameters['zoom-from-rack'] !== null ) {
 172+ } elseif ( $parameters['zoom-from-rack'] !== null ) {
179173 $state['focus']['id'] = $parameters['zoom-from-rack'];
180174 $state['focus']['progress'] = 0;
181175 $state['focus']['inc'] = false;
@@ -183,9 +177,7 @@
184178 return DataCenterJs::toObject( $state );
185179 }
186180
187 - private static function buildPhysicalJsObject(
188 - $parameters
189 - ) {
 181+ private static function buildPhysicalJsObject( $parameters ) {
190182 // Creates shortcut to plan
191183 $plan = $parameters['plan'];
192184 // Gets plan's space from database
@@ -256,7 +248,7 @@
257249 // Creates empty array
258250 $physical = array();
259251 }
260 - // Returns javascript object
 252+ // Returns JavaScript object
261253 return DataCenterJs::toObject( $physical );
262254 }
263255 }
\ No newline at end of file
Index: trunk/extensions/DataCenter/UI/Widgets/Space.php
@@ -40,9 +40,7 @@
4141
4242 /* Static Functions */
4343
44 - public static function render(
45 - array $parameters
46 - ) {
 44+ public static function render( array $parameters ) {
4745 // Adds script to UI
4846 DataCenterUI::addScript(
4947 '/extensions/DataCenter/Resources/Widgets/Space/Space.js'
@@ -92,9 +90,7 @@
9391 return $xmlOutput;
9492 }
9593
96 - private static function addSpaceJsFunction(
97 - array $parameters
98 - ) {
 94+ private static function addSpaceJsFunction( array $parameters ) {
9995 // Adds script to add space to scene
10096 $jsOutput = DataCenterJs::callFunction(
10197 'scene.setModule',
@@ -114,9 +110,7 @@
115111 return DataCenterJs::buildFunction( array( 'scene' ), $jsOutput );
116112 }
117113
118 - private static function buildPhysicalJsObject(
119 - $parameters
120 - ) {
 114+ private static function buildPhysicalJsObject( $parameters ) {
121115 // Creates shortcut to space
122116 $space = $parameters['space'];
123117 // Checks if space was valid
Index: trunk/extensions/DataCenter/UI/Widgets/Body.php
@@ -50,9 +50,7 @@
5151
5252 /* Functions */
5353
54 - public static function render(
55 - array $parameters
56 - ) {
 54+ public static function render( array $parameters ) {
5755 // Sets defaults
5856 $parameters = array_merge( self::$defaultParameters, $parameters );
5957 // Begins widget
@@ -76,7 +74,7 @@
7775 'body', $parameters['message'], $parameters['subject']
7876 );
7977 // Checks if a type was given
80 - } else if ( $parameters['type'] !== null ) {
 78+ } elseif ( $parameters['type'] !== null ) {
8179 // Uses type-based message
8280 $message = DataCenterUI::message(
8381 'body',
@@ -95,7 +93,7 @@
9694 DataCenterXml::div( $message )
9795 );
9896 // Checks if text was given
99 - } else if (
 97+ } elseif (
10098 // Required parameters
10199 isset( $parameters['text'] ) &&
102100 // Required styles
Index: trunk/extensions/DataCenter/UI/Widgets/Gallery.php
@@ -54,9 +54,7 @@
5555
5656 /* Static Functions */
5757
58 - public static function render(
59 - array $parameters
60 - ) {
 58+ public static function render( array $parameters ) {
6159 // Sets defaults
6260 $parameters = array_merge_recursive(
6361 self::$defaultParameters, $parameters
Index: trunk/extensions/DataCenter/UI/Widgets/Heading.php
@@ -45,9 +45,7 @@
4646
4747 /* Functions */
4848
49 - public static function render(
50 - array $parameters
51 - ) {
 49+ public static function render( array $parameters ) {
5250 // Sets defaults
5351 $parameters = array_merge( self::$defaultParameters, $parameters );
5452 // Begins widget
@@ -65,9 +63,7 @@
6664 $message = DataCenterUI::message(
6765 'heading', $parameters['message'], $parameters['subject']
6866 );
69 - }
70 - // Checks if a type was given
71 - else if ( $parameters['type'] !== null ) {
 67+ } elseif ( $parameters['type'] !== null ) { // Checks if a type was given
7268 // Uses type-based message
7369 $message = DataCenterUI::message(
7470 'heading',
@@ -83,7 +79,7 @@
8480 // Returns heading with message
8581 $xmlOutput .= $message;
8682 // Checks if text was given
87 - } else if ( $parameters['text'] !== null ) {
 83+ } elseif ( $parameters['text'] !== null ) {
8884 // Adds a heading with text
8985 $xmlOutput .= $parameters['text'];
9086 }
Index: trunk/extensions/DataCenter/UI/Widgets/Actions.php
@@ -40,9 +40,7 @@
4141
4242 /* Functions */
4343
44 - public static function render(
45 - array $parameters
46 - ) {
 44+ public static function render( array $parameters ) {
4745 // Sets defaults
4846 $parameters = array_merge( self::$defaultParameters, $parameters );
4947 // Checks for permissions
@@ -72,7 +70,7 @@
7371 }
7472 // Builds label
7573 $label = DataCenterUI::message( 'action', $label . '-type',
76 - DataCenterUI::message('type', $subject )
 74+ DataCenterUI::message( 'type', $subject )
7775 );
7876 // Builds link
7977 $link = DataCenterXml::link( $label, $link );
Index: trunk/extensions/DataCenter/UI/Widgets/Model.php
@@ -41,9 +41,7 @@
4242
4343 /* Static Functions */
4444
45 - public static function render(
46 - array $parameters
47 - ) {
 45+ public static function render( array $parameters ) {
4846 // Sets Defaults
4947 $parameters = array_merge( self::$defaultParameters, $parameters );
5048 // Begins widget
@@ -82,17 +80,13 @@
8381
8482 /* Private Static Functions */
8583
86 - private static function renderModel(
87 - $parameters,
88 - $structure,
89 - $level = 0
90 - ) {
 84+ private static function renderModel( $parameters, $structure, $level = 0 ) {
9185 $xmlOutput = '';
9286 foreach ( $structure as $model ) {
9387 $modelLink = DataCenterDB::getModelLink( $model->get( 'link' ) );
9488 if ( !DataCenterPage::userCan( 'change' ) ) {
9589 $rowAttributes = array();
96 - } else if ( $level == 0 && count( $parameters['link'] ) > 0 ) {
 90+ } elseif ( $level == 0 && count( $parameters['link'] ) > 0 ) {
9791 $rowAttributes = array_merge(
9892 array( 'class' => 'link' ),
9993 DataCenterXml::buildLink( $parameters['link'], $model )
Index: trunk/extensions/DataCenter/UI/Widgets/History.php
@@ -83,9 +83,7 @@
8484
8585 /* Static Functions */
8686
87 - public static function render(
88 - array $parameters
89 - ) {
 87+ public static function render( array $parameters ) {
9088 global $wgUser;
9189 // Gets current path
9290 $path = DataCenterPage::getPath();
@@ -388,9 +386,7 @@
389387 return $xmlOutput;
390388 }
391389
392 - public static function compareChanges(
393 - $data
394 - ) {
 390+ public static function compareChanges( $data ) {
395391 global $wgOut;
396392 $path = DataCenterPage::getPath();
397393 $path['parameter'] = array(
Index: trunk/extensions/DataCenter/UI/Widgets/Form.php
@@ -157,9 +157,7 @@
158158
159159 /* Functions */
160160
161 - public static function render(
162 - array $parameters
163 - ) {
 161+ public static function render( array $parameters ) {
164162 global $wgUser;
165163 // Sets defaults
166164 $parameters = array_merge( self::$defaultParameters, $parameters );
@@ -260,7 +258,7 @@
261259 // Sets name of input for form processing
262260 $inputOptions['name'] = "row[{$inputOptions['field']}]";
263261 // Alternatively checks if a list of fields were given
264 - } else if ( isset( $inputOptions['fields'] ) ) {
 262+ } elseif ( isset( $inputOptions['fields'] ) ) {
265263 // Loops over each sub-field
266264 foreach( $inputOptions['fields'] as $key => $field ) {
267265 // Checks if sub-field is an array
Index: trunk/extensions/DataCenter/UI/Widgets/Search.php
@@ -83,9 +83,7 @@
8484
8585 /* Static Functions */
8686
87 - public static function render(
88 - array $parameters
89 - ) {
 87+ public static function render( array $parameters ) {
9088 global $wgUser;
9189 // Gets current path
9290 $path = DataCenterPage::getPath();
@@ -151,9 +149,7 @@
152150 return $xmlOutput;
153151 }
154152
155 - public static function redirect(
156 - $data
157 - ) {
 153+ public static function redirect( $data ) {
158154 global $wgOut;
159155 $path = DataCenterPage::getPath();
160156 if ( isset( $data['meta']['query'] ) ) {
Index: trunk/extensions/DataCenter/UI/Widgets/Map.php
@@ -46,9 +46,7 @@
4747
4848 /* Static Functions */
4949
50 - public static function render(
51 - array $parameters
52 - ) {
 50+ public static function render( array $parameters ) {
5351 global $egDataCenterGoogleMapsAPIKey;
5452 DataCenterUI::addScript(
5553 'http://maps.google.com/maps?file=api&v=2&key=' .
@@ -83,7 +81,7 @@
8482 self::addMarkersJsFunction( $parameters )
8583 );
8684 // Alternatively checks if a single location was given
87 - } else if ( $parameters['location'] ) {
 85+ } elseif ( $parameters['location'] ) {
8886 // Builds script to add setup job to renderer
8987 $jsOutput = sprintf(
9088 "dataCenter.renderer.addJob( 'map', %s, %s );",
@@ -107,10 +105,7 @@
108106
109107 /* Private Funtions */
110108
111 - private static function markerOptions(
112 - array $parameters,
113 - $location
114 - ) {
 109+ private static function markerOptions( array $parameters, $location ) {
115110 // Begins window
116111 $xmlOutput = DataCenterXml::open( 'div', array( 'class' => 'window' ) );
117112 // Adds heading
@@ -150,9 +145,7 @@
151146 return DataCenterJs::toObject( array( 'content' => $xmlOutput ) );
152147 }
153148
154 - private static function showPositionJsFunction(
155 - array $parameters
156 - ) {
 149+ private static function showPositionJsFunction( array $parameters ) {
157150 $location = $parameters['location'];
158151 // Builds script to show position
159152 return sprintf(
@@ -163,9 +156,7 @@
164157 );
165158 }
166159
167 - private static function addMarkersJsFunction(
168 - array $parameters
169 - ) {
 160+ private static function addMarkersJsFunction( array $parameters ) {
170161 // Begins building javascript for adding markers
171162 $jsMarkers = '';
172163 // Loops over each location
Index: trunk/extensions/DataCenter/UI/Widgets/Export.php
@@ -79,9 +79,7 @@
8080
8181 /* Static Functions */
8282
83 - public static function render(
84 - array $parameters
85 - ) {
 83+ public static function render( array $parameters ) {
8684 global $wgUser;
8785 // Gets current path
8886 $path = DataCenterPage::getPath();
@@ -232,11 +230,9 @@
233231 return $xmlOutput;
234232 }
235233
236 - public static function export(
237 - array $data
238 - ) {
 234+ public static function export( array $data ) {
239235 global $wgOut;
240 - // Disables mediawiki output
 236+ // Disables MediaWiki output
241237 $wgOut->disable();
242238 // Gets current path
243239 $path = DataCenterPage::getPath();
@@ -253,8 +249,8 @@
254250 ) .
255251 ' - ' . $date . '.' . $data['meta']['format'];
256252 // Sets headers for downloading CSV file
257 - header("Content-type: application/octet-stream");
258 - header("Content-Disposition: attachment; filename=\"{$fileName}\"");
 253+ header( 'Content-type: application/octet-stream' );
 254+ header( "Content-Disposition: attachment; filename=\"{$fileName}\"" );
259255 $rows = DataCenterDB::getRows(
260256 'DataCenterDBRow',
261257 $data['meta']['category'],
@@ -340,9 +336,7 @@
341337 }
342338 }
343339
344 - private static function exportValue(
345 - $value
346 - ) {
 340+ private static function exportValue( $value ) {
347341 if (
348342 strpos( $value, ',' ) !== false ||
349343 strpos( $value, '"' ) !== false ||
Index: trunk/extensions/DataCenter/UI/Widgets/FieldLinks.php
@@ -93,9 +93,7 @@
9494
9595 /* Static Functions */
9696
97 - public static function render(
98 - array $parameters
99 - ) {
 97+ public static function render( array $parameters ) {
10098 global $wgUser;
10199 // Gets current path
102100 $path = DataCenterPage::getPath();
@@ -274,9 +272,7 @@
275273 return $xmlOutput;
276274 }
277275
278 - public function saveFieldLinks(
279 - array $data
280 - ) {
 276+ public function saveFieldLinks( array $data ) {
281277 $metaField = DataCenterDBMetaField::newFromValues( $data['row'] );
282278 $metaFieldLinks = $metaField->getLinks();
283279 // Build table of links that do exist
@@ -313,7 +309,7 @@
314310 )
315311 );
316312 $metaFieldLink->insert();
317 - } else if (
 313+ } elseif (
318314 !isset( $shouldExistTable[$key] ) &&
319315 isset( $doesExistTable[$key] ) &&
320316 ( $doesExistTable[$key]->numValues() == 0 )
Index: trunk/extensions/DataCenter/UI/Widgets/Details.php
@@ -39,9 +39,7 @@
4040
4141 /* Functions */
4242
43 - public static function render(
44 - array $parameters
45 - ) {
 43+ public static function render( array $parameters ) {
4644 // Sets defaults
4745 $parameters = array_merge( self::$defaultParameters, $parameters );
4846 // Begins widget
Index: trunk/extensions/DataCenter/UI/Widgets/SearchResults.php
@@ -82,9 +82,7 @@
8383
8484 /* Static Functions */
8585
86 - public static function render(
87 - array $parameters
88 - ) {
 86+ public static function render( array $parameters ) {
8987 global $wgUser;
9088 // Gets current path
9189 $path = DataCenterPage::getPath();
@@ -139,8 +137,7 @@
140138 'body',
141139 array( 'message' => 'notice-no-results', 'style' => 'notice' )
142140 );
143 - }
144 - else {
 141+ } else {
145142 $joins = array();
146143 if ( $currentTarget['class'] == 'DataCenterDBAsset' ) {
147144 $joins = array_merge_recursive(
Index: trunk/extensions/DataCenter/UI/Widgets/Table.php
@@ -79,9 +79,7 @@
8080
8181 /* Static Functions */
8282
83 - public static function render(
84 - array $parameters
85 - ) {
 83+ public static function render( array $parameters ) {
8684 // Sets defaults
8785 $parameters = array_merge_recursive(
8886 self::$defaultParameters, $parameters
@@ -195,9 +193,7 @@
196194 * the widget as options for the entire column,
197195 * merging with default options to ensure keys exist
198196 */
199 - private static function processFields(
200 - $fields
201 - ) {
 197+ private static function processFields( $fields ) {
202198 // Checks that fields is an array with at least one element
203199 if ( count( $fields ) == 0 ) {
204200 return null;

Status & tagging log