Index: trunk/extensions/SemanticForms/includes/SF_PageSchemas.php |
— | — | @@ -55,13 +55,19 @@ |
56 | 56 | public static function getSchemaXML( $request, &$xmlArray ) { |
57 | 57 | foreach ( $request->getValues() as $var => $val ) { |
58 | 58 | if ( $var == 'sf_form_name' ) { |
59 | | - $xml = '<semanticforms_Form name="'.$val.'" >'; |
| 59 | + $xml = '<semanticforms_Form name="' . $val . '" >'; |
60 | 60 | } elseif ( $var == 'sf_page_name_formula' ) { |
61 | | - $xml .= '<PageNameFormula>'.$val.'</PageNameFormula>'; |
| 61 | + if ( !empty( $val ) ) { |
| 62 | + $xml .= '<PageNameFormula>' . $val . '</PageNameFormula>'; |
| 63 | + } |
62 | 64 | } elseif ( $var == 'sf_create_title' ) { |
63 | | - $xml .= '<CreateTitle>'.$val.'</CreateTitle>'; |
| 65 | + if ( !empty( $val ) ) { |
| 66 | + $xml .= '<CreateTitle>' . $val . '</CreateTitle>'; |
| 67 | + } |
64 | 68 | } elseif ( $var == 'sf_edit_title' ) { |
65 | | - $xml .= '<EditTitle>'.$val.'</EditTitle>'; |
| 69 | + if ( !empty( $val ) ) { |
| 70 | + $xml .= '<EditTitle>' . $val . '</EditTitle>'; |
| 71 | + } |
66 | 72 | $xml .= '</semanticforms_Form>'; |
67 | 73 | } |
68 | 74 | } |
— | — | @@ -264,14 +270,17 @@ |
265 | 271 | } |
266 | 272 | |
267 | 273 | /** |
268 | | - * Creates wiki-text for a template, based on the contents of a |
269 | | - * <PageSchema> tag. |
| 274 | + * Returns an array of SFTemplateField objects, representing the fields |
| 275 | + * of a template, based on the contents of a <PageSchema> tag. |
270 | 276 | */ |
271 | 277 | public static function getFieldsFromTemplateSchema( $templateFromSchema ) { |
272 | 278 | $field_all = $templateFromSchema->getFields(); |
273 | 279 | $template_fields = array(); |
274 | 280 | foreach( $field_all as $fieldObj ) { |
275 | 281 | $smw_array = $fieldObj->getObject('semanticmediawiki_Property'); |
| 282 | + if ( !array_key_exists( 'smw', $smw_array ) ) { |
| 283 | + continue; |
| 284 | + } |
276 | 285 | $propertyName = $smw_array['smw']['name']; |
277 | 286 | if ( $fieldObj->getLabel() == '' ) { |
278 | 287 | $fieldLabel = $fieldObj->getName(); |
— | — | @@ -290,6 +299,10 @@ |
291 | 300 | return $template_fields; |
292 | 301 | } |
293 | 302 | |
| 303 | + /** |
| 304 | + * Creates a form page, when called from the 'generatepages' page |
| 305 | + * of Page Schemas. |
| 306 | + */ |
294 | 307 | public static function generateForm( $formName, $formTitle, $formTemplates, $formDataFromSchema ) { |
295 | 308 | global $wgUser; |
296 | 309 | |