Index: trunk/extensions/PageSchemas/PageSchemas.classes.php |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | public $pageXml=null; |
106 | 106 | public $pageXmlstr= ""; |
107 | 107 | public $pageName=""; |
108 | | - |
| 108 | + public $formName=""; |
109 | 109 | /* Stores the templte objects */ |
110 | 110 | public $PSTemplates = array(); |
111 | 111 | |
— | — | @@ -133,7 +133,7 @@ |
134 | 134 | $pageXmlstr = $row[2]; |
135 | 135 | |
136 | 136 | $pageXml = simplexml_load_string ( $pageXmlstr ); |
137 | | - $pageName = $pageXml->attributes()->name; |
| 137 | + $this->pageName = (string)$pageXml->attributes()->name; |
138 | 138 | /* index for template objects */ |
139 | 139 | $i = 0 ; |
140 | 140 | foreach ( $pageXml->children() as $tag => $child ) { |
— | — | @@ -141,6 +141,9 @@ |
142 | 142 | $templateObj = new PSTemplate($child); |
143 | 143 | $this->PSTemplates[$i++]= $templateObj; |
144 | 144 | } |
| 145 | + if ( $tag == 'FormName' ) { |
| 146 | + $this->formName = (string)$child; |
| 147 | + } |
145 | 148 | } |
146 | 149 | |
147 | 150 | } |
— | — | @@ -149,7 +152,9 @@ |
150 | 153 | function generateAllPages () { |
151 | 154 | //Get templates |
152 | 155 | $template_all = $this->getTemplates(); |
153 | | - //For each template, Get Fields |
| 156 | + /*obj. to create form Page */ |
| 157 | + $form_templates = array(); |
| 158 | + $genFormObj = array(); |
154 | 159 | foreach ( $template_all as $template ) { |
155 | 160 | $template_array = array(); |
156 | 161 | $template_array['name'] = $template->getName(); |
— | — | @@ -158,21 +163,21 @@ |
159 | 164 | $genPageObject = array(); |
160 | 165 | $field_count = 0; //counts the number of fields |
161 | 166 | 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++; |
166 | 168 | $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; |
170 | 171 | $form_input_array = $field->getObject('FormInput'); //this returns an array with property values filled |
171 | 172 | $genPageObject['FormInput'] = $form_input_array; |
172 | | - wfRunHooks( 'PageSchemasGeneratePages', array( $genPageObject )); |
| 173 | + wfRunHooks( 'PageSchemasGeneratePages', array( $genPageObject )); |
173 | 174 | } |
174 | | - $genPageObject['Template'] = $template_array ; |
| 175 | + $genPageObject['Template'] = $template_array ; |
175 | 176 | 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 )); |
177 | 182 | } |
178 | 183 | |
179 | 184 | /*return an array of PSTemplate Objects */ |
— | — | @@ -182,8 +187,11 @@ |
183 | 188 | |
184 | 189 | /*returns the name of the PageSchema object */ |
185 | 190 | function getName(){ |
186 | | - return $pageName; |
| 191 | + return $this->pageName; |
187 | 192 | } |
| 193 | + function getFormName(){ |
| 194 | + return $this->formName; |
| 195 | + } |
188 | 196 | } |
189 | 197 | class PSTemplate { |
190 | 198 | /* Stores the field objects */ |