<?php
 require_once 'PEAR/XMLParser.php'; require_once 'PEAR/PackageFile/v2.php'; class PEAR_PackageFile_Parser_v2 extends PEAR_XMLParser { var $_config; var $_logger; var $_registry; function setConfig(&$c) { $this->_config = &$c; $this->_registry = &$c->getRegistry(); } function setLogger(&$l) { $this->_logger = &$l; } function _unIndent($str) { $str = preg_replace('/^[\r\n]+/', '', $str); $indent_len = strspn($str, " \t"); $indent = substr($str, 0, $indent_len); $data = ''; foreach (explode("\n", $str) as $line) { if (substr($line, 0, $indent_len) == $indent) { $data .= substr($line, $indent_len) . "\n"; } else { $data .= $line . "\n"; } } return $data; } function postProcess($data, $element) { if ($element == 'notes') { return trim($this->_unIndent($data)); } return trim($data); } function &parse($data, $file, $archive = false, $class = 'PEAR_PackageFile_v2') { if (PEAR::isError($err = parent::parse($data, $file))) { return $err; } $ret = new $class; $ret->encoding = $this->encoding; $ret->setConfig($this->_config); if (isset($this->_logger)) { $ret->setLogger($this->_logger); } $ret->fromArray($this->_unserializedData); $ret->setPackagefile($file, $archive); return $ret; } }