class update_status_xml_parser in Update Status 5.2
XML Parser object to read Drupal's project info files This uses PHP4's lame XML parsing, but it works. Mostly.
Hierarchy
- class \update_status_xml_parser
Expanded class hierarchy of update_status_xml_parser
File
- ./
update_status.module, line 1676
View source
class update_status_xml_parser {
var $projects = array();
var $current_project;
var $current_release;
var $current_term;
var $current_tag;
var $current_object;
/**
* Parse an array of XML data files.
*/
function parse($data) {
foreach ($data as $datum) {
$parser = xml_parser_create();
xml_set_object($parser, $this);
xml_set_element_handler($parser, 'start', 'end');
xml_set_character_data_handler($parser, "data");
xml_parse($parser, $datum);
xml_parser_free($parser);
}
return $this->projects;
}
function start($parser, $name, $attr) {
$this->current_tag = $name;
switch ($name) {
case 'PROJECT':
unset($this->current_object);
$this->current_project = array();
$this->current_object =& $this->current_project;
break;
case 'RELEASE':
unset($this->current_object);
$this->current_release = array();
$this->current_object =& $this->current_release;
break;
case 'TERM':
unset($this->current_object);
$this->current_term = array();
$this->current_object =& $this->current_term;
break;
}
}
function end($parser, $name) {
switch ($name) {
case 'PROJECT':
unset($this->current_object);
$this->projects[$this->current_project['short_name']] = $this->current_project;
$this->current_project = array();
break;
case 'RELEASE':
unset($this->current_object);
$this->current_project['releases'][$this->current_release['version']] = $this->current_release;
break;
case 'RELEASES':
$this->current_object =& $this->current_project;
break;
case 'TERM':
unset($this->current_object);
$term_name = $this->current_term['name'];
if (!isset($this->current_release['terms'])) {
$this->current_release['terms'] = array();
}
if (!isset($this->current_release['terms'][$term_name])) {
$this->current_release['terms'][$term_name] = array();
}
$this->current_release['terms'][$term_name][] = $this->current_term['value'];
break;
case 'TERMS':
$this->current_object =& $this->current_release;
break;
default:
$this->current_object[strtolower($this->current_tag)] = trim($this->current_object[strtolower($this->current_tag)]);
$this->current_tag = '';
}
}
function data($parser, $data) {
if ($this->current_tag && !in_array($this->current_tag, array(
'PROJECT',
'RELEASE',
'RELEASES',
'TERM',
'TERMS',
))) {
$tag = strtolower($this->current_tag);
if (isset($this->current_object[$tag])) {
$this->current_object[$tag] .= $data;
}
else {
$this->current_object[$tag] = $data;
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
update_status_xml_parser:: |
property | |||
update_status_xml_parser:: |
property | |||
update_status_xml_parser:: |
property | |||
update_status_xml_parser:: |
property | |||
update_status_xml_parser:: |
property | |||
update_status_xml_parser:: |
property | |||
update_status_xml_parser:: |
function | |||
update_status_xml_parser:: |
function | |||
update_status_xml_parser:: |
function | Parse an array of XML data files. | ||
update_status_xml_parser:: |
function |