本文整理汇总了PHP中TYPO3\CMS\Core\Resource\File::getSize方法的典型用法代码示例。如果您正苦于以下问题:PHP File::getSize方法的具体用法?PHP File::getSize怎么用?PHP File::getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Resource\File
的用法示例。
在下文中一共展示了File::getSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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() . ' ' . '<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));
}
}
示例3: getIfFalRelationIfAlreadyExists
/**
* Get an existing items from the references that matches the file
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\GeorgRinger\News\Domain\Model\FileReference> $items
* @param \TYPO3\CMS\Core\Resource\File $file
* @return bool|FileReference
*/
protected function getIfFalRelationIfAlreadyExists(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $items, \TYPO3\CMS\Core\Resource\File $file)
{
$result = FALSE;
if ($items->count() !== 0) {
/** @var $item FileReference */
foreach ($items as $item) {
// only check already persisted items
if ($item->getFileUid() === (int) $file->getUid() || $item->getUid() && $item->getOriginalResource()->getName() === $file->getName() && $item->getOriginalResource()->getSize() === (int) $file->getSize()) {
$result = $item;
break;
}
}
}
return $result;
}
示例4: getSize
/**
* Returns the size of this file
*
* @return int
*/
public function getSize()
{
return (int) $this->originalFile->getSize();
}