r93042 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93041‎ | r93042 | r93043 >
Date:04:25, 25 July 2011
Author:yaron
Status:deferred
Tags:
Comment:
Replaced 'var' with 'public' for class fields; updated handling of recently-modified SF classes, like SFTemplateField
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -14,10 +14,10 @@
1515
1616 class SFFormPrinter {
1717
18 - var $mSemanticTypeHooks;
19 - var $mInputTypeHooks;
20 - var $standardInputsIncluded;
21 - var $mPageTitle;
 18+ public $mSemanticTypeHooks;
 19+ public $mInputTypeHooks;
 20+ public $standardInputsIncluded;
 21+ public $mPageTitle;
2222
2323 public function __construct() {
2424 // Initialize variables.
@@ -420,7 +420,6 @@
421421 $all_instances_printed = false;
422422 $strict_parsing = false;
423423 for ( $section_num = 0; $section_num < count( $form_def_sections ); $section_num++ ) {
424 - $tif = new SFTemplateInForm();
425424 $start_position = 0;
426425 $template_text = "";
427426 // the append is there to ensure that the original
@@ -438,7 +437,7 @@
439438 if ( $tag_title == 'for template' ) {
440439 $old_template_name = $template_name;
441440 $template_name = trim( $tag_components[1] );
442 - $tif->template_name = $template_name;
 441+ $tif = SFTemplateInForm::create( $template_name );
443442 $query_template_name = str_replace( ' ', '_', $template_name );
444443 $add_button_text = wfMsg( 'sf_formedit_addanother' );
445444 // Also replace periods with underlines, since that's what
@@ -471,7 +470,7 @@
472471 $form_text .= "\t" . '<div class="multipleTemplateList">' . "\n";
473472 }
474473 }
475 - $template_text .= "{{" . $tif->template_name;
 474+ $template_text .= "{{" . $template_name;
476475 $all_fields = $tif->getAllFields();
477476 // remove template tag
478477 $section = substr_replace( $section, '', $brackets_loc, $brackets_end_loc + 3 - $brackets_loc );
@@ -483,7 +482,7 @@
484483 if ( $source_is_page || $form_is_partial ) {
485484 // Replace underlines with spaces in template name, to allow for
486485 // searching on either.
487 - $search_template_str = str_replace( '_', ' ', $tif->template_name );
 486+ $search_template_str = str_replace( '_', ' ', $template_name );
488487 $preg_match_template_str = str_replace(
489488 array( '/', '(', ')' ),
490489 array( '\/', '\(', '\)' ),
@@ -1008,8 +1007,9 @@
10091008 // SFFormField object, not the SFTemplateField object it contains;
10101009 // it seemed like too much work, though, to create an
10111010 // SFFormField::setSemanticProperty() function just for this call
1012 - if ( $semantic_property != null )
1013 - $form_field->template_field->setSemanticProperty( $semantic_property );
 1011+ if ( $semantic_property != null ) {
 1012+ $form_field->setSemanticProperty( $semantic_property );
 1013+ }
10141014
10151015 // call hooks - unfortunately this has to be split into two
10161016 // separate calls, because of the different variable names in
@@ -1035,7 +1035,7 @@
10361036 ( $cur_value == '' || $cur_value == 'now' ) ) {
10371037 if ( $input_type == 'date' || $input_type == 'datetime' ||
10381038 $input_type == 'year' ||
1039 - ( $input_type == '' && $form_field->template_field->property_type == '_dat' ) ) {
 1039+ ( $input_type == '' && $form_field->getTemplateField()->getPropertyType() == '_dat' ) ) {
10401040 // Get current time, for the time zone specified in the wiki.
10411041 global $wgLocaltimezone;
10421042 if ( isset( $wgLocaltimezone ) ) {
@@ -1442,15 +1442,15 @@
14431443 * Create the HTML and Javascript to display this field within a form
14441444 */
14451445 function formFieldHTML( $form_field, $cur_value ) {
1446 - // also get the actual field, with all the semantic information (type is
1447 - // SFTemplateField, instead of SFFormField)
1448 - $template_field = $form_field->template_field;
 1446+ // Also get the actual field, with all the semantic information
 1447+ // (type is SFTemplateField, instead of SFFormField)
 1448+ $template_field = $form_field->getTemplateField();
14491449
14501450 if ( $form_field->is_hidden ) {
14511451 $text = SFFormUtils::hiddenFieldHTML( $form_field->input_name, $cur_value );
1452 - } elseif ( $form_field->input_type != '' &&
1453 - array_key_exists( $form_field->input_type, $this->mInputTypeHooks ) &&
1454 - $this->mInputTypeHooks[$form_field->input_type] != null ) {
 1452+ } elseif ( $form_field->getInputType() != '' &&
 1453+ array_key_exists( $form_field->getInputType(), $this->mInputTypeHooks ) &&
 1454+ $this->mInputTypeHooks[$form_field->getInputType()] != null ) {
14551455 $funcArgs = array();
14561456 $funcArgs[] = $cur_value;
14571457 $funcArgs[] = $form_field->input_name;
@@ -1459,13 +1459,13 @@
14601460 // last argument to function should be a hash, merging the default
14611461 // values for this input type with all other properties set in
14621462 // the form definition, plus some semantic-related arguments
1463 - $hook_values = $this->mInputTypeHooks[$form_field->input_type];
 1463+ $hook_values = $this->mInputTypeHooks[$form_field->getInputType()];
14641464 $other_args = $form_field->getArgumentsForInputCall( $hook_values[1] );
14651465 $funcArgs[] = $other_args;
14661466 $text = call_user_func_array( $hook_values[0], $funcArgs );
14671467 } else { // input type not defined in form
1468 - $property_type = $template_field->property_type;
1469 - $is_list = ( $form_field->is_list || $template_field->is_list );
 1468+ $property_type = $template_field->getPropertyType();
 1469+ $is_list = ( $form_field->is_list || $template_field->getIsList() );
14701470 if ( $property_type != '' &&
14711471 array_key_exists( $property_type, $this->mSemanticTypeHooks ) &&
14721472 isset( $this->mSemanticTypeHooks[$property_type][$is_list] ) ) {