r94120 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94119‎ | r94120 | r94121 >
Date:16:19, 9 August 2011
Author:ankitgarg833
Status:deferred
Tags:
Comment:
adding <form handeling code for PageSchema extension
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_Utils.php
@@ -157,7 +157,21 @@
158158 * Function to return the Property based on the xml passed from the PageSchema extension
159159 */
160160 public static function createPageSchemasObject( $objectName, $xmlForField, &$object ) {
161 - $sfarray = array();
 161+ $sfarray = array();
 162+ $formName="";
 163+ if ( $objectName == "Form" ) {
 164+ foreach ( $xmlForField->children() as $tag => $child ) {
 165+ if ( $tag == $objectName ) {
 166+ $formName = (string) $child->attributes()->name;
 167+ $sfarray['name'] = $formName;
 168+ foreach ($child->children() as $tag => $formelem) {
 169+ $sfarray[(string)$tag] = (string)$formelem;
 170+ }
 171+ }
 172+ }
 173+ $object['sf'] = $sfarray;
 174+ return true;
 175+ }
162176 if ( $objectName == "FormInput" ) {
163177 foreach ( $xmlForField->children() as $tag => $child ) {
164178 if ( $tag == $objectName ) {
@@ -217,11 +231,12 @@
218232 public static function getFilledHtmlTextForPS( $pageSchemaObj, &$text_extensions ){
219233 $template_fields = array();
220234 $html_text = "";
221 - $template_all = $pageSchemaObj->getTemplates();
 235+ $template_all = $pageSchemaObj->getTemplates();
 236+ $html_text_array = array();
222237 foreach ( $template_all as $template ) {
223238 $field_all = $template->getFields();
224239 $field_count = 0; //counts the number of fields
225 - $html_text_array = array();
 240+
226241 foreach( $field_all as $field ) { //for each Field, retrieve smw properties and fill $prop_name , $prop_type
227242 $field_count++;
228243 $sf_array = $field->getObject('FormInput');//this returns an array with property values filled
@@ -336,6 +351,7 @@
337352 *Thi Function parses the Field elements in the xml of the pages. Hooks for PageSchemas extension
338353 */
339354 public static function parseFieldElements( $field_xml, &$text_object ) {
 355+
340356 foreach ( $field_xml->children() as $tag => $child ) {
341357 if ( $tag == "FormInput" ) {
342358 $text = "";