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


PHP PEAR_PackageFile::fromAnyFile方法代码示例

本文整理汇总了PHP中PEAR_PackageFile::fromAnyFile方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_PackageFile::fromAnyFile方法的具体用法?PHP PEAR_PackageFile::fromAnyFile怎么用?PHP PEAR_PackageFile::fromAnyFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PEAR_PackageFile的用法示例。


在下文中一共展示了PEAR_PackageFile::fromAnyFile方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:relue,项目名称:magento2,代码行数:25,代码来源:Pear.php

示例2: 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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:27,代码来源:Pear.php

示例3: 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

示例4: realpath

 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;
 }
开发者ID:zseand,项目名称:kloxo,代码行数:34,代码来源:Installer.php

示例5: dirname

 function _analyzeBundledPackages()
 {
     if (!$this->_isValid) {
         return false;
     }
     if (!$this->_pf->getPackageType() == 'bundle') {
         return false;
     }
     if (!isset($this->_pf->_packageFile)) {
         return false;
     }
     $dir_prefix = dirname($this->_pf->_packageFile);
     $common = new PEAR_Common();
     $log = isset($this->_pf->_logger) ? array(&$this->_pf->_logger, 'log') : array($common, 'log');
     $info = $this->_pf->getContents();
     $info = $info['bundledpackage'];
     if (!is_array($info)) {
         $info = array($info);
     }
     $pkg = new PEAR_PackageFile($this->_pf->_config);
     foreach ($info as $package) {
         if (!file_exists($dir_prefix . DIRECTORY_SEPARATOR . $package)) {
             $this->_fileNotFound($dir_prefix . DIRECTORY_SEPARATOR . $package);
             $this->_isValid = 0;
             continue;
         }
         call_user_func_array($log, array(1, "Analyzing bundled package {$package}"));
         PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
         $ret = $pkg->fromAnyFile($dir_prefix . DIRECTORY_SEPARATOR . $package, PEAR_VALIDATE_NORMAL);
         PEAR::popErrorHandling();
         if (PEAR::isError($ret)) {
             call_user_func_array($log, array(0, "ERROR: package {$package} is not a valid " . 'package'));
             $inf = $ret->getUserInfo();
             if (is_array($inf)) {
                 foreach ($inf as $err) {
                     call_user_func_array($log, array(1, $err['message']));
                 }
             }
             return false;
         }
     }
     return true;
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:43,代码来源:Validator.php

示例6: 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;
 }
开发者ID:harriswong,项目名称:AContent,代码行数:39,代码来源:Common.php

示例7: foreach

 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;
 }
开发者ID:cheeepsan,项目名称:pear-core,代码行数:21,代码来源:Installer.php

示例8: getenv

$options['upgrade'] = true;
$install_root = getenv('INSTALL_ROOT');
if (!empty($install_root)) {
    $options['packagingroot'] = $install_root;
    $reg =& new PEAR_Registry($options['packagingroot'], false, false, $metadata_dir);
} else {
    $reg = $config->getRegistry('default');
}
$ui = PEAR_Frontend::singleton('PEAR_Frontend_CLI');
if (PEAR::isError($ui)) {
    die($ui->getMessage());
}
$installer = new PEAR_Installer($ui);
$pkg = new PEAR_PackageFile($config, $debug);
foreach ($install_files as $package => $instfile) {
    $info = $pkg->fromAnyFile($instfile, PEAR_VALIDATE_INSTALLING);
    if (PEAR::isError($info)) {
        if (is_array($info->getUserInfo())) {
            foreach ($info->getUserInfo() as $err) {
                $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err['message']));
            }
        }
        $ui->outputData(sprintf("[PEAR] %s: %s", $package, $info->getMessage()));
        continue;
    }
    $new_ver = $info->getVersion();
    $downloaderpackage = new PEAR_Downloader_Package($installer);
    $err = $downloaderpackage->initialize($instfile);
    if (PEAR::isError($err)) {
        $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage()));
        continue;
开发者ID:phpsource,项目名称:pear-core,代码行数:31,代码来源:install-pear.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: foreach

    $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']));
            $tar =& new Archive_Tar($fileinfo);
            if ($pxml = $tar->extractInString('package2.xml')) {
            } elseif ($pxml = $tar->extractInString('package.xml')) {
            }
            PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
            $pf = $pkg->fromAnyFile($fileinfo, PEAR_VALIDATE_NORMAL);
            PEAR::popErrorHandling();
            if (!PEAR::isError($pf)) {
                echo "     Version {$version}...";
                $pear_rest->saveReleaseREST($fileinfo, $pxml, $pf, $blah['doneby'], $blah['id']);
                echo "done\n";
            } else {
                echo "     Skipping INVALID Version {$version}\n";
            }
        }
        echo "\n";
    } else {
        echo "  done\n";
    }
}
echo "Generating Category Package REST...\n";
开发者ID:stof,项目名称:pearweb,代码行数:31,代码来源:generateREST.php

示例11: 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'];
//.........这里部分代码省略.........
开发者ID:orcoliver,项目名称:oneye,代码行数:101,代码来源:Registry.php


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