Index: trunk/extensions/PageSchemas/PageSchemas.classes.php |
— | — | @@ -8,7 +8,6 @@ |
9 | 9 | |
10 | 10 | class PageSchemas { |
11 | 11 | |
12 | | - |
13 | 12 | /* Functions */ |
14 | 13 | //Copied from SFUtils |
15 | 14 | public static function titleString( $title ) { |
— | — | @@ -41,9 +40,11 @@ |
42 | 41 | <?xml version="1.0" encoding="utf-8"?> |
43 | 42 | <!DOCTYPE PageSchema [ |
44 | 43 | <!ELEMENT PageSchema (Template*)> |
| 44 | +<!ELEMENT PageSchema (Form*)> |
45 | 45 | <!ATTLIST PageSchema name CDATA #REQUIRED> |
46 | 46 | <!ELEMENT Template (Field*)> |
47 | 47 | <!ATTLIST Template name CDATA #REQUIRED> |
| 48 | +<!ATTLIST Form name CDATA #REQUIRED> |
48 | 49 | <!ATTLIST Field name CDATA #REQUIRED> |
49 | 50 | ]> |
50 | 51 | |
— | — | @@ -88,7 +89,10 @@ |
89 | 90 | $name = $class_schema_xml->attributes()->name; |
90 | 91 | $text .= self::tableRowHTML('paramGroup', 'PageSchema', $name); |
91 | 92 | foreach ( $class_schema_xml->children() as $tag => $child ) { |
92 | | - if ($tag == 'Template') { |
| 93 | + if ( $tag == 'Form' ){ |
| 94 | + $text .= self::parseFormElem($child); |
| 95 | + } |
| 96 | + else if ($tag == 'Template') { |
93 | 97 | $text .= self::parseTemplate($child); |
94 | 98 | } else{ |
95 | 99 | echo "Code to be added by other extension\n"; |
— | — | @@ -100,6 +104,14 @@ |
101 | 105 | } |
102 | 106 | return $text; |
103 | 107 | } |
| 108 | + static function parseFormElem( $form_xml ) { |
| 109 | + $name = $form_xml->attributes()->name; |
| 110 | + $text = self::tableRowHTML('param', 'Form', $name); |
| 111 | + foreach ($form_xml->children() as $key => $value ) { |
| 112 | + $text .= self::tableMessageRowHTML("paramAttrMsg", (string)$key, (string)$value ); |
| 113 | + } |
| 114 | + return $text; |
| 115 | + } |
104 | 116 | static function parseTemplate ( $template_xml ) { |
105 | 117 | $name = $template_xml->attributes()->name; |
106 | 118 | $text = self::tableRowHTML('param', 'Template', $name); |
— | — | @@ -129,6 +141,7 @@ |
130 | 142 | public $pageXmlstr= ""; |
131 | 143 | public $pageName=""; |
132 | 144 | public $formName=""; |
| 145 | + public $formArray = array(); |
133 | 146 | /* Stores the templte objects */ |
134 | 147 | public $PSTemplates = array(); |
135 | 148 | |
— | — | @@ -163,13 +176,13 @@ |
164 | 177 | $schema_to_inherit = (string) $child->attributes()->schema; |
165 | 178 | if( $schema_to_inherit !=null ){ |
166 | 179 | $inheritedSchemaObj = new PSSchema( $schema_to_inherit ); |
167 | | - $inherited_templates = $inheritedSchemaObj->getTemplates(); |
| 180 | + $inherited_templates = $inheritedSchemaObj->getTemplates(); |
168 | 181 | } |
169 | 182 | } |
170 | 183 | if ( $tag == 'Template' ) { |
171 | 184 | $ignore = (string) $child->attributes()->ignore; |
172 | | - if( $child->children() != null ){ |
173 | | - $templateObj = new PSTemplate($child); |
| 185 | + if( count($child->children()) > 1 ){ |
| 186 | + $templateObj = new PSTemplate($child); |
174 | 187 | $this->PSTemplates[$i++]= $templateObj; |
175 | 188 | }else if( $ignore != "true" ) { |
176 | 189 | //Code to Add Templates from Inherited templates |
— | — | @@ -181,8 +194,12 @@ |
182 | 195 | } |
183 | 196 | } |
184 | 197 | } |
185 | | - if ( $tag == 'FormName' ) { |
186 | | - $this->formName = (string)$child; |
| 198 | + if ( $tag == 'Form' ) { |
| 199 | + $this->formName = (string) $child->attributes()->name; |
| 200 | + $this->formArray['name'] = (string) $child->attributes()->name; |
| 201 | + foreach ($child->children() as $tag => $formelem) { |
| 202 | + $this->formArray[(string)$tag] = (string)$formelem; |
| 203 | + } |
187 | 204 | } |
188 | 205 | } |
189 | 206 | } |
— | — | @@ -191,6 +208,10 @@ |
192 | 209 | wfRunHooks( 'PageSchemasGeneratePages', array( $this, $toGenPageList )); |
193 | 210 | } |
194 | 211 | /*return an array of PSTemplate Objects */ |
| 212 | + function getFormArray () { |
| 213 | + return $this->formArray; |
| 214 | + } |
| 215 | + /*return an array of PSTemplate Objects */ |
195 | 216 | function getTemplates () { |
196 | 217 | return $this->PSTemplates; |
197 | 218 | } |
— | — | @@ -220,17 +241,17 @@ |
221 | 242 | } |
222 | 243 | /*index for template objects */ |
223 | 244 | $i = 0 ; |
224 | | - $inherited_fields = null ; |
225 | | - foreach ($template_xml->children() as $child) { |
226 | | - if ( $child->getName == 'InheritsFrom ' ) { |
| 245 | + $inherited_fields = null ; |
| 246 | + foreach ($template_xml->children() as $child) { |
| 247 | + if ( $child->getName() == 'InheritsFrom' ) { |
227 | 248 | $schema_to_inherit = (string) $child->attributes()->schema; |
228 | | - $template_to_inherit = (string) $child->attributes()->template; |
| 249 | + $template_to_inherit = (string) $child->attributes()->template; |
229 | 250 | if( $schema_to_inherit !=null && $template_to_inherit != null ) { |
230 | 251 | $inheritedSchemaObj = new PSSchema( $schema_to_inherit ); |
231 | | - $inherited_templates = $inheritedSchemaObj->getTemplates(); |
| 252 | + $inherited_templates = $inheritedSchemaObj->getTemplates(); |
232 | 253 | foreach( $inherited_templates as $inherited_template ) { |
233 | 254 | if( $template_to_inherit == $inherited_template->getName() ){ |
234 | | - $inherited_fields = $inherited_template->getFields(); |
| 255 | + $inherited_fields = $inherited_template->getFields(); |
235 | 256 | } |
236 | 257 | } |
237 | 258 | } |
— | — | @@ -239,12 +260,13 @@ |
240 | 261 | $this->label_name = (string)$child; |
241 | 262 | } else if ( $child->getName() == "Field" ){ |
242 | 263 | $ignore = (string) $child->attributes()->ignore; |
243 | | - if( $child->children() != null ){ |
| 264 | + wfDebugLog( 'myextension', 'Something is not right: ' . print_r( count($child->children()), true ) ); |
| 265 | + if( count($child->children()) > 1 ){ //@TODO :Can be dealt more efficiently |
244 | 266 | $fieldObj = new PSTemplateField($child); |
245 | 267 | $this->PSFields[$i++]= $fieldObj; |
246 | 268 | }else if( $ignore != "true" ) { |
247 | 269 | //Code to Add Templates from Inherited templates |
248 | | - $field_name = (string) $child->attributes()->name; |
| 270 | + $field_name = (string) $child->attributes()->name; |
249 | 271 | foreach( $inherited_fields as $inherited_field ) { |
250 | 272 | if( $field_name == $inherited_field->getName() ){ |
251 | 273 | $this->PSFields[$i++]= $inherited_field; |
— | — | @@ -278,13 +300,13 @@ |
279 | 301 | $this->fieldXml = $field_xml; |
280 | 302 | $this->fieldName = (string)$this->fieldXml->attributes()->name; |
281 | 303 | if( ((string)$this->fieldXml->attributes()->list) == "list") { |
282 | | - $this->list_values = true; |
| 304 | + $this->list_values = true; |
283 | 305 | } |
284 | 306 | foreach ($this->fieldXml->children() as $tag => $child ) { |
285 | 307 | if ( $tag == 'Label' ) { |
286 | | - $this->fieldLabel = (string)$child; |
287 | | - } |
288 | | - } |
| 308 | + $this->fieldLabel = (string)$child; |
| 309 | + } |
| 310 | + } |
289 | 311 | } |
290 | 312 | function getName(){ |
291 | 313 | return $this->fieldName; |