2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /************************************************************************/
\r
16 * Class for parsing XML language info and returning a Theme Object
\r
18 * @author Shozub Qureshi
\r
24 var $parser; // the XML handler
\r
25 var $theme_rows = array(); // the language data used for creating the Language Object
\r
26 var $character_data; // tmp variable for storing the data
\r
27 var $element_path; // array of element paths (basically a stack)
\r
30 function ThemeParser() {
\r
31 $this->parser = xml_parser_create();
\r
33 xml_set_object($this->parser, $this);
\r
34 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false); /* conform to W3C specs */
\r
35 xml_set_element_handler($this->parser, 'startElement', 'endElement');
\r
36 xml_set_character_data_handler($this->parser, 'characterData');
\r
40 function parse($xml_data) {
\r
41 $this->element_path = array();
\r
42 $this->theme_rows = array();
\r
43 $this->character_data = '';
\r
44 xml_parse($this->parser, $xml_data, TRUE);
\r
48 function startElement($parser, $name, $attributes) {
\r
49 array_push($this->element_path, $name);
\r
53 /* called when an element ends */
\r
54 /* removed the current element from the $path */
\r
55 function endElement($parser, $name) {
\r
56 if ($this->element_path == array('theme', 'dir_name')) {
\r
57 $this->theme_rows['dir_name'] = trim($this->character_data);
\r
59 } else if ($this->element_path == array('theme', 'title')) {
\r
60 $this->theme_rows['title'] = trim($this->character_data);
\r
62 } else if ($this->element_path == array('theme', 'version')) {
\r
63 $this->theme_rows['version'] = trim($this->character_data);
\r
65 } else if ($this->element_path == array('theme', 'type')) {
\r
66 $this->theme_rows['type'] = trim($this->character_data);
\r
68 } else if ($this->element_path == array('theme', 'last_updated')) {
\r
69 $this->theme_rows['last_updated'] = trim($this->character_data);
\r
71 } else if ($this->element_path == array('theme', 'extra_info')) {
\r
72 $this->theme_rows['extra_info'] = trim($this->character_data);
\r
76 array_pop($this->element_path);
\r
77 $this->character_data = '';
\r
81 function characterData($parser, $data){
\r
82 $this->character_data .= $data;
\r