本文整理汇总了PHP中TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getCurrentFile方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentObjectRenderer::getCurrentFile方法的具体用法?PHP ContentObjectRenderer::getCurrentFile怎么用?PHP ContentObjectRenderer::getCurrentFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
的用法示例。
在下文中一共展示了ContentObjectRenderer::getCurrentFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDataExtension
/**
* Extends the getData()-Method of ContentObjectRenderer to process more/other commands
*
* @param string $getDataString Full content of getData-request e.g. "TSFE:id // field:title // field:uid
* @param array $fields Current field-array
* @param string $sectionValue Currently examined section value of the getData request e.g. "field:title
* @param string $returnValue Current returnValue that was processed so far by getData
* @param ContentObjectRenderer $parentObject Parent content object
*
* @return string Get data result
*/
public function getDataExtension($getDataString, array $fields, $sectionValue, $returnValue, ContentObjectRenderer &$parentObject)
{
$parts = explode(':', $getDataString);
if (isset($parts[0]) && isset($parts[1]) && $parts[0] === 'fp') {
$fileObject = $parentObject->getCurrentFile();
if (!$fileObject instanceof FileReference) {
return $returnValue;
}
$originalFile = $fileObject->getOriginalFile();
switch ($parts[1]) {
case 'x':
case 'y':
$metaData = $originalFile->_getMetaData();
return $metaData['focus_point_' . $parts[1]] / 100;
case 'xp':
case 'yp':
$metaData = $originalFile->_getMetaData();
return (double) $metaData['focus_point_' . substr($parts[1], 0, 1)];
case 'xp_positive':
case 'yp_positive':
$metaData = $originalFile->_getMetaData();
return ((double) $metaData['focus_point_' . substr($parts[1], 0, 1)] + 100) / 2;
case 'w':
case 'h':
$fileName = GeneralUtility::getFileAbsFileName($fileObject->getPublicUrl(true));
if (file_exists($fileName)) {
$sizes = getimagesize($fileName);
return $sizes[$parts[1] == 'w' ? 0 : 1];
}
break;
}
}
return $returnValue;
}
示例2: addFileData
public function addFileData($content, array $configuration = NULL)
{
$currentFile = $this->cObj->getCurrentFile();
if ($currentFile instanceof \TYPO3\CMS\Core\Resource\File) {
$tableName = 'sys_file';
} elseif ($currentFile instanceof \TYPO3\CMS\Core\Resource\FileReference) {
$tableName = 'sys_file_reference';
} else {
return;
}
$recordData = $this->filterFields($tableName, $currentFile->getProperties());
$recordIdentifier = $tableName . ':' . $currentFile->getUid();
$this->records[$recordIdentifier] = $recordData;
$currentWatcherValue = $this->getCurrentWatcherValue();
$levelIdentifier = rtrim($currentWatcherValue, '/');
$this->addToStructure($levelIdentifier, $recordIdentifier, $recordData);
}