Overview

Packages

  • Pear

Classes

  • Horde_Pear_Exception
  • Horde_Pear_Package_Contents_Ignore_Composite
  • Horde_Pear_Package_Contents_Ignore_Dot
  • Horde_Pear_Package_Contents_Ignore_Git
  • Horde_Pear_Package_Contents_Ignore_Hidden
  • Horde_Pear_Package_Contents_Ignore_Nothing
  • Horde_Pear_Package_Contents_Ignore_Patterns
  • Horde_Pear_Package_Contents_Include_All
  • Horde_Pear_Package_Contents_InstallAs_Horde
  • Horde_Pear_Package_Contents_InstallAs_HordeApplication
  • Horde_Pear_Package_Contents_InstallAs_HordeComponent
  • Horde_Pear_Package_Contents_InstallAs_HordeRole
  • Horde_Pear_Package_Contents_List
  • Horde_Pear_Package_Contents_Role_HordeApplication
  • Horde_Pear_Package_Contents_Role_HordeComponent
  • Horde_Pear_Package_Dependencies
  • Horde_Pear_Package_Task_UpdateContents
  • Horde_Pear_Package_Type_Horde
  • Horde_Pear_Package_Xml
  • Horde_Pear_Package_Xml_Contents
  • Horde_Pear_Package_Xml_Directory
  • Horde_Pear_Package_Xml_Element_Directory
  • Horde_Pear_Package_Xml_Element_File
  • Horde_Pear_Package_Xml_Factory
  • Horde_Pear_Registry
  • Horde_Pear_Remote
  • Horde_Pear_Rest
  • Horde_Pear_Rest_Dependencies
  • Horde_Pear_Rest_Package
  • Horde_Pear_Rest_PackageList
  • Horde_Pear_Rest_Release
  • Horde_Pear_Rest_Releases

Interfaces

  • Horde_Pear_Package_Contents
  • Horde_Pear_Package_Contents_Ignore
  • Horde_Pear_Package_Contents_Include
  • Horde_Pear_Package_Contents_InstallAs
  • Horde_Pear_Package_Contents_Role
  • Horde_Pear_Package_Task
  • Horde_Pear_Package_Type
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * A parser for a package list response from a PEAR server.
  4:  *
  5:  * PHP version 5
  6:  *
  7:  * @category Horde
  8:  * @package  Pear
  9:  * @author   Gunnar Wrobel <wrobel@pardus.de>
 10:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 11:  * @link     http://pear.horde.org/index.php?package=Pear
 12:  */
 13: 
 14: /**
 15:  * A parser for a package list response from a PEAR server.
 16:  *
 17:  * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
 18:  *
 19:  * See the enclosed file COPYING for license information (LGPL). If you
 20:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 21:  *
 22:  * @category Horde
 23:  * @package  Pear
 24:  * @author   Gunnar Wrobel <wrobel@pardus.de>
 25:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 26:  * @link     http://pear.horde.org/index.php?package=Pear
 27:  */
 28: class Horde_Pear_Rest_PackageList extends Horde_Xml_Element_List
 29: {
 30:     /**
 31:      * The list of packages.
 32:      *
 33:      * @var array
 34:      */
 35:     private $_packages;
 36: 
 37:     /**
 38:      * Constructor.
 39:      *
 40:      * @param resource|string $xml The XML document received from the server.
 41:      */
 42:     public function __construct($xml)
 43:     {
 44:         if (is_resource($xml)) {
 45:             rewind($xml);
 46:             $xml = stream_get_contents($xml);
 47:         }
 48:         parent::registerNamespace('xlink', 'http://www.w3.org/1999/xlink');
 49:         parent::__construct($xml);
 50:         $this->_packages = $this->_buildPackageList();
 51:     }
 52: 
 53:     /**
 54:      * Build the list of elements.
 55:      *
 56:      * @return array The list of elements.
 57:      */
 58:     protected function _buildListItemCache()
 59:     {
 60:         $entries = array();
 61:         foreach ($this->_element->getElementsByTagName('p') as $child) {
 62:             $entries[] = $child;
 63:         }
 64:         return $entries;
 65:     }
 66: 
 67:     /**
 68:      * Build the list of packages.
 69:      *
 70:      * @return array The list of elements.
 71:      */
 72:     private function _buildPackageList()
 73:     {
 74:         $packages = array();
 75:         foreach ($this->p as $p) {
 76:             $packages[(string)$p] = $p['xlink:href'];
 77:         }
 78:         return $packages;
 79:     }
 80: 
 81:     /**
 82:      * Return the list of package names.
 83:      *
 84:      * @return array The package names.
 85:      */
 86:     public function listPackages()
 87:     {
 88:         return array_keys($this->_packages);
 89:     }
 90: 
 91:     /**
 92:      * Return the list of packages.
 93:      *
 94:      * @return array The packages.
 95:      */
 96:     public function getPackages()
 97:     {
 98:         return $this->_packages;
 99:     }
100: 
101:     /**
102:      * Return the link for additional information on the specified package.
103:      *
104:      * @param string $package The package name.
105:      *
106:      * @return string The URL for additional information.
107:      */
108:     public function getPackageLink($package)
109:     {
110:         if (isset($this->_packages[$package])) {
111:             return $this->_packages[$package];
112:         } else {
113:             throw new Horde_Pear_Exception(
114:                 sprintf('No package named "%s" available!', $package)
115:             );
116:         }
117:     }
118: }
API documentation generated by ApiGen