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


PHP eZPackage::temporaryImportPath方法代码示例

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


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

示例1: import

 /**
  * Imports a package from a gzip compressed tarball file
  *
  * @param string $archiveName Path to the archive file
  * @param string $packageName Package name
  * @param bool $dbAvailable
  * @param bool $repositoryID
  *
  * @return eZPackage The eZPackage object if successfull, or one of the
  *         STATUS_* class constants if an error occurs
  */
 static function import($archiveName, &$packageName, $dbAvailable = true, $repositoryID = false)
 {
     if (is_dir($archiveName)) {
         eZDebug::writeError("Importing from directory is not supported.");
         $retValue = false;
         return $retValue;
     } else {
         $tempDirPath = eZPackage::temporaryImportPath();
         // make a temporary directory to extract the package file to
         do {
             $archivePath = eZDir::path(array($tempDirPath, mt_rand()));
         } while (file_exists($archivePath));
         eZDir::mkdir($archivePath, false, true);
         $archiveOptions = new ezcArchiveOptions(array('readOnly' => true));
         // Fix for issue #15891: ezjscore - file names are cutted
         // Force the type of the archive as ezcArchive::TAR_GNU so that long file names are supported on Windows
         // The previous value for the second parameter was null which meant the type was guessed from the
         // archive, but on Windows it was detected as TAR_USTAR and this lead to filenames being limited
         // to 100 characters
         $archive = ezcArchive::open("compress.zlib://{$archiveName}", ezcArchive::TAR_GNU, $archiveOptions);
         $fileList = array();
         $fileList[] = eZPackage::definitionFilename();
         // Search for the files we want to extract
         foreach ($archive as $entry) {
             if (in_array($entry->getPath(), $fileList)) {
                 if (!$archive->extractCurrent($archivePath)) {
                     eZDebug::writeError("Failed extracting package definition file from {$archivePath}");
                     return false;
                 }
             }
         }
         $definitionFileName = eZDir::path(array($archivePath, self::definitionFilename()));
         $package = eZPackage::fetchFromFile($definitionFileName);
         eZPackage::removeFiles($archivePath);
         if ($package) {
             $packageName = $package->attribute('name');
             if (!self::isValidName($packageName)) {
                 return eZPackage::STATUS_INVALID_NAME;
             }
             if (!$repositoryID) {
                 $repositoryID = $package->attribute('vendor-dir');
             }
             $existingPackage = eZPackage::fetch($packageName, false, false, $dbAvailable);
             if ($existingPackage) {
                 return eZPackage::STATUS_ALREADY_EXISTS;
             }
             unset($package);
             $fullRepositoryPath = eZPackage::repositoryPath() . '/' . $repositoryID;
             $packagePath = $fullRepositoryPath . '/' . $packageName;
             if (!file_exists($packagePath)) {
                 eZDir::mkdir($packagePath, false, true);
             }
             $archive->extract($packagePath);
             $package = eZPackage::fetch($packageName, $fullRepositoryPath, false, $dbAvailable);
             if (!$package) {
                 eZDebug::writeError("Failed loading imported package {$packageName} from {$fullRepositoryPath}");
             }
         } else {
             eZDebug::writeError("Failed loading temporary package {$packageName}");
         }
         return $package;
     }
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:74,代码来源:ezpackage.php


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