class update_xml_parser in Drupal 6
XML Parser object to read Drupal's release history info files. This uses PHP4's lame XML parsing, but it works.
Hierarchy
- class \update_xml_parser
Expanded class hierarchy of update_xml_parser
File
- modules/
update/ update.fetch.inc, line 183 - Code required only when fetching information about available updates.
View source
class update_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;
case 'FILE':
unset($this->current_object);
$this->current_file = array();
$this->current_object =& $this->current_file;
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;
case 'FILE':
unset($this->current_object);
$this->current_release['files'][] = $this->current_file;
break;
case 'FILES':
$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',
'FILE',
'FILES',
))) {
$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_xml_parser:: |
property | |||
update_xml_parser:: |
property | |||
update_xml_parser:: |
property | |||
update_xml_parser:: |
property | |||
update_xml_parser:: |
property | |||
update_xml_parser:: |
property | |||
update_xml_parser:: |
function | |||
update_xml_parser:: |
function | |||
update_xml_parser:: |
function | Parse an array of XML data files. | ||
update_xml_parser:: |
function |