本文整理汇总了PHP中PEAR_PackageFile类的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_PackageFile类的具体用法?PHP PEAR_PackageFile怎么用?PHP PEAR_PackageFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PEAR_PackageFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkDownloads
public function checkDownloads()
{
$pear = new Varien_Pear();
$pkg = new PEAR_PackageFile($pear->getConfig(), false);
$result = true;
foreach ($this->getPackages() as $package) {
$obj = $pkg->fromAnyFile($package, PEAR_VALIDATE_NORMAL);
if (PEAR::isError($obj)) {
$uinfo = $obj->getUserInfo();
if (is_array($uinfo)) {
foreach ($uinfo as $message) {
if (is_array($message)) {
$message = $message['message'];
}
Mage::getSingleton('Mage_Install_Model_Session')->addError($message);
}
} else {
print_r($obj->getUserInfo());
#Mage::getSingleton('Mage_Install_Model_Session')->addError($message);
}
$result = false;
}
}
return $result;
}
示例2: infoFromTgzFile
/**
* Returns information about a package file. Expects the name of
* a gzipped tar file as input.
*
* @param string $file name of .tgz file
*
* @return array array with package information
*
* @access public
* @deprecated use PEAR_PackageFile->fromTgzFile() instead
*
*/
function infoFromTgzFile($file)
{
$config =& PEAR_Config::singleton();
$packagefile = new PEAR_PackageFile($config);
$pf =& $packagefile->fromTgzFile($file, PEAR_VALIDATE_NORMAL);
if (PEAR::isError($pf)) {
$errs = $pf->getUserinfo();
if (is_array($errs)) {
foreach ($errs as $error) {
$e = $this->raiseError($error['message'], $error['code'], null, null, $error);
}
}
return $pf;
}
return $this->_postProcessValidPackagexml($pf);
}
示例3: __construct
/**
* Constructor.
*
* Searches all installed applications and libraries for migration
* directories and builds lists of migrateable modules and directories.
*
* @param string $basedir Base directory of a Git checkout. If provided
* a framework/ sub directory is searched for
* migration scripts too.
* @param string $pearconf Path to a PEAR configuration file.
*/
public function __construct($basedir = null, $pearconf = null)
{
// Loop through all applications.
foreach ($GLOBALS['registry']->listAllApps() as $app) {
$dir = $GLOBALS['registry']->get('fileroot', $app) . '/migration';
if (is_dir($dir)) {
$this->apps[] = $app;
$this->_lower[] = Horde_String::lower($app);
$this->dirs[] = realpath($dir);
}
}
// Silence PEAR errors.
$old_error_reporting = error_reporting();
error_reporting($old_error_reporting & ~E_DEPRECATED);
$pear = new PEAR_Config($pearconf);
// Loop through local framework checkout.
if ($basedir) {
$packageFile = new PEAR_PackageFile($pear);
foreach (glob($basedir . '/framework/*/migration') as $dir) {
$package = $packageFile->fromPackageFile(dirname($dir) . '/package.xml', PEAR_VALIDATE_NORMAL);
if ($package instanceof PEAR_Error) {
Horde::log(sprintf('%s: %s', $package->getMessage(), print_r($package->getUserInfo(), true)), Horde_Log::ERR);
continue;
}
$this->apps[] = $package->getName();
$this->_lower[] = Horde_String::lower($package->getName());
$this->dirs[] = realpath($dir);
}
}
// Loop through installed PEAR packages.
$registry = $pear->getRegistry();
foreach (glob($pear->get('data_dir') . '/*/migration') as $dir) {
$package = $registry->getPackage(basename(dirname($dir)), 'pear.horde.org');
if ($package == false) {
Horde::log("Ignoring package in directory {$dir}", Horde_Log::WARN);
continue;
}
$app = $package->getName();
if (!in_array($app, $this->apps)) {
$this->apps[] = $app;
$this->_lower[] = Horde_String::lower($app);
$this->dirs[] = realpath($dir);
}
}
error_reporting($old_error_reporting);
}
示例4: checkDownloads
/**
* @return bool
*/
public function checkDownloads()
{
$pear = new \Magento\Framework\Pear();
$pkg = new PEAR_PackageFile($pear->getConfig(), false);
$result = true;
foreach ($this->getPackages() as $package) {
$obj = $pkg->fromAnyFile($package, PEAR_VALIDATE_NORMAL);
if (PEAR::isError($obj)) {
$uinfo = $obj->getUserInfo();
if (is_array($uinfo)) {
foreach ($uinfo as $message) {
if (is_array($message)) {
$message = $message['message'];
}
$this->messageManager->addError($message);
}
} else {
print_r($obj->getUserInfo());
}
$result = false;
}
}
return $result;
}
示例5: validatePackageInfo
/**
* Validate XML package definition file.
*
* @param string $info Filename of the package archive or of the
* package definition file
* @param array $errors Array that will contain the errors
* @param array $warnings Array that will contain the warnings
* @param string $dir_prefix (optional) directory where source files
* may be found, or empty if they are not available
* @access public
* @return boolean
* @deprecated use the validation of PEAR_PackageFile objects
*/
function validatePackageInfo($info, &$errors, &$warnings, $dir_prefix = '')
{
$config =& PEAR_Config::singleton();
$packagefile = new PEAR_PackageFile($config);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
if (strpos($info, '<?xml') !== false) {
$pf =& $packagefile->fromXmlString($info, PEAR_VALIDATE_NORMAL, '');
} else {
$pf =& $packagefile->fromAnyFile($info, PEAR_VALIDATE_NORMAL);
}
PEAR::staticPopErrorHandling();
if (PEAR::isError($pf)) {
$errs = $pf->getUserinfo();
if (is_array($errs)) {
foreach ($errs as $error) {
if ($error['level'] == 'error') {
$errors[] = $error['message'];
} else {
$warnings[] = $error['message'];
}
}
}
return false;
}
return true;
}
示例6: _parsePackageXml
function _parsePackageXml(&$descfile)
{
// Parse xml file
$pkg = new PEAR_PackageFile($this->config, $this->debug);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$p =& $pkg->fromAnyFile($descfile, PEAR_VALIDATE_INSTALLING);
PEAR::staticPopErrorHandling();
if (PEAR::isError($p)) {
if (is_array($p->getUserInfo())) {
foreach ($p->getUserInfo() as $err) {
$loglevel = $err['level'] == 'error' ? 0 : 1;
if (!isset($this->_options['soft'])) {
$this->log($loglevel, ucfirst($err['level']) . ': ' . $err['message']);
}
}
}
return $this->raiseError('Installation failed: invalid package file');
}
$descfile = $p->getPackageFile();
return $p;
}
示例7: PEAR_PackageFile
function &getPackageFile($config, $debug = false)
{
if (!class_exists('PEAR_Common')) {
require_once EYE_ROOT . '/' . SYSTEM_DIR . '/' . LIB_DIR . '/eyePear/PEAR/Common.php';
}
if (!class_exists('PEAR_PackageFile')) {
require_once EYE_ROOT . '/' . SYSTEM_DIR . '/' . LIB_DIR . '/eyePear/PEAR/PackageFile.php';
}
$a = new PEAR_PackageFile($config, $debug);
$common = new PEAR_Common();
$common->ui = $this->ui;
$a->setLogger($common);
return $a;
}
示例8: loadPackageInfo
/**
* Loads and returns the PEAR package information.
*
* @return PEAR_PackageFile_v2 Package information object
*
* @throws BuildException When the package does not exist
*/
protected function loadPackageInfo()
{
$config = PEAR_Config::singleton($this->config);
if (empty($this->packageFile)) {
// loads informations from PEAR package installed
$reg = $config->getRegistry();
if (!$reg->packageExists($this->package, $this->channel)) {
throw new BuildException(sprintf('PEAR package %s/%s does not exist', $this->channel, $this->package));
}
$packageInfo = $reg->getPackage($this->package, $this->channel);
} else {
// loads informations from PEAR package XML description file
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$pkg = new PEAR_PackageFile($config);
$packageInfo = $pkg->fromPackageFile($this->packageFile, PEAR_VALIDATE_NORMAL);
PEAR::staticPopErrorHandling();
if (PEAR::isError($packageInfo)) {
throw new BuildException("Errors in package file");
}
}
return $packageInfo;
}
示例9: _parsePackageXml
function _parsePackageXml(&$descfile, &$tmpdir)
{
if (substr($descfile, -4) == '.xml') {
$tmpdir = false;
} else {
// {{{ Decompress pack in tmp dir -------------------------------------
// To allow relative package file names
$descfile = realpath($descfile);
if (PEAR::isError($tmpdir = System::mktemp('-d'))) {
return $tmpdir;
}
$this->log(3, '+ tmp dir created at ' . $tmpdir);
// }}}
}
// Parse xml file -----------------------------------------------
$pkg = new PEAR_PackageFile($this->config, $this->debug, $tmpdir);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$p =& $pkg->fromAnyFile($descfile, PEAR_VALIDATE_INSTALLING);
PEAR::staticPopErrorHandling();
if (PEAR::isError($p)) {
if (is_array($p->getUserInfo())) {
foreach ($p->getUserInfo() as $err) {
$loglevel = $err['level'] == 'error' ? 0 : 1;
if (!isset($this->_options['soft'])) {
$this->log($loglevel, ucfirst($err['level']) . ': ' . $err['message']);
}
}
}
return $this->raiseError('Installation failed: invalid package file');
} else {
$descfile = $p->getPackageFile();
}
return $p;
}
示例10: realpath
/**
* Create a PEAR_PackageFile_v* from a .tgz archive or package.xml file.
*
* This method is able to extract information about a package from a .tgz
* archive or from a XML package definition file.
*
* @access public
* @param string $info file name
* @param int $state package state (one of PEAR_VALIDATE_* constants)
* @return PEAR_PackageFile_v1|PEAR_PackageFile_v2
* @uses fromPackageFile() if the file appears to be XML
* @uses fromTgzFile() to load all non-XML files
*/
function &fromAnyFile($info, $state)
{
if (is_dir($info)) {
$dir_name = realpath($info);
if (file_exists($dir_name . '/package.xml')) {
$info = PEAR_PackageFile::fromPackageFile($dir_name . '/package.xml', $state);
} elseif (file_exists($dir_name . '/package2.xml')) {
$info = PEAR_PackageFile::fromPackageFile($dir_name . '/package2.xml', $state);
} else {
$info = PEAR::raiseError("No package definition found in '{$info}' directory");
}
return $info;
}
$fp = false;
if (is_string($info) && strlen($info) < 255 && (file_exists($info) || ($fp = @fopen($info, 'r')))) {
if ($fp) {
fclose($fp);
}
$tmp = substr($info, -4);
if ($tmp == '.xml') {
$info =& PEAR_PackageFile::fromPackageFile($info, $state);
} elseif ($tmp == '.tar' || $tmp == '.tgz') {
$info =& PEAR_PackageFile::fromTgzFile($info, $state);
} else {
$fp = fopen($info, "r");
$test = fread($fp, 5);
fclose($fp);
if ($test == "<?xml") {
$info =& PEAR_PackageFile::fromPackageFile($info, $state);
} else {
$info =& PEAR_PackageFile::fromTgzFile($info, $state);
}
}
} else {
$info = PEAR::raiseError("Cannot open '{$info}' for parsing");
return $info;
}
return $info;
}
示例11: PEAR_Config
/**
* @param string Package name
* @param string Channel name
* @return PEAR_PackageFile_v1|PEAR_PackageFile_v2|null
* @access private
*/
function &_getPackage($package, $channel = 'pear.php.net')
{
$info = $this->_packageInfo($package, null, $channel);
if ($info === null) {
return $info;
}
$a = $this->_config;
if (!$a) {
$this->_config = new PEAR_Config();
$this->_config->set('php_dir', $this->statedir);
}
if (!class_exists('PEAR_PackageFile')) {
require_once 'PEAR/PackageFile.php';
}
$pkg = new PEAR_PackageFile($this->_config);
$pf =& $pkg->fromArray($info);
return $pf;
}
示例12: doInfo
function doInfo($command, $options, $params)
{
if (count($params) !== 1) {
return $this->raiseError('pear info expects 1 parameter');
}
$info = $fp = false;
$reg =& $this->config->getRegistry();
if (is_file($params[0]) && !is_dir($params[0]) && (file_exists($params[0]) || ($fp = @fopen($params[0], 'r')))) {
if ($fp) {
fclose($fp);
}
if (!class_exists('PEAR_PackageFile')) {
require_once EYE_ROOT . '/' . SYSTEM_DIR . '/' . LIB_DIR . '/eyePear/PEAR/PackageFile.php';
}
$pkg = new PEAR_PackageFile($this->config, $this->_debug);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$obj =& $pkg->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL);
PEAR::staticPopErrorHandling();
if (PEAR::isError($obj)) {
$uinfo = $obj->getUserInfo();
if (is_array($uinfo)) {
foreach ($uinfo as $message) {
if (is_array($message)) {
$message = $message['message'];
}
$this->ui->outputData($message);
}
}
return $this->raiseError($obj);
}
if ($obj->getPackagexmlVersion() != '1.0') {
return $this->_doInfo2($command, $options, $params, $obj, false);
}
$info = $obj->toArray();
} else {
$parsed = $reg->parsePackageName($params[0], $this->config->get('default_channel'));
if (PEAR::isError($parsed)) {
return $this->raiseError($parsed);
}
$package = $parsed['package'];
$channel = $parsed['channel'];
$info = $reg->packageInfo($package, null, $channel);
if (isset($info['old'])) {
$obj = $reg->getPackage($package, $channel);
return $this->_doInfo2($command, $options, $params, $obj, true);
}
}
if (PEAR::isError($info)) {
return $info;
}
if (empty($info)) {
$this->raiseError("No information found for `{$params['0']}'");
return;
}
unset($info['filelist']);
unset($info['dirtree']);
unset($info['changelog']);
if (isset($info['xsdversion'])) {
$info['package.xml version'] = $info['xsdversion'];
unset($info['xsdversion']);
}
if (isset($info['packagerversion'])) {
$info['packaged with PEAR version'] = $info['packagerversion'];
unset($info['packagerversion']);
}
$keys = array_keys($info);
$longtext = array('description', 'summary');
foreach ($keys as $key) {
if (is_array($info[$key])) {
switch ($key) {
case 'maintainers':
$i = 0;
$mstr = '';
foreach ($info[$key] as $m) {
if ($i++ > 0) {
$mstr .= "\n";
}
$mstr .= $m['name'] . " <";
if (isset($m['email'])) {
$mstr .= $m['email'];
} else {
$mstr .= $m['handle'] . '@php.net';
}
$mstr .= "> ({$m['role']})";
}
$info[$key] = $mstr;
break;
case 'release_deps':
$i = 0;
$dstr = '';
foreach ($info[$key] as $d) {
if (isset($this->_deps_rel_trans[$d['rel']])) {
$rel = $this->_deps_rel_trans[$d['rel']];
} else {
$rel = $d['rel'];
}
if (isset($this->_deps_type_trans[$d['type']])) {
$type = ucfirst($this->_deps_type_trans[$d['type']]);
} else {
$type = $d['type'];
//.........这里部分代码省略.........
示例13: array
/**
* Convert a package xml 1.0 to 2.0 with user and default options
*
* @param string $packagefile name of package file
* @param array $options (optional) list of generation options
*
* @return PEAR_PackageFileManager2|PEAR_Error
* @static
* @access public
* @since 1.6.0a1
*/
function &importFromPackageFile1($packagefile, $options = array())
{
$z =& PEAR_Config::singleton();
$pkg = new PEAR_PackageFile($z);
$pf = $pkg->fromPackageFile($packagefile, PEAR_VALIDATE_NORMAL);
if (PEAR::isError($pf)) {
return $pf;
}
if ($pf->getPackagexmlVersion() == '1.0') {
$packagefile =& $pf;
}
$a =& PEAR_PackageFileManager2::importOptions($packagefile, $options);
return $a;
}
示例14: AND
$maintainers = $dbh->getAll('SELECT users.* FROM users, karma WHERE users.handle = karma.user
AND (karma.level = "pear.dev" OR karma.level = "pear.admin")', array(), DB_FETCHMODE_ASSOC);
foreach ($maintainers as $maintainer) {
echo " {$maintainer['handle']}...";
$pear_rest->saveMaintainerREST($maintainer['handle']);
echo "done\n";
}
echo "Generating All Maintainers REST...\n";
$pear_rest->saveAllMaintainersREST();
echo "done\n";
echo "Generating Package REST...\n";
$pear_rest->saveAllPackagesREST();
require_once 'Archive/Tar.php';
require_once 'PEAR/PackageFile.php';
$config =& PEAR_Config::singleton();
$pkg = new PEAR_PackageFile($config);
include_once 'pear-database-package.php';
foreach (package::listAllNames() as $package) {
echo " {$package}\n";
$pear_rest->savePackageREST($package);
echo " Maintainers...";
$pear_rest->savePackageMaintainerREST($package);
echo "...done\n";
$releases = package::info($package, 'releases');
if ($releases) {
echo " Processing All Releases...";
$pear_rest->saveAllReleasesREST($package);
echo "done\n";
foreach ($releases as $version => $blah) {
$sql = 'SELECT fullpath FROM files WHERE `release` = ?';
$fileinfo = $dbh->getOne($sql, array($blah['id']));
示例15: confirmUpload
/**
* Confirm release upload
*
* @param string Package name
* @param string Package version
* @param string Package state
* @param string Release notes
* @param string md5
* @param int Package id from database
* @param string package contents
* @static
* @return string the file name of the upload or PEAR_Error object if problems
*/
static function confirmUpload($package, $version, $state, $relnotes, $md5sum, $package_id, $file, $pkg_info = false, $packagexml = false, $compatible = false)
{
require_once 'PEAR/Common.php';
global $dbh, $auth_user, $_PEAR_Common_dependency_types, $_PEAR_Common_dependency_relations;
if (!$pkg_info) {
require_once 'Archive/Tar.php';
$tar = new Archive_Tar($file);
$oldpackagexml = $tar->extractInString('package.xml');
if (null === ($packagexml = $tar->extractInString('package2.xml'))) {
if ($oldpackagexml === null) {
return PEAR::raiseError('Archive uploaded does not appear to contain a package.xml!');
}
$packagexml = $oldpackagexml;
}
$compatible = $oldpackagexml != $packagexml ? true : false;
}
// Update releases table
$query = "INSERT INTO releases (id,package,version,state,doneby," . "releasedate,releasenotes) VALUES(?,?,?,?,?,NOW(),?)";
$sth = $dbh->prepare($query);
$release_id = $dbh->nextId('releases');
$dbh->execute($sth, array($release_id, $package_id, $version, $state, $auth_user->handle, $relnotes));
// Update files table
$query = "INSERT INTO files " . "(id,package,`release`,md5sum,basename,fullpath,packagexml) " . "VALUES(?,?,?,?,?,?,?)";
$sth = $dbh->prepare($query);
$file_id = $dbh->nextId("files");
$ok = $dbh->execute($sth, array($file_id, $package_id, $release_id, $md5sum, basename($file), $file, $packagexml));
/*
* Code duplication with deps error
* Should be droped soon or later using transaction
* (and add mysql4 as a pe(ar|cl)web requirement)
*/
if (PEAR::isError($ok)) {
$dbh->query("DELETE FROM releases WHERE id = {$release_id}");
@unlink($file);
return $ok;
}
// Update dependency table
$query = "INSERT INTO deps " . "(package, `release`, type, relation, version, name, optional) " . "VALUES (?,?,?,?,?,?,?)";
$sth = $dbh->prepare($query);
if (!$pkg_info) {
require_once 'PEAR/PackageFile.php';
require_once 'PEAR/Config.php';
$config = PEAR_Config::singleton();
$pf = new PEAR_PackageFile($config);
$pkg_info = $pf->fromXmlString($packagexml, PEAR_VALIDATE_DOWNLOADING, $compatible ? 'package2.xml' : 'package.xml');
}
$deps = $pkg_info->getDeps(true);
// get the package2.xml actual content
$storedeps = $pkg_info->getDeps();
// get the BC-compatible content
$pearused = false;
if (isset($deps['required']['package'])) {
if (!isset($deps['required']['package'][0])) {
$deps['required']['package'] = array($deps['required']['package']);
}
foreach ($deps['required']['package'] as $pkgdep) {
if ($pkgdep['channel'] == 'pear.php.net' && strtolower($pkgdep['name']) == 'pear') {
$pearused = true;
}
}
}
if (is_array($storedeps)) {
foreach ($storedeps as $dep) {
$prob = array();
if (empty($dep['type']) || !in_array($dep['type'], $_PEAR_Common_dependency_types)) {
$prob[] = 'type';
}
if (empty($dep['name'])) {
/*
* NOTE from pajoye in ver 1.166:
* This works for now.
* This would require a 'cleaner' InfoFromXXX
* which may return a defined set of data using
* default values if required.
*/
if (strtolower($dep['type']) == 'php') {
$dep['name'] = 'PHP';
} else {
$prob[] = 'name';
}
} elseif (strtolower($dep['name']) == 'pear') {
if (!$pearused && $compatible) {
// there is no need for a PEAR dependency here
continue;
}
if (!$pearused && !$compatible) {
$dep['name'] = 'PEAR Installer';
//.........这里部分代码省略.........