Parser.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 <cellog@php.net>
  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. * base xml parser class
  18. */
  19. require_once 'PEAR/XMLParser.php';
  20. require_once 'PEAR/ChannelFile.php';
  21. /**
  22. * Parser for channel.xml
  23. * @category pear
  24. * @package PEAR
  25. * @author Greg Beaver <cellog@php.net>
  26. * @copyright 1997-2009 The Authors
  27. * @license http://opensource.org/licenses/bsd-license.php New BSD License
  28. * @version Release: 1.9.4
  29. * @link http://pear.php.net/package/PEAR
  30. * @since Class available since Release 1.4.0a1
  31. */
  32. class PEAR_ChannelFile_Parser extends PEAR_XMLParser
  33. {
  34. var $_config;
  35. var $_logger;
  36. var $_registry;
  37. function setConfig(&$c)
  38. {
  39. $this->_config = &$c;
  40. $this->_registry = &$c->getRegistry();
  41. }
  42. function setLogger(&$l)
  43. {
  44. $this->_logger = &$l;
  45. }
  46. function parse($data, $file)
  47. {
  48. if (PEAR::isError($err = parent::parse($data, $file))) {
  49. return $err;
  50. }
  51. $ret = new PEAR_ChannelFile;
  52. $ret->setConfig($this->_config);
  53. if (isset($this->_logger)) {
  54. $ret->setLogger($this->_logger);
  55. }
  56. $ret->fromArray($this->_unserializedData);
  57. // make sure the filelist is in the easy to read format needed
  58. $ret->flattenFilelist();
  59. $ret->setPackagefile($file, $archive);
  60. return $ret;
  61. }
  62. }