Index: trunk/extensions/SemanticForms/includes/SF_PageSchemas.php |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Static functions for Semantic Forms, for use by the Page Schemas extension. |
| 4 | + * Static functions for Semantic Forms, for use by the Page Schemas |
| 5 | + * extension. |
5 | 6 | * |
6 | 7 | * @author Yaron Koren |
7 | 8 | * @author Ankit Garg |
— | — | @@ -11,11 +12,12 @@ |
12 | 13 | class SFPageSchemas { |
13 | 14 | |
14 | 15 | /** |
15 | | - * Function to return the property based on the XML passed from the Page Schemas extension |
| 16 | + * Creates an object to hold form-wide information, based on an XML |
| 17 | + * object from the Page Schemas extension. |
16 | 18 | */ |
17 | 19 | public static function createPageSchemasObject( $objectName, $xmlForField, &$object ) { |
18 | 20 | $sfarray = array(); |
19 | | - $formName=""; |
| 21 | + $formName = ""; |
20 | 22 | if ( $objectName == "semanticforms_Form" ) { |
21 | 23 | foreach ( $xmlForField->children() as $tag => $child ) { |
22 | 24 | if ( $tag == $objectName ) { |
— | — | @@ -36,12 +38,9 @@ |
37 | 39 | if ( $prop->getName() == 'InputType' ) { |
38 | 40 | $sfarray[$prop->getName()] = (string)$prop; |
39 | 41 | } else { |
40 | | - // Remember these values can be null also. |
41 | | - // While polulating in the page text, take care of that. |
42 | 42 | $sfarray[(string)$prop->attributes()->name] = (string)$prop; |
43 | 43 | } |
44 | 44 | } |
45 | | - // Setting value specific to SF in 'sf' index. |
46 | 45 | $object['sf'] = $sfarray; |
47 | 46 | return true; |
48 | 47 | } |
— | — | @@ -50,6 +49,9 @@ |
51 | 50 | return true; |
52 | 51 | } |
53 | 52 | |
| 53 | + /** |
| 54 | + * Creates Page Schemas XML for form-wide information. |
| 55 | + */ |
54 | 56 | public static function getSchemaXML( $request, &$xmlArray ) { |
55 | 57 | foreach ( $request->getValues() as $var => $val ) { |
56 | 58 | if ( $var == 'sf_form_name' ) { |
— | — | @@ -67,6 +69,9 @@ |
68 | 70 | return true; |
69 | 71 | } |
70 | 72 | |
| 73 | + /** |
| 74 | + * Creates Page Schemas XML for a specific form field. |
| 75 | + */ |
71 | 76 | public static function getFieldXML( $request, &$xmlArray ) { |
72 | 77 | $xmlPerField = array(); |
73 | 78 | $fieldNum = -1; |
— | — | @@ -126,19 +131,19 @@ |
127 | 132 | } else { |
128 | 133 | $pageNameFormula = ''; |
129 | 134 | } |
130 | | - $text .= "\t<p>" . 'Page name formula:' . ' ' . Html::input( 'sf_page_name_formula', $pageNameFormula, 'text', array( 'size' => 20 ) ) . "</p>\n"; |
| 135 | + $text .= "\t<p>" . wfMsg( 'sf-pageschemas-pagenameformula' ) . ' ' . Html::input( 'sf_page_name_formula', $pageNameFormula, 'text', array( 'size' => 20 ) ) . "</p>\n"; |
131 | 136 | if ( array_key_exists( 'CreateTitle', $form_array ) ) { |
132 | 137 | $createTitle = $form_array['CreateTitle']; |
133 | 138 | } else { |
134 | 139 | $createTitle = ''; |
135 | 140 | } |
136 | | - $text .= "\t<p>" . 'Title of form for new pages:' . ' ' . Html::input( 'sf_create_title', $createTitle, 'text', array( 'size' => 25 ) ) . "</p>\n"; |
| 141 | + $text .= "\t<p>" . wfMsg( 'sf-pageschemas-createtitle' ) . ' ' . Html::input( 'sf_create_title', $createTitle, 'text', array( 'size' => 25 ) ) . "</p>\n"; |
137 | 142 | if ( array_key_exists( 'EditTitle', $form_array ) ) { |
138 | 143 | $editTitle = $form_array['EditTitle']; |
139 | 144 | } else { |
140 | 145 | $editTitle = ''; |
141 | 146 | } |
142 | | - $text .= "\t<p>" . 'Title of form for existing pages:' . ' ' . Html::input( 'sf_edit_title', $editTitle, 'text', array( 'size' => 25 ) ) . "</p>\n"; |
| 147 | + $text .= "\t<p>" . wfMsg( 'sf-pageschemas-edittitle' ) . ' ' . Html::input( 'sf_edit_title', $editTitle, 'text', array( 'size' => 25 ) ) . "</p>\n"; |
143 | 148 | $text_extensions['sf'] = array( 'Form', '#CF9', $text, $hasExistingValues ); |
144 | 149 | |
145 | 150 | return true; |
— | — | @@ -149,16 +154,13 @@ |
150 | 155 | * within the Page Schemas 'edit schema' page. |
151 | 156 | */ |
152 | 157 | public static function getFieldHTML( $field, &$text_extensions ) { |
153 | | - if ( is_null( $field ) ) { |
154 | | - $fieldValues = array(); |
155 | | - } else { |
156 | | - $sf_array = $field->getObject('semanticforms_FormInput'); //this returns an array with property values filled |
| 158 | + $hasExistingValues = false; |
| 159 | + $fieldValues = array(); |
| 160 | + if ( !is_null( $field ) ) { |
| 161 | + $sf_array = $field->getObject('semanticforms_FormInput'); |
157 | 162 | if ( array_key_exists( 'sf', $sf_array ) ) { |
158 | 163 | $fieldValues = $sf_array['sf']; |
159 | 164 | $hasExistingValues = true; |
160 | | - } else { |
161 | | - $fieldValues = array(); |
162 | | - $hasExistingValues = false; |
163 | 165 | } |
164 | 166 | } |
165 | 167 | |
— | — | @@ -167,10 +169,21 @@ |
168 | 170 | } else { |
169 | 171 | $inputType = ''; |
170 | 172 | } |
171 | | - $inputTypeAttrs = array( 'size' => 15 ); |
172 | | - $inputTypeInput = Html::input( 'sf_input_type_num', $inputType, 'text', $inputTypeAttrs ); |
173 | | - $text = '<p>Input type: ' . $inputTypeInput . '</p>'; |
174 | | - $text .= "\t" . '<p>Parameter name and its value as a key=value pair, separated by commas (if a value contains a comma, replace it with "\,"): For example: size=20,mandatory</p>' . "\n"; |
| 173 | + |
| 174 | + global $sfgFormPrinter; |
| 175 | + $possibleInputTypes = $sfgFormPrinter->getAllInputTypes(); |
| 176 | + $inputTypeDropdownHTML = ''; |
| 177 | + foreach ( $possibleInputTypes as $possibleInputType ) { |
| 178 | + $inputTypeOptionAttrs = array(); |
| 179 | + if ( $possibleInputType == $inputType ) { |
| 180 | + $inputTypeOptionAttrs['selected'] = true; |
| 181 | + } |
| 182 | + $inputTypeDropdownHTML .= Html::element( 'option', $inputTypeOptionAttrs, $possibleInputType ) . "\n"; |
| 183 | + } |
| 184 | + $inputTypeDropdown = Html::rawElement( 'select', array( 'name' => 'sf_input_type_num' ), $inputTypeDropdownHTML ); |
| 185 | + $text = '<p>' . wfMsg( 'sf_createform_inputtype' ) . ' ' . $inputTypeDropdown . '</p>'; |
| 186 | + |
| 187 | + $text .= "\t" . '<p>Enter parameter names and their values as key=value pairs, separated by commas (if a value contains a comma, replace it with "\,") For example: size=20, mandatory</p>' . "\n"; |
175 | 188 | $paramValues = array(); |
176 | 189 | foreach ( $fieldValues as $param => $value ) { |
177 | 190 | if ( !empty( $param ) && $param != 'InputType' ) { |
— | — | @@ -357,7 +370,7 @@ |
358 | 371 | |
359 | 372 | foreach ( $field_xml->children() as $tag => $child ) { |
360 | 373 | if ( $tag == "semanticforms_FormInput" ) { |
361 | | - $text = PageSchemas::tableMessageRowHTML( "paramAttr", "SemanticForms", (string)$tag ); |
| 374 | + $text = PageSchemas::tableMessageRowHTML( "paramAttr", wfMsg( 'specialpages-group-sf_group' ), (string)$tag ); |
362 | 375 | foreach ( $child->children() as $prop ) { |
363 | 376 | if ( $prop->getName() == 'InputType' ) { |
364 | 377 | $text .= PageSchemas::tableMessageRowHTML("paramAttrMsg", $prop->getName(), $prop ); |