r97790 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97789‎ | r97790 | r97791 >
Date:04:17, 22 September 2011
Author:yaron
Status:deferred
Tags:
Comment:
PHP improvements
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_PageSchemas.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_PageSchemas.php
@@ -17,13 +17,12 @@
1818 */
1919 public static function createPageSchemasObject( $objectName, $xmlForField, &$object ) {
2020 $sfarray = array();
21 - $formName = "";
2221 if ( $objectName == "semanticforms_Form" ) {
2322 foreach ( $xmlForField->children() as $tag => $child ) {
2423 if ( $tag == $objectName ) {
2524 $formName = (string) $child->attributes()->name;
2625 $sfarray['name'] = $formName;
27 - foreach ($child->children() as $tag => $formelem) {
 26+ foreach ( $child->children() as $tag => $formelem ) {
2827 $sfarray[(string)$tag] = (string)$formelem;
2928 }
3029 $object['sf'] = $sfarray;
@@ -53,6 +52,7 @@
5453 * Creates Page Schemas XML for form-wide information.
5554 */
5655 public static function getSchemaXML( $request, &$xmlArray ) {
 56+ $xml = '';
5757 foreach ( $request->getValues() as $var => $val ) {
5858 if ( $var == 'sf_form_name' ) {
5959 $xml = '<semanticforms_Form name="' . $val . '" >';
@@ -210,12 +210,18 @@
211211 }
212212
213213 public static function getFormName( $psSchemaObj ) {
214 - $formData = $psSchemaObj->getObject( 'semanticforms_Form' );
215 - return $formData['sf']['name'];
 214+ $mainFormInfo = self::getMainFormInfo( $psSchemaObj );
 215+ if ( is_null( $mainFormInfo ) || !array_key_exists( 'name', $mainFormInfo ) ) {
 216+ return null;
 217+ }
 218+ return $mainFormInfo['name']
216219 }
217220
218221 public static function getMainFormInfo( $psSchemaObj ) {
219222 $formData = $psSchemaObj->getObject( 'semanticforms_Form' );
 223+ if ( !array_key_exists( 'sf', $formData ) ) {
 224+ return null;
 225+ }
220226 return $formData['sf'];
221227 }
222228

Follow-up revisions

RevisionCommit summaryAuthorDate
r97792Follow-up to r97790 - bug fix, plus various additional improvementsyaron04:54, 22 September 2011