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


PHP File::getStorage方法代码示例

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


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

示例1: 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, ['width' => 150, 'height' => 150]);
         $previewImage = $processedFile->getPublicUrl(true);
         $content = '';
         if ($file->isMissing()) {
             $content .= '<span class="label label-danger label-space-right">' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:warning.file_missing')) . '</span>';
         }
         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 .= htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_misc.xlf:fileMetaDataLocation')) . ': ';
         $content .= htmlspecialchars($file->getStorage()->getName()) . ' - ' . htmlspecialchars($file->getIdentifier()) . '<br />';
         $content .= '<br />';
     } else {
         $content = '<h2>' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_misc.xlf:fileMetaErrorInvalidRecord')) . '</h2>';
     }
     return $content;
 }
开发者ID:,项目名称:,代码行数:31,代码来源:

示例2: updateWithLocalFile

 /**
  * Injects a local file, which is a processing result into the object.
  *
  * @param string $filePath
  * @return void
  * @throws \RuntimeException
  */
 public function updateWithLocalFile($filePath)
 {
     if ($this->identifier === null) {
         throw new \RuntimeException('Cannot update original file!', 1350582054);
     }
     $processingFolder = $this->originalFile->getStorage()->getProcessingFolder();
     $addedFile = $this->storage->updateProcessedFile($filePath, $this, $processingFolder);
     // Update some related properties
     $this->identifier = $addedFile->getIdentifier();
     $this->originalFileSha1 = $this->originalFile->getSha1();
     if ($addedFile instanceof AbstractFile) {
         $this->updateProperties($addedFile->getProperties());
     }
     $this->deleted = false;
     $this->updated = true;
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:23,代码来源:ProcessedFile.php

示例3: checkFileAccess

 /**
  * Check file access for given FeGroups combination
  *
  * @param \TYPO3\CMS\Core\Resource\File $file
  * @param bool|array $userFeGroups FALSE = no login, array() fe groups of user
  * @return bool
  */
 public function checkFileAccess($file, $userFeGroups)
 {
     // all files in public storage are accessible
     if ($file->getStorage()->isPublic()) {
         return true;
         // check folder access
     } elseif ($this->checkFolderRootLineAccess($file->getParentFolder(), $userFeGroups)) {
         // access to folder then check file privileges if present
         $feGroups = $file->getProperty('fe_groups');
         if ($feGroups !== '') {
             return $this->matchFeGroupsWithFeUser($feGroups, $userFeGroups);
         }
         return true;
     }
     return false;
 }
开发者ID:s-nunez,项目名称:fal_securedownload,代码行数:23,代码来源:CheckPermissions.php

示例4: findByFile

 /**
  * Returns array of meta-data properties
  *
  * @param File $file
  * @return array
  */
 public function findByFile(File $file)
 {
     $record = $this->findByFileUid($file->getUid());
     // It could be possible that the meta information is freshly
     // created and inserted into the database. If this is the case
     // we have to take care about correct meta information for width and
     // height in case of an image.
     if (!empty($record['newlyCreated'])) {
         if ($file->getType() === File::FILETYPE_IMAGE && $file->getStorage()->getDriverType() === 'Local') {
             $fileNameAndPath = $file->getForLocalProcessing(false);
             $imageInfo = GeneralUtility::makeInstance(FileType\ImageInfo::class, $fileNameAndPath);
             $additionalMetaInformation = array('width' => $imageInfo->getWidth(), 'height' => $imageInfo->getHeight());
             $this->update($file->getUid(), $additionalMetaInformation);
         }
         $record = $this->findByFileUid($file->getUid());
     }
     return $record;
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:24,代码来源:MetaDataRepository.php

示例5: init

    /**
     * Initialize
     *
     * @throws \TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException
     */
    protected function init()
    {
        // Initialize GPvars:
        $this->target = GeneralUtility::_GP('target');
        $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
        // Cleaning and checking target
        if ($this->target) {
            $this->fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->target);
        }
        if (!$this->fileOrFolderObject) {
            $title = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:paramError', TRUE);
            $message = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:targetNoDir', TRUE);
            throw new \RuntimeException($title . ': ' . $message, 1294586844);
        }
        if ($this->fileOrFolderObject->getStorage()->getUid() === 0) {
            throw new \TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException('You are not allowed to access files outside your storages', 1375889840);
        }
        // If a folder should be renamed, AND the returnURL should go to the old directory name, the redirect is forced
        // so the redirect will NOT end in a error message
        // this case only happens if you select the folder itself in the foldertree and then use the clickmenu to
        // rename the folder
        if ($this->fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
            $parsedUrl = parse_url($this->returnUrl);
            $queryParts = GeneralUtility::explodeUrl2Array(urldecode($parsedUrl['query']));
            if ($queryParts['id'] === $this->fileOrFolderObject->getCombinedIdentifier()) {
                $this->returnUrl = str_replace(urlencode($queryParts['id']), urlencode($this->fileOrFolderObject->getStorage()->getRootLevelFolder()->getCombinedIdentifier()), $this->returnUrl);
            }
        }
        // Setting icon and title
        $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('apps-filetree-root');
        $this->title = $icon . htmlspecialchars($this->fileOrFolderObject->getStorage()->getName()) . ': ' . htmlspecialchars($this->fileOrFolderObject->getIdentifier());
        // Setting template object
        $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
        $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/file_rename.html');
        $this->doc->backPath = $GLOBALS['BACK_PATH'];
        $this->doc->JScode = $this->doc->wrapScriptTags('
			function backToList() {	//
				top.goToModule("file_list");
			}
		');
    }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:46,代码来源:RenameFileController.php

示例6: init

 /**
  * Initialize
  *
  * @throws \TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException
  */
 protected function init()
 {
     // Initialize GPvars:
     $this->target = GeneralUtility::_GP('target');
     $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
     // Cleaning and checking target
     if ($this->target) {
         $this->fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->target);
     }
     if (!$this->fileOrFolderObject) {
         $title = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:paramError', true);
         $message = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:targetNoDir', true);
         throw new \RuntimeException($title . ': ' . $message, 1294586844);
     }
     if ($this->fileOrFolderObject->getStorage()->getUid() === 0) {
         throw new \TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException('You are not allowed to access files outside your storages', 1375889840);
     }
     // If a folder should be renamed, AND the returnURL should go to the old directory name, the redirect is forced
     // so the redirect will NOT end in an error message
     // this case only happens if you select the folder itself in the foldertree and then use the clickmenu to
     // rename the folder
     if ($this->fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
         $parsedUrl = parse_url($this->returnUrl);
         $queryParts = GeneralUtility::explodeUrl2Array(urldecode($parsedUrl['query']));
         if ($queryParts['id'] === $this->fileOrFolderObject->getCombinedIdentifier()) {
             $this->returnUrl = str_replace(urlencode($queryParts['id']), urlencode($this->fileOrFolderObject->getStorage()->getRootLevelFolder()->getCombinedIdentifier()), $this->returnUrl);
         }
     }
     // building pathInfo for metaInformation
     $pathInfo = ['combined_identifier' => $this->fileOrFolderObject->getCombinedIdentifier()];
     $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($pathInfo);
     // Setting up the context sensitive menu
     $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu');
     // Add javaScript
     $this->moduleTemplate->addJavaScriptCode('RenameFileInlineJavaScript', 'function backToList() {top.goToModule("file_FilelistList");}');
 }
开发者ID:Gregpl,项目名称:TYPO3.CMS,代码行数:41,代码来源:RenameFileController.php

示例7: getWhereClauseForFile

 /**
  * Returns a where clause to find a file in database
  *
  * @param File $file
  *
  * @return string
  */
 protected function getWhereClauseForFile(File $file)
 {
     if ((int) $file->_getPropertyRaw('uid') > 0) {
         $where = 'uid=' . (int) $file->getUid();
     } else {
         $where = sprintf('storage=%u AND identifier LIKE %s', (int) $file->getStorage()->getUid(), $this->getDatabaseConnection()->fullQuoteStr($file->_getPropertyRaw('identifier'), $this->table));
     }
     return $where;
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:16,代码来源:FileIndexRepository.php

示例8: getFileIndexRecord

 /**
  * Returns an index record of a file, or FALSE if the file is not indexed.
  *
  * @TODO : throw an exception if nothing found, for consistent handling as in AbstractRepository?
  * @param \TYPO3\CMS\Core\Resource\File $fileObject
  * @return bool|array
  */
 public function getFileIndexRecord(\TYPO3\CMS\Core\Resource\File $fileObject)
 {
     $storageUid = $fileObject->getStorage()->getUid();
     $identifier = $fileObject->getIdentifier();
     $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', $this->table, sprintf('storage=%u AND identifier=%s', $storageUid, $GLOBALS['TYPO3_DB']->fullQuoteStr($identifier, $this->table)));
     if (!is_array($row)) {
         return FALSE;
     } else {
         return $row;
     }
 }
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:18,代码来源:FileRepository.php

示例9: modifyFileIndexEntry

 /**
  * Get user permissions
  *
  * @param string|File $file
  * @param string $content
  * @param array $additionalFields
  * @param array $indexRecordValues
  * @param \tx_kesearch_indexer_types_file $indexer
  */
 public function modifyFileIndexEntry($file, $content, $additionalFields, &$indexRecordValues, $indexer)
 {
     if ($file instanceof File && !$file->getStorage()->isPublic()) {
         $indexRecordValues['fe_group'] = $this->checkPermissionsService->getPermissions($file);
     }
 }
开发者ID:camrun91,项目名称:fal_securedownload,代码行数:15,代码来源:KeSearchFilesHook.php

示例10: getStorage

 /**
  * Get the storage the original file is located in
  *
  * @return ResourceStorage
  */
 public function getStorage()
 {
     return $this->originalFile->getStorage();
 }
开发者ID:,项目名称:,代码行数:9,代码来源:

示例11: getFileIndexStatus

 /**
  * Checks the index status of a file and returns FALSE if the file is not
  * indexed, the uid otherwise.
  *
  * @param File $fileObject
  * @return boolean|integer
  * @deprecated since TYPO3 6.2, will be removed two versions later - use FileIndexRepository::isIndexed
  */
 public function getFileIndexStatus(File $fileObject)
 {
     GeneralUtility::logDeprecatedFunction();
     $storageUid = $fileObject->getStorage()->getUid();
     $identifier = $fileObject->getIdentifier();
     $row = $this->getFileIndexRepository()->findOneByStorageUidAndIdentifier($storageUid, $identifier);
     return is_array($row) ? $row['uid'] : FALSE;
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:16,代码来源:FileRepository.php

示例12: updateAction

 /**
  * Handle file upload for an existing file.
  *
  * @param File $file
  * @return string
  */
 public function updateAction(File $file)
 {
     $uploadedFile = $this->handleUpload();
     if (!is_object($uploadedFile)) {
         return htmlspecialchars(json_encode($uploadedFile), ENT_NOQUOTES);
     }
     /** @var $file File */
     $targetFolder = $file->getStorage()->getFolder(dirname($file->getIdentifier()));
     try {
         $storage = $file->getStorage();
         $storage->replaceFile($file, $uploadedFile->getFileWithAbsolutePath());
         // Run the indexer for extracting metadata.
         $this->getMediaIndexer($file->getStorage())->updateIndex($file)->extractMetadata($file);
         // Clear cache on pages holding a reference to this file.
         $this->getCacheService()->clearCache($file);
         $response = array('success' => TRUE, 'uid' => $file->getUid(), 'name' => $file->getName(), 'thumbnail' => $this->getThumbnailService($file)->create(), 'fileInfo' => $this->getMetadataViewHelper()->render($file));
     } catch (UploadException $e) {
         $response = array('error' => 'The upload has failed, no uploaded file found!');
     } catch (InsufficientUserPermissionsException $e) {
         $response = array('error' => 'You are not allowed to upload files!');
     } catch (UploadSizeException $e) {
         $response = array('error' => vsprintf('The uploaded file "%s" exceeds the size-limit', array($uploadedFile->getName())));
     } catch (InsufficientFolderWritePermissionsException $e) {
         $response = array('error' => vsprintf('Destination path "%s" was not within your mount points!', array($targetFolder->getIdentifier())));
     } catch (IllegalFileExtensionException $e) {
         $response = array('error' => vsprintf('Extension of file name "%s" is not allowed in "%s"!', array($uploadedFile->getName(), $targetFolder->getIdentifier())));
     } catch (ExistingTargetFileNameException $e) {
         $response = array('error' => vsprintf('No unique filename available in "%s"!', array($targetFolder->getIdentifier())));
     } catch (\RuntimeException $e) {
         $response = array('error' => vsprintf('Uploaded file could not be moved! Write-permission problem in "%s"?', array($targetFolder->getIdentifier())));
     }
     // to pass data through iframe you will need to encode all html tags
     header("Content-Type: text/plain");
     return htmlspecialchars(json_encode($response), ENT_NOQUOTES);
 }
开发者ID:visol,项目名称:media,代码行数:41,代码来源:AssetController.php


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