Index: trunk/extensions/SemanticForms/includes/SF_FormField.php |
— | — | @@ -13,58 +13,58 @@ |
14 | 14 | * @ingroup SF |
15 | 15 | */ |
16 | 16 | class SFFormField { |
17 | | - private $num; |
| 17 | + private $mNum; |
18 | 18 | public $template_field; |
19 | | - private $input_type; |
20 | | - public $is_mandatory; |
21 | | - public $is_hidden; |
22 | | - private $is_restricted; |
23 | | - private $possible_values; |
24 | | - public $is_list; |
| 19 | + private $mInputType; |
| 20 | + private $mIsMandatory; |
| 21 | + private $mIsHidden; |
| 22 | + private $mIsRestricted; |
| 23 | + private $mPossibleValues; |
| 24 | + private $mIsList; |
25 | 25 | // the following fields are not set by the form-creation page |
26 | 26 | // (though they could be) |
27 | | - private $is_uploadable; |
28 | | - private $field_args; |
| 27 | + private $mIsUploadable; |
| 28 | + private $mFieldArgs; |
29 | 29 | // somewhat of a hack - these two fields are for a field in a specific |
30 | 30 | // representation of a form, not the form definition; ideally these |
31 | 31 | // should be contained in a third 'field' class, called something like |
32 | 32 | // SFFormInstanceField, that holds these fields plus an instance of |
33 | 33 | // SFFormField. Too much work? |
34 | | - public $input_name; |
35 | | - public $is_disabled; |
| 34 | + private $mInputName; |
| 35 | + private $mIsDisabled; |
36 | 36 | |
37 | 37 | static function create( $num, $template_field ) { |
38 | 38 | $f = new SFFormField(); |
39 | | - $f->num = $num; |
| 39 | + $f->mNum = $num; |
40 | 40 | $f->template_field = $template_field; |
41 | | - $f->input_type = ""; |
42 | | - $f->is_mandatory = false; |
43 | | - $f->is_hidden = false; |
44 | | - $f->is_restricted = false; |
45 | | - $f->is_uploadable = false; |
46 | | - $f->possible_values = null; |
47 | | - $f->field_args = array(); |
| 41 | + $f->mInputType = ""; |
| 42 | + $f->mIsMandatory = false; |
| 43 | + $f->mIsHidden = false; |
| 44 | + $f->mIsRestricted = false; |
| 45 | + $f->mIsUploadable = false; |
| 46 | + $f->mPossibleValues = null; |
| 47 | + $f->mFieldArgs = array(); |
48 | 48 | return $f; |
49 | 49 | } |
50 | 50 | |
51 | | - 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 ) { |
| 51 | + static function createFromDefinition( $fieldName, $inputName, $isMandatory, $isHidden, $isUploadable, $possibleValues, $isDisabled, $isList, $inputType, $fieldArgs, $allFields, $strictParsing ) { |
52 | 52 | // see if this field matches one of the fields defined for this |
53 | 53 | // template - if it is, use all available information about |
54 | 54 | // that field; if it's not, either include it in the form or |
55 | 55 | // not, depending on whether the template has a 'strict' |
56 | 56 | // setting in the form definition |
57 | 57 | $the_field = null; |
58 | | - foreach ( $all_fields as $cur_field ) { |
59 | | - if ( $field_name == $cur_field->getFieldName() ) { |
| 58 | + foreach ( $allFields as $cur_field ) { |
| 59 | + if ( $fieldName == $cur_field->getFieldName() ) { |
60 | 60 | $the_field = $cur_field; |
61 | 61 | break; |
62 | 62 | } |
63 | 63 | } |
64 | 64 | if ( $the_field == null ) { |
65 | | - if ( $strict_parsing ) { |
| 65 | + if ( $strictParsing ) { |
66 | 66 | $dummy_ff = new SFFormField(); |
67 | 67 | $dummy_ff->template_field = new SFTemplateField(); |
68 | | - $dummy_ff->is_list = false; |
| 68 | + $dummy_ff->mIsList = false; |
69 | 69 | return $dummy_ff; |
70 | 70 | } |
71 | 71 | $the_field = new SFTemplateField(); |
— | — | @@ -74,15 +74,15 @@ |
75 | 75 | // as settings from the form definition file |
76 | 76 | $f = new SFFormField(); |
77 | 77 | $f->template_field = $the_field; |
78 | | - $f->is_mandatory = $is_mandatory; |
79 | | - $f->is_hidden = $is_hidden; |
80 | | - $f->is_uploadable = $is_uploadable; |
81 | | - $f->possible_values = $possible_values; |
82 | | - $f->input_type = $input_type; |
83 | | - $f->field_args = $field_args; |
84 | | - $f->input_name = $input_name; |
85 | | - $f->is_disabled = $is_disabled; |
86 | | - $f->is_list = $is_list; |
| 78 | + $f->mIsMandatory = $isMandatory; |
| 79 | + $f->mIsHidden = $isHidden; |
| 80 | + $f->mIsUploadable = $isUploadable; |
| 81 | + $f->mPossibleValues = $possibleValues; |
| 82 | + $f->mInputType = $inputType; |
| 83 | + $f->mFieldArgs = $fieldArgs; |
| 84 | + $f->mInputName = $inputName; |
| 85 | + $f->mIsDisabled = $isDisabled; |
| 86 | + $f->mIsList = $isList; |
87 | 87 | return $f; |
88 | 88 | } |
89 | 89 | |
— | — | @@ -91,13 +91,37 @@ |
92 | 92 | } |
93 | 93 | |
94 | 94 | public function getInputType() { |
95 | | - return $this->input_type; |
| 95 | + return $this->mInputType; |
96 | 96 | } |
97 | 97 | |
| 98 | + public function isMandatory() { |
| 99 | + return $this->mIsMandatory; |
| 100 | + } |
| 101 | + |
| 102 | + public function isHidden() { |
| 103 | + return $this->mIsHidden; |
| 104 | + } |
| 105 | + |
| 106 | + public function isList() { |
| 107 | + return $this->mIsList; |
| 108 | + } |
| 109 | + |
| 110 | + public function getInputName() { |
| 111 | + return $this->mInputName; |
| 112 | + } |
| 113 | + |
| 114 | + public function isDisabled() { |
| 115 | + return $this->mIsDisabled; |
| 116 | + } |
| 117 | + |
98 | 118 | public function setTemplateField( $templateField ) { |
99 | 119 | $this->template_field = $templateField; |
100 | 120 | } |
101 | 121 | |
| 122 | + public function setIsHidden( $isHidden ) { |
| 123 | + $this->mIsHidden = $isHidden; |
| 124 | + } |
| 125 | + |
102 | 126 | public function setSemanticProperty( $semanticProperty ) { |
103 | 127 | $this->template_field->setSemanticProperty( $semanticProperty ); |
104 | 128 | } |
— | — | @@ -130,7 +154,7 @@ |
131 | 155 | } |
132 | 156 | |
133 | 157 | function creationHTML( $template_num ) { |
134 | | - $field_form_text = $template_num . "_" . $this->num; |
| 158 | + $field_form_text = $template_num . "_" . $this->mNum; |
135 | 159 | $template_field = $this->template_field; |
136 | 160 | $text = '<h3>' . wfMsg( 'sf_createform_field' ) . " '" . $template_field->getFieldName() . "'</h3>\n"; |
137 | 161 | $prop_link_text = SFUtils::linkText( SMW_NS_PROPERTY, $template_field->getSemanticProperty() ); |
— | — | @@ -140,7 +164,7 @@ |
141 | 165 | } elseif ( $template_field->getPropertyType() == "" ) { |
142 | 166 | $text .= '<p>' . wfMsg( 'sf_createform_fieldpropunknowntype', $prop_link_text ) . "</p>\n"; |
143 | 167 | } else { |
144 | | - if ( $template_field->getIsList() ) { |
| 168 | + if ( $template_field->isList() ) { |
145 | 169 | $propDisplayMsg = 'sf_createform_fieldproplist'; |
146 | 170 | } else { |
147 | 171 | $propDisplayMsg = 'sf_createform_fieldprop'; |
— | — | @@ -184,8 +208,8 @@ |
185 | 209 | $default_input_type = null; |
186 | 210 | $possible_input_types = $sfgFormPrinter->getAllInputTypes(); |
187 | 211 | } else { |
188 | | - $default_input_type = $sfgFormPrinter->getDefaultInputType( $template_field->getIsList(), $template_field->getPropertyType() ); |
189 | | - $possible_input_types = $sfgFormPrinter->getPossibleInputTypes( $template_field->getIsList(), $template_field->getPropertyType() ); |
| 212 | + $default_input_type = $sfgFormPrinter->getDefaultInputType( $template_field->isList(), $template_field->getPropertyType() ); |
| 213 | + $possible_input_types = $sfgFormPrinter->getPossibleInputTypes( $template_field->isList(), $template_field->getPropertyType() ); |
190 | 214 | } |
191 | 215 | $text .= $this->inputTypeDropdownHTML( $field_form_text, $default_input_type, $possible_input_types, $template_field->getInputType() ); |
192 | 216 | |
— | — | @@ -236,21 +260,21 @@ |
237 | 261 | } |
238 | 262 | if ( ! $part_of_multiple ) { $text .= "| "; } |
239 | 263 | $text .= "{{{field|" . $this->template_field->getFieldName(); |
240 | | - if ( $this->is_hidden ) { |
| 264 | + if ( $this->mIsHidden ) { |
241 | 265 | $text .= "|hidden"; |
242 | 266 | } elseif ( $this->template_field->getInputType() != '' ) { |
243 | 267 | $text .= "|input type=" . $this->template_field->getInputType(); |
244 | 268 | } |
245 | | - foreach ( $this->field_args as $arg => $value ) { |
| 269 | + foreach ( $this->mFieldArgs as $arg => $value ) { |
246 | 270 | if ( $value === true ) { |
247 | 271 | $text .= "|$arg"; |
248 | 272 | } else { |
249 | 273 | $text .= "|$arg=$value"; |
250 | 274 | } |
251 | 275 | } |
252 | | - if ( $this->is_mandatory ) { |
| 276 | + if ( $this->mIsMandatory ) { |
253 | 277 | $text .= "|mandatory"; |
254 | | - } elseif ( $this->is_restricted ) { |
| 278 | + } elseif ( $this->mIsRestricted ) { |
255 | 279 | $text .= "|restricted"; |
256 | 280 | } |
257 | 281 | $text .= "}}}\n"; |
— | — | @@ -270,16 +294,16 @@ |
271 | 295 | */ |
272 | 296 | function getArgumentsForInputCall( $default_args = null ) { |
273 | 297 | // start with the arguments array already defined |
274 | | - $other_args = $this->field_args; |
| 298 | + $other_args = $this->mFieldArgs; |
275 | 299 | // a value defined for the form field should always supersede |
276 | 300 | // the coresponding value for the template field |
277 | | - if ( $this->possible_values != null ) |
278 | | - $other_args['possible_values'] = $this->possible_values; |
279 | | - else { |
| 301 | + if ( $this->mPossibleValues != null ) { |
| 302 | + $other_args['possible_values'] = $this->mPossibleValues; |
| 303 | + } else { |
280 | 304 | $other_args['possible_values'] = $this->template_field->getPossibleValues(); |
281 | 305 | $other_args['value_labels'] = $this->template_field->getValueLabels(); |
282 | 306 | } |
283 | | - $other_args['is_list'] = ( $this->is_list || $this->template_field->getIsList() ); |
| 307 | + $other_args['is_list'] = ( $this->mIsList || $this->template_field->isList() ); |
284 | 308 | if ( $this->template_field->getSemanticProperty() != '' && |
285 | 309 | ! array_key_exists( 'semantic_property', $other_args ) ) { |
286 | 310 | $other_args['semantic_property'] = $this->template_field->getSemanticProperty(); |