/** * Returns information about a package file. Expects the contents * of a package xml file as input. * * @param string $data name of package xml file * * @return array array with package information * * @access public * */ function infoFromString($data) { require_once 'PEAR/Dependency.php'; if (PEAR_Dependency::checkExtension($error, 'xml')) { return $this->raiseError($error); } $xp = @xml_parser_create(); if (!$xp) { return $this->raiseError('Unable to create XML parser'); } xml_set_object($xp, $this); xml_set_element_handler($xp, '_element_start', '_element_end'); xml_set_character_data_handler($xp, '_pkginfo_cdata'); xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false); $this->element_stack = array(); $this->pkginfo = array('provides' => array()); $this->current_element = false; unset($this->dir_install); $this->pkginfo['filelist'] = array(); $this->filelist =& $this->pkginfo['filelist']; $this->dir_names = array(); $this->in_changelog = false; $this->d_i = 0; $this->cdata = ''; $this->_validPackageFile = false; if (!xml_parse($xp, $data, 1)) { $code = xml_get_error_code($xp); $msg = sprintf("XML error: %s at line %d", xml_error_string($code), xml_get_current_line_number($xp)); xml_parser_free($xp); return $this->raiseError($msg, $code); } xml_parser_free($xp); if (!$this->_validPackageFile) { return $this->raiseError('Invalid Package File, no <package> tag'); } foreach ($this->pkginfo as $k => $v) { if (!is_array($v)) { $this->pkginfo[$k] = trim($v); } } return $this->pkginfo; }