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


PHP File::process方法代码示例

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


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

示例1: renderPreview

 /**
  * Render preview for current record
  *
  * @return string
  */
 protected function renderPreview()
 {
     // Perhaps @TODO in future: Also display preview for records - without fileObject
     if (!$this->fileObject) {
         return;
     }
     $imageTag = '';
     $downloadLink = '';
     // check if file is marked as missing
     if ($this->fileObject->isMissing()) {
         $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($this->fileObject);
         $imageTag .= $flashMessage->render();
     } else {
         $fileExtension = $this->fileObject->getExtension();
         $thumbUrl = '';
         if (GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
             $thumbUrl = $this->fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => '400m', 'height' => '400m'))->getPublicUrl(TRUE);
         }
         // Create thumbnail image?
         if ($thumbUrl) {
             $imageTag .= '<img src="' . $thumbUrl . '" ' . 'alt="' . htmlspecialchars(trim($this->fileObject->getName())) . '" ' . 'title="' . htmlspecialchars(trim($this->fileObject->getName())) . '" />';
         }
         // Display download link?
         $url = $this->fileObject->getPublicUrl(TRUE);
         if ($url) {
             $downloadLink .= '<a href="' . htmlspecialchars($url) . '" target="_blank" class="t3-button">' . IconUtility::getSpriteIcon('actions-edit-download') . ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:download', TRUE) . '</a>';
         }
     }
     return ($imageTag ? '<p>' . $imageTag . '</p>' : '') . ($downloadLink ? '<p>' . $downloadLink . '</p>' : '');
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:35,代码来源:ElementInformationController.php

示例2: renderFileInformationContent

 /**
  * Renders a HTML Block with file information
  *
  * @param File $file
  * @return string
  */
 protected function renderFileInformationContent(File $file = null)
 {
     /** @var LanguageService $lang */
     $lang = $GLOBALS['LANG'];
     if ($file !== null) {
         $processedFile = $file->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => 150, 'height' => 150));
         $previewImage = $processedFile->getPublicUrl(true);
         $content = '';
         if ($file->isMissing()) {
             $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($file);
             $content .= $flashMessage->render();
         }
         if ($previewImage) {
             $content .= '<img src="' . htmlspecialchars($previewImage) . '" ' . 'width="' . $processedFile->getProperty('width') . '" ' . 'height="' . $processedFile->getProperty('height') . '" ' . 'alt="" class="t3-tceforms-sysfile-imagepreview" />';
         }
         $content .= '<strong>' . htmlspecialchars($file->getName()) . '</strong>';
         $content .= ' (' . htmlspecialchars(GeneralUtility::formatSize($file->getSize())) . 'bytes)<br />';
         $content .= BackendUtility::getProcessedValue('sys_file', 'type', $file->getType()) . ' (' . $file->getMimeType() . ')<br />';
         $content .= $lang->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaDataLocation', true) . ': ';
         $content .= htmlspecialchars($file->getStorage()->getName()) . ' - ' . htmlspecialchars($file->getIdentifier()) . '<br />';
         $content .= '<br />';
     } else {
         $content = '<h2>' . $lang->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaErrorInvalidRecord', true) . '</h2>';
     }
     return $content;
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:32,代码来源:FileInfoHook.php

示例3: createAction

 /**
  * Create a processed file according to some configuration.
  *
  * @param File $file
  * @param array $processingConfiguration
  * @return string
  */
 public function createAction(File $file, array $processingConfiguration = array())
 {
     $processedFile = $file->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $processingConfiguration);
     $response = array('success' => TRUE, 'original' => $file->getUid(), 'title' => $file->getProperty('title') ? $file->getProperty('title') : $file->getName(), 'publicUrl' => $processedFile->getPublicUrl(), 'width' => $processedFile->getProperty('width'), 'height' => $processedFile->getProperty('height'));
     header("Content-Type: text/json");
     return htmlspecialchars(json_encode($response), ENT_NOQUOTES);
 }
开发者ID:visol,项目名称:media,代码行数:14,代码来源:ProcessedFileController.php

示例4: renderFileInfo

    /**
     * Main function. Will generate the information to display for the item
     * set internally.
     *
     * @param string $returnLinkTag <a> tag closing/returning.
     * @return void
     * @todo Define visibility
     */
    public function renderFileInfo($returnLinkTag)
    {
        $fileExtension = $this->fileObject->getExtension();
        $code = '<div class="fileInfoContainer">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile($fileExtension) . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.file', TRUE) . ':</strong> ' . $this->fileObject->getName() . '&nbsp;&nbsp;' . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.filesize') . ':</strong> ' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($this->fileObject->getSize()) . '</div>
			';
        $this->content .= $this->doc->section('', $code);
        $this->content .= $this->doc->divider(2);
        // If the file was an image...
        // @todo: add this check in the domain model, or in the processing folder
        if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
            // @todo: find a way to make getimagesize part of the t3lib_file object
            $imgInfo = @getimagesize($this->fileObject->getForLocalProcessing(FALSE));
            $thumbUrl = $this->fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => '150m', 'height' => '150m'))->getPublicUrl(TRUE);
            $code = '<div class="fileInfoContainer fileDimensions">' . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.dimensions') . ':</strong> ' . $imgInfo[0] . 'x' . $imgInfo[1] . ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.pixels') . '</div>';
            $code .= '<br />
				<div align="center">' . $returnLinkTag . '<img src="' . $thumbUrl . '" alt="' . htmlspecialchars(trim($this->fileObject->getName())) . '" title="' . htmlspecialchars(trim($this->fileObject->getName())) . '" /></a></div>';
            $this->content .= $this->doc->section('', $code);
        } elseif ($fileExtension == 'ttf') {
            $thumbUrl = $this->fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => '530m', 'height' => '600m'))->getPublicUrl(TRUE);
            $thumb = '<br />
				<div align="center">' . $returnLinkTag . '<img src="' . $thumbUrl . '" border="0" title="' . htmlspecialchars(trim($this->fileObject->getName())) . '" alt="" /></a></div>';
            $this->content .= $this->doc->section('', $thumb);
        }
        // Traverse the list of fields to display for the record:
        $tableRows = array();
        $showRecordFieldList = $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'];
        $fieldList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $showRecordFieldList, TRUE);
        foreach ($fieldList as $name) {
            $name = trim($name);
            if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
                continue;
            }
            $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
            if ($isExcluded) {
                continue;
            }
            $uid = $this->row['uid'];
            $itemValue = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
            $itemLabel = $GLOBALS['LANG']->sL(\TYPO3\CMS\Backend\Utility\BackendUtility::getItemLabel($this->table, $name), 1);
            $tableRows[] = '
				<tr>
					<td class="t3-col-header">' . $itemLabel . '</td>
					<td>' . htmlspecialchars($itemValue) . '</td>
				</tr>';
        }
        // Create table from the information:
        $tableCode = '
			<table border="0" cellpadding="0" cellspacing="0" id="typo3-showitem" class="t3-table-info">
				' . implode('', $tableRows) . '
			</table>';
        $this->content .= $this->doc->section('', $tableCode);
        // References:
        if ($this->fileObject->isIndexed()) {
            $header = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem');
            $this->content .= $this->doc->section($header, $this->makeRef('_FILE', $this->fileObject));
        }
    }
开发者ID:noxludo,项目名称:TYPO3v4-Core,代码行数:65,代码来源:ElementInformationController.php

示例5: processImage

 /**
  * Does the actual image processing
  *
  * @return \TYPO3\CMS\Core\Resource\ProcessedFile
  */
 protected function processImage()
 {
     if (strstr($this->width . $this->height, 'm')) {
         $max = 'm';
     } else {
         $max = '';
     }
     $this->height = MathUtility::forceIntegerInRange($this->height, 0);
     $this->width = MathUtility::forceIntegerInRange($this->width, 0) . $max;
     $processingConfiguration = array('width' => $this->width, 'height' => $this->height, 'frame' => $this->frame);
     return $this->file->process('Image.CropScaleMask', $processingConfiguration);
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:17,代码来源:ShowImageController.php

示例6: createMagicImage

 /**
  * Creates a magic image
  *
  * @param Resource\File $imageFileObject: the original image file
  * @param array $fileConfiguration (width, height)
  * @return Resource\ProcessedFile
  */
 public function createMagicImage(Resource\File $imageFileObject, array $fileConfiguration)
 {
     // Process dimensions
     $maxWidth = MathUtility::forceIntegerInRange($fileConfiguration['width'], 0, $this->magicImageMaximumWidth);
     $maxHeight = MathUtility::forceIntegerInRange($fileConfiguration['height'], 0, $this->magicImageMaximumHeight);
     if (!$maxWidth) {
         $maxWidth = $this->magicImageMaximumWidth;
     }
     if (!$maxHeight) {
         $maxHeight = $this->magicImageMaximumHeight;
     }
     // Create the magic image
     $magicImage = $imageFileObject->process(Resource\ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, array('width' => $maxWidth . 'm', 'height' => $maxHeight . 'm'));
     return $magicImage;
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:22,代码来源:MagicImageService.php

示例7: renderPreview

    /**
     * Render preview for current record
     *
     * @return string
     */
    protected function renderPreview()
    {
        // Perhaps @todo in future: Also display preview for records - without fileObject
        if (!$this->fileObject) {
            return '';
        }
        $previewTag = '';
        $showLink = '';
        // check if file is marked as missing
        if ($this->fileObject->isMissing()) {
            $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($this->fileObject);
            $previewTag .= $flashMessage->render();
        } else {
            /** @var \TYPO3\CMS\Core\Resource\Rendering\RendererRegistry $rendererRegistry */
            $rendererRegistry = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Rendering\RendererRegistry::class);
            $fileRenderer = $rendererRegistry->getRenderer($this->fileObject);
            $fileExtension = $this->fileObject->getExtension();
            $url = $this->fileObject->getPublicUrl(true);
            // Check if there is a FileRenderer
            if ($fileRenderer !== null) {
                $previewTag = $fileRenderer->render($this->fileObject, '590m', '400m', array(), true);
                // else check if we can create an Image preview
            } elseif (GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
                $processedFile = $this->fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => '590m', 'height' => '400m'));
                // Create thumbnail image?
                if ($processedFile) {
                    $thumbUrl = $processedFile->getPublicUrl(true);
                    $previewTag .= '<img class="img-responsive img-thumbnail" src="' . $thumbUrl . '" ' . 'width="' . $processedFile->getProperty('width') . '" ' . 'height="' . $processedFile->getProperty('height') . '" ' . 'alt="' . htmlspecialchars(trim($this->fileObject->getName())) . '" ' . 'title="' . htmlspecialchars(trim($this->fileObject->getName())) . '" />';
                }
            }
            // Show
            if ($url) {
                $showLink .= '
					<a class="btn btn-primary" href="' . htmlspecialchars($url) . '" target="_blank">
						' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '
						' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.show', true) . '
					</a>';
            }
        }
        return ($previewTag ? '<p>' . $previewTag . '</p>' : '') . ($showLink ? '<p>' . $showLink . '</p>' : '');
    }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:46,代码来源:ElementInformationController.php

示例8: getPreview

 /**
  * Get preview image if cropping is set
  *
  * @param File $file
  * @param string $crop
  * @return string
  */
 public function getPreview(File $file, $crop)
 {
     $thumbnail = '';
     $maxWidth = 150;
     $maxHeight = 200;
     if ($crop) {
         $imageSetup = array('maxWidth' => $maxWidth, 'maxHeight' => $maxHeight, 'crop' => $crop);
         $processedImage = $file->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $imageSetup);
         // Only use a thumbnail if the processing process was successful by checking if image width is set
         if ($processedImage->getProperty('width')) {
             $imageUrl = $processedImage->getPublicUrl(TRUE);
             $thumbnail = '<img src="' . $imageUrl . '" ' . 'class="thumbnail thumbnail-status" ' . 'width="' . $processedImage->getProperty('width') . '" ' . 'height="' . $processedImage->getProperty('height') . '" >';
         }
     }
     $preview = '<div class="media-left">';
     $preview .= '<div class="t3js-image-manipulation-preview media-object' . ($thumbnail ? '' : ' hide') . '" ';
     // Set preview width/height needed by cropper
     $preview .= 'data-preview-width="' . $maxWidth . '" data-preview-height="' . $maxHeight . '">';
     $preview .= $thumbnail;
     $preview .= '</div></div>';
     return $preview;
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:29,代码来源:ImageManipulationElement.php

示例9: flattenResultDataValue

 /**
  * Flatten result value from FileProcessor
  *
  * The value can be a File, Folder or boolean
  *
  * @param bool|\TYPO3\CMS\Core\Resource\File|\TYPO3\CMS\Core\Resource\Folder $result
  * @return bool|string|array
  */
 protected function flattenResultDataValue($result)
 {
     if ($result instanceof \TYPO3\CMS\Core\Resource\File) {
         $thumbUrl = '';
         if (GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $result->getExtension())) {
             $processedFile = $result->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array());
             if ($processedFile) {
                 $thumbUrl = $processedFile->getPublicUrl(true);
             }
         }
         $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
         $result = array_merge($result->toArray(), array('date' => BackendUtility::date($result->getModificationTime()), 'icon' => $iconFactory->getIconForFileExtension($result->getExtension(), Icon::SIZE_SMALL)->render(), 'thumbUrl' => $thumbUrl));
     } elseif ($result instanceof \TYPO3\CMS\Core\Resource\Folder) {
         $result = $result->getIdentifier();
     }
     return $result;
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:25,代码来源:FileController.php

示例10: processSourceCollection

 /**
  * @param File $originalFile
  * @param array $defaultProcessConfiguration
  */
 protected function processSourceCollection(File $originalFile, array $defaultProcessConfiguration)
 {
     $configuration = $this->getConfiguration();
     foreach ($configuration->getSourceCollection() as $sourceCollection) {
         try {
             if (!is_array($sourceCollection)) {
                 throw new \RuntimeException();
             }
             if (isset($sourceCollection['sizes'])) {
                 $this->sizes[] = trim($sourceCollection['sizes'], ' ,');
             }
             if ((int) $sourceCollection['width'] > (int) $this->defaultWidth) {
                 throw new \RuntimeException();
             }
             $localProcessingConfiguration = $defaultProcessConfiguration;
             $localProcessingConfiguration['width'] = $sourceCollection['width'];
             $processedFile = $originalFile->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $localProcessingConfiguration);
             $url = $configuration->getAbsRefPrefix() . $processedFile->getPublicUrl();
             $this->data['data-' . $sourceCollection['dataKey']] = $url;
             $this->srcset[] = $url . rtrim(' ' . $sourceCollection['srcset'] ?: '');
         } catch (\Exception $ignoredException) {
             continue;
         }
     }
 }
开发者ID:alexanderschnitzler,项目名称:fluid-styled-responsive-images,代码行数:29,代码来源:ImageRenderer.php


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