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:  * Remote access to 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:  * Remote access to 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_Remote
 29: {
 30:     /**
 31:      * The instance accessing the REST interface of the PEAR server.
 32:      *
 33:      * @var Horde_Pear_Rest
 34:      */
 35:     private $_rest;
 36: 
 37:     /**
 38:      * Constructor
 39:      *
 40:      * @param string          $server The server name.
 41:      * @param Horde_Pear_Rest $rest   The accessor to the PEAR server rest
 42:      *                                interface.
 43:      */
 44:     public function __construct($server = 'pear.horde.org',
 45:                                 Horde_Pear_Rest $rest = null)
 46:     {
 47:         if ($rest === null) {
 48:             $this->_rest = new Horde_Pear_Rest(
 49:                 new Horde_Http_Client(),
 50:                 $server
 51:             );
 52:         } else {
 53:             $this->_rest = $rest;
 54:             $this->_rest->setServer($server);
 55:         }
 56:     }
 57: 
 58:     /**
 59:      * Return the list of package names.
 60:      *
 61:      * @return array The package names.
 62:      */
 63:     public function listPackages()
 64:     {
 65:         $list = new Horde_Pear_Rest_PackageList(
 66:             $this->_rest->fetchPackageList()
 67:         );
 68:         return $list->listPackages();
 69:     }
 70: 
 71:     /**
 72:      * Return the latest release for a specific package and stability.
 73:      *
 74:      * @param string $package The name of the package.
 75:      * @param string $stability The stability of the release. Must be one of
 76:      *                          "stable", "beta", "alpha", or "devel". The
 77:      *                          default is "stable" If you explicitely set the
 78:      *                          $stability parameter to NULL the method will
 79:      *                          return the highest release version independent
 80:      *                          of the stability.
 81:      *
 82:      * @return string|boolean The latest version for this stability or false if
 83:      *                        no version with this stability level exists.
 84:      */
 85:     public function getLatestRelease($package, $stability = 'stable')
 86:     {
 87:         if ($stability === null) {
 88:             return $this->_rest->fetchLatestRelease($package);
 89:         } else {
 90:             $result = $this->_rest->fetchLatestPackageReleases($package);
 91:             return isset($result[$stability]) ? $result[$stability] : false;
 92:         }
 93:     }
 94: 
 95:     /**
 96:      * Retrieve the dependencies for the specified package release.
 97:      *
 98:      * @param string $package  The package name.
 99:      * @param string $version  The package version.
100:      *
101:      * @return array The package dependencies.
102:      */
103:     public function getDependencies($package, $version)
104:     {
105:         $deps = new Horde_Pear_Rest_Dependencies(
106:             $this->_rest->fetchPackageDependencies($package, $version)
107:         );
108:         return $deps->getDependencies();
109:     }
110: 
111:     /**
112:      * Return the package.xml for the specified release from the server.
113:      *
114:      * @param string $package The name of the package.
115:      * @param string $version The version of the release.
116:      *
117:      * @return Horde_Pear_Package_Xml The package.xml handler.
118:      */
119:     public function getPackageXml($package, $version)
120:     {
121:         return new Horde_Pear_Package_Xml(
122:             $this->_rest->fetchReleasePackageXml($package, $version)
123:         );
124:     }
125: 
126:     /**
127:      * Return the channel.xml from the server.
128:      *
129:      * @return string The content of the channel.xml file.
130:      */
131:     public function getChannel()
132:     {
133:         return $this->_rest->fetchChannelXml();
134:     }
135: 
136:     /**
137:      * Test if the specified release exists.
138:      *
139:      * @param string $package The name of the package.
140:      * @param string $version The version of the release.
141:      *
142:      * @return boolean True if the release exists.
143:      */
144:     public function releaseExists($package, $version)
145:     {
146:         return $this->_rest->releaseExists($package, $version);
147:     }
148: 
149:     /**
150:      * Retrieve the download location for the latest package release.
151:      *
152:      * @param string $package   The package name.
153:      * @param string $stability The stability the release should have. Must be one of
154:      *                          "stable", "beta", "alpha", or "devel". The
155:      *                          default is "stable" If you explicitely set the
156:      *                          $stability parameter to NULL the method will
157:      *                          return the download URI for the highest release
158:      *                          version independent of the stability.
159:      *
160:      * @return string The URI for downloading the release.
161:      *
162:      * @throws Horde_Pear_Exception In case there is no release for
163:      *                              this package with the specified
164:      *                              stability level.
165:      */
166:     public function getLatestDownloadUri($package, $stability = 'stable')
167:     {
168:         if ($latest = $this->getLatestRelease($package, $stability)) {
169:             return $this->_getRelease($package, $latest)->getDownloadUri();
170:         } else {
171:             throw new Horde_Pear_Exception(
172:                 sprintf(
173:                     'No release of stability "%s" for package "%s".',
174:                     $stability,
175:                     $package
176:                 )
177:             );
178:         }
179:     }
180: 
181:     /**
182:      * Retrieve the release details for the most stable package version.
183:      *
184:      * @param string $package   The package name.
185:      * @param string $stability The stability of the release. Must be one of
186:      *                          "stable", "beta", "alpha", or "devel". The
187:      *                          default is "stable" If you explicitely set the
188:      *                          $stability parameter to NULL the method will
189:      *                          return the details for the highest release
190:      *                          version independent of the stability.
191:      *
192:      * @return Horde_Pear_Rest_Release|boolean The details of the most stable
193:      *                                         release. Or false if no release
194:      *                                         was found.
195:      */
196:     public function getLatestDetails($package, $stability = 'stable')
197:     {
198:         $result = false;
199:         if ($latest = $this->getLatestRelease($package, $stability)) {
200:             return $this->_getRelease($package, $latest);
201:         }
202:         return $result;
203:     }
204: 
205:     /**
206:      * Return the release information wrapper for a specific package version
207:      * from the server.
208:      *
209:      * @param string $package The name of the package.
210:      * @param string $version The version of the release.
211:      *
212:      * @return Horde_Pear_Rest_Release The wrapper.
213:      */
214:     private function _getRelease($package, $version)
215:     {
216:         return new Horde_Pear_Rest_Release(
217:             $this->_rest->fetchReleaseInformation($package, $version)
218:         );
219:     }
220: }
API documentation generated by ApiGen