本文整理汇总了PHP中PEAR_PackageFile_v2类的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_PackageFile_v2类的具体用法?PHP PEAR_PackageFile_v2怎么用?PHP PEAR_PackageFile_v2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PEAR_PackageFile_v2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
function parse($data, $file, $archive = false)
{
if (PEAR::isError($err = parent::parse($data, $file))) {
return $err;
}
$ret = new PEAR_PackageFile_v2();
$ret->setConfig($this->_config);
if (isset($this->_logger)) {
$ret->setLogger($this->_logger);
}
$ret->fromArray($this->_unserializedData);
$ret->setPackagefile($file, $archive);
return $ret;
}
示例2: _getDepPackageDownloadUrl
/**
* @param array dependency array
* @access private
*/
function _getDepPackageDownloadUrl($dep, $parr)
{
$xsdversion = isset($dep['rel']) ? '1.0' : '2.0';
$curchannel = $this->config->get('default_channel');
if (isset($dep['uri'])) {
$xsdversion = '2.0';
$chan =& $this->_registry->getChannel('__uri');
if (PEAR::isError($chan)) {
return $chan;
}
$version = $this->_registry->packageInfo($dep['name'], 'version', '__uri');
$this->configSet('default_channel', '__uri');
} else {
if (isset($dep['channel'])) {
$remotechannel = $dep['channel'];
} else {
$remotechannel = 'pear.php.net';
}
if (!$this->_registry->channelExists($remotechannel)) {
do {
if ($this->config->get('auto_discover')) {
if ($this->discover($remotechannel)) {
break;
}
}
return PEAR::raiseError('Unknown remote channel: ' . $remotechannel);
} while (false);
}
$chan =& $this->_registry->getChannel($remotechannel);
if (PEAR::isError($chan)) {
return $chan;
}
$version = $this->_registry->packageInfo($dep['name'], 'version', $remotechannel);
$this->configSet('default_channel', $remotechannel);
}
$state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state');
if (isset($parr['state']) && isset($parr['version'])) {
unset($parr['state']);
}
if (isset($dep['uri'])) {
$info =& $this->newDownloaderPackage($this);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$err = $info->initialize($dep);
PEAR::staticPopErrorHandling();
if (!$err) {
// skip parameters that were missed by preferred_state
return PEAR::raiseError('Cannot initialize dependency');
}
if (PEAR::isError($err)) {
if (!isset($this->_options['soft'])) {
$this->log(0, $err->getMessage());
}
if (is_object($info)) {
$param = $info->getChannel() . '/' . $info->getPackage();
}
return PEAR::raiseError('Package "' . $param . '" is not valid');
}
return $info;
} elseif ($chan->supportsREST($this->config->get('preferred_mirror')) && (($base2 = $chan->getBaseURL('REST1.3', $this->config->get('preferred_mirror'))) || ($base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))))) {
if ($base2) {
$base = $base2;
$rest =& $this->config->getREST('1.3', $this->_options);
} else {
$rest =& $this->config->getREST('1.0', $this->_options);
}
$url = $rest->getDepDownloadURL($base, $xsdversion, $dep, $parr, $state, $version, $chan->getName());
if (PEAR::isError($url)) {
return $url;
}
if ($parr['channel'] != $curchannel) {
$this->configSet('default_channel', $curchannel);
}
if (!is_array($url)) {
return $url;
}
$url['raw'] = false;
// no checking is necessary for REST
if (!is_array($url['info'])) {
return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . 'this should never happen');
}
if (isset($url['info']['required'])) {
if (!class_exists('PEAR_PackageFile_v2')) {
require_once 'PEAR/PackageFile/v2.php';
}
$pf = new PEAR_PackageFile_v2();
$pf->setRawChannel($remotechannel);
} else {
if (!class_exists('PEAR_PackageFile_v1')) {
require_once 'PEAR/PackageFile/v1.php';
}
$pf = new PEAR_PackageFile_v1();
}
$pf->setRawPackage($url['package']);
$pf->setDeps($url['info']);
if ($url['compatible']) {
$pf->setCompatible($url['compatible']);
//.........这里部分代码省略.........
示例3: listAll
//.........这里部分代码省略.........
unset($state);
if ($releases) {
if (!isset($releases['r'][0])) {
$releases['r'] = array($releases['r']);
}
foreach ($releases['r'] as $release) {
if (!isset($latest)) {
if ($dostable && $release['s'] == 'stable') {
$latest = $release['v'];
$state = 'stable';
}
if (!$dostable) {
$latest = $release['v'];
$state = $release['s'];
}
}
if (!isset($stable) && $release['s'] == 'stable') {
$stable = $release['v'];
if (!isset($unstable)) {
$unstable = $stable;
}
}
if (!isset($unstable) && $release['s'] != 'stable') {
$unstable = $release['v'];
$state = $release['s'];
}
if (isset($latest) && !isset($state)) {
$state = $release['s'];
}
if (isset($latest) && isset($stable) && isset($unstable)) {
break;
}
}
}
if ($basic) {
// remote-list command
if (!isset($latest)) {
$latest = false;
}
if ($dostable) {
// $state is not set if there are no releases
if (isset($state) && $state == 'stable') {
$ret[$package] = array('stable' => $latest);
} else {
$ret[$package] = array('stable' => '-n/a-');
}
} else {
$ret[$package] = array('stable' => $latest);
}
continue;
}
// list-all command
$deps = array();
if (!isset($unstable)) {
$unstable = false;
$state = 'stable';
if (isset($stable)) {
$latest = $unstable = $stable;
}
} else {
$latest = $unstable;
}
if (!isset($latest)) {
$latest = false;
}
if ($latest && isset($packageinfo['deps'])) {
if (!is_array($packageinfo['deps']) || !isset($packageinfo['deps'][0])) {
$packageinfo['deps'] = array($packageinfo['deps']);
}
$d = false;
foreach ($packageinfo['deps'] as $dep) {
if ($dep['v'] == $latest) {
$d = unserialize($dep['d']);
}
}
if ($d) {
if (isset($d['required'])) {
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);
$ret[$package] = $info;
}
}
PEAR::popErrorHandling();
return $ret;
}
示例4: loadLocal
public function loadLocal($package, $options = array())
{
$pear = $this->getPear();
$pear->getFrontend()->clear();
$result = $pear->run('info', $options, array($package));
if ($result instanceof PEAR_Error) {
Mage::throwException($result->message);
break;
}
$output = $pear->getOutput();
$pkg = new PEAR_PackageFile_v2();
$pkg->fromArray($output[0]['output']['raw']);
return $pkg;
}
示例5: packageInfo
function packageInfo($base, $package)
{
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$pinfo = $this->_rest->retrieveData($base . 'p/' . strtolower($package) . '/info.xml');
if (PEAR::isError($pinfo)) {
PEAR::popErrorHandling();
return PEAR::raiseError('Unknown package: "' . $package . '" (Debug: ' . $pinfo->getMessage() . ')');
}
$releases = array();
$allreleases = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/allreleases.xml');
if (!PEAR::isError($allreleases)) {
if (!class_exists('PEAR_PackageFile_v2')) {
require_once 'PEAR/PackageFile/v2.php';
}
if (!is_array($allreleases['r']) || !isset($allreleases['r'][0])) {
$allreleases['r'] = array($allreleases['r']);
}
$pf = new PEAR_PackageFile_v2();
foreach ($allreleases['r'] as $release) {
$ds = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/deps.' . $release['v'] . '.txt');
if (PEAR::isError($ds)) {
continue;
}
if (!isset($latest)) {
$latest = $release['v'];
}
$pf->setDeps(unserialize($ds));
$ds = $pf->getDeps();
$info = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/' . $release['v'] . '.xml');
if (PEAR::isError($info)) {
continue;
}
$releases[$release['v']] = array('doneby' => $info['m'], 'license' => $info['l'], 'summary' => $info['s'], 'description' => $info['d'], 'releasedate' => $info['da'], 'releasenotes' => $info['n'], 'state' => $release['s'], 'deps' => $ds ? $ds : array());
}
} else {
$latest = '';
}
PEAR::popErrorHandling();
if (isset($pinfo['dc']) && isset($pinfo['dp'])) {
if (is_array($pinfo['dp'])) {
$deprecated = array('channel' => (string) $pinfo['dc'], 'package' => trim($pinfo['dp']['_content']));
} else {
$deprecated = array('channel' => (string) $pinfo['dc'], 'package' => trim($pinfo['dp']));
}
} else {
$deprecated = false;
}
return array('name' => $pinfo['n'], 'channel' => $pinfo['c'], 'category' => $pinfo['ca']['_content'], 'stable' => $latest, 'license' => $pinfo['l'], 'summary' => $pinfo['s'], 'description' => $pinfo['d'], 'releases' => $releases, 'deprecated' => $deprecated);
}
示例6: _getDepPackageDownloadUrl
/**
* @param array dependency array
* @access private
*/
function _getDepPackageDownloadUrl($dep, $parr)
{
$xsdversion = isset($dep['rel']) ? '1.0' : '2.0';
$curchannel = $this->config->get('default_channel');
if (isset($dep['channel'])) {
$remotechannel = $dep['channel'];
} else {
$remotechannel = 'pear.php.net';
}
if (!$this->_registry->channelExists($remotechannel)) {
do {
if ($this->config->get('auto_discover')) {
if ($this->discover($remotechannel)) {
break;
}
}
return PEAR::raiseError('Unknown remote channel: ' . $remotechannel);
} while (false);
}
$this->configSet('default_channel', $remotechannel);
$state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state');
if (isset($parr['state']) && isset($parr['version'])) {
unset($parr['state']);
}
$chan =& $this->_registry->getChannel($remotechannel);
if (PEAR::isError($chan)) {
return $chan;
}
$version = $this->_registry->packageInfo($dep['name'], 'version', $remotechannel);
if ($chan->supportsREST($this->config->get('preferred_mirror')) && ($base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror')))) {
$rest =& $this->config->getREST('1.0', $this->_options);
$url = $rest->getDepDownloadURL($base, $xsdversion, $dep, $parr, $state, $version);
if (PEAR::isError($url)) {
return $url;
}
if ($parr['channel'] != $curchannel) {
$this->configSet('default_channel', $curchannel);
}
if (!is_array($url)) {
return $url;
}
$url['raw'] = false;
// no checking is necessary for REST
if (!is_array($url['info'])) {
return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . 'this should never happen');
}
if (isset($url['info']['required'])) {
if (!class_exists('PEAR_PackageFile_v2')) {
require_once 'PEAR/PackageFile/v2.php';
}
$pf = new PEAR_PackageFile_v2();
$pf->setRawChannel($remotechannel);
} else {
if (!class_exists('PEAR_PackageFile_v1')) {
require_once 'PEAR/PackageFile/v1.php';
}
$pf = new PEAR_PackageFile_v1();
}
$pf->setRawPackage($url['package']);
$pf->setDeps($url['info']);
$pf->setRawState($url['stability']);
$url['info'] =& $pf;
if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) {
$ext = '.tar';
} else {
$ext = '.tgz';
}
if (is_array($url)) {
if (isset($url['url'])) {
$url['url'] .= $ext;
}
}
return $url;
} elseif ($chan->supports('xmlrpc', 'package.getDepDownloadURL', false, '1.1')) {
if ($version) {
$url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state, $version);
} else {
$url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state);
}
} else {
$url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state);
}
if ($parr['channel'] != $curchannel) {
$this->configSet('default_channel', $curchannel);
}
if (!is_array($url)) {
return $url;
}
if (isset($url['__PEAR_ERROR_CLASS__'])) {
return PEAR::raiseError($url['message']);
}
$url['raw'] = $url['info'];
$pkg =& $this->getPackagefileObject($this->config, $this->debug);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$pinfo =& $pkg->fromXmlString($url['info'], PEAR_VALIDATE_DOWNLOADING, 'remote');
PEAR::staticPopErrorHandling();
//.........这里部分代码省略.........
示例7: Array
/**
* @param array $xml contents of postinstallscript tag
* example: Array (
[paramgroup] => Array (
[id] => webSetup
[param] => Array (
[name] => webdirpath
[prompt] => Where should... ?
[default] => '/var/www/htdocs/webpear
[type] => string
)
)
)
* @param object $script post-installation script
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 $pkg
* @param string $contents contents of the install script
*/
function runInstallScript($xml, &$script, &$pkg)
{
if (!isset($_SESSION['_PEAR_Frontend_Web_ScriptCompletedPhases'])) {
$_SESSION['_PEAR_Frontend_Web_ScriptCompletedPhases'] = array();
$_SESSION['_PEAR_Frontend_Web_ScriptSkipSections'] = array();
}
if (isset($_SESSION['_PEAR_Frontend_Web_ScriptObj'])) {
foreach ($_SESSION['_PEAR_Frontend_Web_ScriptObj'] as $name => $val) {
if ($name[0] == '_') {
// only public variables will be restored
continue;
}
$script->{$name} = $val;
}
} else {
$_SESSION['_PEAR_Frontend_Web_ScriptObj'] = (array) $script;
}
if (!is_array($xml) || !isset($xml['paramgroup'])) {
$script->run(array(), '_default');
} else {
if (!isset($xml['paramgroup'][0])) {
$xml['paramgroup'] = array($xml['paramgroup']);
}
foreach ($xml['paramgroup'] as $i => $group) {
if (isset($_SESSION['_PEAR_Frontend_Web_ScriptSkipSections'][$group['id']])) {
continue;
}
if (isset($_SESSION['_PEAR_Frontend_Web_ScriptSection'])) {
if ($i < $_SESSION['_PEAR_Frontend_Web_ScriptSection']) {
$lastgroup = $group;
continue;
}
}
if (isset($_SESSION['_PEAR_Frontend_Web_answers'])) {
$answers = $_SESSION['_PEAR_Frontend_Web_answers'];
}
if (isset($group['name'])) {
if (isset($answers)) {
if (isset($answers[$group['name']])) {
switch ($group['conditiontype']) {
case '=':
if ($answers[$group['name']] != $group['value']) {
continue 2;
}
break;
case '!=':
if ($answers[$group['name']] == $group['value']) {
continue 2;
}
break;
case 'preg_match':
if (!@preg_match('/' . $group['value'] . '/', $answers[$group['name']])) {
continue 2;
}
break;
default:
$this->_clearScriptSession();
return;
}
}
} else {
$this->_clearScriptSession();
return;
}
}
if (!isset($group['param'][0])) {
$group['param'] = array($group['param']);
}
$_SESSION['_PEAR_Frontend_Web_ScriptSection'] = $i;
if (!isset($answers)) {
$answers = array();
}
if (isset($group['param'])) {
if (method_exists($script, 'postProcessPrompts')) {
$prompts = $script->postProcessPrompts($group['param'], $group['name']);
if (!is_array($prompts) || count($prompts) != count($group['param'])) {
$this->outputData('postinstall', 'Error: post-install script did not ' . 'return proper post-processed prompts');
$prompts = $group['param'];
} else {
foreach ($prompts as $i => $var) {
if (!is_array($var) || !isset($var['prompt']) || !isset($var['name']) || $var['name'] != $group['param'][$i]['name'] || $var['type'] != $group['param'][$i]['type']) {
$this->outputData('postinstall', 'Error: post-install script ' . 'modified the variables or prompts, severe security risk. ' . 'Will instead use the defaults from the package.xml');
$prompts = $group['param'];
//.........这里部分代码省略.........
示例8: setOld
/**
* @return void
* @since 1.6.0a1
*/
function setOld()
{
$this->_oldPackageFile = new PEAR_PackageFile_v2_rw();
$this->_oldPackageFile->fromArray($this->getArray());
}
示例9: array
//.........这里部分代码省略.........
$arr['summary'] = $this->_packagefile->getSummary();
$arr['description'] = $this->_packagefile->getDescription();
$maintainers = $this->_packagefile->getMaintainers();
foreach ($maintainers as $maintainer) {
if ($maintainer['role'] != 'lead') {
continue;
}
$new = array('name' => $maintainer['name'], 'user' => $maintainer['handle'], 'email' => $maintainer['email'], 'active' => 'yes');
$arr['lead'][] = $new;
}
if (!isset($arr['lead'])) {
// some people... you know?
$arr['lead'] = array('name' => 'unknown', 'user' => 'unknown', 'email' => 'noleadmaintainer@example.com', 'active' => 'no');
}
if (count($arr['lead']) == 1) {
$arr['lead'] = $arr['lead'][0];
}
foreach ($maintainers as $maintainer) {
if ($maintainer['role'] == 'lead') {
continue;
}
$new = array('name' => $maintainer['name'], 'user' => $maintainer['handle'], 'email' => $maintainer['email'], 'active' => 'yes');
$arr[$maintainer['role']][] = $new;
}
if (isset($arr['developer']) && count($arr['developer']) == 1) {
$arr['developer'] = $arr['developer'][0];
}
if (isset($arr['contributor']) && count($arr['contributor']) == 1) {
$arr['contributor'] = $arr['contributor'][0];
}
if (isset($arr['helper']) && count($arr['helper']) == 1) {
$arr['helper'] = $arr['helper'][0];
}
$arr['date'] = $this->_packagefile->getDate();
$arr['version'] = array('release' => $this->_packagefile->getVersion(), 'api' => $this->_packagefile->getVersion());
$arr['stability'] = array('release' => $this->_packagefile->getState(), 'api' => $this->_packagefile->getState());
$licensemap = array('php license' => 'http://www.php.net/license', 'lgpl' => 'http://www.gnu.org/copyleft/lesser.html', 'bsd' => 'http://www.opensource.org/licenses/bsd-license.php', 'mit' => 'http://www.opensource.org/licenses/mit-license.php', 'gpl' => 'http://www.gnu.org/copyleft/gpl.html', 'apache' => 'http://www.opensource.org/licenses/apache2.0.php');
if (isset($licensemap[strtolower($this->_packagefile->getLicense())])) {
$uri = $licensemap[strtolower($this->_packagefile->getLicense())];
} else {
$uri = 'http://www.example.com';
}
$arr['license'] = array('attribs' => array('uri' => $uri), '_content' => $this->_packagefile->getLicense());
$arr['notes'] = $this->_packagefile->getNotes();
$temp = array();
$arr['contents'] = $this->_convertFilelist2_0($temp);
$this->_convertDependencies2_0($arr);
$release = $this->_packagefile->getConfigureOptions() || $this->_isExtension ? 'extsrcrelease' : 'phprelease';
if ($release == 'extsrcrelease') {
$arr['channel'] = 'pecl.php.net';
$arr['providesextension'] = strtolower($arr['name']);
// assumption
}
$arr[$release] = array();
if ($this->_packagefile->getConfigureOptions()) {
$arr[$release]['configureoption'] = $this->_packagefile->getConfigureOptions();
foreach ($arr[$release]['configureoption'] as $i => $opt) {
$arr[$release]['configureoption'][$i] = array('attribs' => $opt);
}
if (count($arr[$release]['configureoption']) == 1) {
$arr[$release]['configureoption'] = $arr[$release]['configureoption'][0];
}
}
$this->_convertRelease2_0($arr[$release], $temp);
if ($cl = $this->_packagefile->getChangelog()) {
foreach ($cl as $release) {
$rel = array();
$rel['version'] = array('release' => $release['version'], 'api' => $release['version']);
if (!isset($release['release_state'])) {
$release['release_state'] = 'stable';
}
$rel['stability'] = array('release' => $release['release_state'], 'api' => $release['release_state']);
if (isset($release['release_date'])) {
$rel['date'] = $release['release_date'];
} else {
$rel['date'] = date('Y-m-d');
}
if (isset($release['release_license'])) {
if (isset($licensemap[strtolower($release['release_license'])])) {
$uri = $licensemap[strtolower($release['release_license'])];
} else {
$uri = 'http://www.example.com';
}
$rel['license'] = array('attribs' => array('uri' => $uri), '_content' => $release['release_license']);
} else {
$rel['license'] = $arr['license'];
}
if (!isset($release['release_notes'])) {
$release['release_notes'] = 'no release notes';
}
$rel['notes'] = $release['release_notes'];
$arr['changelog']['release'][] = $rel;
}
}
$ret = new PEAR_PackageFile_v2();
$ret->setConfig($this->_packagefile->_config);
$ret->setLogger($this->_packagefile->_logger);
$ret->fromArray($arr);
return $ret;
}
示例10: REST_listAll
//.........这里部分代码省略.........
return $inf;
}
if ($searchpackage) {
$found = !empty($searchpackage) && stristr($package, $searchpackage) !== false;
if (!$found && !(isset($searchsummary) && !empty($searchsummary) && (stristr($inf['s'], $searchsummary) !== false || stristr($inf['d'], $searchsummary) !== false))) {
continue;
}
}
$releases = $rest->_rest->retrieveData($base . 'r/' . strtolower($package) . '/allreleases.xml');
if (PEAR::isError($releases)) {
continue;
}
if (!isset($releases['r'][0])) {
$releases['r'] = array($releases['r']);
}
unset($latest);
unset($unstable);
unset($stable);
unset($state);
foreach ($releases['r'] as $release) {
if (!isset($latest)) {
if ($dostable && $release['s'] == 'stable') {
$latest = $release['v'];
$state = 'stable';
}
if (!$dostable) {
$latest = $release['v'];
$state = $release['s'];
}
}
if (!isset($stable) && $release['s'] == 'stable') {
$stable = $release['v'];
if (!isset($unstable)) {
$unstable = $stable;
}
}
if (!isset($unstable) && $release['s'] != 'stable') {
$latest = $unstable = $release['v'];
$state = $release['s'];
}
if (isset($latest) && !isset($state)) {
$state = $release['s'];
}
if (isset($latest) && isset($stable) && isset($unstable)) {
break;
}
}
$deps = array();
if (!isset($unstable)) {
$unstable = false;
$state = 'stable';
if (isset($stable)) {
$latest = $unstable = $stable;
}
} else {
$latest = $unstable;
}
if (!isset($latest)) {
$latest = false;
}
if ($latest) {
$d = $rest->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/deps.' . $latest . '.txt');
if (!PEAR::isError($d)) {
$d = unserialize($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;
}
}
}
}
if (!isset($stable)) {
$stable = '-n/a-';
}
if (!$searchpackage) {
$info = array('stable' => $latest, 'summary' => $inf['s'], 'description' => $inf['d'], 'deps' => $deps, 'category' => $inf['ca']['_content'], 'unstable' => $unstable, 'state' => $state);
} else {
$info = array('stable' => $stable, 'summary' => $inf['s'], 'description' => $inf['d'], 'deps' => $deps, 'category' => $inf['ca']['_content'], 'unstable' => $unstable, 'state' => $state);
}
}
$ret[$package] = $info;
}
PEAR::popErrorHandling();
return $ret;
}
示例11: array
/**
* Strip the tasks: namespace from internal params
*
* @access private
*/
function _stripNamespace($params = null)
{
if ($params === null) {
$params = array();
if (!is_array($this->_params)) {
return;
}
foreach ($this->_params as $i => $param) {
if (is_array($param)) {
$param = $this->_stripNamespace($param);
}
$params[str_replace($this->_pkg->getTasksNs() . ':', '', $i)] = $param;
}
$this->_params = $params;
} else {
$newparams = array();
foreach ($params as $i => $param) {
if (is_array($param)) {
$param = $this->_stripNamespace($param);
}
$newparams[str_replace($this->_pkg->getTasksNs() . ':', '', $i)] = $param;
}
return $newparams;
}
}
示例12: toXml
/**
* Return an XML document based on the package info (as returned
* by the PEAR_Common::infoFrom* methods).
*
* @return string XML data
*/
function toXml($state = PEAR_VALIDATE_NORMAL, $options = array())
{
$this->_packagefile->setDate(date('Y-m-d'));
$this->_packagefile->setTime(date('H:i:s'));
if (!$this->_packagefile->validate($state)) {
return false;
}
if (is_array($options)) {
$this->options = array_merge($this->_defaultOptions, $options);
} else {
$this->options = $this->_defaultOptions;
}
$arr = $this->_packagefile->getArray();
if (isset($arr['filelist'])) {
unset($arr['filelist']);
}
if (isset($arr['_lastversion'])) {
unset($arr['_lastversion']);
}
// Fix the notes a little bit
if (isset($arr['notes'])) {
// This trims out the indenting, needs fixing
$arr['notes'] = "\n" . trim($arr['notes']) . "\n";
}
if (isset($arr['changelog']) && !empty($arr['changelog'])) {
// Fix for inconsistency how the array is filled depending on the changelog release amount
if (!isset($arr['changelog']['release'][0])) {
$release = $arr['changelog']['release'];
unset($arr['changelog']['release']);
$arr['changelog']['release'] = array();
$arr['changelog']['release'][0] = $release;
}
foreach (array_keys($arr['changelog']['release']) as $key) {
$c =& $arr['changelog']['release'][$key];
if (isset($c['notes'])) {
// This trims out the indenting, needs fixing
$c['notes'] = "\n" . trim($c['notes']) . "\n";
}
}
}
if ($state ^ PEAR_VALIDATE_PACKAGING && !isset($arr['bundle'])) {
$use = $this->_recursiveXmlFilelist($arr['contents']['dir']['file']);
unset($arr['contents']['dir']['file']);
if (isset($use['dir'])) {
$arr['contents']['dir']['dir'] = $use['dir'];
}
if (isset($use['file'])) {
$arr['contents']['dir']['file'] = $use['file'];
}
$this->options['beautifyFilelist'] = true;
}
$arr['attribs']['packagerversion'] = '@PEAR-VER@';
if ($this->serialize($arr, $options)) {
return $this->_serializedData . "\n";
}
return false;
}
示例13: basename
function _addDir(&$dirs, $dir, $file = null, $attributes = null, $replacements = null)
{
if ($dir == array() || $dir == array('.')) {
$attributes['name'] = basename($file);
$dirs['file'][basename($file)]['attribs'] = $attributes;
if (isset($replacements)) {
$dirs['file'][basename($file)][$this->_packagefile->getTasksNs() . ':replace'] = $replacements;
}
return;
}
$curdir = array_shift($dir);
if (!isset($dirs['dir'][$curdir])) {
$dirs['dir'][$curdir] = array();
}
$this->_addDir($dirs['dir'][$curdir], $dir, $file, $attributes, $replacements);
}
示例14: validateStability
/**
* @access protected
*/
function validateStability()
{
$ret = true;
$packagestability = $this->_packagexml->getState();
$apistability = $this->_packagexml->getState('api');
if (!PEAR_Validate::validState($packagestability)) {
$this->_addFailure('state', 'invalid release stability "' . $this->_packagexml->getState() . '", must be one of: ' . implode(', ', PEAR_Validate::getValidStates()));
$ret = false;
}
$apistates = PEAR_Validate::getValidStates();
array_shift($apistates);
// snapshot is not allowed
if (!in_array($apistability, $apistates)) {
$this->_addFailure('state', 'invalid API stability "' . $this->_packagexml->getState('api') . '", must be one of: ' . implode(', ', $apistates));
$ret = false;
}
return $ret;
}
示例15: array
/**
* Build a "provides" array from data returned by
* analyzeSourceCode(). The format of the built array is like
* this:
*
* array(
* 'class;MyClass' => 'array('type' => 'class', 'name' => 'MyClass'),
* ...
* )
*
*
* @param array $srcinfo array with information about a source file
* as returned by the analyzeSourceCode() method.
*
* @return void
*
* @access private
*
*/
function _buildProvidesArray($srcinfo)
{
if (!$this->_isValid) {
return array();
}
$providesret = array();
$file = basename($srcinfo['source_file']);
$pn = isset($this->_pf) ? $this->_pf->getPackage() : '';
$pnl = strlen($pn);
foreach ($srcinfo['declared_classes'] as $class) {
$key = "class;{$class}";
if (isset($providesret[$key])) {
continue;
}
$providesret[$key] = array('file' => $file, 'type' => 'class', 'name' => $class);
if (isset($srcinfo['inheritance'][$class])) {
$providesret[$key]['extends'] = $srcinfo['inheritance'][$class];
}
}
foreach ($srcinfo['declared_methods'] as $class => $methods) {
foreach ($methods as $method) {
$function = "{$class}::{$method}";
$key = "function;{$function}";
if ($method[0] == '_' || !strcasecmp($method, $class) || isset($providesret[$key])) {
continue;
}
$providesret[$key] = array('file' => $file, 'type' => 'function', 'name' => $function);
}
}
foreach ($srcinfo['declared_functions'] as $function) {
$key = "function;{$function}";
if ($function[0] == '_' || isset($providesret[$key])) {
continue;
}
if (!strstr($function, '::') && strncasecmp($function, $pn, $pnl)) {
$warnings[] = "in1 " . $file . ": function \"{$function}\" not prefixed with package name \"{$pn}\"";
}
$providesret[$key] = array('file' => $file, 'type' => 'function', 'name' => $function);
}
return $providesret;
}