r90048 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90047‎ | r90048 | r90049 >
Date:14:48, 14 June 2011
Author:ankitgarg833
Status:deferred
Tags:
Comment:
adding generateAllPages function.
Modified paths:
  • /trunk/extensions/PageSchemas/PageSchemas.classes.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/PageSchemas.classes.php
@@ -100,17 +100,15 @@
101101
102102 class PageSchema {
103103
104 - $categoryName = "";
105 - $pageId=0;
106 - $pageXml="";
107 - $pageName="";
 104+ public $categoryName="";
 105+ public $pageId=0;
 106+ public $pageXml="";
 107+ public $pageName="";
108108
109109 /* Stores the templte objects */
110 - $PSTemplates = array();
 110+ public $PSTemplates = array();
111111
112 - function __construct ( $category_name ) {
113 -
114 - $pageName = $pageXml->attributes()->name;
 112+ function __construct ( $category_name ) {
115113 $this->categoryName = $category_name;
116114 $title = Title::newFromText( $categoryName, NS_CATEGORY );
117115 $pageId = $title->getArticleID();
@@ -134,7 +132,7 @@
135133
136134 /* retrievimg the third attribute which is pp_value */
137135 $pageXml = $row[2];
138 -
 136+ $pageName = $pageXml->attributes()->name;
139137 /* index for template objects */
140138 $i = 0 ;
141139 foreach ( $pageXml->children() as $tag => $child ) {
@@ -146,8 +144,17 @@
147145 }
148146
149147 /* function to generate all pages based on the Xml contained in the page */
150 - function generateAllPages () {
151 - wfRunHooks( 'PageSchemasGeneratePages', array($this->pageXml) );
 148+ function generateAllPages () {
 149+ //Get templates
 150+ $template_all = $this->getTemplates();
 151+ //For each template, Get Fields
 152+ foreach ( $template_all as $template ) {
 153+ $field_all = $template->getFields();
 154+ foreach( $field_all as $field ) { //for each Field, retrieve smw properties and fill $prop_name , $prop_type
 155+ $prop_array = $field->getObject('semanticmediawiki:Property'); //this returns an array with property values filled
 156+ wfRunHooks( 'PageSchemasGeneratePages', array( $prop_array['name'], $prop_array['Type'] ) );
 157+ }
 158+ }
152159 }
153160
154161 /*return an array of PSTemplate Objects */
@@ -162,9 +169,9 @@
163170 }
164171 class PSTemplate {
165172 /* Stores the field objects */
166 - $PSFields = array();
167 - $templateName ="";
168 - $templateXml ="";
 173+ public $PSFields = array();
 174+ public $templateName ="";
 175+ public $templateXml ="";
169176 function __construct( $template_xml ) {
170177 $templateXml = $template_xml;
171178 $templateName = $templateXml->attributes()->name;
@@ -185,8 +192,8 @@
186193
187194 class PSTemplateField {
188195
189 - $fieldName ="";
190 - $fieldXml= "";
 196+ public $fieldName ="";
 197+ public $fieldXml= "";
191198
192199 function __construct( $field_xml ) {
193200 $fieldXml = $field_xml;

Status & tagging log