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


PHP PhabricatorFile::loadFileData方法代码示例

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


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

示例1: calculatePatch

 /**
  * Calculate the DiffMatchPatch patch between two Phabricator files.
  *
  * @phutil-external-symbol class diff_match_patch
  */
 public static function calculatePatch(PhabricatorFile $old = null, PhabricatorFile $new = null)
 {
     $root = dirname(phutil_get_library_root('phabricator'));
     require_once $root . '/externals/diff_match_patch/diff_match_patch.php';
     $old_hash = self::EMPTY_HASH;
     $new_hash = self::EMPTY_HASH;
     if ($old !== null) {
         $old_hash = $old->getContentHash();
     }
     if ($new !== null) {
         $new_hash = $new->getContentHash();
     }
     $old_content = '';
     $new_content = '';
     if ($old_hash === $new_hash) {
         return null;
     }
     if ($old_hash !== self::EMPTY_HASH) {
         $old_content = $old->loadFileData();
     } else {
         $old_content = '';
     }
     if ($new_hash !== self::EMPTY_HASH) {
         $new_content = $new->loadFileData();
     } else {
         $new_content = '';
     }
     $dmp = new diff_match_patch();
     $dmp_patches = $dmp->patch_make($old_content, $new_content);
     return $dmp->patch_toText($dmp_patches);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:36,代码来源:PhragmentPatchUtil.php

示例2: crudelyScaleTo

 /**
  * Very crudely scale an image up or down to an exact size.
  */
 private function crudelyScaleTo(PhabricatorFile $file, $dx, $dy)
 {
     $data = $file->loadFileData();
     $src = imagecreatefromstring($data);
     $dst = $this->applyScaleTo($src, $dx, $dy);
     return $this->saveImageDataInAnyFormat($dst, $file->getMimeType());
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:10,代码来源:PhabricatorImageTransformer.php

示例3: applyMemeToFile

 private function applyMemeToFile(PhabricatorFile $file, $upper_text, $lower_text)
 {
     $data = $file->loadFileData();
     $img_type = $file->getMimeType();
     $imagemagick = PhabricatorEnv::getEnvConfig('files.enable-imagemagick');
     if ($img_type != 'image/gif' || $imagemagick == false) {
         return $this->applyMemeTo($data, $upper_text, $lower_text, $img_type);
     }
     $data = $file->loadFileData();
     $input = new TempFile();
     Filesystem::writeFile($input, $data);
     list($out) = execx('convert %s info:', $input);
     $split = phutil_split_lines($out);
     if (count($split) > 1) {
         return $this->applyMemeWithImagemagick($input, $upper_text, $lower_text, count($split), $img_type);
     } else {
         return $this->applyMemeTo($data, $upper_text, $lower_text, $img_type);
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:19,代码来源:PhabricatorImageTransformer.php

示例4: buildSourceCodeView

 private function buildSourceCodeView(PhabricatorPaste $paste, PhabricatorFile $file)
 {
     $language = $paste->getLanguage();
     $source = $file->loadFileData();
     if (empty($language)) {
         $source = PhabricatorSyntaxHighlighter::highlightWithFilename($paste->getTitle(), $source);
     } else {
         $source = PhabricatorSyntaxHighlighter::highlightWithLanguage($language, $source);
     }
     $lines = explode("\n", $source);
     return id(new PhabricatorSourceCodeView())->setLines($lines);
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:12,代码来源:PhabricatorPasteViewController.php

示例5: generatePreview

 private function generatePreview(PhabricatorFile $file, $size)
 {
     $data = $file->loadFileData();
     $src = imagecreatefromstring($data);
     $x = imagesx($src);
     $y = imagesy($src);
     $scale = min($size / $x, $size / $y, 1);
     $dx = max($size / 4, $scale * $x);
     $dy = max($size / 4, $scale * $y);
     $dst = imagecreatetruecolor($dx, $dy);
     imagesavealpha($dst, true);
     imagefill($dst, 0, 0, imagecolorallocatealpha($dst, 255, 255, 255, 127));
     $sdx = $scale * $x;
     $sdy = $scale * $y;
     imagecopyresampled($dst, $src, ($dx - $sdx) / 2, ($dy - $sdy) / 2, 0, 0, $sdx, $sdy, $x, $y);
     return $this->saveImageDataInAnyFormat($dst, $file->getMimeType());
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:17,代码来源:PhabricatorImageTransformer.php

示例6: getFileDataIterator

 public function getFileDataIterator(PhabricatorFile $file, $begin, $end)
 {
     // The default implementation is trivial and just loads the entire file
     // upfront.
     $data = $file->loadFileData();
     if ($begin !== null && $end !== null) {
         $data = substr($data, $begin, $end - $begin);
     } else {
         if ($begin !== null) {
             $data = substr($data, $begin);
         } else {
             if ($end !== null) {
                 $data = substr($data, 0, $end);
             }
         }
     }
     return array($data);
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:18,代码来源:PhabricatorFileStorageEngine.php

示例7: applyScaleWithImagemagick

 private function applyScaleWithImagemagick(PhabricatorFile $file, $dx, $dy)
 {
     $img_type = $file->getMimeType();
     $imagemagick = PhabricatorEnv::getEnvConfig('files.enable-imagemagick');
     if ($img_type != 'image/gif' || $imagemagick == false) {
         return null;
     }
     $data = $file->loadFileData();
     $src = imagecreatefromstring($data);
     $x = imagesx($src);
     $y = imagesy($src);
     if (self::isEnormousGIF($x, $y)) {
         return null;
     }
     $scale = min($dx / $x, $dy / $y, 1);
     $sdx = $scale * $x;
     $sdy = $scale * $y;
     $input = new TempFile();
     Filesystem::writeFile($input, $data);
     $resized = new TempFile();
     $future = new ExecFuture('convert %s -coalesce -resize %sX%s%s %s', $input, $sdx, $sdy, '!', $resized);
     // Don't spend more than 10 seconds resizing; just fail if it takes longer
     // than that.
     $future->setTimeout(10)->resolvex();
     return Filesystem::readFile($resized);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:26,代码来源:PhabricatorImageTransformer.php

示例8: executeProfileTransform

 public function executeProfileTransform(PhabricatorFile $file, $x, $min_y, $max_y)
 {
     $data = $file->loadFileData();
     $image = $this->crudelyCropTo($data, $x, $min_y, $max_y);
     return PhabricatorFile::newFromFileData($image, array('name' => 'profile-' . $file->getName()));
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:6,代码来源:PhabricatorImageTransformer.php


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