Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc |
— | — | @@ -6,6 +6,7 @@ |
7 | 7 | * @author Nils Oppermann |
8 | 8 | * @author Jeffrey Stuckman |
9 | 9 | * @author Harold Solbrig |
| 10 | + * @author Daniel Hansch |
10 | 11 | */ |
11 | 12 | |
12 | 13 | class SFFormPrinter { |
— | — | @@ -116,7 +117,7 @@ |
117 | 118 | } |
118 | 119 | |
119 | 120 | |
120 | | - function formHTML($form_def, $form_submitted, $source_is_page, $existing_page_content = null, $page_title = null, $page_name_formula = null) { |
| 121 | + function formHTML($form_def, $form_submitted, $source_is_page, $existing_page_content = null, $page_title = null, $page_name_formula = null, $is_query = false) { |
121 | 122 | global $wgRequest, $wgUser, $wgParser; |
122 | 123 | global $sfgTabIndex; // used to represent the current tab index in the form |
123 | 124 | global $sfgFieldNum; // used for setting various HTML IDs |
— | — | @@ -135,6 +136,8 @@ |
136 | 137 | // the parsing, so we have to assume that it will become a possibility |
137 | 138 | $form_is_partial = false; |
138 | 139 | $new_text = ""; |
| 140 | + // flag for placing "<includeonly>" and "<noinclude>" tags in form output |
| 141 | + $includeonly_free_text; |
139 | 142 | |
140 | 143 | // if we have existing content and we're not in an active replacement |
141 | 144 | // situation, preserve the original content. We do this because we want |
— | — | @@ -167,7 +170,7 @@ |
168 | 171 | // show previous set of deletions for this page, if it's been deleted before |
169 | 172 | if (! $form_submitted && ! $this->mPageTitle->exists()) |
170 | 173 | $this->showDeletionLog($wgOut); |
171 | | - if ($wgUser->isAllowed('edit') && $this->mPageTitle->userCan( 'edit', true ) ) { |
| 174 | + if ($wgUser->isAllowed('edit') && $this->mPageTitle->userCan('edit')) { |
172 | 175 | $form_is_disabled = false; |
173 | 176 | $form_text = ""; |
174 | 177 | // show "Your IP address will be recorded" warning if user is |
— | — | @@ -632,7 +635,7 @@ |
633 | 636 | $data_text .= "<free_text>\n"; |
634 | 637 | } |
635 | 638 | |
636 | | - if ($template_name == '') { |
| 639 | + if ($template_name == '' || $field_name == '<freetext>') { |
637 | 640 | $section = substr_replace($section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc); |
638 | 641 | } else { |
639 | 642 | if (is_array($cur_value)) { |
— | — | @@ -896,6 +899,12 @@ |
897 | 900 | // standard input processing |
898 | 901 | // ===================================================== |
899 | 902 | } elseif ($tag_title == 'standard input') { |
| 903 | + // if it's a query, ignore all standard inputs |
| 904 | + if ($is_query) { |
| 905 | + $new_text = ""; |
| 906 | + $section = substr_replace($section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc); |
| 907 | + continue; |
| 908 | + } |
900 | 909 | // set a flag so that the standard 'form bottom' won't get displayed |
901 | 910 | $this->standardInputsIncluded = true; |
902 | 911 | // handle all the possible values |
— | — | @@ -963,8 +972,11 @@ |
964 | 973 | $form_is_partial = true; |
965 | 974 | // replacement pages may have minimal matches... |
966 | 975 | $source_page_matches_this_form = true; |
967 | | - } |
| 976 | + } |
| 977 | + elseif($tag == 'includeonly free text') { |
| 978 | + $includeonly_free_text = true; |
968 | 979 | } |
| 980 | + } |
969 | 981 | $section = substr_replace($section, '', $brackets_loc, $brackets_end_loc + 3 - $brackets_loc); |
970 | 982 | // ===================================================== |
971 | 983 | // default outer level processing |
— | — | @@ -1091,6 +1103,17 @@ |
1092 | 1104 | } else { |
1093 | 1105 | $free_text = null; |
1094 | 1106 | } |
| 1107 | + // modify free text and data text to insert <noinclude> and <includeonly> |
| 1108 | + // tags, if necessary |
| 1109 | + if ($includeonly_free_text) { |
| 1110 | + $free_text = str_replace("<noinclude>",'', $free_text); |
| 1111 | + $free_text = str_replace("</noinclude>",'', $free_text); |
| 1112 | + $free_text = str_replace("<includeonly>",'', $free_text); |
| 1113 | + $free_text = str_replace("</includeonly>",'', $free_text); |
| 1114 | + $free_text = trim($free_text); |
| 1115 | + $data_text = str_replace('<free_text>','</noinclude><includeonly><free_text></includeonly><noinclude>', $data_text); |
| 1116 | + $data_text = "<noinclude>".$data_text."</noinclude>"; |
| 1117 | + } |
1095 | 1118 | // if the FCKeditor extension is installed, use that for the free text input |
1096 | 1119 | global $wgFCKEditorDir; |
1097 | 1120 | if ($wgFCKEditorDir) { |
— | — | @@ -1192,7 +1215,9 @@ |
1193 | 1216 | $form_text = str_replace('{{{choosers}}}', $chooser_text, $form_text); |
1194 | 1217 | |
1195 | 1218 | // add form bottom, if no custom "standard inputs" have been defined |
1196 | | - if (! $this->standardInputsIncluded) |
| 1219 | + if ($is_query) |
| 1220 | + $form_text .= SFFormUtils::queryFormBottom($form_is_disabled); |
| 1221 | + elseif (! $this->standardInputsIncluded) |
1197 | 1222 | $form_text .= SFFormUtils::formBottom($form_is_disabled); |
1198 | 1223 | $starttime = wfTimestampNow(); |
1199 | 1224 | $page_article = new Article($this->mPageTitle); |