r91748 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91747‎ | r91748 | r91749 >
Date:18:45, 8 July 2011
Author:ankitgarg833
Status:deferred
Tags:
Comment:
added getLabel method in PSSchema class
added isMultiple method
added isList method in PSTemplateField class.
Modified paths:
  • /trunk/extensions/PageSchemas/PageSchemas.classes.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/PageSchemas.classes.php
@@ -132,8 +132,7 @@
133133 $pageXml = simplexml_load_string ( $pageXmlstr );
134134 $this->pageName = (string)$pageXml->attributes()->name;
135135 /* index for template objects */
136 - $i = 0 ;
137 - $j = 1;
 136+ $i = 0 ;
138137 foreach ( $pageXml->children() as $tag => $child ) {
139138 if ( $tag == 'Template' ) {
140139 $templateObj = new PSTemplate($child);
@@ -145,8 +144,8 @@
146145 }
147146 }
148147 /* function to generate all pages based on the Xml contained in the page */
149 - function generateAllPages () {
150 - wfRunHooks( 'PageSchemasGeneratePages', array( $this ));
 148+ function generateAllPages ( $toGenPageList ) {
 149+ wfRunHooks( 'PageSchemasGeneratePages', array( $this, $toGenPageList ));
151150 }
152151 /*return an array of PSTemplate Objects */
153152 function getTemplates () {
@@ -169,19 +168,34 @@
170169 public $PSFields = array();
171170 public $templateName ="";
172171 public $templateXml = null;
 172+ public $multiple_allowed = false;
 173+ private $label_name = null;
173174 function __construct( $template_xml ) {
174 - $this->templateXml = $template_xml;
 175+ $this->templateXml = $template_xml;
175176 $this->templateName = (string) $template_xml->attributes()->name;
 177+ if( ((string) $template_xml->attributes()->multiple) == "multiple" ) {
 178+ $this->multiple_allowed = true;
 179+ }
176180 /*index for template objects */
177181 $i = 0 ;
178 - foreach ($template_xml->children() as $child) {
179 - $fieldObj = new PSTemplateField($child);
180 - $this->PSFields[$i++]= $fieldObj;
181 - }
 182+ foreach ($template_xml->children() as $child) {
 183+ if( $child->getName() == "Label" ) { //@TODO Label => sf:Label
 184+ $this->label_name = (string)$child;
 185+ }else{
 186+ $fieldObj = new PSTemplateField($child);
 187+ $this->PSFields[$i++]= $fieldObj;
 188+ }
 189+ }
182190 }
183191 function getName(){
184192 return $this->templateName;
185 - }
 193+ }
 194+ function isMultiple(){
 195+ return $this->multiple_allowed;
 196+ }
 197+ public function getLabel(){
 198+ return $this->label_name;
 199+ }
186200 function getFields(){
187201 return $this->PSFields;
188202 }
@@ -191,10 +205,14 @@
192206
193207 public $fieldName ="";
194208 public $fieldXml= null;
195 - public $fieldLabel = "";
 209+ public $fieldLabel = "";
 210+ private $list_values = false;
196211 function __construct( $field_xml ) {
197212 $this->fieldXml = $field_xml;
198213 $this->fieldName = (string)$this->fieldXml->attributes()->name;
 214+ if( ((string)$this->fieldXml->attributes()->list) == "list") {
 215+ $this->list_values = true;
 216+ }
199217 foreach ($this->fieldXml->children() as $tag => $child ) {
200218 if ( $tag == 'Label' ) {
201219 $this->fieldLabel = (string)$child;
@@ -207,6 +225,9 @@
208226 function getLabel(){
209227 return $this->fieldLabel;
210228 }
 229+ public function isList(){
 230+ return $this->list_values;
 231+ }
211232 function getObject( $objectName ) {
212233 $object = array();
213234 wfRunHooks( 'PageSchemasGetObject', array( $objectName, $this->fieldXml, &$object ) );

Status & tagging log