Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php |
— | — | @@ -148,8 +148,7 @@ |
149 | 149 | global $wgRequest, $wgUser, $wgParser; |
150 | 150 | global $sfgTabIndex; // used to represent the current tab index in the form |
151 | 151 | global $sfgFieldNum; // used for setting various HTML IDs |
152 | | - global $sfgJSValidationCalls; // array of Javascript calls to determine if page can be saved |
153 | | - global $sfgAdderButtons, $sfgRemoverButtons; |
| 152 | + global $sfgAdderButtons; |
154 | 153 | |
155 | 154 | // initialize some variables |
156 | 155 | $sfgTabIndex = 1; |
— | — | @@ -231,8 +230,6 @@ |
232 | 231 | $wgOut->readOnlyPage( null, false, $permissionErrors, 'edit' ); |
233 | 232 | $wgOut->addHTML( "\n<hr />\n" ); |
234 | 233 | } |
235 | | - $javascript_text = ""; |
236 | | - $fields_javascript_text = ""; |
237 | 234 | |
238 | 235 | // Remove <noinclude> sections and <includeonly> tags from form definition |
239 | 236 | $form_def = StringUtils::delimiterReplace( '<noinclude>', '</noinclude>', '', $form_def ); |
— | — | @@ -705,7 +702,7 @@ |
706 | 703 | } else { |
707 | 704 | $default_value = $cur_value; |
708 | 705 | } |
709 | | - list( $new_text, $new_javascript_text ) = SFTextAreaInput::getText( $default_value, 'free_text', false, ( $form_is_disabled || $is_restricted ), $field_args ); |
| 706 | + $new_text = SFTextAreaInput::getText( $default_value, 'free_text', false, ( $form_is_disabled || $is_restricted ), $field_args ); |
710 | 707 | if ( in_array( 'edittools', $free_text_components ) ) { |
711 | 708 | // borrowed from EditPage::showEditTools() |
712 | 709 | $options[] = 'parse'; |
— | — | @@ -718,7 +715,6 @@ |
719 | 716 | |
720 | 717 | END; |
721 | 718 | } |
722 | | - $fields_javascript_text .= $new_javascript_text; |
723 | 719 | } |
724 | 720 | $free_text_was_included = true; |
725 | 721 | // add a similar placeholder to the data text |
— | — | @@ -939,10 +935,8 @@ |
940 | 936 | $cur_value = $cur_value_in_template; |
941 | 937 | } |
942 | 938 | } |
943 | | - list( $new_text, $new_javascript_text ) = $this->formFieldHTML( $form_field, $cur_value ); |
| 939 | + $new_text = $this->formFieldHTML( $form_field, $cur_value ); |
944 | 940 | |
945 | | - $fields_javascript_text .= $new_javascript_text; |
946 | | - |
947 | 941 | // if this field is disabled, add a hidden field holding |
948 | 942 | // the value of this field, because disabled inputs for some |
949 | 943 | // reason don't submit their value |
— | — | @@ -964,40 +958,6 @@ |
965 | 959 | $template_text .= "\n|$field_name=$cur_value_in_template"; |
966 | 960 | } |
967 | 961 | $section = substr_replace( $section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc ); |
968 | | - // also add to Javascript validation code |
969 | | - $input_id = "input_" . $sfgFieldNum; |
970 | | - $info_id = "info_" . $sfgFieldNum; |
971 | | - if ( $is_mandatory ) { |
972 | | - if ( $input_type == 'date' || $input_type == 'datetime' || $input_type == 'datetime with timezone' || |
973 | | - ( $input_type == '' && $form_field->template_field->propertyIsOfType( '_dat' ) ) ) { |
974 | | - $sfgJSValidationCalls[] = "validate_mandatory_field ('$input_id" . "_month', '$info_id')"; |
975 | | - $sfgJSValidationCalls[] = "validate_mandatory_field ('$input_id" . "_day', '$info_id')"; |
976 | | - $sfgJSValidationCalls[] = "validate_mandatory_field ('$input_id" . "_year', '$info_id')"; |
977 | | - if ( $input_type == 'datetime' || $input_type == 'datetime with timezone' ) { |
978 | | - // TODO - validate the time fields |
979 | | - if ( $input_type == 'datetime with timezone' ) { |
980 | | - // TODO - validate the timezone |
981 | | - } |
982 | | - } |
983 | | - } else { |
984 | | - if ( $allow_multiple ) { |
985 | | - if ( $all_instances_printed ) { |
986 | | - $sfgJSValidationCalls[] = "validate_multiple_mandatory_fields($sfgFieldNum)"; |
987 | | - } else { |
988 | | - $sfgJSValidationCalls[] = "validate_mandatory_field(\"input_$sfgFieldNum\", \"info_$sfgFieldNum\")"; |
989 | | - } |
990 | | - } elseif ( $input_type == 'radiobutton' || $input_type == 'category' ) { |
991 | | - // only add this if there's a "None" option |
992 | | - if ( empty( $default_value ) ) { |
993 | | - $sfgJSValidationCalls[] = "validate_mandatory_radiobutton('$input_id', '$info_id')"; |
994 | | - } |
995 | | - } elseif ( ( $form_field->template_field->is_list && $form_field->template_field->field_type == 'enumeration' && $input_type != 'listbox' ) || ( $input_type == 'checkboxes' ) ) { |
996 | | - $sfgJSValidationCalls[] = "validate_mandatory_checkboxes('$input_id', '$info_id')"; |
997 | | - } else { |
998 | | - $sfgJSValidationCalls[] = "validate_mandatory_field('$input_id', '$info_id')"; |
999 | | - } |
1000 | | - } |
1001 | | - } |
1002 | 962 | } else { |
1003 | 963 | $start_position = $brackets_end_loc; |
1004 | 964 | } |
— | — | @@ -1143,24 +1103,21 @@ |
1144 | 1104 | // in the form, to differentiate the inputs the form starts out |
1145 | 1105 | // with from any inputs added by the Javascript |
1146 | 1106 | $section = str_replace( '[num]', "[{$instance_num}a]", $section ); |
1147 | | - $wrapperID = "wrapper_$sfgFieldNum"; |
1148 | | - $removerID = "remover_$sfgFieldNum"; |
1149 | 1107 | $remove_text = wfMsg( 'sf_formedit_remove' ); |
1150 | 1108 | $form_text .= <<<END |
1151 | | - <div id="$wrapperID" class="multipleTemplate"> |
| 1109 | + <div class="multipleTemplate"> |
1152 | 1110 | $section |
1153 | | - <input type="button" id="$removerID" value="$remove_text" tabindex="$sfgTabIndex" class="remove" /> |
| 1111 | + <input type="button" value="$remove_text" tabindex="$sfgTabIndex" class="remover" /> |
1154 | 1112 | </div> |
1155 | 1113 | |
1156 | 1114 | END; |
1157 | | - $sfgRemoverButtons[] = "$removerID,$wrapperID"; |
1158 | 1115 | // this will cause the section to be re-parsed on the next go |
1159 | 1116 | $section_num--; |
1160 | 1117 | } else { |
1161 | 1118 | // this is the last instance of this template - stick an 'add' |
1162 | 1119 | // button in the form |
1163 | 1120 | $form_text .= <<<END |
1164 | | - <div id="starter_$query_template_name" class="multipleTemplate" style="display: none;"> |
| 1121 | + <div id="starter_$query_template_name" class="multipleTemplateStarter" style="display: none;"> |
1165 | 1122 | $section |
1166 | 1123 | </div> |
1167 | 1124 | <div id="main_$query_template_name"></div> |
— | — | @@ -1266,6 +1223,7 @@ |
1267 | 1224 | END; |
1268 | 1225 | |
1269 | 1226 | // add Javascript code for form-wide use |
| 1227 | + $javascript_text = ""; |
1270 | 1228 | if ( $free_text_was_included && $showFCKEditor > 0 ) { |
1271 | 1229 | $javascript_text .= SFFormUtils::mainFCKJavascript( $showFCKEditor ); |
1272 | 1230 | if ( $showFCKEditor & ( RTE_TOGGLE_LINK | RTE_POPUP ) ) { |
— | — | @@ -1281,7 +1239,7 @@ |
1282 | 1240 | // if doing a replace, the data text is actually the modified original page |
1283 | 1241 | if ( $wgRequest->getCheck( 'partial' ) ) |
1284 | 1242 | $data_text = $existing_page_content; |
1285 | | - $javascript_text .= $fields_javascript_text; |
| 1243 | + |
1286 | 1244 | global $wgParser; |
1287 | 1245 | $new_text = ""; |
1288 | 1246 | if ( !$embedded ) |
— | — | @@ -1309,7 +1267,6 @@ |
1310 | 1268 | |
1311 | 1269 | if ( $form_field->is_hidden ) { |
1312 | 1270 | $text = SFFormUtils::hiddenFieldHTML( $form_field->input_name, $cur_value ); |
1313 | | - $javascript_text = ""; |
1314 | 1271 | } elseif ( $form_field->input_type != '' && |
1315 | 1272 | array_key_exists( $form_field->input_type, $this->mInputTypeHooks ) && |
1316 | 1273 | $this->mInputTypeHooks[$form_field->input_type] != null ) { |
— | — | @@ -1324,7 +1281,7 @@ |
1325 | 1282 | $hook_values = $this->mInputTypeHooks[$form_field->input_type]; |
1326 | 1283 | $other_args = $form_field->getArgumentsForInputCall( $hook_values[1] ); |
1327 | 1284 | $funcArgs[] = $other_args; |
1328 | | - list( $text, $javascript_text ) = call_user_func_array( $hook_values[0], $funcArgs ); |
| 1285 | + $text = call_user_func_array( $hook_values[0], $funcArgs ); |
1329 | 1286 | } else { // input type not defined in form |
1330 | 1287 | $field_type = $template_field->field_type; |
1331 | 1288 | $is_list = ( $form_field->is_list || $template_field->is_list ); |
— | — | @@ -1339,7 +1296,7 @@ |
1340 | 1297 | $hook_values = $this->mSemanticTypeHooks[$field_type][$is_list]; |
1341 | 1298 | $other_args = $form_field->getArgumentsForInputCall( $hook_values[1] ); |
1342 | 1299 | $funcArgs[] = $other_args; |
1343 | | - list( $text, $javascript_text ) = call_user_func_array( $hook_values[0], $funcArgs ); |
| 1300 | + $text = call_user_func_array( $hook_values[0], $funcArgs ); |
1344 | 1301 | } else { // anything else |
1345 | 1302 | $other_args = $form_field->getArgumentsForInputCall(); |
1346 | 1303 | // special call to ensure that a list input is the right default size |
— | — | @@ -1347,10 +1304,10 @@ |
1348 | 1305 | if ( ! array_key_exists( 'size', $other_args ) ) |
1349 | 1306 | $other_args['size'] = 100; |
1350 | 1307 | } |
1351 | | - list( $text, $javascript_text ) = SFTextInput::getText( $cur_value, $form_field->input_name, $form_field->is_mandatory, $form_field->is_disabled, $other_args ); |
| 1308 | + $text = SFTextInput::getText( $cur_value, $form_field->input_name, $form_field->is_mandatory, $form_field->is_disabled, $other_args ); |
1352 | 1309 | } |
1353 | 1310 | } |
1354 | | - return array( $text, $javascript_text ); |
| 1311 | + return $text; |
1355 | 1312 | } |
1356 | 1313 | |
1357 | 1314 | } |