r91412 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91411‎ | r91412 | r91413 >
Date:16:53, 4 July 2011
Author:ankitgarg833
Status:deferred
Tags:
Comment:
1_ adding helper code to create Form Page from xml.
2_ Populating formName variable .
Modified paths:
  • /trunk/extensions/PageSchemas/PageSchemas.classes.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/PageSchemas.classes.php
@@ -104,7 +104,7 @@
105105 public $pageXml=null;
106106 public $pageXmlstr= "";
107107 public $pageName="";
108 -
 108+ public $formName="";
109109 /* Stores the templte objects */
110110 public $PSTemplates = array();
111111
@@ -133,7 +133,7 @@
134134 $pageXmlstr = $row[2];
135135
136136 $pageXml = simplexml_load_string ( $pageXmlstr );
137 - $pageName = $pageXml->attributes()->name;
 137+ $this->pageName = (string)$pageXml->attributes()->name;
138138 /* index for template objects */
139139 $i = 0 ;
140140 foreach ( $pageXml->children() as $tag => $child ) {
@@ -141,6 +141,9 @@
142142 $templateObj = new PSTemplate($child);
143143 $this->PSTemplates[$i++]= $templateObj;
144144 }
 145+ if ( $tag == 'FormName' ) {
 146+ $this->formName = (string)$child;
 147+ }
145148 }
146149
147150 }
@@ -149,7 +152,9 @@
150153 function generateAllPages () {
151154 //Get templates
152155 $template_all = $this->getTemplates();
153 - //For each template, Get Fields
 156+ /*obj. to create form Page */
 157+ $form_templates = array();
 158+ $genFormObj = array();
154159 foreach ( $template_all as $template ) {
155160 $template_array = array();
156161 $template_array['name'] = $template->getName();
@@ -158,21 +163,21 @@
159164 $genPageObject = array();
160165 $field_count = 0; //counts the number of fields
161166 foreach( $field_all as $field ) { //for each Field, retrieve smw properties and fill $prop_name , $prop_type
162 - $field_count++;
163 - $field_array = array();
164 - $field_array['name'] = $field->getName();
165 - $field_array['label'] = $field->getLabel();
 167+ $field_count++;
166168 $prop_array = $field->getObject('Property'); //this returns an array with property values filled
167 - $genPageObject['Property'] = $prop_array;
168 - $field_array['Property'] = $prop_array;
169 - $template_array['Field'.$field_count] = $field_array;
 169+ $genPageObject['Property'] = $prop_array;
 170+ $template_array['Field'.$field_count] = $field;
170171 $form_input_array = $field->getObject('FormInput'); //this returns an array with property values filled
171172 $genPageObject['FormInput'] = $form_input_array;
172 - wfRunHooks( 'PageSchemasGeneratePages', array( $genPageObject ));
 173+ wfRunHooks( 'PageSchemasGeneratePages', array( $genPageObject ));
173174 }
174 - $genPageObject['Template'] = $template_array ;
 175+ $genPageObject['Template'] = $template_array ;
175176 wfRunHooks( 'PageSchemasGeneratePages', array( $genPageObject ));
176 - }
 177+ $form_templates[] = $template_array;
 178+ }
 179+ $genFormObj['Form'] = $form_templates;
 180+ $genFormObj['FormName'] = $this->getFormName();
 181+ wfRunHooks( 'PageSchemasGeneratePages', array( $genFormObj ));
177182 }
178183
179184 /*return an array of PSTemplate Objects */
@@ -182,8 +187,11 @@
183188
184189 /*returns the name of the PageSchema object */
185190 function getName(){
186 - return $pageName;
 191+ return $this->pageName;
187192 }
 193+ function getFormName(){
 194+ return $this->formName;
 195+ }
188196 }
189197 class PSTemplate {
190198 /* Stores the field objects */

Status & tagging log