Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc |
— | — | @@ -51,9 +51,11 @@ |
52 | 52 | function formHTML($form_def, $form_submitted, $source_is_page, $existing_page_content = null, $page_title = null) { |
53 | 53 | global $wgRequest, $wgUser, $wgParser; |
54 | 54 | global $sfgTabIndex; // used to represent the current tab index in the form |
| 55 | + global $sfgFieldNum; // used for setting various HTML IDs |
55 | 56 | |
56 | 57 | // initialize some variables |
57 | | - $sfgTabIndex = 0; |
| 58 | + $sfgTabIndex = 1; |
| 59 | + $sfgFieldNum = 1; |
58 | 60 | // disable all form elements if user doesn't have edit permission |
59 | 61 | $true_page_title = Title::newFromText($page_title); |
60 | 62 | if ( $true_page_title->userCanEdit() ) { |
— | — | @@ -122,6 +124,7 @@ |
123 | 125 | // modified; is it necessary? |
124 | 126 | $section = " " . $form_def_sections[$section_num]; |
125 | 127 | |
| 128 | +$while_instance = 0; |
126 | 129 | while ($brackets_loc = strpos($section, '{{{', $start_position)) { |
127 | 130 | $brackets_end_loc = strpos($section, "}}}", $brackets_loc); |
128 | 131 | $bracketed_string = substr($section, $brackets_loc + 3, $brackets_end_loc - ($brackets_loc + 3)); |
— | — | @@ -358,6 +361,8 @@ |
359 | 362 | $field_args['rows'] = 5; |
360 | 363 | if ($field_args['cols'] == null) |
361 | 364 | $field_args['cols'] = 30; |
| 365 | + $sfgTabIndex++; |
| 366 | + $sfgFieldNum++; |
362 | 367 | list($new_text, $new_javascript_text) = $this->textAreaHTML('<free_text>', 'free_text', false, $form_is_disabled, $field_args); |
363 | 368 | } |
364 | 369 | $free_text_was_included = true; |
— | — | @@ -461,8 +466,8 @@ |
462 | 467 | $section = substr_replace($section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc); |
463 | 468 | // also add to Javascript validation code |
464 | 469 | if ($is_mandatory) { |
465 | | - $input_id = "input_" . $sfgTabIndex; |
466 | | - $info_id = "info_" . $sfgTabIndex; |
| 470 | + $input_id = "input_" . $sfgFieldNum; |
| 471 | + $info_id = "info_" . $sfgFieldNum; |
467 | 472 | if ($input_type == 'date' || $input_type == 'datetime' || $input_type == 'datetime with timezone') { |
468 | 473 | $js_validation_calls[] = "validate_mandatory_field ('$input_id" . "_1', '$info_id')"; |
469 | 474 | $js_validation_calls[] = "validate_mandatory_field ('$input_id" . "_2', '$info_id')"; |
— | — | @@ -507,9 +512,9 @@ |
508 | 513 | $section = str_replace('[num]', "[{$instance_num}a]", $section); |
509 | 514 | $remove_text = wfMsg('sf_editdata_remove'); |
510 | 515 | $form_text .=<<<END |
511 | | - <div id="wrapper_$sfgTabIndex" class="multiple_template"> |
| 516 | + <div id="wrapper_$sfgFieldNum" class="multiple_template"> |
512 | 517 | $section |
513 | | - <input type="button" onclick="removeInstance('wrapper_$sfgTabIndex');" value="$remove_text" tabindex="$sfgTabIndex" /> |
| 518 | + <input type="button" onclick="removeInstance('wrapper_$sfgFieldNum');" value="$remove_text" tabindex="$sfgTabIndex" /> |
514 | 519 | </div> |
515 | 520 | |
516 | 521 | END; |
— | — | @@ -531,13 +536,13 @@ |
532 | 537 | $add_another = wfMsg('sf_editdata_addanother'); |
533 | 538 | $form_text .=<<<END |
534 | 539 | <p style="margin-left:10px;"> |
535 | | - <p><input type="button" onclick="addInstance('starter_$query_template_name', 'main_$query_template_name', '$sfgTabIndex');" value="$add_another" tabindex="$sfgTabIndex" /></p> |
| 540 | + <p><input type="button" onclick="addInstance('starter_$query_template_name', 'main_$query_template_name', '$sfgFieldNum');" value="$add_another" tabindex="$sfgTabIndex" /></p> |
536 | 541 | |
537 | 542 | END; |
538 | 543 | // if a chooser is being used for this template, add the template |
539 | 544 | // to the chooser data array |
540 | 545 | if ($chooser_name !== false) |
541 | | - $choosers[$chooser_name][]= array($query_template_name, $sfgTabIndex, $chooser_caption); |
| 546 | + $choosers[$chooser_name][]= array($query_template_name, $sfgFieldNum, $chooser_caption); |
542 | 547 | } |
543 | 548 | } else { |
544 | 549 | $form_text .= $section; |
— | — | @@ -545,14 +550,10 @@ |
546 | 551 | |
547 | 552 | } // end for |
548 | 553 | |
549 | | - // if it wasn't already included in the form definition, put the |
550 | | - // 'free text' input at the bottom of the form |
| 554 | + // if it wasn't included in the form definition, add the |
| 555 | + // 'free text' input as a hidden field at the bottom |
551 | 556 | if (! $free_text_was_included) { |
552 | | - $form_text .= ' <fieldset><legend>' . wfMsg('sf_editdata_freetextlabel') . "</legend>\n"; |
553 | | - $other_args = array('rows' => 5, 'cols' => 30); |
554 | | - list($text, $new_javascript_text) = $this->textAreaHTML('<free_text>', 'free_text', false, $form_is_disabled, $other_args); |
555 | | - $form_text .= $text; |
556 | | - $form_text .= " </fieldset>\n"; |
| 557 | + $form_text .= $this->hiddenFieldHTML('free_text', '<free_text>'); |
557 | 558 | } |
558 | 559 | // get free text, and add to page data, as well as retroactively |
559 | 560 | // inserting it into the form |
— | — | @@ -803,7 +804,7 @@ |
804 | 805 | } |
805 | 806 | |
806 | 807 | function formTemplateFieldHTML($field_name, $input_name, $cur_value, $is_mandatory, $is_hidden, $is_disabled, $input_type, $field_args, $all_fields, $strict_parsing) { |
807 | | - global $sfgTabIndex; |
| 808 | + global $sfgTabIndex, $sfgFieldNum; |
808 | 809 | |
809 | 810 | // see if this field matches one of the fields defined for this template - |
810 | 811 | // if it is, use all available information about that field; if it's not, |
— | — | @@ -823,10 +824,11 @@ |
824 | 825 | } |
825 | 826 | |
826 | 827 | // if this is not part of a 'multiple' template, incrememt the |
827 | | - // global tab index (used for correct tabbing, and for creating |
828 | | - // unique div IDs.) |
| 828 | + // global tab index (used for correct tabbing) |
829 | 829 | if (! $field_args['part_of_multiple']) |
830 | 830 | $sfgTabIndex++; |
| 831 | + // increment the global field number regardless |
| 832 | + $sfgFieldNum++; |
831 | 833 | |
832 | 834 | // create an SFFormTemplateField object, containing this field as well |
833 | 835 | // as settings from the form definition file |
— | — | @@ -868,17 +870,18 @@ |
869 | 871 | $other_args['is_relation'] = true; |
870 | 872 | $other_args['semantic_field_name'] = $template_field->semantic_field; |
871 | 873 | } |
| 874 | + // merge default values and values from form - put the default values |
| 875 | + // first, so that if there's a conflict they'll be overridden |
872 | 876 | $funcArgs[] = array_merge($default_args, $other_args); |
873 | 877 | list($text, $javascript_text) = call_user_func_array($hook_values[0], $funcArgs); |
874 | 878 | // escape out here if user doesn't have SMW installed |
875 | 879 | } elseif ($smwgContLang == null) { |
876 | | - $size = $template_field->size; |
| 880 | + $size = $template_field->field_args['size']; |
877 | 881 | if ($size == null) $size = 35; |
878 | 882 | $field_args = array('size' => $size); |
879 | 883 | list($text, $javascript_text) = $this->textEntryHTML($cur_value, $form_field->input_name, $form_field->is_mandatory, $form_field->is_disabled, $field_args); |
880 | 884 | } else { // input type not defined in form, and not a relation |
881 | 885 | $field_type = $template_field->field_type; |
882 | | - $size = $template_field->size; |
883 | 886 | if ($field_type != '' && $this->mSemanticTypeHooks[$field_type] != null) { |
884 | 887 | $hook_values = $this->mSemanticTypeHooks[$field_type]; |
885 | 888 | $funcArgs = array(); |
— | — | @@ -886,7 +889,9 @@ |
887 | 890 | $funcArgs[] = $form_field->input_name; |
888 | 891 | $funcArgs[] = $form_field->is_mandatory; |
889 | 892 | $funcArgs[] = $form_field->is_disabled; |
890 | | - $other_args = array_merge($form_field->field_args, $hook_values[1]); |
| 893 | + // merge default values and values from form - put the default values |
| 894 | + // first, so that if there's a conflict they'll be overridden |
| 895 | + $other_args = array_merge($hook_values[1], $form_field->field_args); |
891 | 896 | $other_args['possible_values'] = $template_field->possible_values; |
892 | 897 | if ($template_field->is_relation) { |
893 | 898 | $other_args['is_relation'] = true; |
— | — | @@ -895,59 +900,125 @@ |
896 | 901 | $funcArgs[] = $other_args; |
897 | 902 | list($text, $javascript_text) = call_user_func_array($hook_values[0], $funcArgs); |
898 | 903 | } else { // anything else |
899 | | - if ($field_args['size'] == null) |
900 | | - $field_args['size'] = 35; |
901 | | - list($text, $javascript_text) = $this->textEntryHTML($cur_value, $form_field->input_name, $form_field->is_mandatory, $form_field->is_disabled, $field_args); |
| 904 | + $other_args = $form_field->field_args; |
| 905 | + if ($other_args['size'] == null) |
| 906 | + $other_args['size'] = 35; |
| 907 | + list($text, $javascript_text) = $this->textEntryHTML($cur_value, $form_field->input_name, $form_field->is_mandatory, $form_field->is_disabled, $other_args); |
902 | 908 | } |
903 | 909 | } |
904 | 910 | return array($text, $javascript_text); |
905 | 911 | } |
906 | 912 | |
907 | | - function createAutocompleteValuesString($field_name, $is_relation) { |
| 913 | + /* |
| 914 | + * Get all the pages that belong to a category and all its subcategories, |
| 915 | + * down a certain number of levels - heavily based on SMW's |
| 916 | + * SMWInlineQuery::includeSubcategories() |
| 917 | + */ |
| 918 | + private function getAllPagesForCategory($dbr, $top_category, $num_levels) { |
| 919 | + if (0 == $num_levels) return $top_category; |
908 | 920 | global $sfgMaxAutocompleteValues; |
909 | | - $fname = '$this->createAutocompleteValuesString'; |
| 921 | + |
| 922 | + $fname = "SFFormPrinter::getAllPagesForCategory"; |
| 923 | + $categories = array($top_category); |
| 924 | + $checkcategories = array($top_category); |
| 925 | + $pages = array(); |
| 926 | + for ($level = $num_levels; $level > 0; $level--) { |
| 927 | + $newcategories = array(); |
| 928 | + foreach ($checkcategories as $category) { |
| 929 | + $res = $dbr->select( // make the query |
| 930 | + array('categorylinks', 'page'), |
| 931 | + array('page_title', 'page_namespace'), |
| 932 | + array('cl_from = page_id', |
| 933 | + 'cl_to = '. $dbr->addQuotes($category)), |
| 934 | + $fname); |
| 935 | + if ($res) { |
| 936 | + while ($res && $row = $dbr->fetchRow($res)) { |
| 937 | + if (array_key_exists('page_title', $row)) { |
| 938 | + $page_namespace = $row['page_namespace']; |
| 939 | + if ($page_namespace == NS_CATEGORY) { |
| 940 | + $new_category = $row[ 'page_title' ]; |
| 941 | + if (!in_array($new_category, $categories)) { |
| 942 | + $newcategories[] = $new_category; |
| 943 | + } |
| 944 | + } else { |
| 945 | + $cur_value = str_replace("'", "\'", $row['page_title']); |
| 946 | + $pages[] = str_replace("_", " ", $cur_value); |
| 947 | + // return if we've reached the maximum number of allowed values |
| 948 | + if (count($pages) > $sfgMaxAutocompleteValues) |
| 949 | + return $pages; |
| 950 | + } |
| 951 | + } |
| 952 | + } |
| 953 | + $dbr->freeResult( $res ); |
| 954 | + } |
| 955 | + } |
| 956 | + if (count($newcategories) == 0) { |
| 957 | + return $pages; |
| 958 | + } else { |
| 959 | + $categories = array_merge($categories, $newcategories); |
| 960 | + } |
| 961 | + $checkcategories = array_diff($newcategories, array()); |
| 962 | + } |
| 963 | + return $pages; |
| 964 | + } |
| 965 | + |
| 966 | + function createAutocompleteValuesString($field_name, $autocomplete_field_type) { |
| 967 | + global $sfgMaxAutocompleteValues; |
| 968 | + $fname = 'SFFormPrinter::createAutocompleteValuesString'; |
| 969 | + |
| 970 | + $names_array = array(); |
910 | 971 | $db = wfGetDB( DB_SLAVE ); |
911 | 972 | $sql_options = array(); |
912 | 973 | $sql_options['LIMIT'] = $sfgMaxAutocompleteValues; |
913 | | - // the query depends on whether this field is a relation or a category |
914 | | - if ($is_relation) { |
| 974 | + // the query depends on whether this field is a relation, category or |
| 975 | + // namespace |
| 976 | + if ($autocomplete_field_type == 'relation') { |
915 | 977 | $conditions = "relation_title = '$field_name'"; |
916 | 978 | $sql_options['ORDER BY'] = 'object_title'; |
917 | 979 | $res = $db->select( $db->tableName('smw_relations'), |
918 | 980 | 'DISTINCT object_title', |
919 | 981 | $conditions, $fname, $sql_options); |
920 | | - } else { |
921 | | - $conditions = "cl_from = page_id AND cl_to = '$field_name'"; |
922 | | - $sql_options['ORDER BY'] = 'page_title'; |
923 | | - $res = $db->select( $db->tableNames('categorylinks', 'page'), |
924 | | - 'page_title', |
925 | | - $conditions, $fname, $sql_options); |
926 | | - } |
927 | | - if ($db->numRows( $res ) > 0) { |
928 | | - $names_array = array(); |
929 | 982 | while ($row = $db->fetchRow($res)) { |
930 | 983 | $cur_value = str_replace("'", "\'", $row[0]); |
931 | 984 | $names_array[] = str_replace('_', ' ', $cur_value); |
932 | 985 | } |
933 | | - $array_str = "['" . implode("', '", $names_array) . "']"; |
934 | | - } else { |
935 | | - // return an empty array |
936 | | - $array_str = "[]"; |
| 986 | + $db->freeResult($res); |
| 987 | + } elseif ($autocomplete_field_type == 'category') { |
| 988 | + $names_array = $this->getAllPagesForCategory($db, $field_name, 10); |
| 989 | + } else { // i.e., $autocomplete_field_type == 'namespace' |
| 990 | + // cycle through all the namespace names for this language, and if |
| 991 | + // one matches the namespace specified in the form, add the names |
| 992 | + // of all the pages in that namespace to $names_array |
| 993 | + global $wgContLang; |
| 994 | + $namespaces = $wgContLang->getNamespaces(); |
| 995 | + foreach ($namespaces as $ns_code => $ns_name) { |
| 996 | + if ($ns_name == $field_name) { |
| 997 | + $conditions = "page_namespace = $ns_code"; |
| 998 | + $sql_options['ORDER BY'] = 'page_title'; |
| 999 | + $res = $db->select( $db->tableNames('page'), |
| 1000 | + 'page_title', |
| 1001 | + $conditions, $fname, $sql_options); |
| 1002 | + while ($row = $db->fetchRow($res)) { |
| 1003 | + $cur_value = str_replace("'", "\'", $row[0]); |
| 1004 | + $names_array[] = str_replace('_', ' ', $cur_value); |
| 1005 | + } |
| 1006 | + $db->freeResult($res); |
| 1007 | + } |
| 1008 | + } |
937 | 1009 | } |
938 | | - $db->freeResult($res); |
| 1010 | + $array_str = "['" . implode("', '", $names_array) . "']"; |
939 | 1011 | return $array_str; |
940 | 1012 | } |
941 | 1013 | |
942 | 1014 | function textEntryHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) { |
943 | 1015 | // if it's an autocomplete, call the with-autocomplete function insted |
944 | | - if ($other_args['autocomplete on'] != null) { |
| 1016 | + if ($other_args['autocomplete on'] != null || $other_args['autocomplete on namespace'] != null) { |
945 | 1017 | return SFFormPrinter::textEntryWithAutocompleteHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args); |
946 | 1018 | } |
947 | 1019 | |
948 | | - global $sfgTabIndex; |
949 | | - $input_id = "input_$sfgTabIndex"; |
950 | | - $info_id = "info_$sfgTabIndex"; |
951 | | - $className = ($is_mandatory) ? "mandatoryField" : "createboxInput"; |
| 1020 | + global $sfgTabIndex, $sfgFieldNum; |
| 1021 | + $input_id = "input_$sfgFieldNum"; |
| 1022 | + $info_id = "info_$sfgFieldNum"; |
952 | 1023 | $disabled_text = ($is_disabled) ? "disabled" : ""; |
953 | 1024 | $size = $other_args['size']; |
954 | 1025 | |
— | — | @@ -992,21 +1063,24 @@ |
993 | 1064 | if ($other_args['no_autocomplete'] == true) |
994 | 1065 | return SFFormPrinter::textEntryHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args); |
995 | 1066 | |
996 | | - global $sfgTabIndex; |
| 1067 | + global $sfgTabIndex, $sfgFieldNum; |
997 | 1068 | |
998 | 1069 | $className = ($is_mandatory) ? "mandatoryField" : "createboxInput"; |
999 | 1070 | $disabled_text = ($is_disabled) ? "disabled" : ""; |
1000 | 1071 | $size = $other_args['size']; |
1001 | 1072 | if ($other_args['autocomplete on'] != null) { |
1002 | | - $is_relation = false; |
| 1073 | + $autocomplete_field_type = "category"; |
1003 | 1074 | $semantic_field_name = $other_args['autocomplete on']; |
| 1075 | + } elseif ($other_args['autocomplete on namespace'] != null) { |
| 1076 | + $autocomplete_field_type = "namespace"; |
| 1077 | + $semantic_field_name = $other_args['autocomplete on namespace']; |
1004 | 1078 | } else { |
1005 | | - $is_relation = true; |
| 1079 | + $autocomplete_field_type = "relation"; |
1006 | 1080 | $semantic_field_name = $other_args['semantic_field_name']; |
1007 | 1081 | } |
1008 | | - $input_id = "input_" . $sfgTabIndex; |
1009 | | - $info_id = "info_" . $sfgTabIndex; |
1010 | | - $div_name = "div_" . $sfgTabIndex; |
| 1082 | + $input_id = "input_" . $sfgFieldNum; |
| 1083 | + $info_id = "info_" . $sfgFieldNum; |
| 1084 | + $div_name = "div_" . $sfgFieldNum; |
1011 | 1085 | $text =<<<END |
1012 | 1086 | <input tabindex="$sfgTabIndex" id="$input_id" name="$input_name" type="text" |
1013 | 1087 | value="" size="$size" class="$className" $disabled_text/> |
— | — | @@ -1017,10 +1091,10 @@ |
1018 | 1092 | END; |
1019 | 1093 | $autocomplete_values = array(); |
1020 | 1094 | $autocomplete_values['mappings'] = array(); |
1021 | | - $options_str_key = $semantic_field_name . ',' . $is_relation; |
| 1095 | + $options_str_key = $semantic_field_name . ',' . $autocomplete_field_type; |
1022 | 1096 | if (!$autocomplete_values[$options_str_key]) |
1023 | | - $autocomplete_values[$options_str_key] = $this->createAutocompleteValuesString(str_replace(' ', '_', $semantic_field_name), $is_relation); |
1024 | | - $autocomplete_values['mappings'][$sfgTabIndex] = $options_str_key; |
| 1097 | + $autocomplete_values[$options_str_key] = $this->createAutocompleteValuesString(str_replace(' ', '_', $semantic_field_name), $autocomplete_field_type); |
| 1098 | + $autocomplete_values['mappings'][$sfgFieldNum] = $options_str_key; |
1025 | 1099 | foreach ($autocomplete_values as $autocomplete_key => $autocomplete_string) { |
1026 | 1100 | if ($autocomplete_key == "mappings") { |
1027 | 1101 | foreach ($autocomplete_string as $field_number => $field_key) { |
— | — | @@ -1038,11 +1112,11 @@ |
1039 | 1113 | } |
1040 | 1114 | |
1041 | 1115 | function textAreaHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) { |
1042 | | - global $sfgTabIndex; |
| 1116 | + global $sfgTabIndex, $sfgFieldNum; |
1043 | 1117 | |
1044 | 1118 | $className = ($is_mandatory) ? "mandatoryField" : "createboxInput"; |
1045 | | - $input_id = "input_$sfgTabIndex"; |
1046 | | - $info_id = "info_$sfgTabIndex"; |
| 1119 | + $input_id = "input_$sfgFieldNum"; |
| 1120 | + $info_id = "info_$sfgFieldNum"; |
1047 | 1121 | $disabled_text = ($is_disabled) ? "disabled" : ""; |
1048 | 1122 | |
1049 | 1123 | $rows = $other_args['rows']; |
— | — | @@ -1057,11 +1131,11 @@ |
1058 | 1132 | } |
1059 | 1133 | |
1060 | 1134 | function monthDropdownHTML($cur_month, $input_name, $is_disabled) { |
1061 | | - global $sfgTabIndex; |
| 1135 | + global $sfgTabIndex, $sfgFieldNum; |
1062 | 1136 | |
1063 | 1137 | $className = ($is_mandatory) ? "mandatoryField" : "createboxInput"; |
1064 | 1138 | $disabled_text = ($is_disabled) ? "disabled" : ""; |
1065 | | - $text = ' <select tabindex="' . $sfgTabIndex . '" id="input_' . $sfgTabIndex . '_1" name="' . $input_name . "[month]\" $disabled_text>\n"; |
| 1139 | + $text = ' <select tabindex="' . $sfgTabIndex . '" id="input_' . $sfgFieldNum . '_1" name="' . $input_name . "[month]\" $disabled_text>\n"; |
1066 | 1140 | $month_names = array( |
1067 | 1141 | wfMsgForContent('sf_january'), |
1068 | 1142 | wfMsgForContent('sf_february'), |
— | — | @@ -1086,7 +1160,7 @@ |
1087 | 1161 | } |
1088 | 1162 | |
1089 | 1163 | function dateEntryHTML($date, $input_name, $is_mandatory, $is_disabled, $other_args) { |
1090 | | - global $sfgTabIndex; |
| 1164 | + global $sfgTabIndex, $sfgFieldNum; |
1091 | 1165 | |
1092 | 1166 | if ($date) { |
1093 | 1167 | // can show up here either as an array or a string, depending on |
— | — | @@ -1113,9 +1187,9 @@ |
1114 | 1188 | } |
1115 | 1189 | $disabled_text = ($is_disabled) ? "disabled" : ""; |
1116 | 1190 | $text = $this->monthDropdownHTML($month, $input_name, $is_disabled); |
1117 | | - $text .= ' <input tabindex="' . $sfgTabIndex . '" id="input_' . $sfgTabIndex . '_2" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2"/ ' . $disabled_text . '>' . "\n"; |
1118 | | - $text .= ' <input tabindex="' . $sfgTabIndex . '" id="input_' . $sfgTabIndex . '_3" name="' . $input_name . '[year]" type="text" value="' . $year . '" size="4"/ ' . $disabled_text . '>' . "\n"; |
1119 | | - $info_id = "info_$sfgTabIndex"; |
| 1191 | + $text .= ' <input tabindex="' . $sfgTabIndex . '" id="input_' . $sfgFieldNum . '_2" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2"/ ' . $disabled_text . '>' . "\n"; |
| 1192 | + $text .= ' <input tabindex="' . $sfgTabIndex . '" id="input_' . $sfgFieldNum . '_3" name="' . $input_name . '[year]" type="text" value="' . $year . '" size="4"/ ' . $disabled_text . '>' . "\n"; |
| 1193 | + $info_id = "info_$sfgFieldNum"; |
1120 | 1194 | $text .= " <span id=\"$info_id\" class=\"error_message\"></span>"; |
1121 | 1195 | return array($text, null); |
1122 | 1196 | } |
— | — | @@ -1207,10 +1281,10 @@ |
1208 | 1282 | } |
1209 | 1283 | |
1210 | 1284 | function checkboxHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) { |
1211 | | - global $sfgTabIndex; |
| 1285 | + global $sfgTabIndex, $sfgFieldNum; |
1212 | 1286 | |
1213 | 1287 | $className = ($is_mandatory) ? "mandatoryField" : "createboxInput"; |
1214 | | - $info_id = "info_$sfgTabIndex"; |
| 1288 | + $info_id = "info_$sfgFieldNum"; |
1215 | 1289 | $disabled_text = ($is_disabled) ? "disabled" : ""; |
1216 | 1290 | |
1217 | 1291 | // can show up here either as an array or a string, depending on |
— | — | @@ -1228,7 +1302,7 @@ |
1229 | 1303 | } |
1230 | 1304 | $text =<<<END |
1231 | 1305 | <input name="{$input_name}[is_checkbox]" type="hidden" value="true" /> |
1232 | | - <input id="input_$sfgTabIndex" name="{$input_name}[value]" type="checkbox" class="$className" tabindex="$sfgTabIndex" $checked_str $disabled_text/> |
| 1306 | + <input id="input_$sfgFieldNum" name="{$input_name}[value]" type="checkbox" class="$className" tabindex="$sfgTabIndex" $checked_str $disabled_text/> |
1233 | 1307 | <span id="$info_id" class="error_message"></span> |
1234 | 1308 | |
1235 | 1309 | END; |
— | — | @@ -1291,19 +1365,11 @@ |
1292 | 1366 | |
1293 | 1367 | // Much of this function is based on MediaWiki's EditPage::showEditForm() |
1294 | 1368 | function formBottom($target_title = null, $is_disabled) { |
1295 | | - global $wgVersion, $wgUser, $wgRightsText, $wgParser; |
| 1369 | + global $wgVersion, $wgUser; |
1296 | 1370 | global $sfgTabIndex; |
1297 | 1371 | $sk = $wgUser->getSkin(); |
1298 | 1372 | |
1299 | | - $copywarn = "<div id=\"editpage-copywarn\">\n" . |
1300 | | - wfMsg( $wgRightsText ? 'copyrightwarning' : 'copyrightwarning2', |
1301 | | - '[[' . wfMsgForContent( 'copyrightpage' ) . ']]', |
1302 | | - null, |
1303 | | - $wgRightsText ) . "\n</div>"; |
1304 | 1373 | $title = new Title(); |
1305 | | - $options = new ParserOptions(); |
1306 | | - $copywarn_output = $wgParser->parse($copywarn, $title, $options); |
1307 | | - $copywarn_text = $copywarn_output->getText(); |
1308 | 1374 | $summary_text = wfMsg('summary'); |
1309 | 1375 | if ($target_title == null) |
1310 | 1376 | $cancel = ''; |
— | — | @@ -1328,7 +1394,7 @@ |
1329 | 1395 | $sfgTabIndex++; |
1330 | 1396 | $disabled_text = ($is_disabled) ? "disabled" : ""; |
1331 | 1397 | $text =<<<END |
1332 | | - $copywarn_text |
| 1398 | + <br /><br /> |
1333 | 1399 | <span id='wpSummaryLabel'><label for='wpSummary'>{$summary_text}:</label></span> |
1334 | 1400 | <div class='editOptions'> |
1335 | 1401 | <input tabindex="$sfgTabIndex" type='text' value="" name='wpSummary' id='wpSummary' maxlength='200' size='60' $disabled_text/><br /> |