| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * PEAR_ChannelFile_Parser for parsing channel.xml |
|---|
| 4 | * |
|---|
| 5 | * PHP versions 4 and 5 |
|---|
| 6 | * |
|---|
| 7 | * @category pear |
|---|
| 8 | * @package PEAR |
|---|
| 9 | * @author Greg Beaver <[email protected]> |
|---|
| 10 | * @copyright 1997-2009 The Authors |
|---|
| 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License |
|---|
| 12 | * @version CVS: $Id: Parser.php 313023 2011-07-06 19:17:11Z dufuz $ |
|---|
| 13 | * @link http://pear.php.net/package/PEAR |
|---|
| 14 | * @since File available since Release 1.4.0a1 |
|---|
| 15 | */ |
|---|
| 16 | |
|---|
| 17 | /** |
|---|
| 18 | * base xml parser class |
|---|
| 19 | */ |
|---|
| 20 | require_once 'PEAR/XMLParser.php'; |
|---|
| 21 | require_once 'PEAR/ChannelFile.php'; |
|---|
| 22 | /** |
|---|
| 23 | * Parser for channel.xml |
|---|
| 24 | * @category pear |
|---|
| 25 | * @package PEAR |
|---|
| 26 | * @author Greg Beaver <[email protected]> |
|---|
| 27 | * @copyright 1997-2009 The Authors |
|---|
| 28 | * @license http://opensource.org/licenses/bsd-license.php New BSD License |
|---|
| 29 | * @version Release: 1.9.4 |
|---|
| 30 | * @link http://pear.php.net/package/PEAR |
|---|
| 31 | * @since Class available since Release 1.4.0a1 |
|---|
| 32 | */ |
|---|
| 33 | class PEAR_ChannelFile_Parser extends PEAR_XMLParser |
|---|
| 34 | { |
|---|
| 35 | var $_config; |
|---|
| 36 | var $_logger; |
|---|
| 37 | var $_registry; |
|---|
| 38 | |
|---|
| 39 | function setConfig(&$c) |
|---|
| 40 | { |
|---|
| 41 | $this->_config = &$c; |
|---|
| 42 | $this->_registry = &$c->getRegistry(); |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | function setLogger(&$l) |
|---|
| 46 | { |
|---|
| 47 | $this->_logger = &$l; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | function parse($data, $file) |
|---|
| 51 | { |
|---|
| 52 | if (PEAR::isError($err = parent::parse($data, $file))) { |
|---|
| 53 | return $err; |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | $ret = new PEAR_ChannelFile; |
|---|
| 57 | $ret->setConfig($this->_config); |
|---|
| 58 | if (isset($this->_logger)) { |
|---|
| 59 | $ret->setLogger($this->_logger); |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | $ret->fromArray($this->_unserializedData); |
|---|
| 63 | // make sure the filelist is in the easy to read format needed |
|---|
| 64 | $ret->flattenFilelist(); |
|---|
| 65 | $ret->setPackagefile($file, $archive); |
|---|
| 66 | return $ret; |
|---|
| 67 | } |
|---|
| 68 | } |
|---|