r97688 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97687‎ | r97688 | r97689 >
Date:01:35, 21 September 2011
Author:yaron
Status:deferred
Tags:
Comment:
Various improvements to code and comments
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_PageSchemas.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_PageSchemas.php
@@ -55,13 +55,19 @@
5656 public static function getSchemaXML( $request, &$xmlArray ) {
5757 foreach ( $request->getValues() as $var => $val ) {
5858 if ( $var == 'sf_form_name' ) {
59 - $xml = '<semanticforms_Form name="'.$val.'" >';
 59+ $xml = '<semanticforms_Form name="' . $val . '" >';
6060 } elseif ( $var == 'sf_page_name_formula' ) {
61 - $xml .= '<PageNameFormula>'.$val.'</PageNameFormula>';
 61+ if ( !empty( $val ) ) {
 62+ $xml .= '<PageNameFormula>' . $val . '</PageNameFormula>';
 63+ }
6264 } elseif ( $var == 'sf_create_title' ) {
63 - $xml .= '<CreateTitle>'.$val.'</CreateTitle>';
 65+ if ( !empty( $val ) ) {
 66+ $xml .= '<CreateTitle>' . $val . '</CreateTitle>';
 67+ }
6468 } elseif ( $var == 'sf_edit_title' ) {
65 - $xml .= '<EditTitle>'.$val.'</EditTitle>';
 69+ if ( !empty( $val ) ) {
 70+ $xml .= '<EditTitle>' . $val . '</EditTitle>';
 71+ }
6672 $xml .= '</semanticforms_Form>';
6773 }
6874 }
@@ -264,14 +270,17 @@
265271 }
266272
267273 /**
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.
270276 */
271277 public static function getFieldsFromTemplateSchema( $templateFromSchema ) {
272278 $field_all = $templateFromSchema->getFields();
273279 $template_fields = array();
274280 foreach( $field_all as $fieldObj ) {
275281 $smw_array = $fieldObj->getObject('semanticmediawiki_Property');
 282+ if ( !array_key_exists( 'smw', $smw_array ) ) {
 283+ continue;
 284+ }
276285 $propertyName = $smw_array['smw']['name'];
277286 if ( $fieldObj->getLabel() == '' ) {
278287 $fieldLabel = $fieldObj->getName();
@@ -290,6 +299,10 @@
291300 return $template_fields;
292301 }
293302
 303+ /**
 304+ * Creates a form page, when called from the 'generatepages' page
 305+ * of Page Schemas.
 306+ */
294307 public static function generateForm( $formName, $formTitle, $formTemplates, $formDataFromSchema ) {
295308 global $wgUser;
296309

Follow-up revisions

RevisionCommit summaryAuthorDate
r97691Fix to r97688yaron02:15, 21 September 2011