当前位置: 首页>>代码示例>>PHP>>正文


PHP PEAR_Common类代码示例

本文整理汇总了PHP中PEAR_Common的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Common类的具体用法?PHP PEAR_Common怎么用?PHP PEAR_Common使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PEAR_Common类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doUninstall

 function doUninstall($command, $options, $params)
 {
     if (empty($this->installer)) {
         $this->installer =& new PEAR_Installer($this->ui);
     }
     if (sizeof($params) < 1) {
         return $this->raiseError("Please supply the package(s) you want to uninstall");
     }
     include_once 'PEAR/Registry.php';
     $reg = new PEAR_Registry($this->config->get('php_dir'));
     $newparams = array();
     $badparams = array();
     foreach ($params as $pkg) {
         $info = $reg->packageInfo($pkg);
         if ($info === null) {
             $badparams[] = $pkg;
         } else {
             $newparams[] = $info;
         }
     }
     PEAR_Common::sortPkgDeps($newparams, true);
     $params = array();
     foreach ($newparams as $info) {
         $params[] = $info['info']['package'];
     }
     $params = array_merge($params, $badparams);
     foreach ($params as $pkg) {
         if ($this->installer->uninstall($pkg, $options)) {
             if ($this->config->get('verbose') > 0) {
                 $this->ui->outputData("uninstall ok: {$pkg}", $command);
             }
         } else {
             return $this->raiseError("uninstall failed: {$pkg}");
         }
     }
     return true;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:37,代码来源:Install.php

示例2: _analyzeDownloadURL

 /**
  * @param array output of package.getDownloadURL
  * @param string|array|object information for detecting packages to be downloaded, and
  *                            for errors
  * @param array name information of the package
  * @param array|null packages to be downloaded
  * @param bool is this an optional dependency?
  * @param bool is this any kind of dependency?
  * @access private
  */
 function _analyzeDownloadURL($info, $param, $pname, $params = null, $optional = false, $isdependency = false)
 {
     if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {
         return false;
     }
     if ($info === false) {
         $saveparam = !is_string($param) ? ", cannot download \"{$param}\"" : '';
         // no releases exist
         return PEAR::raiseError('No releases for package "' . $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);
     }
     if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {
         $err = false;
         if ($pname['channel'] == 'pecl.php.net') {
             if ($info['info']->getChannel() != 'pear.php.net') {
                 $err = true;
             }
         } elseif ($info['info']->getChannel() == 'pecl.php.net') {
             if ($pname['channel'] != 'pear.php.net') {
                 $err = true;
             }
         } else {
             $err = true;
         }
         if ($err) {
             return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] . '" retrieved another channel\'s name for download! ("' . $info['info']->getChannel() . '")');
         }
     }
     $preferred_state = $this->_config->get('preferred_state');
     if (!isset($info['url'])) {
         $package_version = $this->_registry->packageInfo($info['info']->getPackage(), 'version', $info['info']->getChannel());
         if ($this->isInstalled($info)) {
             if ($isdependency && version_compare($info['version'], $package_version, '<=')) {
                 // ignore bogus errors of "failed to download dependency"
                 // if it is already installed and the one that would be
                 // downloaded is older or the same version (Bug #7219)
                 return false;
             }
         }
         if ($info['version'] === $package_version) {
             if (!isset($options['soft'])) {
                 $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . '-' . $package_version . ', additionally the suggested version' . ' (' . $package_version . ') is the same as the locally installed one.');
             }
             return false;
         }
         if (version_compare($info['version'], $package_version, '<=')) {
             if (!isset($options['soft'])) {
                 $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . '-' . $package_version . ', additionally the suggested version' . ' (' . $info['version'] . ') is a lower version than the locally installed one (' . $package_version . ').');
             }
             return false;
         }
         $instead = ', will instead download version ' . $info['version'] . ', stability "' . $info['info']->getState() . '"';
         // releases exist, but we failed to get any
         if (isset($this->_downloader->_options['force'])) {
             if (isset($pname['version'])) {
                 $vs = ', version "' . $pname['version'] . '"';
             } elseif (isset($pname['state'])) {
                 $vs = ', stability "' . $pname['state'] . '"';
             } elseif ($param == 'dependency') {
                 if (!class_exists('PEAR_Common')) {
                     require_once 'PEAR/Common.php';
                 }
                 if (!in_array($info['info']->getState(), PEAR_Common::betterStates($preferred_state, true))) {
                     if ($optional) {
                         // don't spit out confusing error message
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = ' within preferred state "' . $preferred_state . '"';
                 } else {
                     if (!class_exists('PEAR_Dependency2')) {
                         require_once 'PEAR/Dependency2.php';
                     }
                     if ($optional) {
                         // don't spit out confusing error message
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = PEAR_Dependency2::_getExtraString($pname);
                     $instead = '';
                 }
             } else {
                 $vs = ' within preferred state "' . $preferred_state . '"';
             }
             if (!isset($options['soft'])) {
                 $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . $vs . $instead);
             }
             // download the latest release
             return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
         } else {
             if (isset($info['php']) && $info['php']) {
                 $err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . ', latest release is version ' . $info['php']['v'] . ', but it requires PHP version "' . $info['php']['m'] . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['php']['v'])) . '" to install', PEAR_DOWNLOADER_PACKAGE_PHPVERSION);
                 return $err;
//.........这里部分代码省略.........
开发者ID:upmunspel,项目名称:abiturient,代码行数:101,代码来源:Package.php

示例3: PEAR_Downloader

 /**
  * @param PEAR_Frontend_*
  * @param array
  * @param PEAR_Config
  */
 function PEAR_Downloader(&$ui, $options, &$config)
 {
     parent::PEAR_Common();
     $this->_options = $options;
     $this->config =& $config;
     $this->_preferredState = $this->config->get('preferred_state');
     $this->ui =& $ui;
     if (!$this->_preferredState) {
         // don't inadvertantly use a non-set preferred_state
         $this->_preferredState = null;
     }
     if (isset($this->_options['installroot'])) {
         $this->config->setInstallRoot($this->_options['installroot']);
     }
     $this->_registry =& $config->getRegistry();
     if (isset($this->_options['alldeps']) || isset($this->_options['onlyreqdeps'])) {
         $this->_installed = $this->_registry->listAllPackages();
         foreach ($this->_installed as $key => $unused) {
             if (!count($unused)) {
                 continue;
             }
             $strtolower = create_function('$a', 'return strtolower($a);');
             array_walk($this->_installed[$key], $strtolower);
         }
     }
 }
开发者ID:shen0834,项目名称:util,代码行数:31,代码来源:Downloader.php

示例4: auth_require

   | This source file is subject to version 2.02 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available at through the world-wide-web at                           |
   | http://www.php.net/license/2_02.txt.                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
   | Authors:                                                             |
   +----------------------------------------------------------------------+
   $Id$
*/
require_once "PEAR/Common.php";
auth_require(true);
response_header('Fix Dependencies');
$pc = new PEAR_Common();
$pkg_id2name = $dbh->getAssoc("SELECT id,name FROM packages");
$rel_id2name = $dbh->getAssoc("SELECT r.id,concat_ws('-', p.name, r.version) FROM packages p, releases r WHERE r.package = p.id");
print "<h2>Deleting Existing Dependencies...</h2>\n";
$dbh->setOption("optimize", "portability");
$dbh->query("DELETE FROM deps");
$ar = $dbh->affectedRows();
$dbh->setOption("optimize", "performance");
print "{$ar} rows deleted<br />\n";
print "<h2>Inserting New Dependencies...</h2>\n";
$sth = $dbh->query("SELECT package, release, fullpath FROM files");
while ($sth->fetchInto($row)) {
    list($package, $release, $fullpath) = $row;
    printf("<h3>%s (package %d, release %d):</h3>\n", basename($fullpath), $package, $release);
    if (!@file_exists($fullpath)) {
        continue;
开发者ID:phpsource,项目名称:web-pecl,代码行数:31,代码来源:fixdeps.php

示例5: isValidRole

 /**
  * Check if role is valid
  *
  * @static
  * @param string Name of the role
  * @return boolean
  */
 function isValidRole($role)
 {
     require_once "PEAR/Common.php";
     static $roles;
     if (empty($roles)) {
         $roles = PEAR_Common::getUserRoles();
     }
     return in_array($role, $roles);
 }
开发者ID:ThaDafinser,项目名称:web-pecl,代码行数:16,代码来源:pear-database.php

示例6: _convertPackage


//.........这里部分代码省略.........
             }
             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') {
                 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['exclude'])) {
                 $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
             }
             if (isset($dep['min'])) {
                 $pf->addPackageDep($dep['name'], $dep['min'], 'ge', 'yes');
             }
             if (isset($dep['max'])) {
                 $pf->addPackageDep($dep['name'], $dep['max'], 'le', 'yes');
             }
         }
     }
     if (isset($deps['optional']['extension'])) {
         if (!isset($deps['optional']['extension'][0])) {
             $deps['optional']['extension'] = array($deps['optional']['extension']);
         }
         foreach ($deps['optional']['extension'] as $dep) {
             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', 'yes');
             }
             if (isset($dep['max'])) {
                 $pf->addExtensionDep($dep['name'], $dep['max'], 'le', 'yes');
             }
         }
     }
     $contents = $pf2->getContents();
     $release = $pf2->getReleases();
     if (isset($releases[0])) {
         return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' . 'multiple extsrcrelease/zendextsrcrelease tags.  Using a PEAR_PackageFileManager-based script ' . 'or the convert command is an option');
     }
     if ($configoptions = $pf2->getConfigureOptions()) {
         foreach ($configoptions as $option) {
             $pf->addConfigureOption($option['name'], $option['prompt'], isset($option['default']) ? $option['default'] : false);
         }
     }
     if (isset($release['filelist']['ignore'])) {
         return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' . 'ignore tags.  Using a PEAR_PackageFileManager-based script or the convert' . ' command is an option');
     }
     if (isset($release['filelist']['install']) && !isset($release['filelist']['install'][0])) {
         $release['filelist']['install'] = array($release['filelist']['install']);
     }
     if (isset($contents['dir']['attribs']['baseinstalldir'])) {
         $baseinstalldir = $contents['dir']['attribs']['baseinstalldir'];
     } else {
         $baseinstalldir = false;
     }
     if (!isset($contents['dir']['file'][0])) {
         $contents['dir']['file'] = array($contents['dir']['file']);
     }
     foreach ($contents['dir']['file'] as $file) {
         if ($baseinstalldir && !isset($file['attribs']['baseinstalldir'])) {
             $file['attribs']['baseinstalldir'] = $baseinstalldir;
         }
         $processFile = $file;
         unset($processFile['attribs']);
         if (count($processFile)) {
             foreach ($processFile as $name => $task) {
                 if ($name != $pf2->getTasksNs() . ':replace') {
                     return $this->raiseError('Cannot safely process "' . $packagexml . '" contains tasks other than replace.  Using a ' . 'PEAR_PackageFileManager-based script is an option.');
                 }
                 $file['attribs']['replace'][] = $task;
             }
         }
         if (!in_array($file['attribs']['role'], PEAR_Common::getFileRoles())) {
             return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains custom roles.  Using a PEAR_PackageFileManager-based script ' . 'or the convert command is an option');
         }
         if (isset($release['filelist']['install'])) {
             foreach ($release['filelist']['install'] as $installas) {
                 if ($installas['attribs']['name'] == $file['attribs']['name']) {
                     $file['attribs']['install-as'] = $installas['attribs']['as'];
                 }
             }
         }
         $pf->addFile('/', $file['attribs']['name'], $file['attribs']);
     }
     if ($pf2->getChangeLog()) {
         $this->ui->outputData('WARNING: changelog is not translated to package.xml ' . '1.0, use PEAR_PackageFileManager-based script if you need changelog-' . 'translation for package.xml 1.0');
     }
     $gen =& $pf->getDefaultGenerator();
     $gen->toPackageFile('.');
 }
开发者ID:villos,项目名称:tree_admin,代码行数:101,代码来源:Pickle.php

示例7: _PEAR_Packager

 function _PEAR_Packager()
 {
     parent::_PEAR_Common();
 }
开发者ID:BackupTheBerlios,项目名称:wcms,代码行数:4,代码来源:Packager.php

示例8: _analyzeDownloadURL

 /**
  * @param array output of package.getDownloadURL
  * @param string|array|object information for detecting packages to be downloaded, and
  *                            for errors
  * @param array name information of the package
  * @param array|null packages to be downloaded
  * @param bool is this an optional dependency?
  * @access private
  */
 function _analyzeDownloadURL($info, $param, $pname, $params = null, $optional = false)
 {
     if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {
         return false;
     }
     if (!$info) {
         if (!is_string($param)) {
             $saveparam = ", cannot download \"{$param}\"";
         } else {
             $saveparam = '';
         }
         // no releases exist
         return PEAR::raiseError('No releases for package "' . $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);
     }
     if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {
         $err = false;
         if ($pname['channel'] == 'pecl.php.net') {
             if ($info['info']->getChannel() != 'pear.php.net') {
                 $err = true;
             }
         } elseif ($info['info']->getChannel() == 'pecl.php.net') {
             if ($pname['channel'] != 'pear.php.net') {
                 $err = true;
             }
         } else {
             $err = true;
         }
         if ($err) {
             return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] . '" retrieved another channel\'s name for download! ("' . $info['info']->getChannel() . '")');
         }
     }
     if (!isset($info['url'])) {
         $instead = ', will instead download version ' . $info['version'] . ', stability "' . $info['info']->getState() . '"';
         // releases exist, but we failed to get any
         if (isset($this->_downloader->_options['force'])) {
             if (isset($pname['version'])) {
                 $vs = ', version "' . $pname['version'] . '"';
             } elseif (isset($pname['state'])) {
                 $vs = ', stability "' . $pname['state'] . '"';
             } elseif ($param == 'dependency') {
                 if (!class_exists('PEAR_Common')) {
                     require_once 'PEAR/Common.php';
                 }
                 if (!in_array($info['info']->getState(), PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) {
                     if ($optional) {
                         // don't spit out confusing error message
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = ' within preferred state "' . $this->_config->get('preferred_state') . '"';
                 } else {
                     if (!class_exists('PEAR_Dependency2')) {
                         require_once 'PEAR/Dependency2.php';
                     }
                     if ($optional) {
                         // don't spit out confusing error message
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = PEAR_Dependency2::_getExtraString($pname);
                     $instead = '';
                 }
             } else {
                 $vs = ' within preferred state "' . $this->_config->get('preferred_state') . '"';
             }
             if (!isset($options['soft'])) {
                 $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . $vs . $instead);
             }
             // download the latest release
             return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
         } else {
             // construct helpful error message
             if (isset($pname['version'])) {
                 $vs = ', version "' . $pname['version'] . '"';
             } elseif (isset($pname['state'])) {
                 $vs = ', stability "' . $pname['state'] . '"';
             } elseif ($param == 'dependency') {
                 if (!class_exists('PEAR_Common')) {
                     require_once 'PEAR/Common.php';
                 }
                 if (!in_array($info['info']->getState(), PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) {
                     if ($optional) {
                         // don't spit out confusing error message, and don't die on
                         // optional dep failure!
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = ' within preferred state "' . $this->_config->get('preferred_state') . '"';
                 } else {
                     if (!class_exists('PEAR_Dependency2')) {
                         require_once 'PEAR/Dependency2.php';
                     }
                     if ($optional) {
                         // don't spit out confusing error message, and don't die on
//.........这里部分代码省略.........
开发者ID:hbustun,项目名称:agilebill,代码行数:101,代码来源:Package.php

示例9: analyzeSourceCode

 function analyzeSourceCode($file)
 {
     return PEAR_Common::analyzeSourceCode($file);
 }
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:4,代码来源:ComplexGenerator.php

示例10: HTTP_Request2

    $cookies = $response->getCookies();
    $session = $cookies[0]['value'];
    
    $send = new HTTP_Request2($hostname . '/syncACL.php/sync');
    $send->addCookie('PHPSESSID', $session);
    $send->addPostParameter('salt', $salt);
    $send->addPostParameter('package',     $_POST['name']);
    $send->addPostParameter('maintainers', $maintainers);
    $send->addPostParameter('project',     'pear1');
    $response = $send->send();
    $sendBody = $response->getBody();
    $sendCode = $response->getCode();
    */
}
include_once 'PEAR/Common.php';
$roles = PEAR_Common::getUserRoles();
$csrf_token_value = create_csrf_token($csrf_token_name);
?>
<h1>Package Information: <?php 
echo $package_name;
?>
</h1>
<?php 
print_package_navigation($pid, $package_name, '/admin/package-maintainers.php?pid=' . $pid);
?>
<form name="maintainers_edit" method="post" action="?pid=<?php 
echo $pid;
?>
">
<table class="form-holder" style="margin-bottom: 2em;" cellspacing="1" border="0">
<caption class="form-caption">Edit Maintainers list</caption>
开发者ID:stof,项目名称:pearweb,代码行数:31,代码来源:package-maintainers.php

示例11: doInfo

 function doInfo($command, $options, $params)
 {
     // $params[0] The package for showing info
     if (sizeof($params) != 1) {
         return $this->raiseError("This command only accepts one param: " . "the package you want information");
     }
     if (@is_file($params[0])) {
         $obj = new PEAR_Common();
         $info = $obj->infoFromAny($params[0]);
     } else {
         $reg = new PEAR_Registry($this->config->get('php_dir'));
         $info = $reg->packageInfo($params[0]);
     }
     if (PEAR::isError($info)) {
         return $info;
     }
     if (empty($info)) {
         $this->raiseError("Nothing found for `{$params['0']}'");
         return;
     }
     unset($info['filelist']);
     unset($info['changelog']);
     $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'];
                         }
                         if (isset($d['name'])) {
                             $name = $d['name'] . ' ';
                         } else {
                             $name = '';
                         }
                         if (isset($d['version'])) {
                             $version = $d['version'] . ' ';
                         } else {
                             $version = '';
                         }
                         $dstr .= "{$type} {$name}{$rel} {$version}\n";
                     }
                     $info[$key] = $dstr;
                     break;
                 case 'provides':
                     $debug = $this->config->get('verbose');
                     if ($debug < 2) {
                         $pstr = 'Classes: ';
                     } else {
                         $pstr = '';
                     }
                     $i = 0;
                     foreach ($info[$key] as $p) {
                         if ($debug < 2 && $p['type'] != "class") {
                             continue;
                         }
                         // Only print classes when verbosity mode is < 2
                         if ($debug < 2) {
                             if ($i++ > 0) {
                                 $pstr .= ", ";
                             }
                             $pstr .= $p['name'];
                         } else {
                             if ($i++ > 0) {
                                 $pstr .= "\n";
                             }
                             $pstr .= ucfirst($p['type']) . " " . $p['name'];
                             if (isset($p['explicit']) && $p['explicit'] == 1) {
                                 $pstr .= " (explicit)";
                             }
                         }
                     }
//.........这里部分代码省略.........
开发者ID:radicaldesigns,项目名称:amp,代码行数:101,代码来源:Registry.php

示例12: _sortPkgDepsRev

 /**
  * Compare two package's package.xml, and sort
  * so that dependencies are uninstalled last
  *
  * This is a crude compare, real dependency checking is done on uninstall.
  * The only purpose this serves is to make the command-line
  * order-independent (you can list a dependency first, and
  * uninstallation occurs in the order required)
  * @access private
  */
 function _sortPkgDepsRev($p1, $p2)
 {
     $p1name = $p1['info']['package'];
     $p2name = $p2['info']['package'];
     $p1deps = PEAR_Common::_getRevPkgDeps($p1);
     $p2deps = PEAR_Common::_getRevPkgDeps($p2);
     if (!count($p1deps) && !count($p2deps)) {
         return 0;
         // order makes no difference
     }
     if (!count($p1deps)) {
         return 1;
         // package 2 has dependencies, package 1 doesn't
     }
     if (!count($p2deps)) {
         return -1;
         // package 2 has dependencies, package 1 doesn't
     }
     // both have dependencies
     if (in_array($p1name, $p2deps)) {
         return 1;
         // put package 1 last
     }
     if (in_array($p2name, $p1deps)) {
         return -1;
         // put package 2 last
     }
     // doesn't really matter if neither depends on the other
     return 0;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:40,代码来源:Common.php

示例13: doListUpgrades

 function doListUpgrades($command, $options, $params)
 {
     include_once "PEAR/Registry.php";
     $remote = new PEAR_Remote($this->config);
     if (empty($params[0])) {
         $state = $this->config->get('preferred_state');
     } else {
         $state = $params[0];
     }
     $caption = 'Available Upgrades';
     if (empty($state) || $state == 'any') {
         $latest = $remote->call("package.listLatestReleases");
     } else {
         $latest = $remote->call("package.listLatestReleases", $state);
         $caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')';
     }
     $caption .= ':';
     if (PEAR::isError($latest)) {
         return $latest;
     }
     $reg = new PEAR_Registry($this->config->get('php_dir'));
     $inst = array_flip($reg->listPackages());
     $data = array('caption' => $caption, 'border' => 1, 'headline' => array('Package', 'Local', 'Remote', 'Size'));
     foreach ((array) $latest as $pkg => $info) {
         $package = strtolower($pkg);
         if (!isset($inst[$package])) {
             // skip packages we don't have installed
             continue;
         }
         extract($info);
         $pkginfo = $reg->packageInfo($package);
         $inst_version = $pkginfo['version'];
         $inst_state = $pkginfo['release_state'];
         if (version_compare("{$version}", "{$inst_version}", "le")) {
             // installed version is up-to-date
             continue;
         }
         if ($filesize >= 20480) {
             $filesize += 1024 - $filesize % 1024;
             $fs = sprintf("%dkB", $filesize / 1024);
         } elseif ($filesize > 0) {
             $filesize += 103 - $filesize % 103;
             $fs = sprintf("%.1fkB", $filesize / 1024.0);
         } else {
             $fs = "  -";
             // XXX center instead
         }
         $data['data'][] = array($pkg, "{$inst_version} ({$inst_state})", "{$version} ({$state})", $fs);
     }
     if (empty($data['data'])) {
         $this->ui->outputData('No upgrades available');
     } else {
         $this->ui->outputData($data, $command);
     }
     return true;
 }
开发者ID:alex-k,项目名称:velotur,代码行数:56,代码来源:Remote.php

示例14: writePackageFile

 /**
  * Writes the package.xml file out with the newly created <release></release> tag
  *
  * ALWAYS use {@link debugPackageFile} to verify that output is correct before
  * overwriting your package.xml
  *
  * @param boolean $debuginterface (optional) null if no debugging, true if web interface, false if command-line
  *
  * @throws PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS
  * @throws PEAR_PACKAGEFILEMANAGER_ADD_MAINTAINERS
  * @throws PEAR_PACKAGEFILEMANAGER_NONOTES
  * @throws PEAR_PACKAGEFILEMANAGER_NOLICENSE
  * @throws PEAR_PACKAGEFILEMANAGER_INVALID_PACKAGE
  * @throws PEAR_PACKAGEFILEMANAGER_CANTWRITE_PKGFILE
  * @throws PEAR_PACKAGEFILEMANAGER_CANTCOPY_PKGFILE
  * @throws PEAR_PACKAGEFILEMANAGER_CANTOPEN_TMPPKGFILE
  * @throws PEAR_PACKAGEFILEMANAGER_DEST_UNWRITABLE
  * @return true|PEAR_Error
  * @access public
  * @since  0.1
  */
 function writePackageFile($debuginterface = null)
 {
     if (!$this->_packageXml) {
         return $this->raiseError(PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS);
     }
     if (!isset($this->_packageXml['maintainers']) || empty($this->_packageXml['maintainers'])) {
         return $this->raiseError(PEAR_PACKAGEFILEMANAGER_ADD_MAINTAINERS);
     }
     if (!isset($this->_options['notes']) || empty($this->_options['notes'])) {
         return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NONOTES);
     }
     if (!isset($this->_options['license']) || empty($this->_options['license'])) {
         return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NOLICENSE);
     }
     extract($this->_options);
     $date = date('Y-m-d');
     if (isset($package)) {
         $this->_packageXml['package'] = $package;
     }
     if (isset($summary)) {
         $this->_packageXml['summary'] = $summary;
     }
     if (isset($description)) {
         $this->_packageXml['description'] = $description;
     }
     $this->_packageXml['release_date'] = $date;
     $this->_packageXml['version'] = $version;
     $this->_packageXml['release_license'] = $license;
     $this->_packageXml['release_state'] = $state;
     $this->_packageXml['release_notes'] = $notes;
     $PEAR_Common = $this->_options['pearcommonclass'];
     $this->_pear = new $PEAR_Common();
     if (method_exists($this->_pear, 'setPackageFileManager')) {
         $this->_pear->setPackageFileManager($this);
     }
     $this->_packageXml['filelist'] = $this->_getFileList();
     $warnings = $this->getWarnings();
     if (count($warnings)) {
         $nl = isset($debuginterface) && $debuginterface ? '<br />' : "\n";
         foreach ($warnings as $errmsg) {
             echo 'WARNING: ' . $errmsg['message'] . $nl;
         }
     }
     if (PEAR::isError($this->_packageXml['filelist'])) {
         return $this->_packageXml['filelist'];
     }
     if (isset($this->_pear->pkginfo['provides'])) {
         $this->_packageXml['provides'] = $this->_pear->pkginfo['provides'];
     }
     if ($this->_options['simpleoutput']) {
         unset($this->_packageXml['provides']);
     }
     $this->_packageXml['release_deps'] = $this->_getDependencies();
     $this->_updateChangeLog();
     $common =& $this->_pear;
     $warnings = $errors = array();
     if (method_exists($common, 'setPackageFileManagerOptions')) {
         $common->setPackageFileManagerOptions($this->_options);
     }
     $packagexml = $common->xmlFromInfo($this->_packageXml);
     if (PEAR::isError($packagexml)) {
         $errs = $packagexml->getUserinfo();
         if (is_array($errs)) {
             foreach ($errs as $error) {
                 if ($error['level'] == 'error') {
                     $errors[] = $error['message'];
                 } else {
                     $warnings[] = $error['message'];
                 }
             }
         }
     } else {
         $common->validatePackageInfo($packagexml, $warnings, $errors, $this->_options['packagedirectory']);
     }
     if (count($errors)) {
         $ret = '';
         $nl = isset($debuginterface) && $debuginterface ? '<br />' : "\n";
         foreach ($errors as $errmsg) {
             $ret .= $errmsg . $nl;
//.........这里部分代码省略.........
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:101,代码来源:PackageFileManager.php

示例15: doDownload

 function doDownload($command, $options, $params)
 {
     //$params[0] -> The package to download
     if (count($params) != 1) {
         return PEAR::raiseError("download expects one argument: the package to download");
     }
     $server = $this->config->get('master_server');
     if (!ereg('^http://', $params[0])) {
         $pkgfile = "http://{$server}/get/{$params['0']}";
     } else {
         $pkgfile = $params[0];
     }
     $this->bytes_downloaded = 0;
     $saved = PEAR_Common::downloadHttp($pkgfile, $this->ui, '.', array(&$this, 'downloadCallback'));
     if (PEAR::isError($saved)) {
         return $this->raiseError($saved);
     }
     $fname = basename($saved);
     $this->ui->outputData("File {$fname} downloaded ({$this->bytes_downloaded} bytes)", $command);
     return true;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:21,代码来源:Remote.php


注:本文中的PEAR_Common类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。