本文整理汇总了PHP中TYPO3\CMS\Core\Resource\File::getUid方法的典型用法代码示例。如果您正苦于以下问题:PHP File::getUid方法的具体用法?PHP File::getUid怎么用?PHP File::getUid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Resource\File
的用法示例。
在下文中一共展示了File::getUid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOnlineMediaId
/**
* Get Online Media item id
*
* @param File $file
* @return string
*/
public function getOnlineMediaId(File $file)
{
if (!isset($this->onlineMediaIdCache[$file->getUid()])) {
// By definition these files only contain the ID of the remote media source
$this->onlineMediaIdCache[$file->getUid()] = trim($file->getContents());
}
return $this->onlineMediaIdCache[$file->getUid()];
}
示例2: 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);
}
示例3: create
/**
* Render a thumbnail of a media
*
* @throws MissingTcaConfigurationException
* @return string
*/
public function create()
{
if (empty($this->file)) {
throw new MissingTcaConfigurationException('Missing File object. Forgotten to set a file?', 1355933144);
}
// Default class name
$className = 'Fab\\Media\\Thumbnail\\FallBackThumbnailProcessor';
if (File::FILETYPE_IMAGE == $this->file->getType()) {
$className = 'Fab\\Media\\Thumbnail\\ImageThumbnailProcessor';
} elseif (File::FILETYPE_AUDIO == $this->file->getType()) {
$className = 'Fab\\Media\\Thumbnail\\AudioThumbnailProcessor';
} elseif (File::FILETYPE_VIDEO == $this->file->getType()) {
$className = 'Fab\\Media\\Thumbnail\\VideoThumbnailProcessor';
} elseif (File::FILETYPE_APPLICATION == $this->file->getType() || File::FILETYPE_TEXT == $this->file->getType()) {
$className = 'Fab\\Media\\Thumbnail\\ApplicationThumbnailProcessor';
}
/** @var $processorInstance \Fab\Media\Thumbnail\ThumbnailProcessorInterface */
$processorInstance = GeneralUtility::makeInstance($className);
$thumbnail = '';
if ($this->file->exists()) {
$thumbnail = $processorInstance->setThumbnailService($this)->create();
} else {
$logger = Logger::getInstance($this);
$logger->warning(sprintf('Resource not found for File uid "%s" at %s', $this->file->getUid(), $this->file->getIdentifier()));
}
return $thumbnail;
}
示例4: generateProcessedFileNameWithoutExtension
/**
* Generate the name of of the new File
*
* @return string
*/
public function generateProcessedFileNameWithoutExtension()
{
$name = $this->originalFile->getNameWithoutExtension();
$name .= '_' . $this->originalFile->getUid();
$name .= '_' . $this->calculateChecksum();
return $name;
}
示例5: 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;
}
示例6: main
/**
* Main function, rendering the content of the rename form
*
* @return void
*/
public function main()
{
// Make page header:
$this->content = $this->doc->startPage($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_rename.php.pagetitle'));
$pageContent = $this->doc->header($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_rename.php.pagetitle'));
if ($this->fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
$fileIdentifier = $this->fileOrFolderObject->getCombinedIdentifier();
} else {
$fileIdentifier = $this->fileOrFolderObject->getUid();
}
$pageContent .= '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_file')) . '" method="post" name="editform" role="form">';
// Making the formfields for renaming:
$pageContent .= '
<div class="form-group">
<input class="form-control" type="text" name="file[rename][0][target]" value="' . htmlspecialchars($this->fileOrFolderObject->getName()) . '" ' . $this->getDocumentTemplate()->formWidth(40) . ' />
<input type="hidden" name="file[rename][0][data]" value="' . htmlspecialchars($fileIdentifier) . '" />
</div>
';
// Making submit button:
$pageContent .= '
<div class="form-group">
<input class="btn btn-primary" type="submit" value="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_rename.php.submit', TRUE) . '" />
<input class="btn btn-danger" type="submit" value="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.cancel', TRUE) . '" onclick="backToList(); return false;" />
<input type="hidden" name="redirect" value="' . htmlspecialchars($this->returnUrl) . '" />
' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction') . '
</div>
';
$pageContent .= '</form>';
$docHeaderButtons = array('back' => '');
$docHeaderButtons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'file_rename');
// Back
if ($this->returnUrl) {
$docHeaderButtons['back'] = '<a href="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::linkThisUrl($this->returnUrl)) . '" class="typo3-goBack" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
}
// Add the HTML as a section:
$markerArray = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => '', 'CONTENT' => $pageContent, 'PATH' => $this->title);
$this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray);
$this->content .= $this->doc->endPage();
$this->content = $this->doc->insertStylesAndJS($this->content);
}
示例7: main
/**
* Main function, rendering the content of the rename form
*
* @return void
*/
public function main()
{
if ($this->fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
$fileIdentifier = $this->fileOrFolderObject->getCombinedIdentifier();
} else {
$fileIdentifier = $this->fileOrFolderObject->getUid();
}
$pageContent = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_file')) . '" method="post" name="editform" role="form">';
// Making the formfields for renaming:
$pageContent .= '
<div class="form-group">
<input class="form-control" type="text" name="file[rename][0][target]" value="' . htmlspecialchars($this->fileOrFolderObject->getName()) . '" ' . $this->getDocumentTemplate()->formWidth(40) . ' />
<input type="hidden" name="file[rename][0][data]" value="' . htmlspecialchars($fileIdentifier) . '" />
</div>
';
// Making submit button:
$pageContent .= '
<div class="form-group">
<input class="btn btn-primary" type="submit" value="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_rename.php.submit', true) . '" />
<input class="btn btn-danger" type="submit" value="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.cancel', true) . '" onclick="backToList(); return false;" />
<input type="hidden" name="redirect" value="' . htmlspecialchars($this->returnUrl) . '" />
</div>
';
$pageContent .= '</form>';
// Create buttons
$buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
// csh button
$cshButton = $buttonBar->makeHelpButton()->setModuleName('xMOD_csh_corebe')->setFieldName('file_rename');
$buttonBar->addButton($cshButton);
// back button
if ($this->returnUrl) {
$backButton = $buttonBar->makeLinkButton()->sethref(GeneralUtility::linkThisUrl($this->returnUrl))->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', true))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
$buttonBar->addButton($backButton);
}
// set header
$this->content = '<h1>' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_rename.php.pagetitle') . '</h1>';
// add section
$this->content .= $this->moduleTemplate->section('', $pageContent);
$this->moduleTemplate->setContent($this->content);
}
示例8: 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;
}
示例9: saveImage
/**
* Save an image with FAL
* @param \TYPO3\CMS\Core\Resource\File $fileObject
* @param \MUM\BjrFreizeit\Domain\Model\Leisure $leisure
* @param $pid
* @return int last insert id, file reference uid
*
*/
public function saveImage(\TYPO3\CMS\Core\Resource\File $fileObject, \MUM\BjrFreizeit\Domain\Model\Leisure $leisure)
{
//$dateiname = $filename; // Dateinamen auslesen
$tabellenName = 'tx_bjrfreizeit_domain_model_leisure';
$feldName = 'image';
$data = array('uid_local' => $fileObject->getUid(), 'uid_foreign' => $leisure->getUid(), 'tablenames' => $tabellenName, 'fieldname' => $feldName, 'pid' => $leisure->getPid(), 'table_local' => 'sys_file', 'tstamp' => time(), 'crdate' => time(), 'cruser_id' => 100);
$where = 'deleted ="0" AND hidden ="0" AND tablenames ="' . $tabellenName . '" AND uid_foreign=' . (int) $leisure->getUid() . ' AND table_local="sys_file"' . ' AND fieldname ="' . $feldName . '"';
$row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_file_reference', $where);
if (empty($row)) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_file_reference', $data, FALSE);
$res = $GLOBALS['TYPO3_DB']->sql_insert_id();
} else {
$data = array('uid_local' => $fileObject->getUid(), 'tstamp' => time(), 'cruser_id' => 100);
$res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_file_reference', $where, $data, FALSE);
}
return $res;
}
示例10: 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;
}
示例11: createFileReferenceFromFalFileObject
/**
* @param FalFile $file
* @param int $resourcePointer
* @return \Bureauoberhoff\H5upldr\Domain\Model\FileReference
*/
protected function createFileReferenceFromFalFileObject(FalFile $file, $resourcePointer = NULL)
{
$fileReference = $this->resourceFactory->createFileReferenceObject(array('uid_local' => $file->getUid(), 'uid_foreign' => uniqid('NEW_'), 'uid' => uniqid('NEW_'), 'crop' => NULL));
return $this->createFileReferenceFromFalFileReferenceObject($fileReference, $resourcePointer);
}
示例12: makeRef
/**
* Make reference display
*
* @param string $table Table name
* @param string|\TYPO3\CMS\Core\Resource\File $ref Filename or uid
* @return string HTML
* @todo Define visibility
*/
public function makeRef($table, $ref)
{
// Look up the path:
if ($table === '_FILE') {
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_file_reference', 'uid_local=' . $ref->getUid());
} else {
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') . ' AND ref_uid=' . intval($ref) . ' AND deleted=0');
}
// Compile information for title tag:
$infoData = array();
if (count($rows)) {
$infoData[] = '<tr class="t3-row-header">' . '<td> </td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.table') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.title') . '</td>' . '<td>[uid]</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.field') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.flexpointer') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.softrefKey') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.sorting') . '</td>' . '</tr>';
}
foreach ($rows as $row) {
if ($table === '_FILE') {
$row = $this->mapFileReferenceOnRefIndex($row);
}
$record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($row['tablename'], $row['recuid']);
$parentRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $record['pid']);
$actions = $this->getRecordActions($row['tablename'], $row['recuid']);
$infoData[] = '<tr class="bgColor4">' . '<td style="white-space:nowrap;">' . $actions . '</td>' . '<td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], TRUE) . '</td>' . '<td>' . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($row['tablename'], $record, TRUE) . '</td>' . '<td><span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': ' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages', $parentRecord)) . ' (uid=' . $record['pid'] . ')">' . $record['uid'] . '</span></td>' . '<td>' . htmlspecialchars($this->getFieldName($row['tablename'], $row['field'])) . '</td>' . '<td>' . htmlspecialchars($row['flexpointer']) . '</td>' . '<td>' . htmlspecialchars($row['softref_key']) . '</td>' . '<td>' . htmlspecialchars($row['sorting']) . '</td>' . '</tr>';
}
$referenceLine = '';
if (count($infoData)) {
$referenceLine = '<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' . implode('', $infoData) . '</table>';
}
return $referenceLine;
}
示例13: findByFile
/**
* Returns array of meta-data properties
*
* @param File $file
* @return array
*/
public function findByFile(File $file)
{
return $this->findByFileUid($file->getUid());
}
示例14: makeRef
/**
* Make reference display
*
* @param string $table Table name
* @param string|\TYPO3\CMS\Core\Resource\File $ref Filename or uid
* @return string HTML
*/
protected function makeRef($table, $ref)
{
$lang = $this->getLanguageService();
// Files reside in sys_file table
if ($table === '_FILE') {
$selectTable = 'sys_file';
$selectUid = $ref->getUid();
} else {
$selectTable = $table;
$selectUid = $ref;
}
$rows = $this->getDatabaseConnection()->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $this->getDatabaseConnection()->fullQuoteStr($selectTable, 'sys_refindex') . ' AND ref_uid=' . (int) $selectUid . ' AND deleted=0');
// Compile information for title tag:
$infoData = array();
$infoDataHeader = '';
if (!empty($rows)) {
$infoDataHeader = '
<tr>
<th class="col-icon"></th>
<th class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.uid') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</th>
<th class="col-control"></th>
</tr>';
}
foreach ($rows as $row) {
if ($row['tablename'] === 'sys_file_reference') {
$row = $this->transformFileReferenceToRecordReference($row);
if ($row['tablename'] === null || $row['recuid'] === null) {
return '';
}
}
$record = BackendUtility::getRecord($row['tablename'], $row['recuid']);
if ($record) {
$parentRecord = BackendUtility::getRecord('pages', $record['pid']);
$parentRecordTitle = is_array($parentRecord) ? BackendUtility::getRecordTitle('pages', $parentRecord) : '';
$icon = $this->iconFactory->getIconForRecord($row['tablename'], $record, Icon::SIZE_SMALL)->render();
$actions = $this->getRecordActions($row['tablename'], $row['recuid']);
$urlParameters = ['edit' => [$row['tablename'] => [$row['recuid'] => 'edit']], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
$url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
$infoData[] = '
<tr>
<td class="col-icon">
<a href="' . htmlspecialchars($url) . '" title="id=' . $record['uid'] . '">
' . $icon . '
</a>
</td>
<td class="col-title">
<a href="' . htmlspecialchars($url) . '" title="id=' . $record['uid'] . '" >
' . BackendUtility::getRecordTitle($row['tablename'], $record, true) . '
</a>
</td>
<td>' . $lang->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], true) . '</td>
<td>
<span title="' . $lang->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': ' . htmlspecialchars($parentRecordTitle) . ' (uid=' . $record['pid'] . ')">
' . $record['uid'] . '
</span>
</td>
<td>' . htmlspecialchars($this->getLabelForTableColumn($row['tablename'], $row['field'])) . '</td>
<td>' . htmlspecialchars($row['flexpointer']) . '</td>
<td>' . htmlspecialchars($row['softref_key']) . '</td>
<td>' . htmlspecialchars($row['sorting']) . '</td>
<td class="col-control">' . $actions . '</td>
</tr>';
} else {
$infoData[] = '
<tr>
<td class="col-icon"></td>
<td class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.missing_record') . ' (uid=' . (int) $row['recuid'] . ')</td>
<td>' . htmlspecialchars($lang->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title']) ?: $row['tablename']) . '</td>
<td></td>
<td>' . htmlspecialchars($this->getLabelForTableColumn($row['tablename'], $row['field'])) . '</td>
<td>' . htmlspecialchars($row['flexpointer']) . '</td>
<td>' . htmlspecialchars($row['softref_key']) . '</td>
<td>' . htmlspecialchars($row['sorting']) . '</td>
<td class="col-control"></td>
</tr>';
}
}
$referenceLine = '';
if (!empty($infoData)) {
$referenceLine = '
<div class="table-fit">
<table class="table table-striped table-hover">
<thead>' . $infoDataHeader . '</thead>
<tbody>' . implode('', $infoData) . '</tbody>
</table>
</div>';
}
//.........这里部分代码省略.........
示例15: extractRequiredMetaData
/**
* Since the core desperately needs image sizes in metadata table put them there
* This should be called after every "content" update and "record" creation
*
* @param File $fileObject
*/
protected function extractRequiredMetaData(File $fileObject)
{
// since the core desperately needs image sizes in metadata table do this manually
// prevent doing this for remote storages, remote storages must provide the data with extractors
if ($fileObject->getType() == File::FILETYPE_IMAGE && $this->storage->getDriverType() === 'Local') {
$rawFileLocation = $fileObject->getForLocalProcessing(FALSE);
$imageInfo = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Type\\File\\ImageInfo', $rawFileLocation);
$metaData = array('width' => $imageInfo->getWidth(), 'height' => $imageInfo->getHeight());
$this->getMetaDataRepository()->update($fileObject->getUid(), $metaData);
$fileObject->_updateMetaDataProperties($metaData);
}
}