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


PHP TempFSFile::getPath方法代码示例

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


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

示例1: generateAndSaveThumb

 /**
  * Generates a thumbnail according to the given parameters and saves it to storage
  * @param TempFSFile $tmpFile Temporary file where the rendered thumbnail will be saved
  * @param array $transformParams
  * @param int $flags
  * @return bool|MediaTransformOutput
  */
 public function generateAndSaveThumb($tmpFile, $transformParams, $flags)
 {
     global $wgIgnoreImageErrors;
     $stats = RequestContext::getMain()->getStats();
     $handler = $this->getHandler();
     $normalisedParams = $transformParams;
     $handler->normaliseParams($this, $normalisedParams);
     $thumbName = $this->thumbName($normalisedParams);
     $thumbUrl = $this->getThumbUrl($thumbName);
     $thumbPath = $this->getThumbPath($thumbName);
     // final thumb path
     $tmpThumbPath = $tmpFile->getPath();
     if ($handler->supportsBucketing()) {
         $this->generateBucketsIfNeeded($normalisedParams, $flags);
     }
     $starttime = microtime(true);
     // Actually render the thumbnail...
     $thumb = $handler->doTransform($this, $tmpThumbPath, $thumbUrl, $transformParams);
     $tmpFile->bind($thumb);
     // keep alive with $thumb
     $statTiming = microtime(true) - $starttime;
     $stats->timing('media.thumbnail.generate.transform', 1000 * $statTiming);
     if (!$thumb) {
         // bad params?
         $thumb = false;
     } elseif ($thumb->isError()) {
         // transform error
         /** @var $thumb MediaTransformError */
         $this->lastError = $thumb->toText();
         // Ignore errors if requested
         if ($wgIgnoreImageErrors && !($flags & self::RENDER_NOW)) {
             $thumb = $handler->getTransform($this, $tmpThumbPath, $thumbUrl, $transformParams);
         }
     } elseif ($this->repo && $thumb->hasFile() && !$thumb->fileIsSource()) {
         // Copy the thumbnail from the file system into storage...
         $starttime = microtime(true);
         $disposition = $this->getThumbDisposition($thumbName);
         $status = $this->repo->quickImport($tmpThumbPath, $thumbPath, $disposition);
         if ($status->isOK()) {
             $thumb->setStoragePath($thumbPath);
         } else {
             $thumb = $this->transformErrorOutput($thumbPath, $thumbUrl, $transformParams, $flags);
         }
         $statTiming = microtime(true) - $starttime;
         $stats->timing('media.thumbnail.generate.store', 1000 * $statTiming);
         // Give extensions a chance to do something with this thumbnail...
         Hooks::run('FileTransformed', array($this, $thumb, $tmpThumbPath, $thumbPath));
     }
     return $thumb;
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:57,代码来源:File.php

示例2: generateAndSaveThumb

 /**
  * Generates a thumbnail according to the given parameters and saves it to storage
  * @param TempFSFile $tmpFile Temporary file where the rendered thumbnail will be saved
  * @param array $transformParams
  * @param int $flags
  * @return bool|MediaTransformOutput
  */
 public function generateAndSaveThumb($tmpFile, $transformParams, $flags)
 {
     global $wgUseSquid, $wgIgnoreImageErrors;
     $handler = $this->getHandler();
     $normalisedParams = $transformParams;
     $handler->normaliseParams($this, $normalisedParams);
     $thumbName = $this->thumbName($normalisedParams);
     $thumbUrl = $this->getThumbUrl($thumbName);
     $thumbPath = $this->getThumbPath($thumbName);
     // final thumb path
     $tmpThumbPath = $tmpFile->getPath();
     if ($handler->supportsBucketing()) {
         $this->generateBucketsIfNeeded($normalisedParams, $flags);
     }
     // Actually render the thumbnail...
     $thumb = $handler->doTransform($this, $tmpThumbPath, $thumbUrl, $transformParams);
     $tmpFile->bind($thumb);
     // keep alive with $thumb
     if (!$thumb) {
         // bad params?
         $thumb = false;
     } elseif ($thumb->isError()) {
         // transform error
         $this->lastError = $thumb->toText();
         // Ignore errors if requested
         if ($wgIgnoreImageErrors && !($flags & self::RENDER_NOW)) {
             $thumb = $handler->getTransform($this, $tmpThumbPath, $thumbUrl, $transformParams);
         }
     } elseif ($this->repo && $thumb->hasFile() && !$thumb->fileIsSource()) {
         // Copy the thumbnail from the file system into storage...
         $disposition = $this->getThumbDisposition($thumbName);
         $status = $this->repo->quickImport($tmpThumbPath, $thumbPath, $disposition);
         if ($status->isOK()) {
             $thumb->setStoragePath($thumbPath);
         } else {
             $thumb = $this->transformErrorOutput($thumbPath, $thumbUrl, $transformParams, $flags);
         }
         // Give extensions a chance to do something with this thumbnail...
         Hooks::run('FileTransformed', array($this, $thumb, $tmpThumbPath, $thumbPath));
     }
     // Purge. Useful in the event of Core -> Squid connection failure or squid
     // purge collisions from elsewhere during failure. Don't keep triggering for
     // "thumbs" which have the main image URL though (bug 13776)
     if ($wgUseSquid) {
         if (!$thumb || $thumb->isError() || $thumb->getUrl() != $this->getURL()) {
             SquidUpdate::purge(array($thumbUrl));
         }
     }
     return $thumb;
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:57,代码来源:File.php


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