4,18 → 4,11 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: 11.php,v 1.8 2007/01/27 16:10:23 cellog Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.3 |
*/ |
31,9 → 24,9 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.3 |
*/ |
44,27 → 37,29 |
*/ |
var $_rest; |
|
function PEAR_REST_11($config, $options = array()) |
function __construct($config, $options = array()) |
{ |
$this->_rest = &new PEAR_REST($config, $options); |
$this->_rest = new PEAR_REST($config, $options); |
} |
|
function listAll($base, $dostable, $basic = true) |
function listAll($base, $dostable, $basic = true, $searchpackage = false, $searchsummary = false, $channel = false) |
{ |
$categorylist = $this->_rest->retrieveData($base . 'c/categories.xml'); |
$categorylist = $this->_rest->retrieveData($base . 'c/categories.xml', false, false, $channel); |
if (PEAR::isError($categorylist)) { |
return $categorylist; |
} |
|
$ret = array(); |
if (!is_array($categorylist['c']) || !isset($categorylist['c'][0])) { |
$categorylist['c'] = array($categorylist['c']); |
} |
|
PEAR::pushErrorHandling(PEAR_ERROR_RETURN); |
|
foreach ($categorylist['c'] as $progress => $category) { |
$category = $category['_content']; |
$packagesinfo = $this->_rest->retrieveData($base . |
'c/' . urlencode($category) . '/packagesinfo.xml'); |
'c/' . urlencode($category) . '/packagesinfo.xml', false, false, $channel); |
|
if (PEAR::isError($packagesinfo)) { |
continue; |
79,6 → 74,10 |
} |
|
foreach ($packagesinfo['pi'] as $packageinfo) { |
if (empty($packageinfo)) { |
continue; |
} |
|
$info = $packageinfo['p']; |
$package = $info['n']; |
$releases = isset($packageinfo['a']) ? $packageinfo['a'] : false; |
91,6 → 90,7 |
if (!isset($releases['r'][0])) { |
$releases['r'] = array($releases['r']); |
} |
|
foreach ($releases['r'] as $release) { |
if (!isset($latest)) { |
if ($dostable && $release['s'] == 'stable') { |
102,6 → 102,7 |
$state = $release['s']; |
} |
} |
|
if (!isset($stable) && $release['s'] == 'stable') { |
$stable = $release['v']; |
if (!isset($unstable)) { |
108,13 → 109,16 |
$unstable = $stable; |
} |
} |
|
if (!isset($unstable) && $release['s'] != 'stable') { |
$latest = $unstable = $release['v']; |
$unstable = $release['v']; |
$state = $release['s']; |
} |
|
if (isset($latest) && !isset($state)) { |
$state = $release['s']; |
} |
|
if (isset($latest) && isset($stable) && isset($unstable)) { |
break; |
} |
125,6 → 129,7 |
if (!isset($latest)) { |
$latest = false; |
} |
|
if ($dostable) { |
// $state is not set if there are no releases |
if (isset($state) && $state == 'stable') { |
135,11 → 140,11 |
} else { |
$ret[$package] = array('stable' => $latest); |
} |
|
continue; |
} |
|
// list-all command |
$deps = array(); |
if (!isset($unstable)) { |
$unstable = false; |
$state = 'stable'; |
154,13 → 159,14 |
$latest = false; |
} |
|
if ($latest && $packageinfo['deps'] !== null) { |
if (isset($packageinfo['deps'])) { |
$deps = array(); |
if ($latest && isset($packageinfo['deps'])) { |
if (!is_array($packageinfo['deps']) || |
!isset($packageinfo['deps'][0])) { |
!isset($packageinfo['deps'][0]) |
) { |
$packageinfo['deps'] = array($packageinfo['deps']); |
} |
} |
|
$d = false; |
foreach ($packageinfo['deps'] as $dep) { |
if ($dep['v'] == $latest) { |
167,40 → 173,150 |
$d = unserialize($dep['d']); |
} |
} |
|
if ($d) { |
if (isset($d['required'])) { |
if (!class_exists('PEAR_PackageFile_v2')) { |
require_once 'PEAR/PackageFile/v2.php'; |
} |
|
if (!isset($pf)) { |
$pf = new PEAR_PackageFile_v2; |
} |
|
$pf->setDeps($d); |
$tdeps = $pf->getDeps(); |
} else { |
$tdeps = $d; |
} |
|
foreach ($tdeps as $dep) { |
if ($dep['type'] !== 'pkg') { |
continue; |
} |
|
$deps[] = $dep; |
} |
} |
} |
|
$info = array('stable' => $latest, 'summary' => $info['s'], |
'description' => |
$info['d'], 'deps' => $deps, 'category' => $info['ca']['_content'], |
'unstable' => $unstable, 'state' => $state); |
$info = array( |
'stable' => $latest, |
'summary' => $info['s'], |
'description' => $info['d'], |
'deps' => $deps, |
'category' => $info['ca']['_content'], |
'unstable' => $unstable, |
'state' => $state |
); |
$ret[$package] = $info; |
} |
} |
|
PEAR::popErrorHandling(); |
return $ret; |
} |
|
/** |
* List all categories of a REST server |
* |
* @param string $base base URL of the server |
* @return array of categorynames |
*/ |
function listCategories($base, $channel = false) |
{ |
$categorylist = $this->_rest->retrieveData($base . 'c/categories.xml', false, false, $channel); |
if (PEAR::isError($categorylist)) { |
return $categorylist; |
} |
|
if (!is_array($categorylist) || !isset($categorylist['c'])) { |
return array(); |
} |
|
if (isset($categorylist['c']['_content'])) { |
// only 1 category |
$categorylist['c'] = array($categorylist['c']); |
} |
|
return $categorylist['c']; |
} |
|
/** |
* List packages in a category of a REST server |
* |
* @param string $base base URL of the server |
* @param string $category name of the category |
* @param boolean $info also download full package info |
* @return array of packagenames |
*/ |
function listCategory($base, $category, $info = false, $channel = false) |
{ |
if ($info == false) { |
$url = '%s'.'c/%s/packages.xml'; |
} else { |
$url = '%s'.'c/%s/packagesinfo.xml'; |
} |
$url = sprintf($url, |
$base, |
urlencode($category)); |
|
// gives '404 Not Found' error when category doesn't exist |
$packagelist = $this->_rest->retrieveData($url, false, false, $channel); |
if (PEAR::isError($packagelist)) { |
return $packagelist; |
} |
if (!is_array($packagelist)) { |
return array(); |
} |
|
if ($info == false) { |
if (!isset($packagelist['p'])) { |
return array(); |
} |
if (!is_array($packagelist['p']) || |
!isset($packagelist['p'][0])) { // only 1 pkg |
$packagelist = array($packagelist['p']); |
} else { |
$packagelist = $packagelist['p']; |
} |
return $packagelist; |
} |
|
// info == true |
if (!isset($packagelist['pi'])) { |
return array(); |
} |
|
if (!is_array($packagelist['pi']) || |
!isset($packagelist['pi'][0])) { // only 1 pkg |
$packagelist_pre = array($packagelist['pi']); |
} else { |
$packagelist_pre = $packagelist['pi']; |
} |
|
$packagelist = array(); |
foreach ($packagelist_pre as $i => $item) { |
// compatibility with r/<latest.txt>.xml |
if (isset($item['a']['r'][0])) { |
// multiple releases |
$item['p']['v'] = $item['a']['r'][0]['v']; |
$item['p']['st'] = $item['a']['r'][0]['s']; |
} elseif (isset($item['a'])) { |
// first and only release |
$item['p']['v'] = $item['a']['r']['v']; |
$item['p']['st'] = $item['a']['r']['s']; |
} |
|
$packagelist[$i] = array('attribs' => $item['p']['r'], |
'_content' => $item['p']['n'], |
'info' => $item['p']); |
} |
|
return $packagelist; |
} |
|
/** |
* Return an array containing all of the states that are more stable than |
* or equal to the passed in state |
* |