Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php |
— | — | @@ -158,7 +158,6 @@ |
159 | 159 | global $wgRequest, $wgUser, $wgParser; |
160 | 160 | global $sfgTabIndex; // used to represent the current tab index in the form |
161 | 161 | global $sfgFieldNum; // used for setting various HTML IDs |
162 | | - global $sfgAdderButtons; |
163 | 162 | |
164 | 163 | // initialize some variables |
165 | 164 | $sfgTabIndex = 1; |
— | — | @@ -355,23 +354,29 @@ |
356 | 355 | } |
357 | 356 | } |
358 | 357 | // If this is the first instance, add the label into the form, if |
359 | | - // there is one. |
360 | | - if ( ( $old_template_name != $template_name ) && isset( $template_label ) ) { |
361 | | - $form_text .= "<fieldset>\n"; |
362 | | - $form_text .= "<legend>$template_label</legend>\n"; |
| 358 | + // there is one, and add the appropriate wrapper div, if this is |
| 359 | + // a multiple-instance template. |
| 360 | + if ( $old_template_name != $template_name ) { |
| 361 | + if ( isset( $template_label ) ) { |
| 362 | + $form_text .= "<fieldset>\n"; |
| 363 | + $form_text .= "<legend>$template_label</legend>\n"; |
| 364 | + } |
| 365 | + if ($allow_multiple) { |
| 366 | + $form_text .= "\t" . '<div class="multipleTemplateWrapper">' . "\n"; |
| 367 | + } |
363 | 368 | } |
364 | 369 | $template_text .= "{{" . $tif->template_name; |
365 | 370 | $all_fields = $tif->getAllFields(); |
366 | 371 | // remove template tag |
367 | 372 | $section = substr_replace( $section, '', $brackets_loc, $brackets_end_loc + 3 - $brackets_loc ); |
368 | 373 | $template_instance_query_values = $wgRequest->getArray( $query_template_name ); |
369 | | - // if we are editing a page, and this template can be found more than |
| 374 | + // If we are editing a page, and this template can be found more than |
370 | 375 | // once in that page, and multiple values are allowed, repeat this |
371 | | - // section |
| 376 | + // section. |
372 | 377 | $existing_template_text = null; |
373 | 378 | if ( $source_is_page || $form_is_partial ) { |
374 | | - // replace underlines with spaces in template name, to allow for |
375 | | - // searching on either |
| 379 | + // Replace underlines with spaces in template name, to allow for |
| 380 | + // searching on either. |
376 | 381 | $search_template_str = str_replace( '_', ' ', $tif->template_name ); |
377 | 382 | $preg_match_template_str = str_replace( |
378 | 383 | array( '/', '(', ')' ), |
— | — | @@ -1126,32 +1131,30 @@ |
1127 | 1132 | // with from any inputs added by the Javascript |
1128 | 1133 | $section = str_replace( '[num]', "[{$instance_num}a]", $section ); |
1129 | 1134 | $remove_text = wfMsg( 'sf_formedit_remove' ); |
| 1135 | + // The "multipleTemplate" class is there for backwards-compatibility |
| 1136 | + // with any custom CSS on people's wikis. |
1130 | 1137 | $form_text .= <<<END |
1131 | | - <div class="multipleTemplate"> |
1132 | | - $section |
1133 | | - <input type="button" value="$remove_text" tabindex="$sfgTabIndex" class="remover" /> |
1134 | | - </div> |
| 1138 | + <div class="multipleTemplateInstance multipleTemplate"> |
| 1139 | + $section |
| 1140 | + <input type="button" value="$remove_text" tabindex="$sfgTabIndex" class="remover" /> |
| 1141 | + </div> |
1135 | 1142 | |
1136 | 1143 | END; |
1137 | 1144 | // this will cause the section to be re-parsed on the next go |
1138 | 1145 | $section_num--; |
1139 | 1146 | } else { |
1140 | | - // this is the last instance of this template - stick an 'add' |
1141 | | - // button in the form |
| 1147 | + // This is the last instance of this template - print all the |
| 1148 | + // sections necessary for adding additional instances. |
1142 | 1149 | $form_text .= <<<END |
1143 | | - <div id="starter_$query_template_name" class="multipleTemplateStarter" style="display: none;"> |
1144 | | - $section |
| 1150 | + <div class="multipleTemplateStarter" style="display: none;"> |
| 1151 | + $section |
| 1152 | + </div> |
| 1153 | + <div class="multipleTemplatePlaceholder"></div> |
| 1154 | + <p style="margin-left:10px;" /> |
| 1155 | + <p><input type="button" value="$add_button_text" tabindex="$sfgTabIndex" class="multipleTemplateAdder" /></p> |
1145 | 1156 | </div> |
1146 | | - <div id="main_$query_template_name"></div> |
1147 | 1157 | |
1148 | 1158 | END; |
1149 | | - $adderID = "adder_$sfgFieldNum"; |
1150 | | - $form_text .= <<<END |
1151 | | - <p style="margin-left:10px;"> |
1152 | | - <p><input type="button" id="$adderID" value="$add_button_text" tabindex="$sfgTabIndex" class="addAnother" /></p> |
1153 | | - |
1154 | | -END; |
1155 | | - $sfgAdderButtons[] = "$adderID,$query_template_name,$sfgFieldNum"; |
1156 | 1159 | } |
1157 | 1160 | } else { |
1158 | 1161 | $form_text .= $section; |