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


PHP PEAR_Registry类代码示例

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


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

示例1: setUp

 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $reg = new PEAR_Registry();
     if ($reg->getPackage("PEAR_Size") == null) {
         $this->markTestSkipped("PEAR_Size is not installed.");
     }
     $this->cli = new PEAR_Size_CLI();
     $this->genericResponse = "Usage: pearsize [OPTIONS] [PACKAGE]\nDisplay information on how much space an installed PEAR package required.\n\n  -a, --all            display information for all installed packages\n  -A, --allchannels    list packages from all channels, not just the default one\n  -c, --channel        specify which channel\n  -C, --csv            output results in CSV format (sizes are measured in bytes).\n  -h, --human-readable print sizes in human readable format (for example: 492 B 1KB 7MB)\n  -H, --si             likewise, but use powers of 1000 not 1024\n  -t, --type           specify what type of files are required for the report\n                       by default all types are assumed\n  -s, --summarise      display channel summary view\n  -S, --fsort          sort by file size\n  -v, --verbose        display more detailed information\n      --help           display this help and exit\n  -V, --version        output version information and exit\n  -X, --xml            output results in XML format\n  -0, --killzero       do not output zero values in verbose mode\n\nTypes:\nYou can specify a subset of roles/file-types to be listed in the report.\nThese roles are those as supported by the PEAR installer.\nThese are: data, doc, ext, php, script, src, test\n\nExamples:\n                \$ pearsize --all\n                \$ pearsize Console_Table\n                \$ pearsize -ttest,doc Console_Table\n                \$ pearsize --type=test,doc,php -h Console_Table Date_Holidays\n";
     $this->genericIntegratedResponse = "Usage: pear size [OPTIONS] [PACKAGE]\nDisplay information on how much space an installed PEAR package required.\n\n  -a, --all            display information for all installed packages\n  -A, --allchannels    list packages from all channels, not just the default one\n  -c, --channel        specify which channel\n  -C, --csv            output results in CSV format (sizes are measured in bytes).\n  -h, --human-readable print sizes in human readable format (for example: 492 B 1KB 7MB)\n  -H, --si             likewise, but use powers of 1000 not 1024\n  -t, --type           specify what type of files are required for the report\n                       by default all types are assumed\n  -s, --summarise      display channel summary view\n  -S, --fsort          sort by file size\n  -v, --verbose        display more detailed information\n      --help           display this help and exit\n  -V, --version        output version information and exit\n  -X, --xml            output results in XML format\n  -0, --killzero       do not output zero values in verbose mode\n\nTypes:\nYou can specify a subset of roles/file-types to be listed in the report.\nThese roles are those as supported by the PEAR installer.\nThese are: data, doc, ext, php, script, src, test\n\nExamples:\n                \$ pear size --all\n                \$ pear size Console_Table\n                \$ pear size -ttest,doc Console_Table\n                \$ pear size --type=test,doc,php -h Console_Table Date_Holidays\n";
 }
开发者ID:pear,项目名称:PEAR_Size,代码行数:16,代码来源:PEAR_Size_TestSuite_CLI.php

示例2: init

 /**
  * Initialize Task.
  * This method includes any necessary PHPUnit2 libraries and triggers
  * appropriate error if they cannot be found.  This is not done in header
  * because we may want this class to be loaded w/o triggering an error.
  */
 function init()
 {
     if (version_compare(PHP_VERSION, '5.0.3') < 0) {
         throw new BuildException("PHPUnit2Task requires PHP version >= 5.0.3.", $this->getLocation());
     }
     /**
      * Ugly hack to get PHPUnit version number
      */
     $config = new PEAR_Config();
     $registry = new PEAR_Registry($config->get('php_dir'));
     $pkg_info = $registry->_packageInfo("PHPUnit", null, "pear.phpunit.de");
     if ($pkg_info != NULL) {
         if (version_compare($pkg_info['version']['api'], "3.0.0") >= 0) {
             PHPUnitUtil::$installedVersion = 3;
         } else {
             PHPUnitUtil::$installedVersion = 2;
         }
     } else {
         /**
          * Try to find PHPUnit2
          */
         require_once 'PHPUnit2/Util/Filter.php';
         if (!class_exists('PHPUnit2_Util_Filter')) {
             throw new BuildException("PHPUnit2Task depends on PEAR PHPUnit2 package being installed.", $this->getLocation());
         }
         PHPUnitUtil::$installedVersion = 2;
     }
     // other dependencies that should only be loaded when class is actually used.
     require_once 'phing/tasks/ext/phpunit/PHPUnitTestRunner.php';
     require_once 'phing/tasks/ext/phpunit/BatchTest.php';
     require_once 'phing/tasks/ext/phpunit/FormatterElement.php';
     //require_once 'phing/tasks/ext/phpunit/SummaryPHPUnit2ResultFormatter.php';
     // add some defaults to the PHPUnit filter
     if (PHPUnitUtil::$installedVersion == 3) {
         require_once 'PHPUnit/Util/Filter.php';
         // point PHPUnit_MAIN_METHOD define to non-existing method
         define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined');
         PHPUnit_Util_Filter::addFileToFilter('PHPUnitTask.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('PHPUnitTestRunner.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing/Task.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing/Target.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing/Project.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing/Phing.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing.php', 'PHING');
     } else {
         require_once 'PHPUnit2/Util/Filter.php';
         PHPUnit2_Util_Filter::addFileToFilter('PHPUnitTask.php');
         PHPUnit2_Util_Filter::addFileToFilter('PHPUnitTestRunner.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing/Task.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing/Target.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing/Project.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing/Phing.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing.php');
     }
 }
开发者ID:nmicht,项目名称:tlalokes-in-acst,代码行数:61,代码来源:PHPUnitTask.php

示例3: packages

 /**
  * Return PEAR packages, versions, etc.
  *
  * @see PEAR_Registry, PEAR_Registry::listPackages()
  * @return array
  */
 public function packages()
 {
     $reg = new PEAR_Registry();
     $packages = $reg->listPackages();
     $p = array();
     foreach ($packages as $package) {
         $pkg = $reg->getPackage($package);
         $p[] = array('package' => $pkg->getName(), 'released' => $pkg->getDate(), 'version' => $pkg->getVersion(), 'state' => $pkg->getState());
     }
     return array('packages' => $p);
 }
开发者ID:jacques,项目名称:butler,代码行数:17,代码来源:pear.php

示例4: pear_prerequisutes

function pear_prerequisutes()
{
    $exists = include_exists('PEAR' . DIRECTORY_SEPARATOR . 'Registry.php');
    if ($exists['result']) {
        require_once 'PEAR/Registry.php';
        $reg = new PEAR_Registry();
        $packages = $reg->listPackages();
        if (in_array('http_request2', $packages)) {
            $results = array('pear' => "Pass", 'http_request2' => "Pass", 'path' => $exists['path']);
        } else {
            $results = array('pear' => "Pass", 'http_request2' => "Fail", 'path' => $exists['path']);
        }
    } else {
        $results = array('pear' => "Fail", 'http_request2' => "Fail", 'path' => $exists['path']);
    }
    return $results;
}
开发者ID:muhamadanjar,项目名称:SIMTARU,代码行数:17,代码来源:proxy-verification.php

示例5: check

 /**
  * Check php package exists and has corresponding version
  *
  * Returns 0 on success, non-zero otherwise
  *
  * @return int
  */
 public function check()
 {
     require_once 'PEAR/Registry.php';
     $registry = new PEAR_Registry();
     $installedVersion = $registry->packageInfo($this->name, 'version', $this->channel);
     if (is_null($installedVersion)) {
         $this->log('Package "' . $this->name . '" from "' . $this->channel . '" is required', Project::MSG_ERR);
         return 1;
     }
     if ($this->min && version_compare($installedVersion, $this->min, '<')) {
         $this->log('Package "' . $this->name . '" from "' . $this->channel . '" is ' . $installedVersion . '. >= ' . $this->min . ' is required', Project::MSG_ERR);
         return 1;
     }
     if ($this->max && version_compare($installedVersion, $this->max, '>')) {
         $this->log('Package "' . $this->name . '" from "' . $this->channel . '" is ' . $installedVersion . '. <= ' . $this->max . ' is required', Project::MSG_ERR);
         return 1;
     }
     $this->log('Package "' . $this->name . '" ' . $installedVersion . ' is passed', Project::MSG_VERBOSE);
     return 0;
 }
开发者ID:kandy,项目名称:system,代码行数:27,代码来源:Package.php

示例6: doInstall

 function doInstall($command, $options, $params)
 {
     if (empty($this->installer)) {
         $this->installer =& new PEAR_Installer($this->ui);
     }
     if ($command == 'upgrade') {
         $options[$command] = true;
     }
     if ($command == 'upgrade-all') {
         include_once "PEAR/Remote.php";
         $options['upgrade'] = true;
         $remote = new PEAR_Remote($this->config);
         $state = $this->config->get('preferred_state');
         if (empty($state) || $state == 'any') {
             $latest = $remote->call("package.listLatestReleases");
         } else {
             $latest = $remote->call("package.listLatestReleases", $state);
         }
         if (PEAR::isError($latest)) {
             return $latest;
         }
         $reg = new PEAR_Registry($this->config->get('php_dir'));
         $installed = array_flip($reg->listPackages());
         $params = array();
         foreach ($latest as $package => $info) {
             if (!isset($installed[$package])) {
                 // skip packages we don't have installed
                 continue;
             }
             $inst_version = $reg->packageInfo($package, 'version');
             if (version_compare("{$info['version']}", "{$inst_version}", "le")) {
                 // installed version is up-to-date
                 continue;
             }
             $params[] = $package;
             $this->ui->outputData("will upgrade {$package}", $command);
         }
     }
     foreach ($params as $pkg) {
         $bn = basename($pkg);
         $info = $this->installer->install($pkg, $options, $this->config);
         if (is_array($info)) {
             if ($this->config->get('verbose') > 0) {
                 $label = "{$info['package']} {$info['version']}";
                 $out = array('data' => "{$command} ok: {$label}");
                 if (isset($info['release_warnings'])) {
                     $out['release_warnings'] = $info['release_warnings'];
                 }
                 $this->ui->outputData($out, $command);
             }
         } else {
             return $this->raiseError("{$command} failed");
         }
     }
     return true;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:56,代码来源:Install.php

示例7: foreach

include_once "PEAR/Registry.php";
if (WEBINSTALLER || isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'local') {
    $config =& PEAR_Config::singleton($prefix . "/pear.conf", '');
} else {
    $config =& PEAR_Config::singleton();
}
$config->set('preferred_state', 'stable');
foreach ($config_vars as $var) {
    if (isset(${$var}) && ${$var} != '') {
        $config->set($var, ${$var});
    }
}
$config->set('download_dir', $temp_dir . '/download');
$config->set('temp_dir', $temp_dir);
$config->store();
$registry = new PEAR_Registry($php_dir);
PEAR_Command::setFrontendType('CLI');
PEAR::staticPushErrorHandling(PEAR_ERROR_DIE);
//fail silently
$ch_cmd =& PEAR_Command::factory('update-channels', $config);
$ch_cmd->run('update-channels', $options, array());
PEAR::staticPopErrorHandling();
// reset error handling
unset($ch_cmd);
print "\n" . 'Installing selected packages..................' . "\n";
displayHTMLProgress($progress = 45);
$install =& PEAR_Command::factory('install', $config);
foreach ($to_install as $pkg) {
    $pkg_basename = substr($pkg, 0, strpos($pkg, '-'));
    if (in_array($pkg, $installer_packages)) {
        $options = array('nodeps' => true);
开发者ID:swat30,项目名称:safeballot,代码行数:31,代码来源:go-pear.php

示例8: doInstall

 function doInstall($command, $options, $params)
 {
     if (!class_exists('PEAR_PackageFile')) {
         require_once 'PEAR/PackageFile.php';
     }
     if (empty($this->installer)) {
         $this->installer =& $this->getInstaller($this->ui);
     }
     if ($command == 'upgrade' || $command == 'upgrade-all') {
         $options['upgrade'] = true;
     } else {
         $packages = $params;
     }
     if (isset($options['installroot']) && isset($options['packagingroot'])) {
         return $this->raiseError('ERROR: cannot use both --installroot and --packagingroot');
     }
     $reg =& $this->config->getRegistry();
     $instreg =& $reg;
     // instreg used to check if package is installed
     if (isset($options['packagingroot']) && !isset($options['upgrade'])) {
         $packrootphp_dir = $this->installer->_prependPath($this->config->get('php_dir', null, 'pear.php.net'), $options['packagingroot']);
         $instreg = new PEAR_Registry($packrootphp_dir);
         // other instreg!
         if ($this->config->get('verbose') > 2) {
             $this->ui->outputData('using package root: ' . $options['packagingroot']);
         }
     }
     $abstractpackages = array();
     $otherpackages = array();
     // parse params
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     foreach ($params as $param) {
         if (strpos($param, 'http://') === 0) {
             $otherpackages[] = $param;
             continue;
         }
         if (strpos($param, 'channel://') === false && @file_exists($param)) {
             if (isset($options['force'])) {
                 $otherpackages[] = $param;
                 continue;
             }
             $pkg = new PEAR_PackageFile($this->config);
             $pf = $pkg->fromAnyFile($param, PEAR_VALIDATE_DOWNLOADING);
             if (PEAR::isError($pf)) {
                 $otherpackages[] = $param;
                 continue;
             }
             if ($reg->packageExists($pf->getPackage(), $pf->getChannel()) && version_compare($pf->getVersion(), $reg->packageInfo($pf->getPackage(), 'version', $pf->getChannel()), '<=')) {
                 if ($this->config->get('verbose')) {
                     $this->ui->outputData('Ignoring installed package ' . $reg->parsedPackageNameToString(array('package' => $pf->getPackage(), 'channel' => $pf->getChannel()), true));
                 }
                 continue;
             }
             $otherpackages[] = $param;
             continue;
         }
         $e = $reg->parsePackageName($param, $this->config->get('default_channel'));
         if (PEAR::isError($e)) {
             $otherpackages[] = $param;
         } else {
             $abstractpackages[] = $e;
         }
     }
     PEAR::staticPopErrorHandling();
     // if there are any local package .tgz or remote static url, we can't
     // filter.  The filter only works for abstract packages
     if (count($abstractpackages) && !isset($options['force'])) {
         // when not being forced, only do necessary upgrades/installs
         if (isset($options['upgrade'])) {
             $abstractpackages = $this->_filterUptodatePackages($abstractpackages, $command);
         } else {
             foreach ($abstractpackages as $i => $package) {
                 if (isset($package['group'])) {
                     // do not filter out install groups
                     continue;
                 }
                 if ($instreg->packageExists($package['package'], $package['channel'])) {
                     if ($this->config->get('verbose')) {
                         $this->ui->outputData('Ignoring installed package ' . $reg->parsedPackageNameToString($package, true));
                     }
                     unset($abstractpackages[$i]);
                 }
             }
         }
         $abstractpackages = array_map(array($reg, 'parsedPackageNameToString'), $abstractpackages);
     } elseif (count($abstractpackages)) {
         $abstractpackages = array_map(array($reg, 'parsedPackageNameToString'), $abstractpackages);
     }
     $packages = array_merge($abstractpackages, $otherpackages);
     if (!count($packages)) {
         $this->ui->outputData('Nothing to ' . $command);
         return true;
     }
     $this->downloader =& $this->getDownloader($this->ui, $options, $this->config);
     $errors = array();
     $binaries = array();
     $downloaded = array();
     $downloaded =& $this->downloader->download($packages);
     if (PEAR::isError($downloaded)) {
         return $this->raiseError($downloaded);
//.........这里部分代码省略.........
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:101,代码来源:Install.php

示例9: getenv

<?php

# $NetBSD: pear_plist.php,v 1.9 2015/12/11 16:16:48 taca Exp $
# Parses package XML file and outputs appropriate PLIST
include_once "PEAR/Registry.php";
include_once "PEAR/PackageFile.php";
$PREFIX = getenv('PREFIX');
$PEAR_LIB = getenv('PEAR_LIB');
$WRKSRC = getenv('WRKSRC');
if (!($DESTDIR = getenv('DESTDIR'))) {
    $DESTDIR = '';
}
$config = PEAR_Config::singleton();
$package = new PEAR_PackageFile($config);
$info = $package->fromAnyFile("{$WRKSRC}/package.xml", PEAR_VALIDATE_INSTALLING);
$pkg = $info->getName();
$channel = $info->getChannel();
$registry = new PEAR_Registry($DESTDIR . $PREFIX . "/" . $PEAR_LIB);
$flist = $registry->packageInfo($pkg, 'filelist', $channel);
$regfile = $PEAR_LIB . '/.registry/.channel.' . $channel . '/' . strtolower($pkg) . '.reg';
if (!file_exists($DESTDIR . $PREFIX . '/' . $regfile)) {
    $regfile = $PEAR_LIB . '/.registry/' . strtolower($pkg) . '.reg';
}
echo "{$regfile}\n";
# output list of package files, in same order as specified in package
foreach ($flist as $f) {
    echo str_replace($PREFIX . '/', '', $f['installed_as']) . "\n";
}
开发者ID:petabi,项目名称:pkgsrc,代码行数:28,代码来源:pear_plist.php

示例10: doList

 function doList($command, $options, $params)
 {
     $reg = new PEAR_Registry($this->config->get('php_dir'));
     if (sizeof($params) == 0) {
         $installed = $reg->packageInfo();
         usort($installed, array(&$this, '_sortinfo'));
         $i = $j = 0;
         $data = array('caption' => 'Installed packages:', 'border' => true, 'headline' => array('Package', 'Version', 'State'));
         foreach ($installed as $package) {
             $data['data'][] = array($package['package'], $package['version'], @$package['release_state']);
         }
         if (count($installed) == 0) {
             $data = '(no packages installed)';
         }
         $this->ui->outputData($data, $command);
     } else {
         if (file_exists($params[0]) && !is_dir($params[0])) {
             include_once "PEAR/Common.php";
             $obj =& new PEAR_Common();
             $info = $obj->infoFromAny($params[0]);
             $headings = array('Package File', 'Install Path');
             $installed = false;
         } else {
             $info = $reg->packageInfo($params[0]);
             $headings = array('Type', 'Install Path');
             $installed = true;
         }
         if (PEAR::isError($info)) {
             return $this->raiseError($info);
         }
         if ($info === null) {
             return $this->raiseError("`{$params['0']}' not installed");
         }
         $list = $info['filelist'];
         if ($installed) {
             $caption = 'Installed Files For ' . $params[0];
         } else {
             $caption = 'Contents of ' . basename($params[0]);
         }
         $data = array('caption' => $caption, 'border' => true, 'headline' => $headings);
         foreach ($list as $file => $att) {
             if ($installed) {
                 if (empty($att['installed_as'])) {
                     continue;
                 }
                 $data['data'][] = array($att['role'], $att['installed_as']);
             } else {
                 if (isset($att['baseinstalldir'])) {
                     $dest = $att['baseinstalldir'] . DIRECTORY_SEPARATOR . $file;
                 } else {
                     $dest = $file;
                 }
                 switch ($att['role']) {
                     case 'test':
                     case 'data':
                         if ($installed) {
                             break 2;
                         }
                         $dest = '-- will not be installed --';
                         break;
                     case 'doc':
                         $dest = $this->config->get('doc_dir') . DIRECTORY_SEPARATOR . $dest;
                         break;
                     case 'php':
                     default:
                         $dest = $this->config->get('php_dir') . DIRECTORY_SEPARATOR . $dest;
                 }
                 $dest = preg_replace('!/+!', '/', $dest);
                 $file = preg_replace('!/+!', '/', $file);
                 $data['data'][] = array($file, $dest);
             }
         }
         $this->ui->outputData($data, $command);
     }
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:logicalframe,代码行数:76,代码来源:Registry.php

示例11: array

if (false && !file_exists($pear_user_config)) {
    // I think PEAR_Frontend_Web is running for the first time!
    // Install it properly ...
    // First of all set some config-vars:
    $cmd = PEAR_Command::factory('config-set', $config);
    $ok = $cmd->run('config-set', array(), array('php_dir', $dir . 'PEAR'));
    $ok = $cmd->run('config-set', array(), array('doc_dir', $dir . 'docs'));
    $ok = $cmd->run('config-set', array(), array('ext_dir', $dir . 'ext'));
    $ok = $cmd->run('config-set', array(), array('bin_dir', $dir . 'bin'));
    $ok = $cmd->run('config-set', array(), array('data_dir', $dir . 'data'));
    $ok = $cmd->run('config-set', array(), array('test_dir', $dir . 'test'));
    $ok = $cmd->run('config-set', array(), array('cache_dir', $dir . 'cache'));
    $ok = $cmd->run('config-set', array(), array('cache_ttl', 300));
    // Register packages
    $packages = array('Archive_Tar', 'Console_Getopt', 'HTML_Template_IT', 'Net_UserAgent_Detect', 'Pager', 'PEAR', 'PEAR_Frontend_Web', 'XML_RPC');
    $reg = new PEAR_Registry($dir . 'PEAR');
    if (!file_exists($dir . 'PEAR/.registry')) {
        PEAR::raiseError('Directory "' . $dir . 'PEAR/.registry" does not exist. please check your installation');
    }
    foreach ($packages as $pkg) {
        $info = $reg->packageInfo($pkg);
        foreach ($info['filelist'] as $fileName => $fileInfo) {
            if ($fileInfo['role'] == "php") {
                $info['filelist'][$fileName]['installed_as'] = str_replace('{dir}', $dir, $fileInfo['installed_as']);
            }
        }
        $reg->updatePackage($pkg, $info, false);
    }
}
// Handle some diffrent Commands
if (isset($_GET["command"])) {
开发者ID:blowfishJ,项目名称:galaxyCode,代码行数:31,代码来源:WebInstaller.php

示例12: rebuildDB

 /**
  * Rebuild the dependency DB by reading registry entries.
  * @return true|PEAR_Error
  */
 function rebuildDB()
 {
     $depdb = array('_version' => $this->_version);
     if (!$this->hasWriteAccess()) {
         // allow startup for read-only with older Registry
         return $depdb;
     }
     $packages = $this->_registry->listAllPackages();
     if (PEAR::isError($packages)) {
         return $packages;
     }
     foreach ($packages as $channel => $ps) {
         foreach ($ps as $package) {
             $package = $this->_registry->getPackage($package, $channel);
             if (PEAR::isError($package)) {
                 return $package;
             }
             $this->_setPackageDeps($depdb, $package);
         }
     }
     $error = $this->_writeDepDB($depdb);
     if (PEAR::isError($error)) {
         return $error;
     }
     $this->_cache = $depdb;
     return true;
 }
开发者ID:fathitarek,项目名称:cop5725-dbms-project,代码行数:31,代码来源:DependencyDB.php

示例13: packageInfo

 /**
  * (non-PHPdoc)
  * @see lib/Faett/Core/Interfaces/Faett_Core_Interfaces_Service#packageInfo($packageName, $channel)
  */
 public function packageInfo($packageName, $channel)
 {
     // store the default channel
     $savechannel = $this->_config->get('default_channel');
     // check if the cannel already exists
     if ($this->_registry->channelExists($channel)) {
         $this->_config->set('default_channel', $channel);
     } else {
         // throw a new exception
         throw Faett_Core_Exceptions_UnknownChannelException::create('Channel ' . $channel . ' does not exist');
     }
     // load the channel from the registry
     $chan = $this->_registry->getChannel($channel);
     // initialize a REST command for checking the channel's state
     $cmd = new PEAR_Command_Remote($this->_ui, $this->_config);
     if (PEAR::isError($e = $cmd->_checkChannelForStatus($channel, $chan))) {
         // reset the default channel
         $this->_config->set('default_channel', $savechannel);
         // throw a new exception
         throw Faett_Core_Exceptions_UnknownChannelStateException::create($e->getMessage());
     }
     // get the channel's base URL
     $base = $chan->getBaseURL('REST1.0', $this->_config->get('preferred_mirror'));
     // check if the channel's server is REST enabled
     $restSupport = $chan->supportsREST($this->_config->get('preferred_mirror'));
     // check if the channel is REST enabled
     if ($restSupport && $base) {
         // load the channel data and the package information
         $rest = $this->_config->getREST('1.0', array());
         $info = $rest->packageInfo($base, $packageName);
     } else {
         $r = $this->_config->getRemote();
         $info = $r->call('package.info', $packageName);
     }
     // check if the package information was loaded successfully
     if (PEAR::isError($info)) {
         // reset the default channel
         $this->_config->set('default_channel', $savechannel);
         // throw a new exception
         throw Faett_Core_Exceptions_PackageInfoException::create($info->getMessage());
     }
     // if no packge name was found log an error message
     if (!isset($info['name'])) {
         // reset the default channel
         $this->_config->set('default_channel', $savechannel);
         // throw a new exception
         throw Faett_Core_Exceptions_PackageInfoException::create('Can\'t find a package name');
     }
     // check if the package is installed
     $installed = $this->_registry->packageInfo($info['name'], null, $channel);
     // if yes, set the information
     $info['installed'] = $installed['version'] ? $installed['version'] : '';
     if (is_array($info['installed'])) {
         $info['installed'] = $info['installed']['release'];
     }
     // return the package information
     return $info;
 }
开发者ID:BGCX067,项目名称:faett-core-svn-to-git,代码行数:62,代码来源:Service.php

示例14: elseif

 /**
  * @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
  * @access private
  */
 function _analyzeDownloadURL($info, $param, $pname, $params = null)
 {
     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'] == 'pear.php.net') {
             if ($info['info']->getChannel() != 'pecl.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'])) {
         // 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'] . '"';
             } 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 . ', will instead download version ' . $info['version'] . ', stability "' . $info['info']->getState() . '"');
             }
             // 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'] . '"';
             } else {
                 $vs = ' within preferred state ' . $this->_downloader->config->get('preferred_state') . '"';
             }
             $err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . $vs . ', latest release is version ' . $info['version'] . ', stability "' . $info['info']->getState() . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['version'])) . '" to install');
             return $err;
         }
     }
     return $info;
 }
开发者ID:alex-k,项目名称:velotur,代码行数:65,代码来源:Package.php

示例15: installBinary

 /**
  * Installation of source package has failed, attempt to download and install the
  * binary version of this package.
  * @param PEAR_Installer
  */
 function installBinary(&$installer)
 {
     if ($this->getPackageType() == 'extsrc') {
         if (!is_array($installer->getInstallPackages())) {
             return false;
         }
         foreach ($installer->getInstallPackages() as $p) {
             if ($p->isExtension($this->_packageInfo['providesextension'])) {
                 if ($p->getPackageType() != 'extsrc') {
                     return false;
                     // the user probably downloaded it separately
                 }
             }
         }
         if (isset($this->_packageInfo['extsrcrelease']['binarypackage'])) {
             $installer->log(0, 'Attempting to download binary version of extension "' . $this->_packageInfo['providesextension'] . '"');
             $params = $this->_packageInfo['extsrcrelease']['binarypackage'];
             if (!is_array($params) || !isset($params[0])) {
                 $params = array($params);
             }
             if (isset($this->_packageInfo['channel'])) {
                 foreach ($params as $i => $param) {
                     $params[$i] = array('channel' => $this->_packageInfo['channel'], 'package' => $param);
                 }
             }
             $dl =& $this->getPEARDownloader($installer->ui, $installer->getOptions(), $installer->config);
             $verbose = $dl->config->get('verbose');
             $dl->config->set('verbose', -1);
             foreach ($params as $param) {
                 PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
                 $ret = $dl->download(array($param));
                 PEAR::popErrorHandling();
                 if (is_array($ret) && count($ret)) {
                     break;
                 }
             }
             $dl->config->set('verbose', $verbose);
             if (is_array($ret)) {
                 if (count($ret) == 1) {
                     $pf = $ret[0]->getPackageFile();
                     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
                     $ret = $installer->install($ret[0]);
                     PEAR::popErrorHandling();
                     if (is_array($ret)) {
                         $installer->log(0, 'Download and install of binary extension "' . $this->_registry->parsedPackageNameToString(array('channel' => $pf->getChannel(), 'package' => $pf->getPackage()), true) . '" successful');
                         return $ret;
                     }
                     $installer->log(0, 'Download and install of binary extension "' . $this->_registry->parsedPackageNameToString(array('channel' => $pf->getChannel(), 'package' => $pf->getPackage()), true) . '" failed');
                 }
             }
         }
     }
     return false;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:59,代码来源:v2.php


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