r102365 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102364‎ | r102365 | r102366 >
Date:02:25, 8 November 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
strict comparators for empty strings
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_AutocompleteAPI.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_AutoeditAPI.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormField.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormLinker.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_PageSchemas.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_TemplateField.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_TemplateInForm.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_Utils.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_CategoryInput.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_DropdownInput.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_RadioButtonInput.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_TextInput.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_TextWithAutocompleteInput.php (modified) (history)
  • /trunk/extensions/SemanticForms/libs/SF_ajax_form_preview.js (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateCategory.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateClass.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateProperty.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_FormEdit.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_FormStart.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_RunQuery.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_Templates.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_UploadWindow.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_CreateCategory.php
@@ -29,7 +29,7 @@
3030 static function createCategoryText( $default_form, $category_name, $parent_category ) {
3131 SFUtils::loadMessages();
3232
33 - if ( $default_form == '' ) {
 33+ if ( $default_form === '' ) {
3434 $text = wfMsgForContent( 'sf_category_desc', $category_name );
3535 } else {
3636 global $sfgContLang;
@@ -37,7 +37,7 @@
3838 $form_tag = "[[" . $specprops[SF_SP_HAS_DEFAULT_FORM] . "::$default_form]]";
3939 $text = wfMsgForContent( 'sf_category_hasdefaultform', $form_tag );
4040 }
41 - if ( $parent_category != '' ) {
 41+ if ( $parent_category !== '' ) {
4242 global $wgContLang;
4343 $namespace_labels = $wgContLang->getNamespaces();
4444 $category_namespace = $namespace_labels[NS_CATEGORY];
@@ -62,7 +62,7 @@
6363 $preview_page = $wgRequest->getCheck( 'wpPreview' );
6464 if ( $save_page || $preview_page ) {
6565 # validate category name
66 - if ( $category_name == '' ) {
 66+ if ( $category_name === '' ) {
6767 $category_name_error_str = wfMsg( 'sf_blank_error' );
6868 } else {
6969 # redirect to wiki interface
Index: trunk/extensions/SemanticForms/specials/SF_FormStart.php
@@ -64,14 +64,14 @@
6565 $page_name = $wgRequest->getVal( 'page_name' );
6666 // This form can be used to create a sub-page for an
6767 // existing page
68 - if ( $super_page != '' )
 68+ if ( $super_page !== '' )
6969 {
7070 $page_name = "$super_page/$page_name";
7171 }
72 - if ( $page_name != '' ) {
 72+ if ( $page_name !== '' ) {
7373 // Append the namespace prefix to the page name,
7474 // if this namespace was not already entered.
75 - if ( strpos( $page_name, $target_namespace . ':' ) === false && $target_namespace != '' )
 75+ if ( strpos( $page_name, $target_namespace . ':' ) === false && $target_namespace !== '' )
7676 $page_name = $target_namespace . ':' . $page_name;
7777 // If there was no page title, it's probably an
7878 // invalid page name, containing forbidden
@@ -88,10 +88,10 @@
8989 }
9090 }
9191
92 - if ( ( !$form_title || !$form_title->exists() ) && ( $form_name != '' ) ) {
 92+ if ( ( !$form_title || !$form_title->exists() ) && ( $form_name !== '' ) ) {
9393 $text = Xml::element( 'p', null, wfMsg( 'sf_formstart_badform', SFUtils::linkText( SF_NS_FORM, $form_name ) ) ) . "\n";
9494 } else {
95 - if ( $form_name == '' ) {
 95+ if ( $form_name === '' ) {
9696 $description = htmlspecialchars( wfMsg( 'sf_formstart_noform_docu', $form_name ) );
9797 }
9898 else {
@@ -106,7 +106,7 @@
107107 END;
108108 // If no form was specified, display a dropdown letting
109109 // the user choose the form.
110 - if ( $form_name == '' )
 110+ if ( $form_name === '' )
111111 $text .= SFUtils::formDropdownHTML();
112112
113113 $text .= "\t</p>\n";
@@ -172,7 +172,7 @@
173173 }
174174 }
175175
176 - if ( $params != '' ) {
 176+ if ( $params !== '' ) {
177177 $redirect_url .= ( strpos( $redirect_url, "?" ) > - 1 ) ? '&' : '?';
178178 $redirect_url .= $params;
179179 }
Index: trunk/extensions/SemanticForms/specials/SF_CreateProperty.php
@@ -31,13 +31,13 @@
3232 $prop_labels = $smwgContLang->getPropertyLabels();
3333 $type_tag = "[[{$prop_labels['_TYPE']}::$property_type]]";
3434 $text = wfMsgForContent( 'sf_property_isproperty', $type_tag );
35 - if ( $default_form != '' ) {
 35+ if ( $default_form !== '' ) {
3636 global $sfgContLang;
3737 $sf_prop_labels = $sfgContLang->getPropertyLabels();
3838 $default_form_tag = "[[{$sf_prop_labels[SF_SP_HAS_DEFAULT_FORM]}::$default_form]]";
3939 $text .= ' ' . wfMsgForContent( 'sf_property_linkstoform', $default_form_tag );
4040 }
41 - if ( $allowed_values_str != '' ) {
 41+ if ( $allowed_values_str !== '' ) {
4242 // replace the comma substitution character that has no chance of
4343 // being included in the values list - namely, the ASCII beep
4444 global $sfgListSeparator;
@@ -74,7 +74,7 @@
7575 $preview_page = $wgRequest->getCheck( 'wpPreview' );
7676 if ( $save_page || $preview_page ) {
7777 # validate property name
78 - if ( $property_name == '' ) {
 78+ if ( $property_name === '' ) {
7979 $property_name_error_str = wfMsg( 'sf_blank_error' );
8080 } else {
8181 # redirect to wiki interface
Index: trunk/extensions/SemanticForms/specials/SF_CreateClass.php
@@ -65,7 +65,7 @@
6666 $template_name = trim( $wgRequest->getVal( "template_name" ) );
6767 $form_name = trim( $wgRequest->getVal( "form_name" ) );
6868 $category_name = trim( $wgRequest->getVal( "category_name" ) );
69 - if ( $template_name == '' | $form_name == '' || $category_name == '' ) {
 69+ if ( $template_name === '' | $form_name === '' || $category_name === '' ) {
7070 $wgOut->addWikiMsg( 'sf_createclass_missingvalues' );
7171 return;
7272 }
Index: trunk/extensions/SemanticForms/specials/SF_FormEdit.php
@@ -93,7 +93,7 @@
9494 SFUtils::loadMessages();
9595
9696 // If we have no form name we might as well stop right away
97 - if ( $form_name == '' ) {
 97+ if ( $form_name === '' ) {
9898 return 'sf_formedit_badurl';
9999 }
100100
@@ -107,7 +107,7 @@
108108 $form_definition = $form_article->getContent();
109109 $form_definition = StringUtils::delimiterReplace( '<noinclude>', '</noinclude>', '', $form_definition );
110110
111 - if ( $target_name == '' ) {
 111+ if ( $target_name === '' ) {
112112
113113 // parse the form to see if it has a 'page name' value set
114114 $matches;
@@ -146,7 +146,7 @@
147147 } else {
148148 $text = Xml::tags( 'p', array( 'class' => 'error' ), wfMsg( 'sf_formstart_badform', SFUtils::linkText( SF_NS_FORM, $form_name ) ) ) . "\n";
149149 }
150 - } elseif ( $target_name == '' && $page_name_formula == '' ) {
 150+ } elseif ( $target_name === '' && $page_name_formula === '' ) {
151151 $text = Xml::element( 'p', array( 'class' => 'error' ), wfMsg( 'sf_formedit_badurl' ) ) . "\n";
152152 } else {
153153
@@ -188,7 +188,7 @@
189189 $wgOut->setPageTitle( $s );
190190
191191 if ( $form_submitted ) {
192 - if ( $page_name_formula != '' ) {
 192+ if ( !is_null( $page_name_formula ) && $page_name_formula !== '' ) {
193193 $target_name = $generated_page_name;
194194 // prepend a super-page, if one was specified
195195 if ( $wgRequest->getCheck( 'super_page' ) ) {
@@ -271,8 +271,12 @@
272272 }
273273
274274 if ( is_null( $target_title ) ) {
275 - if ( $target_name ) return array ( 'sf_formstart_badtitle' , array( $target_name ) );
276 - else return 'sf_formedit_emptytitle';
 275+ if ( $target_name ) {
 276+ return array ( 'sf_formstart_badtitle' , array( $target_name ) );
 277+ }
 278+ else {
 279+ return 'sf_formedit_emptytitle';
 280+ }
277281 }
278282
279283 if ( $save_page ) {
@@ -347,7 +351,7 @@
348352 // override the default title for this page if
349353 // a title was specified in the form
350354 if ( $form_page_title != null ) {
351 - if ( $target_name == '' ) {
 355+ if ( $target_name === '' ) {
352356 $wgOut->setPageTitle( $form_page_title );
353357 } else {
354358 $wgOut->setPageTitle( "$form_page_title: {$target_title->getPrefixedText()}" );
Index: trunk/extensions/SemanticForms/specials/SF_RunQuery.php
@@ -38,7 +38,7 @@
3939 $form_title = Title::makeTitleSafe( SF_NS_FORM, $form_name );
4040
4141 if ( !$form_title || !$form_title->exists() ) {
42 - if ( $form_name == '' ) {
 42+ if ( $form_name === '' ) {
4343 $text = Xml::element( 'p', array( 'class' => 'error' ), wfMsg( 'sf_runquery_badurl' ) ) . "\n";
4444 } else {
4545 $text = Xml::tags( 'p', array( 'class' => 'error' ),
Index: trunk/extensions/SemanticForms/specials/SF_UploadWindow.php
@@ -380,7 +380,7 @@
381381 /**
382382 * If there was no filename or a zero size given, give up quick.
383383 */
384 - if ( trim( $this->mSrcName ) == '' || empty( $this->mFileSize ) ) {
 384+ if ( trim( $this->mSrcName ) === '' || empty( $this->mFileSize ) ) {
385385 $this->mainUploadWindowForm( wfMsgHtml( 'emptyfile' ) );
386386 return;
387387 }
@@ -449,7 +449,7 @@
450450 /* Don't allow users to override the blacklist (check file extension) */
451451 global $wgStrictFileExtensions;
452452 global $wgFileExtensions, $wgFileBlacklist;
453 - if ( $finalExt == '' ) {
 453+ if ( $finalExt === '' ) {
454454 return $this->uploadError( wfMsgExt( 'filetype-missing', array ( 'parseinline' ) ) );
455455 } elseif ( $this->checkFileExtensionList( $ext, $wgFileBlacklist ) ||
456456 ( $wgStrictFileExtensions && !$this->checkFileExtension( $finalExt, $wgFileExtensions ) ) ) {
@@ -517,7 +517,7 @@
518518 if ( !$this->mDestWarningAck ) {
519519 $warning .= self::getExistsWarning( $this->mLocalFile );
520520 }
521 - if ( $warning != '' ) {
 521+ if ( $warning !== '' ) {
522522 /**
523523 * Stash the file in a temporary location; the user can choose
524524 * to let it through and we'll complete the upload then.
@@ -564,7 +564,7 @@
565565 // both a delimiter and a file name; and add on a delimiter
566566 // at the end in any case
567567 var cur_value = parent.document.getElementById("{$this->mInputID}").value;
568 - if (cur_value == '') {
 568+ if (cur_value === '') {
569569 parent.document.getElementById("{$this->mInputID}").value = "$basename{$this->mDelimiter} ";
570570 } else {
571571 var last_char = cur_value.charAt(cur_value.length - 1);
@@ -971,7 +971,7 @@
972972
973973 $watchChecked =
974974 ( $wgUser->getOption( 'watchdefault' ) ||
975 - ( $wgUser->getOption( 'watchcreations' ) && $this->mDesiredDestName == '' ) )
 975+ ( $wgUser->getOption( 'watchcreations' ) && $this->mDesiredDestName === '' ) )
976976 ? 'checked="checked"'
977977 : '';
978978 $warningChecked = $this->mIgnoreWarning ? 'checked' : '';
@@ -1043,7 +1043,7 @@
10441044 EOT
10451045 );
10461046
1047 - if ( $licenseshtml != '' ) {
 1047+ if ( $licenseshtml !== '' ) {
10481048 $wgOut->addHTML( "
10491049 <td align='$align1'><label for='wpLicense'>$license</label></td>
10501050 <td align='$align2'>
@@ -1531,7 +1531,7 @@
15321532 static function getInitialPageText( $comment, $license, $copyStatus, $source ) {
15331533 global $wgUseCopyrightUpload;
15341534 if ( $wgUseCopyrightUpload ) {
1535 - if ( $license != '' ) {
 1535+ if ( $license !== '' ) {
15361536 $licensetxt = '== ' . wfMsgForContent( 'license' ) . " ==\n" . '{{' . $license . '}}' . "\n";
15371537 }
15381538 $pageText = '== ' . wfMsg ( 'filedesc' ) . " ==\n" . $comment . "\n" .
@@ -1539,8 +1539,8 @@
15401540 "$licensetxt" .
15411541 '== ' . wfMsgForContent ( 'filesource' ) . " ==\n" . $source ;
15421542 } else {
1543 - if ( $license != '' ) {
1544 - $filedesc = $comment == '' ? '' : '== ' . wfMsg ( 'filedesc' ) . " ==\n" . $comment . "\n";
 1543+ if ( $license !== '' ) {
 1544+ $filedesc = $comment === '' ? '' : '== ' . wfMsg ( 'filedesc' ) . " ==\n" . $comment . "\n";
15451545 $pageText = $filedesc .
15461546 '== ' . wfMsgForContent ( 'license' ) . " ==\n" . '{{' . $license . '}}' . "\n";
15471547 } else {
Index: trunk/extensions/SemanticForms/specials/SF_Templates.php
@@ -114,7 +114,7 @@
115115 $title = Title::makeTitle( NS_TEMPLATE, $result->value );
116116 $text = $skin->makeLinkObj( $title, htmlspecialchars( $title->getText() ) );
117117 $category = $this->getCategoryDefinedByTemplate( $title );
118 - if ( $category != '' ) {
 118+ if ( $category !== '' ) {
119119 SFUtils::loadMessages();
120120 $text .= ' ' . wfMsg( 'sf_templates_definescat' ) . ' ' . SFUtils::linkText( NS_CATEGORY, $category );
121121 }
Index: trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php
@@ -399,7 +399,7 @@
400400 // both a delimiter and a file name; and add on a delimiter
401401 // at the end in any case
402402 var cur_value = parent.document.getElementById("{$this->mInputID}").value;
403 - if (cur_value == '') {
 403+ if (cur_value === '') {
404404 parent.document.getElementById("{$this->mInputID}").value = '$basename' + '{$this->mDelimiter} ';
405405 } else {
406406 var last_char = cur_value.charAt(cur_value.length - 1);
@@ -431,7 +431,7 @@
432432 global $wgUseCopyrightUpload;
433433 if ( $wgUseCopyrightUpload ) {
434434 $licensetxt = '';
435 - if ( $license != '' ) {
 435+ if ( $license !== '' ) {
436436 $licensetxt = '== ' . wfMsgForContent( 'license-header' ) . " ==\n" . '{{' . $license . '}}' . "\n";
437437 }
438438 $pageText = '== ' . wfMsgForContent ( 'filedesc' ) . " ==\n" . $comment . "\n" .
@@ -439,8 +439,8 @@
440440 "$licensetxt" .
441441 '== ' . wfMsgForContent ( 'filesource' ) . " ==\n" . $source ;
442442 } else {
443 - if ( $license != '' ) {
444 - $filedesc = $comment == '' ? '' : '== ' . wfMsgForContent ( 'filedesc' ) . " ==\n" . $comment . "\n";
 443+ if ( $license !== '' ) {
 444+ $filedesc = $comment === '' ? '' : '== ' . wfMsgForContent ( 'filedesc' ) . " ==\n" . $comment . "\n";
445445 $pageText = $filedesc .
446446 '== ' . wfMsgForContent ( 'license-header' ) . " ==\n" . '{{' . $license . '}}' . "\n";
447447 } else {
Index: trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php
@@ -124,7 +124,7 @@
125125
126126 function validateCreateTemplateForm() {
127127 templateName = jQuery('#template_name').val();
128 - if (templateName == '') {
 128+ if (templateName === '') {
129129 scroll(0, 0);
130130 jQuery('#template_name_p').append(' <font color="red">$template_name_error_str</font>');
131131 return false;
Index: trunk/extensions/SemanticForms/includes/SF_FormField.php
@@ -263,7 +263,7 @@
264264 // such templates in form definitions gets more sophisticated
265265 function createMarkup( $part_of_multiple, $is_last_field_in_template ) {
266266 $text = "";
267 - if ( $this->template_field->getLabel() != '' ) {
 267+ if ( $this->template_field->getLabel() !== '' ) {
268268 if ( $part_of_multiple ) {
269269 $text .= "'''" . $this->template_field->getLabel() . ":''' ";
270270 } else {
@@ -277,9 +277,9 @@
278278 // be removed.
279279 if ( $this->mIsHidden ) {
280280 $text .= "|hidden";
281 - } elseif ( $this->getInputType() != '' ) {
 281+ } elseif ( $this->getInputType() !== '' ) {
282282 $text .= "|input type=" . $this->getInputType();
283 - } elseif ( $this->template_field->getInputType() != '' ) {
 283+ } elseif ( $this->template_field->getInputType() !== '' ) {
284284 $text .= "|input type=" . $this->template_field->getInputType();
285285 }
286286 foreach ( $this->mFieldArgs as $arg => $value ) {
@@ -321,7 +321,7 @@
322322 $other_args['value_labels'] = $this->template_field->getValueLabels();
323323 }
324324 $other_args['is_list'] = ( $this->mIsList || $this->template_field->isList() );
325 - if ( $this->template_field->getSemanticProperty() != '' &&
 325+ if ( $this->template_field->getSemanticProperty() !== '' &&
326326 ! array_key_exists( 'semantic_property', $other_args ) ) {
327327 $other_args['semantic_property'] = $this->template_field->getSemanticProperty();
328328 $other_args['property_type'] = $this->template_field->getPropertyType();
Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -366,7 +366,7 @@
367367 // just use the name of the actual page we're on.
368368 global $wgTitle;
369369 $this->mPageTitle = $wgTitle;
370 - } elseif ( $page_name == '' ) {
 370+ } elseif ( $page_name === '' ) {
371371 $this->mPageTitle = Title::newFromText(
372372 $wgRequest->getVal( 'namespace' ) . ":Semantic Forms permissions test" );
373373 } else {
@@ -967,7 +967,7 @@
968968 } else {
969969 $sfgTabIndex++;
970970 $sfgFieldNum++;
971 - if ( $cur_value == '' ) {
 971+ if ( $cur_value === '' ) {
972972 $default_value = '!free_text!';
973973 } else {
974974 $default_value = $cur_value;
@@ -1001,7 +1001,7 @@
10021002 $data_text .= "!free_text!\n";
10031003 }
10041004
1005 - if ( $template_name == '' || $field_name == '<freetext>' ) {
 1005+ if ( $template_name === '' || $field_name == '<freetext>' ) {
10061006 $section = substr_replace( $section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc );
10071007 } else {
10081008 if ( is_array( $cur_value ) ) {
@@ -1036,7 +1036,7 @@
10371037 } elseif ( count( $cur_value ) >= 3 ) {
10381038 $month = $cur_value['month'];
10391039 $day = $cur_value['day'];
1040 - if ( $day != '' ) {
 1040+ if ( $day !== '' ) {
10411041 global $wgAmericanDates;
10421042 if ( $wgAmericanDates == false ) {
10431043 // pad out day to always be two digits
@@ -1050,7 +1050,7 @@
10511051 if ( isset( $cur_value['second'] ) ) $second = $cur_value['second'];
10521052 if ( isset( $cur_value['ampm24h'] ) ) $ampm24h = $cur_value['ampm24h'];
10531053 if ( isset( $cur_value['timezone'] ) ) $timezone = $cur_value['timezone'];
1054 - if ( $month != '' && $day != '' && $year != '' ) {
 1054+ if ( $month !== '' && $day !== '' && $year !== '' ) {
10551055 // special handling for American dates - otherwise, just
10561056 // the standard year/month/day (where month is a number)
10571057 global $wgAmericanDates;
@@ -1076,7 +1076,7 @@
10771077 } else { // value is not an array
10781078 $cur_value_in_template = $cur_value;
10791079 }
1080 - if ( $template_name == null || $template_name == '' ) {
 1080+ if ( $template_name == null || $template_name === '' ) {
10811081 $input_name = $field_name;
10821082 } elseif ( $allow_multiple ) {
10831083 // 'num' will get replaced by an actual index, either in PHP
@@ -1103,7 +1103,7 @@
11041104 // if we're creating the page name from a formula based on
11051105 // form values, see if the current input is part of that formula,
11061106 // and if so, substitute in the actual value
1107 - if ( $form_submitted && $generated_page_name != '' ) {
 1107+ if ( $form_submitted && $generated_page_name !== '' ) {
11081108 // this line appears to be unnecessary
11091109 // $generated_page_name = str_replace('.', '_', $generated_page_name);
11101110 $generated_page_name = str_replace( ' ', '_', $generated_page_name );
@@ -1154,10 +1154,10 @@
11551155 if ( $default_value == 'now' &&
11561156 // if the date is hidden, cur_value will already be set
11571157 // to the default value
1158 - ( $cur_value == '' || $cur_value == 'now' ) ) {
 1158+ ( $cur_value === '' || $cur_value == 'now' ) ) {
11591159 if ( $input_type == 'date' || $input_type == 'datetime' ||
11601160 $input_type == 'year' ||
1161 - ( $input_type == '' && $form_field->getTemplateField()->getPropertyType() == '_dat' ) ) {
 1161+ ( $input_type === '' && $form_field->getTemplateField()->getPropertyType() == '_dat' ) ) {
11621162 // Get current time, for the time zone specified in the wiki.
11631163 global $wgLocaltimezone;
11641164 if ( isset( $wgLocaltimezone ) ) {
@@ -1206,7 +1206,7 @@
12071207 if ( $default_value == 'current user' &&
12081208 // if the date is hidden, cur_value will already be set
12091209 // to the default value
1210 - ( $cur_value == '' || $cur_value == 'current user' ) ) {
 1210+ ( $cur_value === '' || $cur_value == 'current user' ) ) {
12111211
12121212 $cur_value_in_template = $wgUser->getName();
12131213 $cur_value = $cur_value_in_template;
@@ -1245,7 +1245,7 @@
12461246 $template_text .= "|$cur_value_in_template";
12471247 } else {
12481248 // If the value is null, don't include it at all.
1249 - if ( $cur_value_in_template != '' ) {
 1249+ if ( $cur_value_in_template !== '' ) {
12501250 $template_text .= "\n|$field_name=$cur_value_in_template";
12511251 }
12521252 }
@@ -1370,7 +1370,7 @@
13711371 } // end while
13721372
13731373 if ( ! $all_instances_printed ) {
1374 - if ( $template_text != '' ) {
 1374+ if ( $template_text !== '' ) {
13751375 // For mostly aesthetic purposes, if the template call ends with
13761376 // a bunch of pipes (i.e., it's an indexed template with unused
13771377 // parameters at the end), remove the pipes.
@@ -1529,7 +1529,7 @@
15301530
15311531 // Add a warning in, if we're editing an existing page and that
15321532 // page appears to not have been created with this form.
1533 - if ( $this->mPageTitle->exists() && ( $existing_page_content != '' ) && ! $source_page_matches_this_form ) {
 1533+ if ( $this->mPageTitle->exists() && ( $existing_page_content !== '' ) && ! $source_page_matches_this_form ) {
15341534 $form_text = "\t" . '<div class="warningbox">' . wfMsg( 'sf_formedit_formwarning', $this->mPageTitle->getFullURL() ) . "</div>\n<br clear=\"both\" />\n" . $form_text;
15351535 }
15361536
@@ -1604,7 +1604,7 @@
16051605
16061606 if ( $form_field->isHidden() ) {
16071607 $text = SFFormUtils::hiddenFieldHTML( $form_field->getInputName(), $cur_value );
1608 - } elseif ( $form_field->getInputType() != '' &&
 1608+ } elseif ( $form_field->getInputType() !== '' &&
16091609 array_key_exists( $form_field->getInputType(), $this->mInputTypeHooks ) &&
16101610 $this->mInputTypeHooks[$form_field->getInputType()] != null ) {
16111611 $funcArgs = array();
@@ -1622,7 +1622,7 @@
16231623 } else { // input type not defined in form
16241624 $property_type = $template_field->getPropertyType();
16251625 $is_list = ( $form_field->isList() || $template_field->isList() );
1626 - if ( $property_type != '' &&
 1626+ if ( $property_type !== '' &&
16271627 array_key_exists( $property_type, $this->mSemanticTypeHooks ) &&
16281628 isset( $this->mSemanticTypeHooks[$property_type][$is_list] ) ) {
16291629 $funcArgs = array();
Index: trunk/extensions/SemanticForms/includes/SF_AutoeditAPI.php
@@ -385,7 +385,7 @@
386386 if ( !$name )
387387 continue;
388388
389 - if ( $type == '' )
 389+ if ( $type === '' )
390390 $type = 'text';
391391
392392 switch ( $type ) {
Index: trunk/extensions/SemanticForms/includes/SF_FormLinker.php
@@ -287,7 +287,7 @@
288288 }
289289 self::createLinkedPage( $target, $incoming_properties );
290290 $link = self::formEditLink( $target, $incoming_properties );
291 - if ( $link != '' ) {
 291+ if ( $link !== '' ) {
292292 $attribs['href'] = $link;
293293 }
294294 return true;
Index: trunk/extensions/SemanticForms/includes/SF_TemplateField.php
@@ -209,7 +209,7 @@
210210
211211 foreach ( $template_fields as $i => $field ) {
212212 // Header/field label column
213 - if ( $field->mDisplay == '' ) {
 213+ if ( $field->mDisplay === '' ) {
214214 if ( $i > 0 ) {
215215 $tableText .= "|-\n";
216216 }
@@ -264,7 +264,7 @@
265265
266266 // Add a row with an inline query to this table, for
267267 // aggregation, if a property was specified.
268 - if ( $aggregating_property != '' ) {
 268+ if ( $aggregating_property !== '' ) {
269269 if ( count( $template_fields ) > 0 ) {
270270 $tableText .= "|-\n";
271271 }
@@ -286,13 +286,13 @@
287287 }
288288
289289 // Add a call to #set, if necessary
290 - if ( $setText != '' ) {
 290+ if ( $setText !== '' ) {
291291 $setText = '{{#set:' . $setText . "}}\n";
292292 $text .= $setText;
293293 }
294294
295295 $text .= $tableText;
296 - if ( $category != '' ) {
 296+ if ( $category !== '' ) {
297297 global $wgContLang;
298298 $namespace_labels = $wgContLang->getNamespaces();
299299 $category_namespace = $namespace_labels[NS_CATEGORY];
Index: trunk/extensions/SemanticForms/includes/SF_PageSchemas.php
@@ -131,7 +131,7 @@
132132 $xml .= '<InputType>' . $val . '</InputType>';
133133 }
134134 } elseif ( substr( $var, 0, 14 ) == 'sf_key_values_' ) {
135 - if ( $val != '' ) {
 135+ if ( $val !== '' ) {
136136 // replace the comma substitution character that has no chance of
137137 // being included in the values list - namely, the ASCII beep
138138 $listSeparator = ',';
@@ -186,7 +186,7 @@
187187 // we set it based on whether or not a page formula has been
188188 // specified.
189189 $twoStepProcessAttrs = array( 'id' => 'sf-two-step-process' );
190 - if ( $pageNameFormula == '' ) {
 190+ if ( $pageNameFormula === '' ) {
191191 $twoStepProcessAttrs['checked'] = true;
192192 }
193193 $text .= '<p>' . Html::input( 'sf_two_step_process', null, 'checkbox', $twoStepProcessAttrs );
@@ -380,7 +380,7 @@
381381 foreach( $psFields as $psField ) {
382382 $prop_array = $psField->getObject('semanticmediawiki_Property');
383383 $propertyName = PageSchemas::getValueFromObject( $prop_array, 'name' );
384 - if ( $psField->getLabel() == '' ) {
 384+ if ( $psField->getLabel() === '' ) {
385385 $fieldLabel = $psField->getName();
386386 } else {
387387 $fieldLabel = $psField->getLabel();
Index: trunk/extensions/SemanticForms/includes/SF_TemplateInForm.php
@@ -189,7 +189,7 @@
190190 if ( $this->mAllowMultiple ) {
191191 $text .= "|multiple";
192192 }
193 - if ( $this->mLabel != '' ) {
 193+ if ( $this->mLabel !== '' ) {
194194 $text .= "|label=" . $this->mLabel;
195195 }
196196 $text .= "}}}\n";
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextInput.php
@@ -149,7 +149,7 @@
150150 $text .= self::uploadLinkHTML( $input_id, $delimiter, $default_filename );
151151 }
152152 $spanClass = 'inputSpan';
153 - if ( $inputType != '' ) {
 153+ if ( $inputType !== '' ) {
154154 $spanClass .= " {$inputType}Input";
155155 }
156156 if ( $is_mandatory ) {
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_RadioButtonInput.php
@@ -36,7 +36,7 @@
3737 // mandatory field and there's a current value in place (either
3838 // through a default value or because we're editing an existing
3939 // page).
40 - if ( !$is_mandatory || $cur_value == '' ) {
 40+ if ( !$is_mandatory || $cur_value === '' ) {
4141 array_unshift( $possible_values, '' );
4242 }
4343
@@ -76,7 +76,7 @@
7777 if ( $is_disabled ) {
7878 $radiobutton_attrs['disabled'] = 'disabled';
7979 }
80 - if ( $possible_value == '' ) { // blank/"None" value
 80+ if ( $possible_value === '' ) { // blank/"None" value
8181 $label = wfMsg( 'sf_formedit_none' );
8282 } elseif (
8383 array_key_exists( 'value_labels', $other_args ) &&
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_DropdownInput.php
@@ -49,7 +49,7 @@
5050 // mandatory field and there's a current value in place
5151 // (either through a default value or because we're editing
5252 // an existing page).
53 - if ( !$is_mandatory || $cur_value == '' ) {
 53+ if ( !$is_mandatory || $cur_value === '' ) {
5454 $innerDropdown .= " <option value=\"\"></option>\n";
5555 }
5656 if ( ( $possible_values = $other_args['possible_values'] ) == null ) {
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextWithAutocompleteInput.php
@@ -112,7 +112,7 @@
113113 if ( array_key_exists( 'remote autocompletion', $field_args ) &&
114114 $field_args['remote autocompletion'] == true ) {
115115 $remoteDataType = $autocompleteFieldType;
116 - } elseif ( $autocompletionSource != '' ) {
 116+ } elseif ( $autocompletionSource !== '' ) {
117117 // @TODO - that count() check shouldn't be necessary
118118 if ( array_key_exists( 'possible_values', $field_args ) &&
119119 count( $field_args['possible_values'] ) > 0 ) {
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_CategoryInput.php
@@ -56,7 +56,7 @@
5757 // mandatory field and there's a current value in place
5858 // (either through a default value or because we're editing
5959 // an existing page)
60 - if ( !$is_mandatory || $cur_value == '' ) {
 60+ if ( !$is_mandatory || $cur_value === '' ) {
6161 $text .= ' <input type="radio" tabindex="' . $sfgTabIndex . '" name="' . $input_name . '" value=""';
6262 if ( !$cur_value ) {
6363 $text .= ' checked="checked"';
Index: trunk/extensions/SemanticForms/includes/SF_AutocompleteAPI.php
@@ -33,21 +33,21 @@
3434 $this->dieUsage( 'The substring must be specified', 'param_substr' );
3535 }
3636
37 - if ( $attribute != '' ) {
 37+ if ( $attribute !== '' ) {
3838 $data = self::getAllValuesForProperty( false, $attribute, $substr );
39 - } elseif ( $relation != '' ) {
 39+ } elseif ( $relation !== '' ) {
4040 $data = self::getAllValuesForProperty( true, $relation, $substr );
41 - } elseif ( $category != '' ) {
 41+ } elseif ( $category !== '' ) {
4242 $data = SFUtils::getAllPagesForCategory( $category, 3, $substr );
43 - } elseif ( $concept != '' ) {
 43+ } elseif ( $concept !== '' ) {
4444 $data = SFUtils::getAllPagesForConcept( $concept, $substr );
45 - } elseif ( $namespace != '' ) {
 45+ } elseif ( $namespace !== '' ) {
4646 // Special handling for main (blank) namespace.
4747 if ( $namespace == 'main' ) {
4848 $namespace = '';
4949 }
5050 $data = SFUtils::getAllPagesForNamespace( $namespace, $substr );
51 - } elseif ( $external_url != '' ) {
 51+ } elseif ( $external_url !== '' ) {
5252 $data = SFUtils::getValuesFromExternalURL( $external_url, $substr );
5353 } else {
5454 $data = array();
Index: trunk/extensions/SemanticForms/includes/SF_Utils.php
@@ -40,7 +40,7 @@
4141 */
4242 public static function titleURLString( $title ) {
4343 $namespace = wfUrlencode( $title->getNsText() );
44 - if ( $namespace != '' ) {
 44+ if ( $namespace !== '' ) {
4545 $namespace .= ':';
4646 }
4747 if ( self::isCapitalized( $title ) ) {
@@ -57,7 +57,7 @@
5858 */
5959 public static function titleString( $title ) {
6060 $namespace = $title->getNsText();
61 - if ( $namespace != '' ) {
 61+ if ( $namespace !== '' ) {
6262 $namespace .= ':';
6363 }
6464 if ( self::isCapitalized( $title ) ) {
Index: trunk/extensions/SemanticForms/libs/SF_ajax_form_preview.js
@@ -87,7 +87,7 @@
8888 elts = form.elements;
8989
9090 for (i=0; i < elts.length; ++i) {
91 - if (elts[i].name && elts[i].name != '' && !elts[i].disabled &&
 91+ if (elts[i].name && elts[i].name !== '' && !elts[i].disabled &&
9292 ((elts[i].type!='submit' && elts[i].type!='button' && elts[i].type!='radio' && elts[i].type!='checkbox') || elts[i].checked)) {
9393 addData (elts[i].name, elts[i].value);
9494 }
@@ -124,7 +124,7 @@
125125 elts = frag.getElementsByTagName("form")["editform"].elements;
126126
127127 for (i=0; i < elts.length; ++i)
128 - if (elts[i].name && elts[i].name != '') addData (elts[i].name, elts[i].value);
 128+ if (elts[i].name && elts[i].name !== '') addData (elts[i].name, elts[i].value);
129129
130130 aj2.open('POST', action, true);
131131 aj2.setRequestHeader('Content-Type', 'multipart/form-data; boundary='+boundary);

Follow-up revisions

RevisionCommit summaryAuthorDate
r102368Follow up to r102365;jeroendedauw02:46, 8 November 2011
r102485Follow-up to r102365 - changed comparison to both blank and null to just use ...yaron02:54, 9 November 2011
r102659Follow-up to r102365 - stricter comparators indirectly caused a problem when ...yaron14:58, 10 November 2011
r102676Follow-up to r102365 - changed comparator to check for null, instead of blankyaron19:34, 10 November 2011
r102691Fix for r102365 - replaced checks against '' with checks against null (hopefu...yaron21:07, 10 November 2011
r102940Fix for r102365 - changed comparator to check for null, instead of blank; als...yaron05:23, 14 November 2011
r103048followup r102365: bugfix (free text dropped when editing pages)foxtrott22:07, 14 November 2011
r103718Follow-up to r102365 - somehow the changes in that revision seem to have caus...yaron00:24, 20 November 2011
r104074Another follow-up to r102365 - set $target_name to always be blank instead of...yaron19:45, 23 November 2011
r104462Follow-up to r102365 - standardized $cur_value by setting it to blank if it's...yaron17:58, 28 November 2011
r104814Fix for r102365 - replaced check for blank with check for nullyaron00:46, 1 December 2011
r104823Partial fix for r102365 - $aggregating_property needs to be checked for both ...yaron01:24, 1 December 2011
r104839Fixes for r102704 and r102365 - improved handling for non-Latin characters in...yaron06:10, 1 December 2011
r105150More fixes for r102365 - replaced blank checks with null checks, or restored ...yaron05:20, 5 December 2011
r107598Follow-up to r102365 - stricter comparators sometimes indirectly led to embed...yaron20:56, 29 December 2011
r108067Follow-up to r102365 and r104814 - checks for both blank and null are neededyaron19:10, 4 January 2012
r109410Fix for r102365 - form name can be either blank or nullyaron17:39, 18 January 2012