本文整理汇总了PHP中TYPO3\CMS\Core\Resource\Folder::getPublicUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::getPublicUrl方法的具体用法?PHP Folder::getPublicUrl怎么用?PHP Folder::getPublicUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Resource\Folder
的用法示例。
在下文中一共展示了Folder::getPublicUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: folderList
/**
* Render list of folders.
*
* @param Folder $baseFolder
* @return string HTML output
* @todo Define visibility
*/
public function folderList(Folder $baseFolder)
{
$content = '';
$folders = $baseFolder->getSubfolders();
$baseFolderPath = $baseFolder->getPublicUrl();
// Create headline (showing number of folders):
$content .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('folders') . ' (%s):', count($folders)));
$titleLength = (int) $GLOBALS['BE_USER']->uc['titleLen'];
// Create the header of current folder:
$aTag = '<a href="#" onclick="return insertElement(\'\',' . GeneralUtility::quoteJSvalue($baseFolderPath) . ', \'folder\', ' . GeneralUtility::quoteJSvalue($baseFolderPath) . ', ' . GeneralUtility::quoteJSvalue($baseFolderPath) . ', \'\', \'\',\'\',1);">';
// Add the foder icon
$folderIcon = $aTag;
$folderIcon .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
$folderIcon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs(basename($baseFolder), $titleLength));
$folderIcon .= '</a>';
$content .= $folderIcon . '<br />';
$lines = array();
// Traverse the folder list:
foreach ($folders as $folderPath) {
$pathInfo = pathinfo($folderPath);
// Create folder icon:
$icon = '<img src="clear.gif" width="16" height="16" alt="" /><img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="16" height="16"') . ' title="' . htmlspecialchars($pathInfo['basename']) . '" class="absmiddle" alt="" />';
// Create links for adding the folder:
if ($this->P['itemName'] != '' && $this->P['formName'] != '') {
$aTag = '<a href="#" onclick="return set_folderpath(' . GeneralUtility::quoteJSvalue($folderPath) . ');">';
} else {
$aTag = '<a href="#" onclick="return insertElement(\'\',' . GeneralUtility::quoteJSvalue($folderPath) . ', \'folder\', ' . GeneralUtility::quoteJSvalue($folderPath) . ', ' . GeneralUtility::quoteJSvalue($folderPath) . ', \'' . $pathInfo['extension'] . '\', \'\');">';
}
if (strstr($folderPath, ',') || strstr($folderPath, '|')) {
// In case an invalid character is in the filepath, display error message:
$errorMessage = GeneralUtility::quoteJSvalue(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
$aTag = $aTag_alt = '<a href="#" onclick="alert(' . $errorMessage . ');return false;">';
} else {
// If foldername is OK, just add it:
$aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
}
$aTag_e = '</a>';
// Combine icon and folderpath:
$foldernameAndIcon = $aTag_alt . $icon . htmlspecialchars(GeneralUtility::fixed_lgd_cs(basename($folderPath), $titleLength)) . $aTag_e;
if ($this->P['itemName'] != '') {
$lines[] = '
<tr class="bgColor4">
<td nowrap="nowrap">' . $foldernameAndIcon . ' </td>
<td> </td>
</tr>';
} else {
$lines[] = '
<tr class="bgColor4">
<td nowrap="nowrap">' . $foldernameAndIcon . ' </td>
<td>' . $aTag . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', TRUE) . '" alt="" />' . $aTag_e . ' </td>
<td> </td>
</tr>';
}
$lines[] = '
<tr>
<td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
</tr>';
}
// Wrap all the rows in table tags:
$content .= '
<!--
Folder listing
-->
<table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
' . implode('', $lines) . '
</table>';
// Return accumulated content for folderlisting:
return $content;
}
示例2: makeEdit
/**
* Creates the edit control section
*
* @param File|Folder $fileOrFolderObject Array with information about the file/directory for which to make the edit control section for the listing.
* @return string HTML-table
*/
public function makeEdit($fileOrFolderObject)
{
$cells = array();
$fullIdentifier = $fileOrFolderObject->getCombinedIdentifier();
// Edit file content (if editable)
if ($fileOrFolderObject instanceof File && $fileOrFolderObject->checkActionPermission('write') && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileOrFolderObject->getExtension())) {
$url = BackendUtility::getModuleUrl('file_edit', array('target' => $fullIdentifier));
$editOnClick = 'top.content.list_frame.location.href=' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);return false;';
$cells['edit'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($editOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.editcontent') . '">' . IconUtility::getSpriteIcon('actions-page-open') . '</a>';
} else {
$cells['edit'] = $this->spaceIcon;
}
if ($fileOrFolderObject instanceof File) {
$fileUrl = $fileOrFolderObject->getPublicUrl(TRUE);
if ($fileUrl) {
$aOnClick = 'return top.openUrlInWindow(' . GeneralUtility::quoteJSvalue($fileUrl) . ', \'WebFile\');';
$cells['view'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($aOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.view') . '">' . IconUtility::getSpriteIcon('actions-document-view') . '</a>';
} else {
$cells['view'] = $this->spaceIcon;
}
} else {
$cells['view'] = $this->spaceIcon;
}
// rename the file
if ($fileOrFolderObject->checkActionPermission('rename')) {
$url = BackendUtility::getModuleUrl('file_rename', array('target' => $fullIdentifier));
$renameOnClick = 'top.content.list_frame.location.href = ' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);return false;';
$cells['rename'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($renameOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.rename') . '">' . IconUtility::getSpriteIcon('actions-edit-rename') . '</a>';
} else {
$cells['rename'] = $this->spaceIcon;
}
if ($fileOrFolderObject->checkActionPermission('read')) {
$infoOnClick = '';
if ($fileOrFolderObject instanceof Folder) {
$infoOnClick = 'top.launchView( \'_FOLDER\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;';
} elseif ($fileOrFolderObject instanceof File) {
$infoOnClick = 'top.launchView( \'_FILE\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;';
}
$cells['info'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($infoOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.info') . '">' . IconUtility::getSpriteIcon('status-dialog-information') . '</a>';
} else {
$cells['info'] = $this->spaceIcon;
}
// delete the file
if ($fileOrFolderObject->checkActionPermission('delete')) {
$identifier = $fileOrFolderObject->getIdentifier();
if ($fileOrFolderObject instanceof Folder) {
$referenceCountText = BackendUtility::referenceCount('_FILE', $identifier, ' (There are %s reference(s) to this folder!)');
} else {
$referenceCountText = BackendUtility::referenceCount('sys_file', $fileOrFolderObject->getUid(), ' (There are %s reference(s) to this file!)');
}
if ($this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)) {
$confirmationCheck = 'confirm(' . GeneralUtility::quoteJSvalue(sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:mess.delete'), $fileOrFolderObject->getName()) . $referenceCountText) . ')';
} else {
$confirmationCheck = '1 == 1';
}
$removeOnClick = 'if (' . $confirmationCheck . ') { top.content.list_frame.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_file') . '&file[delete][0][data]=' . rawurlencode($fileOrFolderObject->getCombinedIdentifier()) . '&vC=' . $this->getBackendUser()->veriCode() . BackendUtility::getUrlToken('tceAction') . '&redirect=') . '+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);};';
$cells['delete'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($removeOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.delete') . '">' . IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
} else {
$cells['delete'] = $this->spaceIcon;
}
// Hook for manipulating edit icons.
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'] as $classData) {
$hookObject = GeneralUtility::getUserObj($classData);
if (!$hookObject instanceof FileListEditIconHookInterface) {
throw new \UnexpectedValueException('$hookObject must implement interface \\TYPO3\\CMS\\Filelist\\FileListEditIconHookInterface', 1235225797);
}
$hookObject->manipulateEditIcons($cells, $this);
}
}
// Compile items into a DIV-element:
return '<div class="btn-group">' . implode('', $cells) . '</div>';
}