Index: trunk/extensions/SemanticForms/specials/SF_CreateForm.php |
— | — | @@ -47,29 +47,30 @@ |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | | -function doSpecialCreateForm() { |
52 | | - global $wgOut, $wgRequest, $wgUser, $sfgScriptPath; |
53 | | - $db = wfGetDB( DB_SLAVE ); |
| 51 | + function doSpecialCreateForm() { |
| 52 | + global $wgOut, $wgRequest, $wgUser, $sfgScriptPath; |
| 53 | + $db = wfGetDB( DB_SLAVE ); |
54 | 54 | |
55 | | - SFUtils::loadMessages(); |
| 55 | + SFUtils::loadMessages(); |
56 | 56 | |
57 | | - // Create Javascript to populate fields to let the user input |
58 | | - // parameters for the field, based on the input type selected in the |
59 | | - // dropdown. |
60 | | - $skin = $wgUser->getSkin(); |
61 | | - $url = $skin->makeSpecialUrl( 'CreateForm', "showinputtypeoptions=' + this.val() + '&formfield=' + this.attr('formfieldid') + '" ); |
62 | | - foreach ( $wgRequest->getValues() as $param => $value ) { |
63 | | - $url .= '¶ms[' . Xml::escapeJsString( $param ) . ']=' . Xml::escapeJsString( $value ); |
64 | | - } |
| 57 | + // Create Javascript to populate fields to let the user input |
| 58 | + // parameters for the field, based on the input type selected |
| 59 | + // in the dropdown. |
| 60 | + $skin = $wgUser->getSkin(); |
| 61 | + $url = $skin->makeSpecialUrl( 'CreateForm', "showinputtypeoptions=' + this.val() + '&formfield=' + this.attr('formfieldid') + '" ); |
| 62 | + foreach ( $wgRequest->getValues() as $param => $value ) { |
| 63 | + $url .= '¶ms[' . Xml::escapeJsString( $param ) . ']=' . Xml::escapeJsString( $value ); |
| 64 | + } |
65 | 65 | |
66 | | - // Only add 'collapsible' ability if the ResourceLoader exists, i.e. |
67 | | - // for MW 1.17 - adding backwards compatibility doesn't seem worth |
68 | | - // it for this relatively minor piece of functionality. |
69 | | - if ( method_exists( $wgOut, 'addModules' ) ) { |
70 | | - $wgOut->addModules( 'ext.semanticforms.collapsible' ); |
71 | | - } |
| 66 | + // Only add 'collapsible' ability if the ResourceLoader exists, |
| 67 | + // i.e. for MW 1.17 - adding backwards compatibility doesn't |
| 68 | + // seem worth it for this relatively minor piece of |
| 69 | + // functionality. |
| 70 | + if ( method_exists( $wgOut, 'addModules' ) ) { |
| 71 | + $wgOut->addModules( 'ext.semanticforms.collapsible' ); |
| 72 | + } |
72 | 73 | |
73 | | - $wgOut->addScript("<script> |
| 74 | + $wgOut->addScript("<script> |
74 | 75 | jQuery.fn.displayInputParams = function() { |
75 | 76 | inputParamsDiv = this.closest('.formField').find('.otherInputParams'); |
76 | 77 | jQuery.ajax({ |
— | — | @@ -88,200 +89,203 @@ |
89 | 90 | </script>"); |
90 | 91 | |
91 | 92 | |
92 | | - // Get the names of all templates on this site. |
93 | | - $all_templates = array(); |
94 | | - $res = $db->select( |
95 | | - 'page', |
96 | | - 'page_title', |
97 | | - array( 'page_namespace' => NS_TEMPLATE, 'page_is_redirect' => 0 ), |
98 | | - array( 'ORDER BY' => 'page_title' ) |
99 | | - ); |
| 93 | + // Get the names of all templates on this site. |
| 94 | + $all_templates = array(); |
| 95 | + $res = $db->select( |
| 96 | + 'page', |
| 97 | + 'page_title', |
| 98 | + array( 'page_namespace' => NS_TEMPLATE, 'page_is_redirect' => 0 ), |
| 99 | + array( 'ORDER BY' => 'page_title' ) |
| 100 | + ); |
100 | 101 | |
101 | | - if ( $db->numRows( $res ) > 0 ) { |
102 | | - while ( $row = $db->fetchRow( $res ) ) { |
103 | | - $template_name = str_replace( '_', ' ', $row[0] ); |
104 | | - $all_templates[] = $template_name; |
| 102 | + if ( $db->numRows( $res ) > 0 ) { |
| 103 | + while ( $row = $db->fetchRow( $res ) ) { |
| 104 | + $template_name = str_replace( '_', ' ', $row[0] ); |
| 105 | + $all_templates[] = $template_name; |
| 106 | + } |
105 | 107 | } |
106 | | - } |
107 | 108 | |
108 | | - $form_templates = array(); |
109 | | - $i = 1; |
110 | | - $deleted_template_loc = null; |
| 109 | + $form_templates = array(); |
| 110 | + $i = 1; |
| 111 | + $deleted_template_loc = null; |
111 | 112 | |
112 | | - # handle inputs |
113 | | - $form_name = $wgRequest->getVal( 'form_name' ); |
114 | | - foreach ( $wgRequest->getValues() as $var => $val ) { |
115 | | - # ignore variables that are not of the right form |
116 | | - if ( strpos( $var, "_" ) != false ) { |
117 | | - # get the template declarations and work from there |
118 | | - list ( $action, $id ) = explode( "_", $var, 2 ); |
119 | | - if ( $action == "template" ) { |
120 | | - # if the button was pressed to remove this |
121 | | - # template, just don't add it to the array |
122 | | - if ( $wgRequest->getVal( "del_$id" ) != null ) { |
123 | | - $deleted_template_loc = $id; |
124 | | - } else { |
125 | | - $form_template = SFTemplateInForm::create( $val, |
126 | | - $wgRequest->getVal( "label_$id" ), |
127 | | - $wgRequest->getVal( "allow_multiple_$id" ) ); |
128 | | - $form_templates[] = $form_template; |
| 113 | + # handle inputs |
| 114 | + $form_name = $wgRequest->getVal( 'form_name' ); |
| 115 | + foreach ( $wgRequest->getValues() as $var => $val ) { |
| 116 | + # ignore variables that are not of the right form |
| 117 | + if ( strpos( $var, "_" ) != false ) { |
| 118 | + # get the template declarations and work from there |
| 119 | + list ( $action, $id ) = explode( "_", $var, 2 ); |
| 120 | + if ( $action == "template" ) { |
| 121 | + // If the button was pressed to remove |
| 122 | + // this template, just don't add it to |
| 123 | + // the array. |
| 124 | + if ( $wgRequest->getVal( "del_$id" ) != null ) { |
| 125 | + $deleted_template_loc = $id; |
| 126 | + } else { |
| 127 | + $form_template = SFTemplateInForm::create( $val, |
| 128 | + $wgRequest->getVal( "label_$id" ), |
| 129 | + $wgRequest->getVal( "allow_multiple_$id" ) ); |
| 130 | + $form_templates[] = $form_template; |
| 131 | + } |
129 | 132 | } |
130 | 133 | } |
131 | 134 | } |
132 | | - } |
133 | | - if ( $wgRequest->getVal( 'add_field' ) != null ) { |
134 | | - $form_template = SFTemplateInForm::create( $wgRequest->getVal( 'new_template' ), "", false ); |
135 | | - $new_template_loc = $wgRequest->getVal( 'before_template' ); |
136 | | - if ( $new_template_loc === null ) { $new_template_loc = 0; } |
137 | | - # hack - array_splice() doesn't work for objects, so we have to |
138 | | - # first insert a stub element into the array, then replace that |
139 | | - # with the actual object |
140 | | - array_splice( $form_templates, $new_template_loc, 0, "stub" ); |
141 | | - $form_templates[$new_template_loc] = $form_template; |
142 | | - } else { |
143 | | - $new_template_loc = null; |
144 | | - } |
| 135 | + if ( $wgRequest->getVal( 'add_field' ) != null ) { |
| 136 | + $form_template = SFTemplateInForm::create( $wgRequest->getVal( 'new_template' ), "", false ); |
| 137 | + $new_template_loc = $wgRequest->getVal( 'before_template' ); |
| 138 | + if ( $new_template_loc === null ) { $new_template_loc = 0; } |
| 139 | + // @HACK - array_splice() doesn't work for objects, so |
| 140 | + // we have to first insert a stub element into the |
| 141 | + // array, then replace that with the actual object. |
| 142 | + array_splice( $form_templates, $new_template_loc, 0, "stub" ); |
| 143 | + $form_templates[$new_template_loc] = $form_template; |
| 144 | + } else { |
| 145 | + $new_template_loc = null; |
| 146 | + } |
145 | 147 | |
146 | | - // Now cycle through the templates and fields, modifying each one |
147 | | - // per the query variables. |
148 | | - foreach ( $form_templates as $i => $ft ) { |
149 | | - foreach ( $ft->fields as $j => $field ) { |
150 | | - // handle the change in indexing if a new template was |
151 | | - // inserted before the end, or one was deleted |
152 | | - $old_i = $i; |
153 | | - if ( $new_template_loc != null ) { |
154 | | - if ( $i > $new_template_loc ) { |
155 | | - $old_i = $i - 1; |
156 | | - } elseif ( $i == $new_template_loc ) { |
157 | | - // it's the new template; it shouldn't |
158 | | - // get any query-string data |
159 | | - $old_i = - 1; |
| 148 | + // Now cycle through the templates and fields, modifying each |
| 149 | + // one per the query variables. |
| 150 | + foreach ( $form_templates as $i => $ft ) { |
| 151 | + foreach ( $ft->fields as $j => $field ) { |
| 152 | + // handle the change in indexing if a new template was |
| 153 | + // inserted before the end, or one was deleted |
| 154 | + $old_i = $i; |
| 155 | + if ( $new_template_loc != null ) { |
| 156 | + if ( $i > $new_template_loc ) { |
| 157 | + $old_i = $i - 1; |
| 158 | + } elseif ( $i == $new_template_loc ) { |
| 159 | + // it's the new template; it shouldn't |
| 160 | + // get any query-string data |
| 161 | + $old_i = - 1; |
| 162 | + } |
| 163 | + } elseif ( $deleted_template_loc != null ) { |
| 164 | + if ( $i >= $deleted_template_loc ) { |
| 165 | + $old_i = $i + 1; |
| 166 | + } |
160 | 167 | } |
161 | | - } elseif ( $deleted_template_loc != null ) { |
162 | | - if ( $i >= $deleted_template_loc ) { |
163 | | - $old_i = $i + 1; |
164 | | - } |
165 | | - } |
166 | | - foreach ( $wgRequest->getValues() as $key => $value ) { |
167 | | - if ( ( $pos = strpos( $key, '_' . $old_i . '_' . $j ) ) != false ) { |
168 | | - $paramName = substr( $key, 0, $pos ); |
169 | | - // Spaces got replaced by underlines |
170 | | - // in the query. |
171 | | - $paramName = str_replace( '_', ' ', $paramName ); |
172 | | - } else { |
173 | | - continue; |
174 | | - } |
175 | | - |
176 | | - if ( $paramName == 'label' ) { |
177 | | - $field->template_field->label = $value; |
178 | | - } elseif ( $paramName == 'input type' ) { |
179 | | - $input_type = $wgRequest->getVal( "input_type_" . $old_i . "_" . $j ); |
180 | | - if ( $input_type == 'hidden' ) { |
181 | | - $field->template_field->input_type = $input_type; |
182 | | - $field->is_hidden = true; |
183 | | - } elseif ( substr( $input_type, 0, 1 ) == '.' ) { |
184 | | - // It's the default input type - |
185 | | - // don't do anything. |
| 168 | + foreach ( $wgRequest->getValues() as $key => $value ) { |
| 169 | + if ( ( $pos = strpos( $key, '_' . $old_i . '_' . $j ) ) != false ) { |
| 170 | + $paramName = substr( $key, 0, $pos ); |
| 171 | + // Spaces got replaced by |
| 172 | + // underlines in the query. |
| 173 | + $paramName = str_replace( '_', ' ', $paramName ); |
186 | 174 | } else { |
187 | | - $field->template_field->input_type = $input_type; |
| 175 | + continue; |
188 | 176 | } |
189 | | - } else { |
190 | | - if ( ! empty( $value ) ) { |
191 | | - if ( $value == 'on' ) { |
192 | | - $value = true; |
| 177 | + |
| 178 | + if ( $paramName == 'label' ) { |
| 179 | + $field->template_field->label = $value; |
| 180 | + } elseif ( $paramName == 'input type' ) { |
| 181 | + $input_type = $wgRequest->getVal( "input_type_" . $old_i . "_" . $j ); |
| 182 | + if ( $input_type == 'hidden' ) { |
| 183 | + $field->template_field->input_type = $input_type; |
| 184 | + $field->is_hidden = true; |
| 185 | + } elseif ( substr( $input_type, 0, 1 ) == '.' ) { |
| 186 | + // It's the default input type - |
| 187 | + // don't do anything. |
| 188 | + } else { |
| 189 | + $field->template_field->input_type = $input_type; |
193 | 190 | } |
194 | | - $field->field_args[$paramName] = $value; |
| 191 | + } else { |
| 192 | + if ( ! empty( $value ) ) { |
| 193 | + if ( $value == 'on' ) { |
| 194 | + $value = true; |
| 195 | + } |
| 196 | + $field->field_args[$paramName] = $value; |
| 197 | + } |
195 | 198 | } |
196 | 199 | } |
197 | 200 | } |
198 | 201 | } |
199 | | - } |
200 | | - $form = SFForm::create( $form_name, $form_templates ); |
| 202 | + $form = SFForm::create( $form_name, $form_templates ); |
201 | 203 | |
202 | | - // If a submit button was pressed, create the form-definition file, |
203 | | - // then redirect. |
204 | | - $save_page = $wgRequest->getCheck( 'wpSave' ); |
205 | | - $preview_page = $wgRequest->getCheck( 'wpPreview' ); |
206 | | - if ( $save_page || $preview_page ) { |
207 | | - # validate form name |
208 | | - if ( $form->form_name == "" ) { |
209 | | - $form_name_error_str = wfMsg( 'sf_blank_error' ); |
210 | | - } else { |
211 | | - # redirect to wiki interface |
212 | | - $wgOut->setArticleBodyOnly( true ); |
213 | | - $title = Title::makeTitleSafe( SF_NS_FORM, $form->form_name ); |
214 | | - $full_text = $form->createMarkup(); |
215 | | - $text = SFUtils::printRedirectForm( $title, $full_text, "", $save_page, $preview_page, false, false, false, null, null ); |
216 | | - $wgOut->addHTML( $text ); |
217 | | - return; |
| 204 | + // If a submit button was pressed, create the form-definition |
| 205 | + // file, then redirect. |
| 206 | + $save_page = $wgRequest->getCheck( 'wpSave' ); |
| 207 | + $preview_page = $wgRequest->getCheck( 'wpPreview' ); |
| 208 | + if ( $save_page || $preview_page ) { |
| 209 | + // Validate form name |
| 210 | + if ( $form->form_name == "" ) { |
| 211 | + $form_name_error_str = wfMsg( 'sf_blank_error' ); |
| 212 | + } else { |
| 213 | + // Redirect to wiki interface |
| 214 | + $wgOut->setArticleBodyOnly( true ); |
| 215 | + $title = Title::makeTitleSafe( SF_NS_FORM, $form->form_name ); |
| 216 | + $full_text = $form->createMarkup(); |
| 217 | + $text = SFUtils::printRedirectForm( $title, $full_text, "", $save_page, $preview_page, false, false, false, null, null ); |
| 218 | + $wgOut->addHTML( $text ); |
| 219 | + return; |
| 220 | + } |
218 | 221 | } |
219 | | - } |
220 | 222 | |
221 | | - $text = ' <form action="" method="post">' . "\n"; |
222 | | - $text .= ' <p>' . wfMsg( 'sf_createform_nameinput' ) . ' ' . wfMsg( 'sf_createform_nameinputdesc' ) . ' <input size=25 name="form_name" value="' . $form_name . '">'; |
223 | | - if ( ! empty( $form_name_error_str ) ) |
224 | | - $text .= ' ' . Xml::element( 'font', array( 'color' => 'red' ), $form_name_error_str ); |
225 | | - $text .= "</p>\n"; |
| 223 | + $text = "\t" . '<form action="" method="post">' . "\n"; |
| 224 | + // Set 'title' field, in case there's no URL niceness |
| 225 | + $text .= "\t" . Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; |
| 226 | + $text .= "\t<p>" . wfMsg( 'sf_createform_nameinput' ) . ' ' . wfMsg( 'sf_createform_nameinputdesc' ) . ' <input size=25 name="form_name" value="' . $form_name . '" />'; |
| 227 | + if ( ! empty( $form_name_error_str ) ) |
| 228 | + $text .= "\t" . Xml::element( 'font', array( 'color' => 'red' ), $form_name_error_str ); |
| 229 | + $text .= "</p>\n"; |
226 | 230 | |
227 | | - $text .= $form->creationHTML(); |
| 231 | + $text .= $form->creationHTML(); |
228 | 232 | |
229 | | - $text .= ' <p>' . wfMsg( 'sf_createform_addtemplate' ) . "\n"; |
| 233 | + $text .= "\t<p>" . wfMsg( 'sf_createform_addtemplate' ) . "\n"; |
230 | 234 | |
231 | | - $select_body = ""; |
232 | | - foreach ( $all_templates as $template ) { |
233 | | - $select_body .= " " . Xml::element( 'option', array( 'value' => $template ), $template ) . "\n"; |
234 | | - } |
235 | | - $text .= ' ' . Xml::tags( 'select', array( 'name' => 'new_template' ), $select_body ) . "\n"; |
236 | | - // if a template has already been added, show a dropdown letting the |
237 | | - // user choose where in the list to add a new dropdown |
238 | | - if ( count( $form_templates ) > 0 ) { |
239 | | - $before_template_msg = wfMsg( 'sf_createform_beforetemplate' ); |
240 | | - $text .= $before_template_msg; |
241 | 235 | $select_body = ""; |
242 | | - foreach ( $form_templates as $i => $ft ) { |
243 | | - $select_body .= " " . Xml::element( 'option', array( 'value' => $i ), $ft->template_name ) . "\n"; |
| 236 | + foreach ( $all_templates as $template ) { |
| 237 | + $select_body .= " " . Xml::element( 'option', array( 'value' => $template ), $template ) . "\n"; |
244 | 238 | } |
245 | | - $final_index = count( $form_templates ); |
246 | | - $at_end_msg = wfMsg( 'sf_createform_atend' ); |
247 | | - $select_body .= ' ' . Xml::element( 'option', array( 'value' => $final_index, 'selected' => 'selected' ), $at_end_msg ); |
248 | | - $text .= Xml::tags( 'select', array( 'name' => 'before_template' ), $select_body ) . "\n"; |
249 | | - } |
| 239 | + $text .= "\t" . Xml::tags( 'select', array( 'name' => 'new_template' ), $select_body ) . "\n"; |
| 240 | + // If a template has already been added, show a dropdown letting |
| 241 | + // the user choose where in the list to add a new dropdown. |
| 242 | + if ( count( $form_templates ) > 0 ) { |
| 243 | + $before_template_msg = wfMsg( 'sf_createform_beforetemplate' ); |
| 244 | + $text .= $before_template_msg; |
| 245 | + $select_body = ""; |
| 246 | + foreach ( $form_templates as $i => $ft ) { |
| 247 | + $select_body .= "\t" . Xml::element( 'option', array( 'value' => $i ), $ft->template_name ) . "\n"; |
| 248 | + } |
| 249 | + $final_index = count( $form_templates ); |
| 250 | + $at_end_msg = wfMsg( 'sf_createform_atend' ); |
| 251 | + $select_body .= "\t" . Xml::element( 'option', array( 'value' => $final_index, 'selected' => 'selected' ), $at_end_msg ); |
| 252 | + $text .= Xml::tags( 'select', array( 'name' => 'before_template' ), $select_body ) . "\n"; |
| 253 | + } |
250 | 254 | |
251 | | - // disable 'save' and 'preview' buttons if user has not yet added any |
252 | | - // templates |
253 | | - $disabled_text = ( count( $form_templates ) == 0 ) ? "disabled" : ""; |
254 | | - $add_button_text = wfMsg( 'sf_createform_add' ); |
255 | | - $sk = $wgUser->getSkin(); |
256 | | - $create_template_link = SFUtils::linkForSpecialPage( $sk, 'CreateTemplate' ); |
257 | | - $text .= "\t" . Xml::element( 'input', array( 'type' => 'submit', 'name' => 'add_field', 'value' => $add_button_text ) ); |
258 | | - $text .= <<<END |
| 255 | + // Disable 'save' and 'preview' buttons if user has not yet |
| 256 | + // added any templates. |
| 257 | + $disabled_text = ( count( $form_templates ) == 0 ) ? "disabled" : ""; |
| 258 | + $add_button_text = wfMsg( 'sf_createform_add' ); |
| 259 | + $sk = $wgUser->getSkin(); |
| 260 | + $create_template_link = SFUtils::linkForSpecialPage( $sk, 'CreateTemplate' ); |
| 261 | + $text .= "\t" . Xml::element( 'input', array( 'type' => 'submit', 'name' => 'add_field', 'value' => $add_button_text ) ); |
| 262 | + $text .= <<<END |
259 | 263 | </p> |
260 | 264 | <br /> |
261 | 265 | |
262 | 266 | END; |
263 | | - $saveAttrs = array( 'type' => 'submit', 'id' => 'wpSave', 'name' => 'wpSave', 'value' => wfMsg( 'savearticle' ) ); |
264 | | - if ( count( $form_templates ) == 0 ) { $saveAttrs['disabled'] = 'disabled'; } |
265 | | - $editButtonsText = "\t" . Xml::element( 'input', $saveAttrs ) . "\n"; |
266 | | - $previewAttrs = array( 'type' => 'submit', 'id' => 'wpPreview', 'name' => 'wpPreview', 'value' => wfMsg( 'preview' ) ); |
267 | | - if ( count( $form_templates ) == 0 ) { $previewAttrs['disabled'] = 'disabled'; } |
268 | | - $editButtonsText .= "\t" . Xml::element( 'input', $previewAttrs ) . "\n"; |
269 | | - $text .= "\t" . Xml::tags( 'div', array( 'class' => 'editButtons' ), |
270 | | - Xml::tags( 'p', array(), $editButtonsText ) . "\n" ) . "\n"; |
271 | | - // explanatory message if buttons are disabled because no templates |
272 | | - // have been added |
273 | | - if ( count( $form_templates ) == 0 ) { |
274 | | - $text .= "\t" . Xml::element( 'p', null, "(" . wfMsg( 'sf_createtemplate_addtemplatebeforesave' ) . ")" ); |
275 | | - } |
276 | | - $text .= <<<END |
| 267 | + $saveAttrs = array( 'type' => 'submit', 'id' => 'wpSave', 'name' => 'wpSave', 'value' => wfMsg( 'savearticle' ) ); |
| 268 | + if ( count( $form_templates ) == 0 ) { $saveAttrs['disabled'] = 'disabled'; } |
| 269 | + $editButtonsText = "\t" . Xml::element( 'input', $saveAttrs ) . "\n"; |
| 270 | + $previewAttrs = array( 'type' => 'submit', 'id' => 'wpPreview', 'name' => 'wpPreview', 'value' => wfMsg( 'preview' ) ); |
| 271 | + if ( count( $form_templates ) == 0 ) { $previewAttrs['disabled'] = 'disabled'; } |
| 272 | + $editButtonsText .= "\t" . Xml::element( 'input', $previewAttrs ) . "\n"; |
| 273 | + $text .= "\t" . Xml::tags( 'div', array( 'class' => 'editButtons' ), |
| 274 | + Xml::tags( 'p', array(), $editButtonsText ) . "\n" ) . "\n"; |
| 275 | + // Explanatory message if buttons are disabled because no |
| 276 | + // templates have been added. |
| 277 | + if ( count( $form_templates ) == 0 ) { |
| 278 | + $text .= "\t" . Xml::element( 'p', null, "(" . wfMsg( 'sf_createtemplate_addtemplatebeforesave' ) . ")" ); |
| 279 | + } |
| 280 | + $text .= <<<END |
277 | 281 | </form> |
278 | 282 | <hr /><br /> |
279 | 283 | |
280 | 284 | END; |
281 | | - $text .= "\t" . Xml::tags( 'p', null, $create_template_link . '.' ); |
| 285 | + $text .= "\t" . Xml::tags( 'p', null, $create_template_link . '.' ); |
282 | 286 | |
283 | | - $wgOut->addExtensionStyle( $sfgScriptPath . "/skins/SemanticForms.css" ); |
284 | | - $wgOut->addHTML( $text ); |
285 | | -} |
| 287 | + $wgOut->addExtensionStyle( $sfgScriptPath . "/skins/SemanticForms.css" ); |
| 288 | + $wgOut->addHTML( $text ); |
| 289 | + } |
286 | 290 | |
287 | 291 | /** |
288 | 292 | * Prints an input for a form-field parameter. |
Index: trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | |
27 | 27 | public function execute( $query ) { |
28 | 28 | $this->setHeaders(); |
29 | | - self::printCreateTemplateForm(); |
| 29 | + $this->printCreateTemplateForm(); |
30 | 30 | } |
31 | 31 | |
32 | 32 | public static function getAllPropertyNames() { |
— | — | @@ -149,7 +149,7 @@ |
150 | 150 | $wgOut->addScript( $jsText ); |
151 | 151 | } |
152 | 152 | |
153 | | - static function printCreateTemplateForm() { |
| 153 | + function printCreateTemplateForm() { |
154 | 154 | global $wgOut, $wgRequest, $wgUser, $sfgScriptPath; |
155 | 155 | |
156 | 156 | SFUtils::loadMessages(); |
— | — | @@ -192,6 +192,8 @@ |
193 | 193 | } |
194 | 194 | |
195 | 195 | $text .= ' <form id="createTemplateForm" action="" method="post">' . "\n"; |
| 196 | + // Set 'title' field, in case there's no URL niceness |
| 197 | + $text .= "\t" . Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; |
196 | 198 | $text .= "\t<p id=\"template_name_p\">" . wfMsg( 'sf_createtemplate_namelabel' ) . ' <input size="25" id="template_name" name="template_name" /></p>' . "\n"; |
197 | 199 | $text .= "\t<p>" . wfMsg( 'sf_createtemplate_categorylabel' ) . ' <input size="25" name="category" /></p>' . "\n"; |
198 | 200 | $text .= "\t<fieldset>\n"; |