r45581 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45580‎ | r45581 | r45582 >
Date:20:20, 8 January 2009
Author:yaron
Status:deferred
Tags:
Comment:
Added explicit declaration of all static functions as static
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormClasses.inc (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.inc (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_LinkUtils.inc (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_TemplateField.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_TemplateField.inc
@@ -17,7 +17,7 @@
1818 var $possible_values;
1919 var $is_list;
2020
21 - function newWithValues($name, $label) {
 21+ static function newWithValues($name, $label) {
2222 $f = new SFTemplateField();
2323 $f->field_name = trim(str_replace('\\', '', $name));
2424 $f->label = trim(str_replace('\\', '', $label));
Index: trunk/extensions/SemanticForms/includes/SF_FormClasses.inc
@@ -11,7 +11,7 @@
1212 var $form_name;
1313 var $templates;
1414
15 - function create($form_name, $templates) {
 15+ static function create($form_name, $templates) {
1616 $form = new SFForm();
1717 $form->form_name = ucfirst(str_replace('_', ' ', $form_name));
1818 $form->templates = $templates;
@@ -151,7 +151,7 @@
152152 return $template_fields;
153153 }
154154
155 - function create($name, $label, $allow_multiple, $max_allowed = null) {
 155+ static function create($name, $label, $allow_multiple, $max_allowed = null) {
156156 $tif = new SFTemplateInForm();
157157 $tif->template_name = str_replace('_', ' ', $name);
158158 $tif->fields = array();
@@ -239,7 +239,7 @@
240240 var $input_name;
241241 var $is_disabled;
242242
243 - function create($num, $template_field) {
 243+ static function create($num, $template_field) {
244244 $f = new SFFormTemplateField();
245245 $f->num = $num;
246246 $f->template_field = $template_field;
@@ -252,7 +252,7 @@
253253 return $f;
254254 }
255255
256 - function createFromDefinition($field_name, $input_name, $is_mandatory, $is_hidden, $is_uploadable, $possible_values, $is_disabled, $is_list, $input_type, $field_args, $all_fields, $strict_parsing) {
 256+ static function createFromDefinition($field_name, $input_name, $is_mandatory, $is_hidden, $is_uploadable, $possible_values, $is_disabled, $is_list, $input_type, $field_args, $all_fields, $strict_parsing) {
257257 // see if this field matches one of the fields defined for this template -
258258 // if it is, use all available information about that field; if it's not,
259259 // either include it in the form or not, depending on whether the
Index: trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php
@@ -91,7 +91,7 @@
9292
9393 class SFParserFunctions {
9494
95 - function registerFunctions( &$parser ) {
 95+ static function registerFunctions( &$parser ) {
9696 $parser->setFunctionHook('forminput', array('SFParserFunctions', 'renderFormInput'));
9797 $parser->setFunctionHook('formlink', array('SFParserFunctions', 'renderFormLink'));
9898 if( defined( get_class( $parser ) . '::SFH_OBJECT_ARGS' ) ) {
@@ -104,7 +104,7 @@
105105 return true;
106106 }
107107
108 - function languageGetMagic( &$magicWords, $langCode = "en" ) {
 108+ static function languageGetMagic( &$magicWords, $langCode = "en" ) {
109109 switch ( $langCode ) {
110110 default:
111111 $magicWords['forminput'] = array ( 0, 'forminput' );
@@ -115,7 +115,7 @@
116116 return true;
117117 }
118118
119 - function renderFormLink (&$parser, $inFormName = '', $inLinkStr = '', $inLinkType='', $inQueryStr = '') {
 119+ static function renderFormLink (&$parser, $inFormName = '', $inLinkStr = '', $inLinkType='', $inQueryStr = '') {
120120 $ad = SpecialPage::getPage('AddData');
121121 $link_url = $ad->getTitle()->getLocalURL() . "/$inFormName";
122122 $link_url = str_replace(' ', '_', $link_url);
@@ -133,7 +133,7 @@
134134 return $parser->insertStripItem($str, $parser->mStripState);
135135 }
136136
137 - function renderFormInput (&$parser, $inFormName = '', $inSize = '25', $inValue = '', $inButtonStr = '', $inQueryStr = '') {
 137+ static function renderFormInput (&$parser, $inFormName = '', $inSize = '25', $inValue = '', $inButtonStr = '', $inQueryStr = '') {
138138 $ap = SpecialPage::getPage('AddPage');
139139 $ap_url = $ap->getTitle()->getLocalURL();
140140 $str = <<<END
@@ -172,7 +172,7 @@
173173 /**
174174 * {{#arraymap:value|delimiter|var|formula|new_delimiter}}
175175 */
176 - function renderArrayMap( &$parser, $value = '', $delimiter = ',', $var = 'x', $formula = 'x', $new_delimiter = ', ' ) {
 176+ static function renderArrayMap( &$parser, $value = '', $delimiter = ',', $var = 'x', $formula = 'x', $new_delimiter = ', ' ) {
177177 // let '\n' represent newlines - chances that anyone will
178178 // actually need the '\n' literal are small
179179 $delimiter = str_replace('\n', "\n", $delimiter);
@@ -193,7 +193,7 @@
194194 * SFH_OBJ_ARGS
195195 * {{#arraymap:value|delimiter|var|formula|new_delimiter}}
196196 */
197 - function renderArrayMapObj( &$parser, $frame, $args ) {
 197+ static function renderArrayMapObj( &$parser, $frame, $args ) {
198198 # Set variables
199199 $value = isset($args[0]) ? trim($frame->expand($args[0])) : '';
200200 $delimiter = isset($args[1]) ? trim($frame->expand($args[1])) : ',';
@@ -221,7 +221,7 @@
222222 /**
223223 * {{#arraymaptemplate:value|template|delimiter|new_delimiter}}
224224 */
225 - function renderArrayMapTemplate( &$parser, $value = '', $template = '', $delimiter = ',', $new_delimiter = ', ' ) {
 225+ static function renderArrayMapTemplate( &$parser, $value = '', $template = '', $delimiter = ',', $new_delimiter = ', ' ) {
226226 # let '\n' represent newlines
227227 $delimiter = str_replace('\n', "\n", $delimiter);
228228 $values_array = explode($parser->mStripState->unstripNoWiki($delimiter), $value);
@@ -242,7 +242,7 @@
243243 * SFH_OBJ_ARGS
244244 * {{#arraymaptemplate:value|template|delimiter|new_delimiter}}
245245 */
246 - function renderArrayMapTemplateObj( &$parser, $frame, $args ) {
 246+ static function renderArrayMapTemplateObj( &$parser, $frame, $args ) {
247247 # Set variables
248248 $value = isset($args[0]) ? trim($frame->expand($args[0])) : '';
249249 $template = isset($args[1]) ? trim($frame->expand($args[1])) : '';
Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.inc
@@ -10,7 +10,7 @@
1111
1212 class SFFormUtils {
1313
14 - function chooserJavascript() {
 14+ static function chooserJavascript() {
1515 $javascript_text = <<<END
1616 <script type="text/javascript">/* <![CDATA[ */
1717
@@ -63,7 +63,7 @@
6464 return $javascript_text;
6565 }
6666
67 - function validationJavascript() {
 67+ static function validationJavascript() {
6868 global $sfgJSValidationCalls;
6969
7070 $form_errors_header = wfMsg('sf_formerrors_header');
@@ -234,7 +234,7 @@
235235 return $javascript_text;
236236 }
237237
238 - function instancesJavascript($using_choosers) {
 238+ static function instancesJavascript($using_choosers) {
239239 $remove_text = wfMsg('sf_editdata_remove');
240240 $javascript_text =<<<END
241241
@@ -314,7 +314,7 @@
315315 return $javascript_text;
316316 }
317317
318 - function autocompletionJavascript() {
 318+ static function autocompletionJavascript() {
319319 global $wgScriptPath;
320320
321321 $javascript_text =<<<END
@@ -386,7 +386,7 @@
387387 return $javascript_text;
388388 }
389389
390 - function hiddenFieldHTML($input_name, $cur_value) {
 390+ static function hiddenFieldHTML($input_name, $cur_value) {
391391 $text =<<<END
392392 <input type="hidden" name="$input_name" value="$cur_value" />
393393
@@ -394,7 +394,7 @@
395395 return $text;
396396 }
397397
398 - function summaryInputHTML($is_disabled, $label = null) {
 398+ static function summaryInputHTML($is_disabled, $label = null) {
399399 global $sfgTabIndex;
400400
401401 $sfgTabIndex++;
@@ -409,7 +409,7 @@
410410 return $text;
411411 }
412412
413 - function minorEditInputHTML($is_disabled, $label = null) {
 413+ static function minorEditInputHTML($is_disabled, $label = null) {
414414 global $sfgTabIndex;
415415
416416 $sfgTabIndex++;
@@ -426,8 +426,8 @@
427427 return $text;
428428 }
429429
430 - function watchInputHTML($is_disabled, $label = null) {
431 - global $sfgTabIndex, $wgUser;
 430+ static function watchInputHTML($is_disabled, $label = null) {
 431+ global $sfgTabIndex, $wgUser, $wgTitle;
432432
433433 $sfgTabIndex++;
434434 $checked_text = "";
@@ -437,10 +437,10 @@
438438 if ($wgUser->getOption('watchdefault')) {
439439 # Watch all edits
440440 $checked_text = "checked";
441 - } elseif ($wgUser->getOption('watchcreations') && !$this->mPageTitle->exists() ) {
 441+ } elseif ($wgUser->getOption('watchcreations') && !$wgTitle->exists() ) {
442442 # Watch creations
443443 $checked_text = "checked";
444 - } elseif ($this->mPageTitle->userIsWatching()) {
 444+ } elseif ($wgTitle->userIsWatching()) {
445445 # Already watched
446446 $checked_text = "checked";
447447 }
@@ -456,7 +456,7 @@
457457 return $text;
458458 }
459459
460 - function saveButtonHTML($is_disabled, $label = null) {
 460+ static function saveButtonHTML($is_disabled, $label = null) {
461461 global $sfgTabIndex;
462462
463463 $sfgTabIndex++;
@@ -477,7 +477,7 @@
478478 return $text;
479479 }
480480
481 - function showPreviewButtonHTML($is_disabled, $label = null) {
 481+ static function showPreviewButtonHTML($is_disabled, $label = null) {
482482 global $sfgTabIndex;
483483
484484 $sfgTabIndex++;
@@ -498,7 +498,7 @@
499499 return $text;
500500 }
501501
502 - function showChangesButtonHTML($is_disabled, $label = null) {
 502+ static function showChangesButtonHTML($is_disabled, $label = null) {
503503 global $sfgTabIndex;
504504
505505 $sfgTabIndex++;
@@ -519,22 +519,22 @@
520520 return $text;
521521 }
522522
523 - function cancelLinkHTML($is_disabled, $label = null) {
524 - global $wgUser;
 523+ static function cancelLinkHTML($is_disabled, $label = null) {
 524+ global $wgUser, $wgTitle;
525525
526526 $sk = $wgUser->getSkin();
527527 if ($label == null)
528528 $label = wfMsgExt('cancel', array('parseinline'));
529 - if ($this->mPageTitle == null)
 529+ if ($wgTitle == null)
530530 $cancel = '';
531531 else
532 - $cancel = $sk->makeKnownLink( $this->mPageTitle->getPrefixedText(), $label);
 532+ $cancel = $sk->makeKnownLink( $wgTitle->getPrefixedText(), $label);
533533 $text = " <span class='editHelp'>$cancel</span>\n";
534534 return $text;
535535 }
536536
537537 // Much of this function is based on MediaWiki's EditPage::showEditForm()
538 - function formBottom($is_disabled) {
 538+ static function formBottom($is_disabled) {
539539 global $wgUser;
540540
541541 $summary_text = SFFormUtils::summaryInputHTML($is_disabled);
@@ -570,7 +570,7 @@
571571 }
572572
573573 // based on MediaWiki's EditPage::getPreloadedText()
574 - function getPreloadedText($preload) {
 574+ static function getPreloadedText($preload) {
575575 if ( $preload === '' ) {
576576 return '';
577577 } else {
@@ -589,7 +589,7 @@
590590 }
591591 }
592592
593 - function getMonthNames() {
 593+ static function getMonthNames() {
594594 return array(
595595 wfMsgForContent('january'),
596596 wfMsgForContent('february'),
@@ -606,7 +606,7 @@
607607 );
608608 }
609609
610 - function getShowFCKEditor() {
 610+ static function getShowFCKEditor() {
611611 global $wgUser;
612612
613613 $showFCKEditor = 0;
@@ -631,7 +631,7 @@
632632 return $showFCKEditor;
633633 }
634634
635 - function prepareTextForFCK($text) {
 635+ static function prepareTextForFCK($text) {
636636 global $wgTitle;
637637
638638 $options = new FCKeditorParserOptions();
@@ -642,7 +642,7 @@
643643 return $text;
644644 }
645645
646 - function mainFCKJavascript($showFCKEditor) {
 646+ static function mainFCKJavascript($showFCKEditor) {
647647 global $wgUser, $wgScriptPath, $wgFCKEditorExtDir, $wgFCKEditorDir, $wgFCKEditorToolbarSet, $wgFCKEditorHeight;
648648
649649 $newWinMsg = wfMsg('rich_editor_new_window');
@@ -869,7 +869,7 @@
870870 return $javascript_text;
871871 }
872872
873 - function FCKToggleJavascript() {
 873+ static function FCKToggleJavascript() {
874874 //add toggle link and handler
875875 $javascript_text = <<<END
876876
@@ -957,7 +957,7 @@
958958 return $javascript_text;
959959 }
960960
961 - function FCKPopupJavascript() {
 961+ static function FCKPopupJavascript() {
962962 $javascript_text = <<<END
963963
964964 function FCKeditor_OpenPopup(jsID, textareaID)
Index: trunk/extensions/SemanticForms/includes/SF_LinkUtils.inc
@@ -56,7 +56,7 @@
5757 * Gets the default form specified, if any, for a specific page
5858 * (which should be a category, property, or namespace page)
5959 */
60 - function getDefaultForm($page_title, $page_namespace) {
 60+ static function getDefaultForm($page_title, $page_namespace) {
6161 if ($page_title == NULL)
6262 return null;
6363
@@ -108,7 +108,7 @@
109109 * Gets the alternate forms specified, if any, for a specific page
110110 * (which should always be a property page)
111111 */
112 - function getAlternateForms($page_title, $page_namespace) {
 112+ static function getAlternateForms($page_title, $page_namespace) {
113113 if ($page_title == NULL)
114114 return array();
115115

Status & tagging log