本文整理汇总了PHP中PEAR_PackageFile_v1类的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_PackageFile_v1类的具体用法?PHP PEAR_PackageFile_v1怎么用?PHP PEAR_PackageFile_v1使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PEAR_PackageFile_v1类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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']);
//.........这里部分代码省略.........
示例2: updatePackage
function updatePackage($package, $info, $merge = true)
{
if (is_object($info)) {
return $this->updatePackage2($info, $merge);
}
if (PEAR::isError($e = $this->_lock(LOCK_EX))) {
return $e;
}
$ret = $this->_updatePackage($package, $info, $merge);
$this->_unlock();
if ($ret) {
if (!class_exists('PEAR_PackageFile_v1')) {
require_once 'PEAR/PackageFile/v1.php';
}
$pf = new PEAR_PackageFile_v1();
$pf->setConfig($this->_config);
$pf->fromArray($this->packageInfo($package));
$this->_dependencyDB->uninstallPackage($pf);
$this->_dependencyDB->installPackage($pf);
}
return $ret;
}
示例3: _convertPackage
function _convertPackage($packagexml)
{
$pkg =& $this->getPackageFile($this->config);
$pf2 =& $pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL);
if (!is_a($pf2, 'PEAR_PackageFile_v2')) {
return $this->raiseError('Cannot process "' . $packagexml . '", is not a package.xml 2.0');
}
require_once 'PEAR/PackageFile/v1.php';
$pf = new PEAR_PackageFile_v1();
$pf->setConfig($this->config);
if ($pf2->getPackageType() != 'extsrc' && $pf2->getPackageType() != 'zendextsrc') {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", is not an extension source package. Using a PEAR_PackageFileManager-based ' . 'script is an option');
}
if (is_array($pf2->getUsesRole())) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains custom roles. Using a PEAR_PackageFileManager-based script or ' . 'the convert command is an option');
}
if (is_array($pf2->getUsesTask())) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains custom tasks. Using a PEAR_PackageFileManager-based script or ' . 'the convert command is an option');
}
$deps = $pf2->getDependencies();
if (isset($deps['group'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains dependency groups. Using a PEAR_PackageFileManager-based script ' . 'or the convert command is an option');
}
if (isset($deps['required']['subpackage']) || isset($deps['optional']['subpackage'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains subpackage dependencies. Using a PEAR_PackageFileManager-based ' . 'script is an option');
}
if (isset($deps['required']['os'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains os dependencies. Using a PEAR_PackageFileManager-based ' . 'script is an option');
}
if (isset($deps['required']['arch'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains arch dependencies. Using a PEAR_PackageFileManager-based ' . 'script is an option');
}
$pf->setPackage($pf2->getPackage());
$pf->setSummary($pf2->getSummary());
$pf->setDescription($pf2->getDescription());
foreach ($pf2->getMaintainers() as $maintainer) {
$pf->addMaintainer($maintainer['role'], $maintainer['handle'], $maintainer['name'], $maintainer['email']);
}
$pf->setVersion($pf2->getVersion());
$pf->setDate($pf2->getDate());
$pf->setLicense($pf2->getLicense());
$pf->setState($pf2->getState());
$pf->setNotes($pf2->getNotes());
$pf->addPhpDep($deps['required']['php']['min'], 'ge');
if (isset($deps['required']['php']['max'])) {
$pf->addPhpDep($deps['required']['php']['max'], 'le');
}
if (isset($deps['required']['package'])) {
if (!isset($deps['required']['package'][0])) {
$deps['required']['package'] = array($deps['required']['package']);
}
foreach ($deps['required']['package'] as $dep) {
if (!isset($dep['channel'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains uri-based dependency on a package. Using a ' . 'PEAR_PackageFileManager-based script is an option');
}
if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains dependency on a non-standard channel package. Using a ' . 'PEAR_PackageFileManager-based script is an option');
}
if (isset($dep['conflicts'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains conflicts dependency. Using a ' . 'PEAR_PackageFileManager-based script is an option');
}
if (isset($dep['exclude'])) {
$this->ui->outputData('WARNING: exclude tags are ignored in conversion');
}
if (isset($dep['min'])) {
$pf->addPackageDep($dep['name'], $dep['min'], 'ge');
}
if (isset($dep['max'])) {
$pf->addPackageDep($dep['name'], $dep['max'], 'le');
}
}
}
if (isset($deps['required']['extension'])) {
if (!isset($deps['required']['extension'][0])) {
$deps['required']['extension'] = array($deps['required']['extension']);
}
foreach ($deps['required']['extension'] as $dep) {
if (isset($dep['conflicts'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains conflicts dependency. Using a ' . 'PEAR_PackageFileManager-based script is an option');
}
if (isset($dep['exclude'])) {
$this->ui->outputData('WARNING: exclude tags are ignored in conversion');
}
if (isset($dep['min'])) {
$pf->addExtensionDep($dep['name'], $dep['min'], 'ge');
}
if (isset($dep['max'])) {
$pf->addExtensionDep($dep['name'], $dep['max'], 'le');
}
}
}
if (isset($deps['optional']['package'])) {
if (!isset($deps['optional']['package'][0])) {
$deps['optional']['package'] = array($deps['optional']['package']);
}
foreach ($deps['optional']['package'] as $dep) {
if (!isset($dep['channel'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains uri-based dependency on a package. Using a ' . 'PEAR_PackageFileManager-based script is an option');
}
if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
//.........这里部分代码省略.........
示例4: _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();
//.........这里部分代码省略.........
示例5: parse
/**
* @param string contents of package.xml file, version 1.0
* @return bool success of parsing
*/
function parse($data, $file, $archive = false)
{
if (!extension_loaded('xml')) {
return PEAR::raiseError('Cannot create xml parser for parsing package.xml, no xml extension');
}
$xp = @xml_parser_create();
if (!$xp) {
return PEAR::raiseError('Cannot create xml parser for parsing package.xml');
}
xml_set_object($xp, $this);
xml_set_element_handler($xp, '_element_start_1_0', '_element_end_1_0');
xml_set_character_data_handler($xp, '_pkginfo_cdata_1_0');
xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
$this->element_stack = array();
$this->_packageInfo = array('provides' => array());
$this->current_element = false;
unset($this->dir_install);
$this->_packageInfo['filelist'] = array();
$this->filelist =& $this->_packageInfo['filelist'];
$this->dir_names = array();
$this->in_changelog = false;
$this->d_i = 0;
$this->cdata = '';
$this->_isValid = true;
if (!xml_parse($xp, $data, 1)) {
$code = xml_get_error_code($xp);
$line = xml_get_current_line_number($xp);
xml_parser_free($xp);
return PEAR::raiseError(sprintf("XML error: %s at line %d", $str = xml_error_string($code), $line), 2);
}
xml_parser_free($xp);
$pf = new PEAR_PackageFile_v1();
$pf->setConfig($this->_config);
if (isset($this->_logger)) {
$pf->setLogger($this->_logger);
}
$pf->setPackagefile($file, $archive);
$pf->fromArray($this->_packageInfo);
return $pf;
}
示例6: 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'];
//.........这里部分代码省略.........
示例7: getDeps
function getDeps()
{
if (isset($this->_packagefile)) {
$ver = $this->_packagefile->getPackagexmlVersion();
if (version_compare($ver, '2.0', '>=')) {
return $this->_packagefile->getDeps(true);
}
return $this->_packagefile->getDeps();
} elseif (isset($this->_downloadURL['info'])) {
$ver = $this->_downloadURL['info']->getPackagexmlVersion();
if (version_compare($ver, '2.0', '>=')) {
return $this->_downloadURL['info']->getDeps(true);
}
return $this->_downloadURL['info']->getDeps();
}
return array();
}
示例8: 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;
}
示例9: getDeps
function getDeps()
{
if (isset($this->_packagefile)) {
if ($this->_packagefile->getPackagexmlVersion() == '2.0') {
return $this->_packagefile->getDeps(true);
} else {
return $this->_packagefile->getDeps();
}
} elseif (isset($this->_downloadURL['info'])) {
if ($this->_downloadURL['info']->getPackagexmlVersion() == '2.0') {
return $this->_downloadURL['info']->getDeps(true);
} else {
return $this->_downloadURL['info']->getDeps();
}
} else {
return array();
}
}
示例10: array
/**
* @param array
* @access private
*/
function _convertFilelist2_0(&$package)
{
$ret = array('dir' =>
array(
'attribs' => array('name' => '/'),
'file' => array()
)
);
$package['platform'] =
$package['install-as'] = array();
$this->_isExtension = false;
foreach ($this->_packagefile->getFilelist() as $name => $file) {
$file['name'] = $name;
if (isset($file['role']) && $file['role'] == 'src') {
$this->_isExtension = true;
}
if (isset($file['replacements'])) {
$repl = $file['replacements'];
unset($file['replacements']);
} else {
unset($repl);
}
if (isset($file['install-as'])) {
$package['install-as'][$name] = $file['install-as'];
unset($file['install-as']);
}
if (isset($file['platform'])) {
$package['platform'][$name] = $file['platform'];
unset($file['platform']);
}
$file = array('attribs' => $file);
if (isset($repl)) {
foreach ($repl as $replace ) {
$file['tasks:replace'][] = array('attribs' => $replace);
}
if (count($repl) == 1) {
$file['tasks:replace'] = $file['tasks:replace'][0];
}
}
$ret['dir']['file'][] = $file;
}
return $ret;
}