Index: trunk/extensions/PageSchemas/PageSchemas.classes.php |
— | — | @@ -100,17 +100,15 @@ |
101 | 101 | |
102 | 102 | class PageSchema { |
103 | 103 | |
104 | | - $categoryName = ""; |
105 | | - $pageId=0; |
106 | | - $pageXml=""; |
107 | | - $pageName=""; |
| 104 | + public $categoryName=""; |
| 105 | + public $pageId=0; |
| 106 | + public $pageXml=""; |
| 107 | + public $pageName=""; |
108 | 108 | |
109 | 109 | /* Stores the templte objects */ |
110 | | - $PSTemplates = array(); |
| 110 | + public $PSTemplates = array(); |
111 | 111 | |
112 | | - function __construct ( $category_name ) { |
113 | | - |
114 | | - $pageName = $pageXml->attributes()->name; |
| 112 | + function __construct ( $category_name ) { |
115 | 113 | $this->categoryName = $category_name; |
116 | 114 | $title = Title::newFromText( $categoryName, NS_CATEGORY ); |
117 | 115 | $pageId = $title->getArticleID(); |
— | — | @@ -134,7 +132,7 @@ |
135 | 133 | |
136 | 134 | /* retrievimg the third attribute which is pp_value */ |
137 | 135 | $pageXml = $row[2]; |
138 | | - |
| 136 | + $pageName = $pageXml->attributes()->name; |
139 | 137 | /* index for template objects */ |
140 | 138 | $i = 0 ; |
141 | 139 | foreach ( $pageXml->children() as $tag => $child ) { |
— | — | @@ -146,8 +144,17 @@ |
147 | 145 | } |
148 | 146 | |
149 | 147 | /* 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 | + } |
152 | 159 | } |
153 | 160 | |
154 | 161 | /*return an array of PSTemplate Objects */ |
— | — | @@ -162,9 +169,9 @@ |
163 | 170 | } |
164 | 171 | class PSTemplate { |
165 | 172 | /* Stores the field objects */ |
166 | | - $PSFields = array(); |
167 | | - $templateName =""; |
168 | | - $templateXml =""; |
| 173 | + public $PSFields = array(); |
| 174 | + public $templateName =""; |
| 175 | + public $templateXml =""; |
169 | 176 | function __construct( $template_xml ) { |
170 | 177 | $templateXml = $template_xml; |
171 | 178 | $templateName = $templateXml->attributes()->name; |
— | — | @@ -185,8 +192,8 @@ |
186 | 193 | |
187 | 194 | class PSTemplateField { |
188 | 195 | |
189 | | - $fieldName =""; |
190 | | - $fieldXml= ""; |
| 196 | + public $fieldName =""; |
| 197 | + public $fieldXml= ""; |
191 | 198 | |
192 | 199 | function __construct( $field_xml ) { |
193 | 200 | $fieldXml = $field_xml; |