From 8feaad1575eec6b75fb31e61355d7a04680e703d Mon Sep 17 00:00:00 2001 From: Benjamin Mack Date: Wed, 30 Apr 2014 15:41:22 +0200 Subject: [PATCH] [FEATURE] Add "auto" absRefPrefix option For automatic distribution configuration like the introduction package, a dynamic option to find out whether TYPO3 is installed under "/" or "/mysite/" the TypoScript option config.absRefPrefix = auto calculates the absRefPrefix automatically. Releases: master Resolves: #58366 Change-Id: Ia0d335665c9b30d21b886c8e9ac4c1ccdb069adc Reviewed-on: http://review.typo3.org/29747 Reviewed-by: Stefan Froemken Reviewed-by: Benjamin Kott Reviewed-by: Helmut Hummel Tested-by: Helmut Hummel --- .../Feature-58366-AutomaticAbsRefPrefix.rst | 39 +++++++++++++++++++ .../frontend/Classes/Page/PageGenerator.php | 12 +++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Feature-58366-AutomaticAbsRefPrefix.rst diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-58366-AutomaticAbsRefPrefix.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-58366-AutomaticAbsRefPrefix.rst new file mode 100644 index 000000000000..0327816ab9fb --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-58366-AutomaticAbsRefPrefix.rst @@ -0,0 +1,39 @@ +=========================================================== +Feature: #58366 - Add "auto" Option for config.absRefPrefix +=========================================================== + +Description +=========== + +The TypoScript setting config.absRefPrefix can be used to allow URL rewriting like URL giving a hard +prefix for all relative paths. As an alternative to config.baseURL to be set to a specific domain +absRefPrefix can autodetect the site root and use that instead of manually setting this option. + +Frontend: + +The new option can be set like this: + +.. code-block:: typoscript + + config.absRefPrefix = auto + +instead of hardcoded values for different environments or when moving installations in subfolders. + +.. code-block:: typoscript + + [ApplicationContext = Production] + config.absRefPrefix = / + + [ApplicationContext = Testing] + config.absRefPrefix = /my_site_root/ + +As the feature only works with path prefixes, and not with host name variables from the server, +the new option is also safe for multi-domain environments to avoid duplicate caching mechanism. + + +Impact +====== + +The new special option can be used to automatically set up installations and distributions like +the Introduction Package where a site configuration is shipped with the system but might need +to be adjusted. diff --git a/typo3/sysext/frontend/Classes/Page/PageGenerator.php b/typo3/sysext/frontend/Classes/Page/PageGenerator.php index 9deaf966566f..5f80e4a5c27b 100644 --- a/typo3/sysext/frontend/Classes/Page/PageGenerator.php +++ b/typo3/sysext/frontend/Classes/Page/PageGenerator.php @@ -77,7 +77,17 @@ class PageGenerator { } else { $GLOBALS['TSFE']->spamProtectEmailAddresses = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'], -10, 10, 0); } - $GLOBALS['TSFE']->absRefPrefix = $GLOBALS['TSFE']->config['config']['absRefPrefix'] ? trim($GLOBALS['TSFE']->config['config']['absRefPrefix']) : ''; + // calculate the absolute path prefix + if (!empty($GLOBALS['TSFE']->config['config']['absRefPrefix'])) { + $absRefPrefix = trim($GLOBALS['TSFE']->config['config']['absRefPrefix']); + if ($absRefPrefix === 'auto') { + $GLOBALS['TSFE']->absRefPrefix = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'); + } else { + $GLOBALS['TSFE']->absRefPrefix = $absRefPrefix; + } + } else { + $GLOBALS['TSFE']->absRefPrefix = ''; + } if ($GLOBALS['TSFE']->type && $GLOBALS['TSFE']->config['config']['frameReloadIfNotInFrameset']) { $tdlLD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, '_top', $GLOBALS['TSFE']->no_cache, ''); $GLOBALS['TSFE']->additionalJavaScript['JSCode'] .= 'if(!parent.' . trim($GLOBALS['TSFE']->sPre) . ' && !parent.view_frame) top.location.href="' . $GLOBALS['TSFE']->baseUrlWrap($tdlLD['totalURL']) . '"'; -- 2.20.1