Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php |
— | — | @@ -281,8 +281,6 @@ |
282 | 282 | $instance_num = 0; |
283 | 283 | $all_instances_printed = false; |
284 | 284 | $strict_parsing = false; |
285 | | - // initialize list of choosers (dropdowns with available templates) |
286 | | - $choosers = array(); |
287 | 285 | for ( $section_num = 0; $section_num < count( $form_def_sections ); $section_num++ ) { |
288 | 286 | $tif = new SFTemplateInForm(); |
289 | 287 | $start_position = 0; |
— | — | @@ -307,8 +305,6 @@ |
308 | 306 | // also replace periods with underlines, since that's what |
309 | 307 | // POST does to strings anyway |
310 | 308 | $query_template_name = str_replace( '.', '_', $query_template_name ); |
311 | | - $chooser_name = false; |
312 | | - $chooser_caption = false; |
313 | 309 | // cycle through the other components |
314 | 310 | for ( $i = 2; $i < count( $tag_components ); $i++ ) { |
315 | 311 | $component = $tag_components[$i]; |
— | — | @@ -318,22 +314,12 @@ |
319 | 315 | if ( count( $sub_components ) == 2 ) { |
320 | 316 | if ( $sub_components[0] == 'label' ) { |
321 | 317 | $template_label = $sub_components[1]; |
322 | | - } elseif ( $sub_components[0] == 'chooser' ) { |
323 | | - $allow_multiple = true; |
324 | | - $chooser_name = $sub_components[1]; |
325 | | - } elseif ( $sub_components[0] == 'chooser caption' ) { |
326 | | - $chooser_caption = $sub_components[1]; |
327 | 318 | } |
328 | 319 | } |
329 | 320 | } |
330 | 321 | // if this is the first instance, add the label in the form |
331 | 322 | if ( ( $old_template_name != $template_name ) && isset( $template_label ) ) { |
332 | | - // add a placeholder to the form text so the fieldset can be |
333 | | - // hidden if chooser support demands it |
334 | | - if ( $chooser_name !== false ) |
335 | | - $form_text .= "<fieldset [[placeholder]] haschooser=true>\n"; |
336 | | - else |
337 | | - $form_text .= "<fieldset>\n"; |
| 323 | + $form_text .= "<fieldset>\n"; |
338 | 324 | $form_text .= "<legend>$template_label</legend>\n"; |
339 | 325 | } |
340 | 326 | $template_text .= "{{" . $tif->template_name; |
— | — | @@ -496,10 +482,6 @@ |
497 | 483 | $allow_multiple = false; |
498 | 484 | $all_instances_printed = false; |
499 | 485 | $instance_num = 0; |
500 | | - // if the hiding placeholder is still around, this fieldset should |
501 | | - // be hidden because it is empty and choosers are being used. So, |
502 | | - // hide it. |
503 | | - $form_text = str_replace( "[[placeholder]]", "style='display:none'", $form_text ); |
504 | 486 | // ===================================================== |
505 | 487 | // field processing |
506 | 488 | // ===================================================== |
— | — | @@ -1134,10 +1116,7 @@ |
1135 | 1117 | END; |
1136 | 1118 | // this will cause the section to be re-parsed on the next go |
1137 | 1119 | $section_num--; |
1138 | | - // because there is an instance, the fieldset will never be hidden, |
1139 | | - // even if choosers are being used. So, do not hide the fieldset. |
1140 | | - $form_text = str_replace( "[[placeholder]]", "", $form_text ); |
1141 | | - } else { |
| 1120 | + } else { |
1142 | 1121 | // this is the last instance of this template - stick an 'add' |
1143 | 1122 | // button in the form |
1144 | 1123 | $form_text .= <<<END |
— | — | @@ -1153,10 +1132,6 @@ |
1154 | 1133 | <p><input type="button" onclick="addInstance('starter_$query_template_name', 'main_$query_template_name', '$sfgFieldNum');" value="$add_another" tabindex="$sfgTabIndex" class="addAnother" /></p> |
1155 | 1134 | |
1156 | 1135 | END; |
1157 | | - // if a chooser is being used for this template, add the template |
1158 | | - // to the chooser data array |
1159 | | - if ( $chooser_name !== false ) |
1160 | | - $choosers[$chooser_name][] = array( $query_template_name, $sfgFieldNum, $chooser_caption ); |
1161 | 1136 | } |
1162 | 1137 | } else { |
1163 | 1138 | $form_text .= $section; |
— | — | @@ -1228,84 +1203,6 @@ |
1229 | 1204 | $form_text = ' <div class="warningMessage">' . wfMsg( 'sf_formedit_formwarning', $this->mPageTitle->getFullURL() ) . "</div>\n" . $form_text; |
1230 | 1205 | } |
1231 | 1206 | |
1232 | | - // Substitute the choosers in here too. |
1233 | | - $chooser_count = 0; |
1234 | | - $chooser_text = ""; |
1235 | | - $using_choosers = "false"; |
1236 | | - foreach ( $choosers as $choosername => $chooser ) { |
1237 | | - if ( count( $chooser ) != 0 ) { |
1238 | | - $chooser_count++; |
1239 | | - if ( $chooser_count == 1 ) { |
1240 | | - // emit the initial javascript code |
1241 | | - $using_choosers = "true"; |
1242 | | - $chooser_text .= <<<END |
1243 | | -<script type="text/javascript">/* <![CDATA[ */ |
1244 | | - |
1245 | | -function updatechooserbutton(f,n) |
1246 | | -{ |
1247 | | - document.getElementById(n).disabled = (f.options[f.selectedIndex].value=="invalid"); |
1248 | | -} |
1249 | | - |
1250 | | -function addInstanceFromChooser(chooserid) |
1251 | | -{ |
1252 | | - var chooser = document.getElementById(chooserid); |
1253 | | - var optionstring = chooser.options[chooser.selectedIndex].value; |
1254 | | - var pos = optionstring.indexOf(","); |
1255 | | - var tabindex = optionstring.substr(0,pos); |
1256 | | - var chooservalue = optionstring.substr(pos+1); |
1257 | | - addInstance('starter_' + chooservalue, 'main_' + chooservalue, parseInt(tabindex)); |
1258 | | -} |
1259 | | - |
1260 | | -//The fieldset containing the given element was just updated. If the fieldset is associated with a chooser, |
1261 | | -//ensure that the fieldset is hidden if and only if there are no template instances inside. |
1262 | | -function hideOrShowFieldset(element) |
1263 | | -{ |
1264 | | - //Find fieldset |
1265 | | - while (element.tagName.toLowerCase() != "fieldset") |
1266 | | - element = element.parentNode; |
1267 | | - //Bail out if fieldset is not part of chooser |
1268 | | - if (!element.getAttribute("haschooser")) |
1269 | | - return; |
1270 | | - //Now look for "input" or "select" tags that don't look like they're part of the starter template |
1271 | | - var inputs = element.getElementsByTagName("input"); |
1272 | | - var x; |
1273 | | - var show = false; |
1274 | | - for (x=0;x<inputs.length;x++) |
1275 | | - { |
1276 | | - if (inputs[x].type=="text" && inputs[x].name.indexOf("[num]") == -1) |
1277 | | - show = true; |
1278 | | - } |
1279 | | - var selects = element.getElementsByTagName("select"); |
1280 | | - for (x=0;x<selects.length;x++) |
1281 | | - { |
1282 | | - if (selects[x].name.indexOf("[num]") == -1) |
1283 | | - show = true; |
1284 | | - } |
1285 | | - //Now show or hide fieldset |
1286 | | - element.style.display = (show?"block":"none"); |
1287 | | -} |
1288 | | -/* ]]> */ </script> |
1289 | | - |
1290 | | -END; |
1291 | | - } |
1292 | | - |
1293 | | - $chooser_text .= "<p>$choosername:<select id='chooserselect$chooser_count' size='1' onchange='updatechooserbutton(this,\"chooserbutton$chooser_count\")'>\n"; |
1294 | | - $chooser_text .= "<option value='invalid'>" . wfMsg( 'sf_createform_choosefield' ) . "</option>\n"; |
1295 | | - foreach ( $chooser as $chooser_item ) { |
1296 | | - $chooser_value = str_replace( '"', '\\"', $chooser_item[0] ); |
1297 | | - $tabindex = $chooser_item[1]; |
1298 | | - $chooser_caption = $chooser_item[2]; |
1299 | | - if ( $chooser_caption === false ) |
1300 | | - $chooser_caption = str_replace( '_', ' ', $chooser_value ); |
1301 | | - $chooser_text .= "<option value=\"$tabindex ,$chooser_value\">$chooser_caption</option>\n"; |
1302 | | - } |
1303 | | - $chooser_text .= "</select>\n"; |
1304 | | - } |
1305 | | - $chooser_text .= "<input type='button' onclick=\"addInstanceFromChooser('chooserselect$chooser_count');\" value='" . wfMsg( 'sf_formedit_addanother' ) . "' disabled='true' id='chooserbutton$chooser_count'></p>"; |
1306 | | - } |
1307 | | - |
1308 | | - $form_text = str_replace( '{{{choosers}}}', $chooser_text, $form_text ); |
1309 | | - |
1310 | 1207 | // add form bottom, if no custom "standard inputs" have been defined |
1311 | 1208 | if ( !$this->standardInputsIncluded ) { |
1312 | 1209 | if ( $is_query ) |
— | — | @@ -1329,7 +1226,7 @@ |
1330 | 1227 | |
1331 | 1228 | // add Javascript code for form-wide use |
1332 | 1229 | $javascript_text .= SFFormUtils::validationJavascript(); |
1333 | | - $javascript_text .= SFFormUtils::instancesJavascript( $using_choosers ); |
| 1230 | + $javascript_text .= SFFormUtils::instancesJavascript(); |
1334 | 1231 | $javascript_text .= SFFormUtils::autocompletionJavascript(); |
1335 | 1232 | if ( $free_text_was_included && $showFCKEditor > 0 ) { |
1336 | 1233 | $javascript_text .= SFFormUtils::mainFCKJavascript( $showFCKEditor ); |