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


PHP PEAR_PackageFile_v2::getContents方法代码示例

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


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

示例1: dirname

 function _analyzePhpFiles()
 {
     if (!$this->_isValid) {
         return false;
     }
     if (!isset($this->_pf->_packageFile)) {
         $this->_cannotValidateNoPathSet();
         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['dir']['file'];
     if (isset($info['attribs'])) {
         $info = array($info);
     }
     $provides = array();
     foreach ($info as $fa) {
         $fa = $fa['attribs'];
         $file = $fa['name'];
         if (!file_exists($dir_prefix . DIRECTORY_SEPARATOR . $file)) {
             $this->_fileNotFound($dir_prefix . DIRECTORY_SEPARATOR . $file);
             $this->_isValid = 0;
             continue;
         }
         if (in_array($fa['role'], PEAR_Installer_Role::getPhpRoles()) && $dir_prefix) {
             call_user_func_array($log, array(1, "Analyzing {$file}"));
             $srcinfo = $this->analyzeSourceCode($dir_prefix . DIRECTORY_SEPARATOR . $file);
             if ($srcinfo) {
                 $provides = array_merge($provides, $this->_buildProvidesArray($srcinfo));
             }
         }
     }
     $this->_packageName = $pn = $this->_pf->getPackage();
     $pnl = strlen($pn);
     foreach ($provides as $key => $what) {
         if (isset($what['explicit']) || !$what) {
             // skip conformance checks if the provides entry is
             // specified in the package.xml file
             continue;
         }
         extract($what);
         if ($type == 'class') {
             if (!strncasecmp($name, $pn, $pnl)) {
                 continue;
             }
             $this->_stack->push(__FUNCTION__, 'warning', array('file' => $file, 'type' => $type, 'name' => $name, 'package' => $pn), 'in %file%: %type% "%name%" not prefixed with package name "%package%"');
         } elseif ($type == 'function') {
             if (strstr($name, '::') || !strncasecmp($name, $pn, $pnl)) {
                 continue;
             }
             $this->_stack->push(__FUNCTION__, 'warning', array('file' => $file, 'type' => $type, 'name' => $name, 'package' => $pn), 'in %file%: %type% "%name%" not prefixed with package name "%package%"');
         }
     }
     return $this->_isValid;
 }
开发者ID:laiello,项目名称:coopcrucial,代码行数:57,代码来源:Validator.php

示例2: basename

 /**
  * Package up both a package.xml and package2.xml for the same release
  * @param PEAR_Packager
  * @param PEAR_PackageFile_v1
  * @param bool generate a .tgz or a .tar
  * @param string|null temporary directory to package in
  */
 function toTgz2(&$packager, &$pf1, $compress = true, $where = null)
 {
     require_once 'Archive/Tar.php';
     if (!$this->_packagefile->isEquivalent($pf1)) {
         return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: "' . basename($pf1->getPackageFile()) . '" is not equivalent to "' . basename($this->_packagefile->getPackageFile()) . '"');
     }
     if ($where === null) {
         if (!($where = System::mktemp(array('-d')))) {
             return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: mktemp failed');
         }
     } elseif (!@System::mkDir(array('-p', $where))) {
         return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: "' . $where . '" could' . ' not be created');
     }
     if (file_exists($where . DIRECTORY_SEPARATOR . 'package.xml') && !is_file($where . DIRECTORY_SEPARATOR . 'package.xml')) {
         return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: unable to save package.xml as' . ' "' . $where . DIRECTORY_SEPARATOR . 'package.xml"');
     }
     if (!$this->_packagefile->validate(PEAR_VALIDATE_PACKAGING)) {
         return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: invalid package.xml');
     }
     $ext = $compress ? '.tgz' : '.tar';
     $pkgver = $this->_packagefile->getPackage() . '-' . $this->_packagefile->getVersion();
     $dest_package = getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext;
     if (file_exists(getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext) && !is_file(getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext)) {
         return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: cannot create tgz file "' . getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext . '"');
     }
     if ($pkgfile = $this->_packagefile->getPackageFile()) {
         $pkgdir = dirname(realpath($pkgfile));
         $pkgfile = basename($pkgfile);
     } else {
         return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: package file object must ' . 'be created from a real file');
     }
     // {{{ Create the package file list
     $filelist = array();
     $i = 0;
     $this->_packagefile->flattenFilelist();
     $contents = $this->_packagefile->getContents();
     if (isset($contents['bundledpackage'])) {
         // bundles of packages
         $contents = $contents['bundledpackage'];
         if (!isset($contents[0])) {
             $contents = array($contents);
         }
         $packageDir = $where;
         foreach ($contents as $i => $package) {
             $fname = $package;
             $file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
             if (!file_exists($file)) {
                 return $packager->raiseError("File does not exist: {$fname}");
             }
             $tfile = $packageDir . DIRECTORY_SEPARATOR . $fname;
             System::mkdir(array('-p', dirname($tfile)));
             copy($file, $tfile);
             $filelist[$i++] = $tfile;
             $packager->log(2, "Adding package {$fname}");
         }
     } else {
         // normal packages
         $contents = $contents['dir']['file'];
         if (!isset($contents[0])) {
             $contents = array($contents);
         }
         $packageDir = $where;
         foreach ($contents as $i => $file) {
             $fname = $file['attribs']['name'];
             $atts = $file['attribs'];
             $orig = $file;
             $file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
             if (!file_exists($file)) {
                 return $packager->raiseError("File does not exist: {$fname}");
             } else {
                 $tfile = $packageDir . DIRECTORY_SEPARATOR . $fname;
                 unset($orig['attribs']);
                 if (count($orig)) {
                     // file with tasks
                     // run any package-time tasks
                     if (function_exists('file_get_contents')) {
                         $contents = file_get_contents($file);
                     } else {
                         $fp = fopen($file, "r");
                         $contents = @fread($fp, filesize($file));
                         fclose($fp);
                     }
                     foreach ($orig as $tag => $raw) {
                         $tag = str_replace($this->_packagefile->getTasksNs() . ':', '', $tag);
                         $task = "PEAR_Task_{$tag}";
                         $task =& new $task($this->_packagefile->_config, $this->_packagefile->_logger, PEAR_TASK_PACKAGE);
                         $task->init($raw, $atts, null);
                         $res = $task->startSession($this->_packagefile, $contents, $tfile);
                         if (!$res) {
                             continue;
                             // skip this task
                         }
                         if (PEAR::isError($res)) {
//.........这里部分代码省略.........
开发者ID:prometheus-ev,项目名称:promdilps,代码行数:101,代码来源:v2.php


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