本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::resolveBackPath方法的具体用法?PHP GeneralUtility::resolveBackPath怎么用?PHP GeneralUtility::resolveBackPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::resolveBackPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compressJsFile
/**
* Compresses and minifies a javascript file
*
* @param string $filename Source filename, relative to requested page
* @return string Filename of the compressed file, relative to requested page
*/
public function compressJsFile($filename)
{
// generate the unique name of the file
$filenameAbsolute = GeneralUtility::resolveBackPath($this->rootPath . $this->getFilenameFromMainDir($filename));
if (@file_exists($filenameAbsolute)) {
$fileStatus = stat($filenameAbsolute);
$unique = $filenameAbsolute . $fileStatus['mtime'] . $fileStatus['size'];
} else {
$unique = $filenameAbsolute;
}
$pathinfo = PathUtility::pathinfo($filename);
$targetFile = $this->targetDirectory . $pathinfo['filename'] . '-' . md5($unique) . '.js';
// only create it, if it doesn't exist, yet
if (!file_exists(PATH_site . $targetFile) || $this->createGzipped && !file_exists(PATH_site . $targetFile . '.gzip')) {
$contents = file_get_contents($filenameAbsolute);
try {
$minifiedContents = Minifier::minify($contents);
} catch (\Exception $e) {
// Log error and use un-minified content as fallback
/** @var $logger Logger */
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
$logger->error($e->getMessage(), ['filename' => $filename]);
$minifiedContents = $contents;
}
$this->writeFileAndCompressed($targetFile, $minifiedContents);
}
return $this->relativePath . $this->returnFileReference($targetFile);
}
示例2: fixPathForInput
/**
* Just makes path absolute.
*
* @param $file
*
* @return string
*
* @todo add typehinting
*/
protected static function fixPathForInput($file)
{
if (TYPO3_MODE === 'FE') {
$file = GeneralUtility::getFileAbsFileName($file);
} elseif (TYPO3_MODE === 'BE' && !TYPO3_cliMode) {
$file = GeneralUtility::resolveBackPath(PATH_typo3 . $file);
}
return $file;
}
示例3: generate
/**
* Interface function. This will be called from the sprite manager to
* refresh all caches.
*
* @return void
*/
public function generate()
{
$this->generatorInstance = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Sprite\SpriteGenerator::class, 'GeneratorHandler');
$this->generatorInstance->setOmitSpriteNameInIconName(TRUE)->setIncludeTimestampInCSS(TRUE)->setSpriteFolder(SpriteManager::$tempPath)->setCSSFolder(SpriteManager::$tempPath);
$iconsToProcess = array_merge((array) $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons'], $this->collectTcaSpriteIcons());
foreach ($iconsToProcess as $iconName => $iconFile) {
$iconsToProcess[$iconName] = GeneralUtility::resolveBackPath('typo3/' . $iconFile);
}
$generatorResponse = $this->generatorInstance->generateSpriteFromArray($iconsToProcess);
$this->iconNames = array_merge($this->iconNames, $generatorResponse['iconNames']);
parent::generate();
}
示例4: buildCssAndRegisterIcons
/**
* This function builds an css class for every single icon registered via
* \TYPO3\CMS\Backend\Utility\IconUtility::addSingleIcons to use them via
* \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon and TCA-Icons for
* "classic" record Icons to be uses via
* \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord
* In the simpleHandler the icon just will be added as css-background-image.
*
* @return void
*/
protected function buildCssAndRegisterIcons()
{
// Backpath from the stylesheet file ($cssTcaFile) to PATH_site dir
// in order to set the background-image URL paths correct
$iconPath = '../../' . TYPO3_mainDir;
$iconsToProcess = array_merge((array) $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons'], $this->collectTcaSpriteIcons());
foreach ($iconsToProcess as $iconName => $iconFile) {
$css = str_replace('###NAME###', str_replace(array('extensions-', 'tcarecords-'), array('', ''), $iconName), $this->styleSheetTemplateExtIcons);
$css = str_replace('###IMAGE###', \TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath($iconPath . $iconFile), $css);
$this->iconNames[] = $iconName;
$this->styleSheetData .= $css;
}
}
示例5: render
/**
* renders the actual logo code
*
* @return string Logo html code snippet to use in the backend
*/
public function render()
{
// Default
$logoFile = 'gfx/alt_backend_logo.gif';
if (is_string($this->logo)) {
// Overwrite
$logoFile = $this->logo;
}
$imgInfo = getimagesize(PATH_site . TYPO3_mainDir . $logoFile);
$logo = '<a href="' . TYPO3_URL_GENERAL . '" target="_blank">' . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg('', $logoFile, $imgInfo[3]) . ' title="TYPO3 Content Management System" alt="" />' . '</a>';
// Overwrite with custom logo
if ($GLOBALS['TBE_STYLES']['logo']) {
$imgInfo = @getimagesize(\TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath(PATH_typo3 . $GLOBALS['TBE_STYLES']['logo'], 3));
$logo = '<a href="' . TYPO3_URL_GENERAL . '" target="_blank">' . '<img src="' . $GLOBALS['TBE_STYLES']['logo'] . '" ' . $imgInfo[3] . ' title="TYPO3 Content Management System" alt="" />' . '</a>';
}
return $logo;
}
示例6: render
/**
* renders the actual logo code
*
* @return string Logo html code snippet to use in the backend
*/
public function render()
{
$imgInfo = getimagesize(PATH_site . TYPO3_mainDir . $this->logo);
$imgUrl = $this->logo;
// Overwrite with custom logo
if ($GLOBALS['TBE_STYLES']['logo']) {
$imgInfo = @getimagesize(\TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath(PATH_typo3 . $GLOBALS['TBE_STYLES']['logo'], 3));
$imgUrl = $GLOBALS['TBE_STYLES']['logo'];
}
// High-res?
$width = $imgInfo[0];
$height = $imgInfo[1];
if (strpos($imgUrl, '@2x.')) {
$width = $width / 2;
$height = $height / 2;
}
$logoTag = '<img src="' . $imgUrl . '" width="' . $width . '" height="' . $height . '" title="TYPO3 Content Management System" alt="" />';
return '<a href="' . TYPO3_URL_GENERAL . '" target="_blank">' . $logoTag . '</a>';
}
示例7: render
/**
* renders the actual logo code
*
* @return string Logo html code snippet to use in the backend
*/
public function render()
{
$imgInfo = getimagesize(PATH_site . TYPO3_mainDir . $this->logo);
$imgUrl = $this->logo;
// Overwrite with custom logo
if ($GLOBALS['TBE_STYLES']['logo']) {
$imgInfo = @getimagesize(\TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath(PATH_typo3 . $GLOBALS['TBE_STYLES']['logo'], 3));
$imgUrl = $GLOBALS['TBE_STYLES']['logo'];
}
// High-res?
$width = $imgInfo[0];
$height = $imgInfo[1];
if (strpos($imgUrl, '@2x.')) {
$width = $width / 2;
$height = $height / 2;
}
$logoTag = '<img src="' . $imgUrl . '" width="' . $width . '" height="' . $height . '" title="TYPO3 Content Management System" alt="" />';
return '<a class="typo3-topbar-site-logo" href="' . htmlspecialchars(TYPO3_URL_GENERAL) . '" target="_blank">' . $logoTag . '</a> <span class="typo3-topbar-site-name">' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . ' [' . TYPO3_version . ']</span>';
}
示例8: render
/**
* renders the actual logo code
*
* @return string Logo html code snippet to use in the backend
*/
public function render()
{
if (!$GLOBALS['TBE_STYLES']['logo']) {
return parent::render();
}
// Overwrite with custom logo
if ($GLOBALS['TBE_STYLES']['logo']) {
$imgInfo = @getimagesize(GeneralUtility::resolveBackPath(PATH_typo3 . $GLOBALS['TBE_STYLES']['logo'], 3));
$imgUrl = $GLOBALS['TBE_STYLES']['logo'];
}
// High-res?
$width = $imgInfo[0];
$height = $imgInfo[1];
if (strpos($imgUrl, '@2x.')) {
$width = $width / 2;
$height = $height / 2;
}
$logoTag = '<img src="' . $imgUrl . '" width="' . $width . '" height="' . $height . '" title="' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '" alt="" />' . '<span class="typo3-sitename">' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . ' [' . TYPO3_version . ']</span>';
return '<a href="http://' . GeneralUtility::getIndpEnv('HTTP_HOST') . '/" target="_blank">' . $logoTag . '</a>';
}
示例9: render
/**
* renders the actual logo code
*
* @return string Logo html code snippet to use in the backend
*/
public function render()
{
if (!$GLOBALS['TBE_STYLES']['logo']) {
return parent::render();
}
// Overwrite with custom logo
if ($GLOBALS['TBE_STYLES']['logo']) {
$imgInfo = @getimagesize(\TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath(PATH_typo3 . $GLOBALS['TBE_STYLES']['logo'], 3));
$imgUrl = $GLOBALS['TBE_STYLES']['logo'];
}
// High-res?
$width = $imgInfo[0];
$height = $imgInfo[1];
if (strpos($imgUrl, '@2x.')) {
$width = $width / 2;
$height = $height / 2;
}
$logoTag = '<img src="' . $imgUrl . '" width="' . $width . '" height="' . $height . '" title="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '" alt="" />';
$siteName = '<span class="typo3-sitename"><a style="color:#fff;" href="http://' . $GLOBALS['_SERVER']['HTTP_HOST'] . '/" target="_blank">' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . ' [' . TYPO3_version . ']</a></span>';
return '<a href="http://typo3.org/" target="_blank">' . $logoTag . '</a>' . $siteName;
}
示例10: buildJavascriptConfiguration
/**
* Return JS configuration of the htmlArea plugins registered by the extension
*
* @param integer Relative id of the RTE editing area in the form
* @return string JS configuration for registered plugins
*/
public function buildJavascriptConfiguration($RTEcounter)
{
$registerRTEinJavascriptString = '';
$schema = array('types' => array(), 'properties' => array());
// Parse configured schemas
if (is_array($this->thisConfig['schema.']) && is_array($this->thisConfig['schema.']['sources.'])) {
foreach ($this->thisConfig['schema.']['sources.'] as $source) {
$fileName = $this->htmlAreaRTE->getFullFileName($source);
$absolutePath = $fileName ? \TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath(PATH_site . ($this->htmlAreaRTE->is_FE() || $this->htmlAreaRTE->isFrontendEditActive() ? '' : TYPO3_mainDir) . $fileName) : '';
// Fallback to default schema file if configured file does not exists or is of zero size
if (!$fileName || !file_exists($absolutePath) || !filesize($absolutePath)) {
$fileName = $this->htmlAreaRTE->getFullFileName('EXT:' . $this->ID . '/extensions/MicrodataSchema/res/schemaOrgAll.rdf');
}
$rdf = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($fileName);
if ($rdf) {
$this->parseSchema($rdf, $schema);
}
}
}
uasort($schema['types'], array($this, 'compareLabels'));
uasort($schema['properties'], array($this, 'compareLabels'));
// Insert no type and no property entries
if ($this->htmlAreaRTE->is_FE()) {
$noSchema = $GLOBALS['TSFE']->getLLL('No type', $this->LOCAL_LANG);
$noProperty = $GLOBALS['TSFE']->getLLL('No property', $this->LOCAL_LANG);
} else {
$noSchema = $GLOBALS['LANG']->getLL('No type');
$noProperty = $GLOBALS['LANG']->getLL('No property');
}
array_unshift($schema['types'], array('name' => 'none', 'label' => $noSchema));
array_unshift($schema['properties'], array('name' => 'none', 'label' => $noProperty));
// Convert character set
if ($this->htmlAreaRTE->is_FE()) {
$GLOBALS['TSFE']->csConvObj->convArray($schema, $this->htmlAreaRTE->outputCharset, 'utf-8');
}
// Store json encoded array in temporary file
$registerRTEinJavascriptString = LF . TAB . 'RTEarea[editornumber].schemaUrl = "' . ($this->htmlAreaRTE->is_FE() && $GLOBALS['TSFE']->absRefPrefix ? $GLOBALS['TSFE']->absRefPrefix : '') . $this->htmlAreaRTE->writeTemporaryFile('', 'schema_' . $this->htmlAreaRTE->language, 'js', json_encode($schema), TRUE) . '";';
return $registerRTEinJavascriptString;
}
示例11: getCorrectUrl
/**
* If it is an URL, nothing to do, if it is a file, check if path is allowed and prepend current url
*
* @param string $url
* @return string
* @throws \UnexpectedValueException
*/
public static function getCorrectUrl($url)
{
if (empty($url)) {
throw new \UnexpectedValueException('An empty url is given');
}
$url = self::getFalFilename($url);
// check URL
$urlInfo = parse_url($url);
// means: it is no external url
if (!isset($urlInfo['scheme'])) {
// resolve paths like ../
$url = GeneralUtility::resolveBackPath($url);
// absolute path is used to check path
$absoluteUrl = GeneralUtility::getFileAbsFileName($url);
if (!GeneralUtility::isAllowedAbsPath($absoluteUrl)) {
throw new \UnexpectedValueException('The path "' . $url . '" is not allowed.');
}
// append current domain
$url = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $url;
}
return $url;
}
示例12: jumpUrl
/**
* Sends a header "Location" to jumpUrl, if jumpurl is set.
* Will exit if a location header is sent (for instance if jumpUrl was triggered)
*
* "jumpUrl" is a concept where external links are redirected from the index_ts.php script, which first logs the URL.
*
* @return void
* @todo Define visibility
*/
public function jumpUrl()
{
if ($this->jumpurl) {
if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('juSecure')) {
$locationData = (string) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('locationData');
// Need a type cast here because mimeType is optional!
$mimeType = (string) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('mimeType');
$hArr = array($this->jumpurl, $locationData, $mimeType);
$calcJuHash = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac(serialize($hArr));
$juHash = (string) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('juHash');
if ($juHash === $calcJuHash) {
if ($this->locDataCheck($locationData)) {
// 211002 - goes with cObj->filelink() rawurlencode() of filenames so spaces can be allowed.
$this->jumpurl = rawurldecode($this->jumpurl);
// Deny access to files that match TYPO3_CONF_VARS[SYS][fileDenyPattern] and whose parent directory is typo3conf/ (there could be a backup file in typo3conf/ which does not match against the fileDenyPattern)
$absoluteFileName = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName(\TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath($this->jumpurl), FALSE);
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isAllowedAbsPath($absoluteFileName) && \TYPO3\CMS\Core\Utility\GeneralUtility::verifyFilenameAgainstDenyPattern($absoluteFileName) && !\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($absoluteFileName, PATH_site . 'typo3conf')) {
if (@is_file($absoluteFileName)) {
$mimeType = $mimeType ? $mimeType : 'application/octet-stream';
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: ' . $mimeType);
header('Content-Disposition: attachment; filename="' . basename($absoluteFileName) . '"');
readfile($absoluteFileName);
die;
} else {
throw new \Exception('jumpurl Secure: "' . $this->jumpurl . '" was not a valid file!', 1294585193);
}
} else {
throw new \Exception('jumpurl Secure: The requested file was not allowed to be accessed through jumpUrl (path or file not allowed)!', 1294585194);
}
} else {
throw new \Exception('jumpurl Secure: locationData, ' . $locationData . ', was not accessible.', 1294585195);
}
} else {
throw new \Exception('jumpurl Secure: Calculated juHash did not match the submitted juHash.', 1294585196);
}
} else {
$TSConf = $this->getPagesTSconfig();
if ($TSConf['TSFE.']['jumpUrl_transferSession']) {
$uParts = parse_url($this->jumpurl);
$params = '&FE_SESSION_KEY=' . rawurlencode($this->fe_user->id . '-' . md5($this->fe_user->id . '/' . $this->TYPO3_CONF_VARS['SYS']['encryptionKey']));
// Add the session parameter ...
$this->jumpurl .= ($uParts['query'] ? '' : '?') . $params;
}
if ($TSConf['TSFE.']['jumpURL_HTTPStatusCode']) {
switch (intval($TSConf['TSFE.']['jumpURL_HTTPStatusCode'])) {
case 301:
$statusCode = \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_301;
break;
case 302:
$statusCode = \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_302;
break;
case 307:
$statusCode = \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_307;
break;
case 303:
default:
$statusCode = \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303;
break;
}
}
\TYPO3\CMS\Core\Utility\HttpUtility::redirect($this->jumpurl, $statusCode);
}
}
}
示例13: mapFileExtensionToSpriteIconName
/**
* Generates the spriteicon name for a given path or fileExtension
* usually called from mapFileExtensionToSpriteIconClass and tceforms
*
* @param string $fileExtension FileExtension can be jpg, gif etc, but also be 'mount' or 'folder', but can also be a full path which will be resolved then
* @return string The string of the CSS class, see \TYPO3\CMS\Backend\Utility\IconUtility::$fileSpriteIconNames
* @access private
*/
public static function mapFileExtensionToSpriteIconName($fileExtension)
{
// If the file is a whole file with name etc (mainly, if it has a "." or a "/"),
// then it is checked whether it is a valid directory
if (strpos($fileExtension, '.') !== FALSE || strpos($fileExtension, '/') !== FALSE) {
// Check if it is a directory
$filePath = dirname(GeneralUtility::getIndpEnv('SCRIPT_FILENAME')) . '/' . $GLOBALS['BACK_PATH'] . $fileExtension;
$path = GeneralUtility::resolveBackPath($filePath);
if (is_dir($path) || substr($fileExtension, -1) === '/' || substr($fileExtension, -1) === '\\') {
$fileExtension = 'folder';
} else {
if (($pos = strrpos($fileExtension, '.')) !== FALSE) {
$fileExtension = strtolower(substr($fileExtension, $pos + 1));
} else {
$fileExtension = 'default';
}
}
}
// If the file extension is not valid
// then use the default one
if (!isset(self::$fileSpriteIconNames[$fileExtension])) {
$fileExtension = 'default';
}
$iconName = self::$fileSpriteIconNames[$fileExtension];
return $iconName;
}
示例14: getFullFileName
/**
* Make a file name relative to the PATH_site or to the PATH_typo3
*
* @param string $filename: a file name of the form EXT:.... or relative to the PATH_site
* @return string the file name relative to the PATH_site if in frontend or relative to the PATH_typo3 if in backend
*/
protected function getFullFileName($filename)
{
if (substr($filename, 0, 4) === 'EXT:') {
// extension
list($extKey, $local) = explode('/', substr($filename, 4), 2);
$newFilename = '';
if ((string) $extKey !== '' && ExtensionManagementUtility::isLoaded($extKey) && (string) $local !== '') {
$newFilename = ($this->isFrontendEditActive() ? ExtensionManagementUtility::siteRelPath($extKey) : ExtensionManagementUtility::extRelPath($extKey)) . $local;
}
} else {
$path = $this->isFrontendEditActive() ? '' : '../';
$newFilename = $path . ($filename[0] === '/' ? substr($filename, 1) : $filename);
}
return GeneralUtility::resolveBackPath($newFilename);
}
示例15: wrapCssFile
/**
* wrapCssFile
*
* @param string $cssFile
* @return string
*/
private function wrapCssFile($cssFile)
{
$cssFile = GeneralUtility::resolveBackPath($cssFile);
$cssFile = GeneralUtility::createVersionNumberedFilename($cssFile);
return '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($cssFile) . '" media="screen" />';
}