r91351 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91350‎ | r91351 | r91352 >
Date:12:08, 2 July 2011
Author:ankitgarg833
Status:deferred
Tags:
Comment:
generateAllPages() modified for support of creation of templates and calling apropiate hooks
Modified paths:
  • /trunk/extensions/PageSchemas/PageSchemas.classes.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/PageSchemas.classes.php
@@ -151,11 +151,27 @@
152152 $template_all = $this->getTemplates();
153153 //For each template, Get Fields
154154 foreach ( $template_all as $template ) {
 155+ $template_array = array();
 156+ $template_array['name'] = $template->getName();
 157+ $template_array['category_name'] = $this->categoryName;
155158 $field_all = $template->getFields();
156 - foreach( $field_all as $field ) { //for each Field, retrieve smw properties and fill $prop_name , $prop_type
157 - $prop_array = $field->getObject('Property'); //this returns an array with property values filled
158 - wfRunHooks( 'PageSchemasGeneratePages', array( $prop_array['name'], $prop_array['Type'], $prop_array['allowed_value_array'] ) );
 159+ $genPageObject = array();
 160+ $field_count = 0; //counts the number of fields
 161+ 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();
 166+ $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;
 170+ $form_input_array = $field->getObject('FormInput'); //this returns an array with property values filled
 171+ $genPageObject['FormInput'] = $form_input_array;
 172+ wfRunHooks( 'PageSchemasGeneratePages', array( $genPageObject ));
159173 }
 174+ $genPageObject['Template'] = $template_array ;
 175+ wfRunHooks( 'PageSchemasGeneratePages', array( $genPageObject ));
160176 }
161177 }
162178
@@ -175,11 +191,11 @@
176192 public $templateName ="";
177193 public $templateXml = null;
178194 function __construct( $template_xml ) {
179 - $templateXml = $template_xml;
180 - $templateName = $templateXml->attributes()->name;
 195+ $this->templateXml = $template_xml;
 196+ $this->templateName = (string) $template_xml->attributes()->name;
181197 /*index for template objects */
182198 $i = 0 ;
183 - foreach ($templateXml->children() as $child) {
 199+ foreach ($template_xml->children() as $child) {
184200 $fieldObj = new PSTemplateField($child);
185201 $this->PSFields[$i++]= $fieldObj;
186202 }
@@ -196,14 +212,22 @@
197213
198214 public $fieldName ="";
199215 public $fieldXml= null;
200 -
 216+ public $fieldLabel = "";
201217 function __construct( $field_xml ) {
202218 $this->fieldXml = $field_xml;
203 - $this->fieldName = $this->fieldXml->attributes()->name;
 219+ $this->fieldName = (string)$this->fieldXml->attributes()->name;
 220+ foreach ($this->fieldXml->children() as $tag => $child ) {
 221+ if ( $tag == 'Label' ) {
 222+ $this->fieldLabel = (string)$child;
 223+ }
 224+ }
204225 }
205226 function getName(){
206227 return $this->fieldName;
207228 }
 229+ function getLabel(){
 230+ return $this->fieldLabel;
 231+ }
208232 function getObject( $objectName ) {
209233 $object = array();
210234 wfRunHooks( 'PageSchemasGetObject', array( $objectName, $this->fieldXml, &$object ) );

Status & tagging log