本文整理汇总了PHP中TYPO3\CMS\Core\Resource\Folder类的典型用法代码示例。如果您正苦于以下问题:PHP Folder类的具体用法?PHP Folder怎么用?PHP Folder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Folder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ext_isLinkable
/**
* Returns TRUE if the input "record" contains a folder which can be linked.
*
* @param \TYPO3\CMS\Core\Resource\Folder $folderObject object with information about the folder element. Contains keys like title, uid, path, _title
*
* @return bool TRUE is returned if the path is NOT a recycler or temp folder AND if ->ext_noTempRecyclerDirs is not set.
*/
public function ext_isLinkable($folderObject)
{
if ($this->ext_noTempRecyclerDirs && (substr($folderObject->getIdentifier(), -7) == '_temp_/' || substr($folderObject->getIdentifier(), -11) == '_recycler_/')) {
return FALSE;
} else {
return TRUE;
}
}
示例2: ext_isLinkable
/**
* Returns TRUE if the input "record" contains a folder which can be linked.
*
* @param \TYPO3\CMS\Core\Resource\Folder $folderObject Object with information about the folder element. Contains keys like title, uid, path, _title
* @return bool TRUE is returned if the path is found in the web-part of the server and is NOT a recycler or temp folder
*/
public function ext_isLinkable(\TYPO3\CMS\Core\Resource\Folder $folderObject)
{
if (strstr($folderObject->getIdentifier(), '_recycler_') || strstr($folderObject->getIdentifier(), '_temp_')) {
return FALSE;
} else {
return TRUE;
}
}
示例3: setUp
/**
* @throws \PHPUnit_Framework_Exception
*/
protected function setUp()
{
$this->storageMock = $this->getMock(ResourceStorage::class, array(), array(), '', FALSE);
$this->storageMock->expects($this->any())->method('getUid')->will($this->returnValue(5));
$this->folderMock = $this->getMock(Folder::class, array(), array(), '', FALSE);
$this->folderMock->expects($this->any())->method('getStorage')->willReturn($this->storageMock);
$this->storageMock->expects($this->any())->method('getProcessingFolder')->willReturn($this->folderMock);
$this->databaseRow = array('uid' => '1234567', 'identifier' => 'dummy.txt', 'name' => $this->getUniqueId('dummy_'), 'storage' => $this->storageMock->getUid());
}
示例4: flattenResultDataValueFlattensFileAndFolderResourcesButReturnsAnythingElseAsIs
/**
* @test
*/
public function flattenResultDataValueFlattensFileAndFolderResourcesButReturnsAnythingElseAsIs()
{
$this->fileController = $this->getAccessibleMock('TYPO3\\CMS\\Backend\\Controller\\File\\FileController', array('dummy'));
$this->folderResourceMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('bar'));
$this->mockFileProcessor->expects($this->any())->method('getErrorMessages')->will($this->returnValue(array()));
$this->assertTrue($this->fileController->_call('flattenResultDataValue', TRUE));
$this->assertSame(array(), $this->fileController->_call('flattenResultDataValue', array()));
$this->assertSame(array('id' => 'foo', 'date' => '29-11-73', 'iconClasses' => 't3-icon t3-icon-mimetypes t3-icon-mimetypes-text t3-icon-text-html'), $this->fileController->_call('flattenResultDataValue', $this->fileResourceMock));
$this->assertSame('bar', $this->fileController->_call('flattenResultDataValue', $this->folderResourceMock));
}
示例5: render
/**
* renders <f:then> child if the current visitor ...
* otherwise renders <f:else> child.
*
* @param Folder $folder
* @return string
*/
public function render(Folder $folder)
{
/** @var $leafStateService \BeechIt\FalSecuredownload\Service\LeafStateService */
$leafStateService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('BeechIt\\FalSecuredownload\\Service\\LeafStateService');
$feUser = !empty($GLOBALS['TSFE']) ? $GLOBALS['TSFE']->fe_user : false;
if ($feUser && $leafStateService->getLeafStateForUser($feUser, $folder->getCombinedIdentifier())) {
return $this->renderThenChild();
} else {
return $this->renderElseChild();
}
}
示例6: flattenResultDataValueFlattensFileAndFolderResourcesButReturnsAnythingElseAsIs
/**
* @test
*/
public function flattenResultDataValueFlattensFileAndFolderResourcesButReturnsAnythingElseAsIs()
{
$this->fileController = $this->getAccessibleMock(\TYPO3\CMS\Backend\Controller\File\FileController::class, array('dummy'));
$this->folderResourceMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('bar'));
$this->mockFileProcessor->expects($this->any())->method('getErrorMessages')->will($this->returnValue(array()));
$this->assertTrue($this->fileController->_call('flattenResultDataValue', true));
$this->assertSame(array(), $this->fileController->_call('flattenResultDataValue', array()));
$result = $this->fileController->_call('flattenResultDataValue', $this->fileResourceMock);
$this->assertContains('<span class="t3js-icon icon icon-size-small icon-state-default icon-mimetypes-text-html" data-identifier="mimetypes-text-html">', $result['icon']);
unset($result['icon']);
$this->assertSame(array('id' => 'foo', 'date' => '29-11-73', 'thumbUrl' => ''), $result);
$this->assertSame('bar', $this->fileController->_call('flattenResultDataValue', $this->folderResourceMock));
}
示例7: getFolderName
/**
* Get main headline based on active folder or storage for backend module
*
* Folder names are resolved to their special names like done in the tree view.
*
* @param Folder $folder
* @return string
*/
protected function getFolderName(Folder $folder)
{
$name = $folder->getName();
if ($name === '') {
// Show storage name on storage root
if ($folder->getIdentifier() === '/') {
$name = $folder->getStorage()->getName();
}
} else {
$name = key(ListUtility::resolveSpecialFolderNames(array($name => $folder)));
}
return $name;
}
示例8: getFolderRecord
/**
* Get folder configuration record
*
* @param Folder $folder
* @return array
*/
public function getFolderRecord(Folder $folder)
{
if (!isset(self::$folderRecordCache[$folder->getCombinedIdentifier()]) || !array_key_exists($folder->getCombinedIdentifier(), self::$folderRecordCache)) {
$record = $this->getDatabase()->exec_SELECTgetSingleRow('*', 'tx_falsecuredownload_folder', 'storage = ' . (int) $folder->getStorage()->getUid() . '
AND folder_hash = ' . $this->getDatabase()->fullQuoteStr($folder->getHashedIdentifier(), 'tx_falsecuredownload_folder'));
// cache results
self::$folderRecordCache[$folder->getCombinedIdentifier()] = $record;
}
return self::$folderRecordCache[$folder->getCombinedIdentifier()];
}
示例9: init
/**
* Constructor function for class
*
* @return void
* @todo Define visibility
*/
public function init()
{
// Initialize GPvars:
$this->number = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('number');
$this->target = $combinedIdentifier = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('target');
$this->returnUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::sanitizeLocalUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('returnUrl'));
// create the folder object
if ($combinedIdentifier) {
$this->folderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($combinedIdentifier);
}
// Cleaning and checking target directory
if (!$this->folderObject) {
$title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE);
$message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE);
throw new \RuntimeException($title . ': ' . $message, 1294586843);
}
// Setting the title and the icon
$icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('apps-filetree-root');
$this->title = $icon . htmlspecialchars($this->folderObject->getStorage()->getName()) . ': ' . htmlspecialchars($this->folderObject->getIdentifier());
// Setting template object
$this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
$this->doc->setModuleTemplate('templates/file_newfolder.html');
$this->doc->backPath = $GLOBALS['BACK_PATH'];
$this->doc->JScode = $this->doc->wrapScriptTags('
var path = "' . $this->target . '";
function reload(a) { //
if (!changed || (changed && confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')) . '))) {
var params = "&target="+encodeURIComponent(path)+"&number="+a+"&returnUrl=' . rawurlencode($this->returnUrl) . '";
window.location.href = "file_newfolder.php?"+params;
}
}
function backToList() { //
top.goToModule("file_list");
}
var changed = 0;
');
}
示例10: writeSysFileResourceForLegacyImport
/**
* Writes the file with the is $fileId to the legacy import folder. The file name will used from
* argument $fileName and the file was successfully created or an identical file was already found,
* $fileName will held the uid of the new created file record.
*
* @param string $fileName The file name for the new file. Value would be changed to the uid of the new created file record.
* @param int $fileId The id of the file in data array
* @return bool
*/
protected function writeSysFileResourceForLegacyImport(&$fileName, $fileId)
{
if ($this->legacyImportFolder === null) {
return false;
}
if (!isset($this->dat['files'][$fileId])) {
$this->error('ERROR: File ID "' . $fileId . '" could not be found');
return false;
}
$temporaryFile = $this->writeTemporaryFileFromData($fileId, 'files');
if ($temporaryFile === null) {
// error on writing the file. Error message was already added
return false;
}
$importFolder = $this->legacyImportFolder;
if (isset($this->dat['files'][$fileId]['relFileName'])) {
$relativeFilePath = PathUtility::dirname($this->dat['files'][$fileId]['relFileName']);
if (!$this->legacyImportFolder->hasFolder($relativeFilePath)) {
$this->legacyImportFolder->createFolder($relativeFilePath);
}
$importFolder = $this->legacyImportFolder->getSubfolder($relativeFilePath);
}
$fileObject = null;
try {
// check, if there is alreay the same file in the folder
if ($importFolder->hasFile($fileName)) {
$fileStorage = $importFolder->getStorage();
$file = $fileStorage->getFile($importFolder->getIdentifier() . $fileName);
if ($file->getSha1() === sha1_file($temporaryFile)) {
$fileObject = $file;
}
}
} catch (Exception $e) {
}
if ($fileObject === null) {
try {
$fileObject = $importFolder->addFile($temporaryFile, $fileName, DuplicationBehavior::RENAME);
} catch (Exception $e) {
$this->error('Error: no file could be added to the storage for file name ' . $this->alternativeFileName[$temporaryFile]);
}
}
if (md5_file(PATH_site . $fileObject->getPublicUrl()) == $this->dat['files'][$fileId]['content_md5']) {
$fileName = $fileObject->getUid();
$this->fileIDMap[$fileId] = $fileName;
$this->filePathMap[$fileId] = $fileObject->getPublicUrl();
return true;
} else {
$this->error('ERROR: File content "' . $this->dat['files'][$fileId]['relFileName'] . '" was corrupted');
}
return false;
}
示例11: getSubfoldersForOptionList
/**
* Simple function to make a hierarchical subfolder request into
* a "flat" option list
*
* @param \TYPO3\CMS\Core\Resource\Folder $parentFolder
* @param integer $level a limiter
* @return \TYPO3\CMS\Core\Resource\Folder[]
*/
protected function getSubfoldersForOptionList(\TYPO3\CMS\Core\Resource\Folder $parentFolder, $level = 0)
{
$level++;
// hard break on recursion
if ($level > 99) {
return array();
}
$allFolderItems = array($parentFolder);
$subFolders = $parentFolder->getSubfolders();
foreach ($subFolders as $subFolder) {
$subFolderItems = $this->getSubfoldersForOptionList($subFolder, $level);
$allFolderItems = array_merge($allFolderItems, $subFolderItems);
}
return $allFolderItems;
}
示例12: initFileOrFolderRecord
/**
* Init file/folder parameters
*/
protected function initFileOrFolderRecord()
{
$fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->uid);
if ($fileOrFolderObject instanceof Folder) {
$this->folderObject = $fileOrFolderObject;
$this->access = $this->folderObject->checkActionPermission('read');
$this->type = 'folder';
} else {
$this->fileObject = $fileOrFolderObject;
$this->access = $this->fileObject->checkActionPermission('read');
$this->type = 'file';
$this->table = 'sys_file';
try {
$this->row = BackendUtility::getRecordWSOL($this->table, $fileOrFolderObject->getUid());
} catch (\Exception $e) {
$this->row = array();
}
}
}
示例13: initFileOrFolderRecord
/**
* Init file/folder parameters
*/
protected function initFileOrFolderRecord()
{
$fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->uid);
if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
$this->folderObject = $fileOrFolderObject;
$this->access = $this->folderObject->checkActionPermission('read');
$this->type = 'folder';
} else {
$this->fileObject = $fileOrFolderObject;
$this->access = $this->fileObject->checkActionPermission('read');
$this->type = 'file';
$this->table = 'sys_file_metadata';
try {
$metaData = $fileOrFolderObject->_getMetaData();
$this->row = BackendUtility::getRecordWSOL($this->table, $metaData['uid']);
} catch (\Exception $e) {
$this->row = array();
}
}
}
示例14: 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);
}
示例15: 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);
}