diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84118-VariousPublicMethodsOfAdminPanelViewDeprecated.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84118-VariousPublicMethodsOfAdminPanelViewDeprecated.rst
new file mode 100644
index 000000000000..2aad46a61eeb
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84118-VariousPublicMethodsOfAdminPanelViewDeprecated.rst
@@ -0,0 +1,42 @@
+.. include:: ../../Includes.txt
+
+=========================================================================
+Deprecation: #84118 - Various public methods of AdminPanelView deprecated
+=========================================================================
+
+See :issue:`84118`
+
+Description
+===========
+
+To clean up the admin panel and provide a new API various functions of the main class `AdminPanelView` were deprecated:
+
+* `getAdminPanelHeaderData`
+* `isAdminModuleEnabled`
+* `saveConfigOptions`
+* `extGetFeAdminValue`
+* `forcePreview`
+* `isAdminModuleOpen`
+* `extGetHead`
+* `linkSectionHeader`
+* `extGetItem`
+
+
+Impact
+======
+
+Calling any of the mentioned methods triggers an `E_USER_DEPRECATED` PHP error.
+
+
+Affected Installations
+======================
+
+Any installation that calls one of the above methods.
+
+
+Migration
+=========
+
+Implement your own AdminPanel module by using the new API (see `AdminPanelModuleInterface`).
+
+.. index:: Frontend, FullyScanned, ext:frontend
\ No newline at end of file
diff --git a/typo3/sysext/frontend/Classes/AdminPanel/AbstractModule.php b/typo3/sysext/frontend/Classes/AdminPanel/AbstractModule.php
index 43d90719b9b7..5987fc27813a 100644
--- a/typo3/sysext/frontend/Classes/AdminPanel/AbstractModule.php
+++ b/typo3/sysext/frontend/Classes/AdminPanel/AbstractModule.php
@@ -26,6 +26,7 @@
*/
abstract class AbstractModule implements AdminPanelModuleInterface
{
+
/**
* @inheritdoc
*/
@@ -34,6 +35,64 @@ public function getAdditionalJavaScriptCode(): string
return '';
}
+ /**
+ * @inheritdoc
+ */
+ public function initializeModule(): void
+ {
+ }
+
+ /**
+ * Returns true if the module is
+ * -> either enabled via tsconfig admPanel.enable
+ * -> or any setting is overridden
+ * override is a way to use functionality of the admin panel without displaying the admin panel to users
+ * for example: hidden records or pages can be displayed by default
+ *
+ * @return bool
+ */
+ public function isEnabled(): bool
+ {
+ $identifier = $this->getIdentifier();
+ $result = $this->isEnabledViaTsConfig();
+ if ($this->getBackendUser()->extAdminConfig['override.'][$identifier] ?? false) {
+ $result = (bool)$this->getBackendUser()->extAdminConfig['override.'][$identifier];
+ }
+ return $result;
+ }
+
+ /**
+ * Uses the backend user session to determine if the module is open
+ *
+ * @return bool
+ */
+ public function isOpen(): bool
+ {
+ $option = 'display_' . $this->getIdentifier();
+ return isset($this->getBackendUser()->uc['TSFE_adminConfig'][$option])
+ ? (bool)$this->getBackendUser()->uc['TSFE_adminConfig'][$option]
+ : false;
+ }
+
+ /**
+ * Determines if the panel for this module is shown
+ * -> returns true if panel is enabled in TSConfig
+ *
+ * @see isEnabled()
+ * @return bool
+ */
+ public function isShown(): bool
+ {
+ return $this->isEnabledViaTsConfig();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function onSubmit(array $input): void
+ {
+ }
+
/**
* @inheritdoc
*/
@@ -46,7 +105,7 @@ public function showFormSubmitButton(): bool
* Translate given key
*
* @param string $key Key for a label in the $LOCAL_LANG array of "sysext/lang/Resources/Private/Language/locallang_tsfe.xlf
- * @param bool $convertWithHtmlpecialchars If TRUE the language-label will be sent through htmlspecialchars
+ * @param bool $convertWithHtmlspecialchars If TRUE the language-label will be sent through htmlspecialchars
* @return string The value for the $key
*/
protected function extGetLL($key, $convertWithHtmlspecialchars = true): string
@@ -58,6 +117,37 @@ protected function extGetLL($key, $convertWithHtmlspecialchars = true): string
return $labelStr;
}
+ /**
+ * Returns the current BE user.
+ *
+ * @return \TYPO3\CMS\Backend\FrontendBackendUserAuthentication
+ */
+ protected function getBackendUser(): FrontendBackendUserAuthentication
+ {
+ return $GLOBALS['BE_USER'];
+ }
+
+ /**
+ * Helper method to return configuration options
+ * Checks User TSConfig overrides and current backend user session
+ *
+ * @param string $option
+ * @return string
+ */
+ protected function getConfigurationOption(string $option): string
+ {
+ $beUser = $this->getBackendUser();
+ $identifier = $this->getIdentifier();
+
+ if ($option && isset($beUser->extAdminConfig['override.'][$identifier . '.'][$option])) {
+ $returnValue = $beUser->extAdminConfig['override.'][$identifier . '.'][$option];
+ } else {
+ $returnValue = $beUser->uc['TSFE_adminConfig'][$identifier . '_' . $option] ?? '';
+ }
+
+ return (string)$returnValue;
+ }
+
/**
* Returns LanguageService
*
@@ -69,12 +159,19 @@ protected function getLanguageService(): LanguageService
}
/**
- * Returns the current BE user.
+ * Returns true if TSConfig admPanel.enable is set for this module (or all modules)
*
- * @return \TYPO3\CMS\Backend\FrontendBackendUserAuthentication
+ * @return bool
*/
- protected function getBackendUser(): FrontendBackendUserAuthentication
+ protected function isEnabledViaTsConfig(): bool
{
- return $GLOBALS['BE_USER'];
+ $result = false;
+ $identifier = $this->getIdentifier();
+ if (!empty($this->getBackendUser()->extAdminConfig['enable.']['all'])) {
+ $result = true;
+ } elseif (!empty($this->getBackendUser()->extAdminConfig['enable.'][$identifier])) {
+ $result = true;
+ }
+ return $result;
}
}
diff --git a/typo3/sysext/frontend/Classes/AdminPanel/AdminPanelModuleInterface.php b/typo3/sysext/frontend/Classes/AdminPanel/AdminPanelModuleInterface.php
index a6d2b2fe95c4..886b3c742123 100644
--- a/typo3/sysext/frontend/Classes/AdminPanel/AdminPanelModuleInterface.php
+++ b/typo3/sysext/frontend/Classes/AdminPanel/AdminPanelModuleInterface.php
@@ -23,6 +23,22 @@
*/
interface AdminPanelModuleInterface
{
+ /**
+ * Additional JavaScript code for this module
+ * (you should only use vanilla JS here, as you cannot
+ * rely on the web site providing a specific framework)
+ *
+ * @return string
+ */
+ public function getAdditionalJavaScriptCode(): string;
+
+ /**
+ * Module content as rendered HTML
+ *
+ * @return string
+ */
+ public function getContent(): string;
+
/**
* Identifier for this module,
* for example "preview" or "cache"
@@ -39,25 +55,52 @@ public function getIdentifier(): string;
public function getLabel(): string;
/**
- * Module content as rendered HTML
+ * Initialize the module - runs early in a TYPO3 request
+ */
+ public function initializeModule(): void;
+
+ /**
+ * Module is enabled
+ * -> should be initialized
+ * A module may be enabled but not shown
+ * -> only the initializeModule() method
+ * will be called
*
- * @return string
+ * @return bool
*/
- public function getContent(): string;
+ public function isEnabled(): bool;
/**
- * Does this module need a form submit?
+ * Module is open
+ * -> module is enabled
+ * -> module panel is shown and open
*
* @return bool
*/
- public function showFormSubmitButton(): bool;
+ public function isOpen(): bool;
/**
- * Additional JavaScript code for this module
- * (you should only use vanilla JS here, as you cannot
- * rely on the web site providing a specific framework)
+ * Module is shown
+ * -> module is enabled
+ * -> module panel should be displayed
*
- * @return string
+ * @return bool
*/
- public function getAdditionalJavaScriptCode(): string;
+ public function isShown(): bool;
+
+ /**
+ * Executed on saving / submit of the configuration form
+ * Can be used to react to changed settings
+ * (for example: clearing a specific cache)
+ *
+ * @param array $input
+ */
+ public function onSubmit(array $input): void;
+
+ /**
+ * Does this module need a form submit?
+ *
+ * @return bool
+ */
+ public function showFormSubmitButton(): bool;
}
diff --git a/typo3/sysext/frontend/Classes/AdminPanel/CacheModule.php b/typo3/sysext/frontend/Classes/AdminPanel/CacheModule.php
index ac3786960d08..fd7a6dec83d1 100644
--- a/typo3/sysext/frontend/Classes/AdminPanel/CacheModule.php
+++ b/typo3/sysext/frontend/Classes/AdminPanel/CacheModule.php
@@ -16,8 +16,12 @@
* The TYPO3 project - inspiring people to share!
*/
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
+use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
+
class CacheModule extends AbstractModule
{
+
/**
* Creates the content for the "cache" section ("module") of the Admin Panel
*
@@ -90,6 +94,38 @@ public function getLabel(): string
return $this->extGetLL('cache');
}
+ /**
+ * @inheritdoc
+ */
+ public function initializeModule(): void
+ {
+ if ($this->getConfigurationOption('noCache')) {
+ $this->getTypoScriptFrontendController()->set_no_cache('Admin Panel: No Caching', true);
+ }
+ }
+
+ /**
+ * Clear cache on saving if requested
+ *
+ * @param array $input
+ */
+ public function onSubmit(array $input): void
+ {
+ if (($input['action']['clearCache'] ?? false) ||
+ isset($input['preview_showFluidDebug'])) {
+ $theStartId = (int)$input['cache_clearCacheId'];
+ $this->getTypoScriptFrontendController()
+ ->clearPageCacheContent_pidList(
+ $this->getBackendUser()->extGetTreeList(
+ $theStartId,
+ (int)$this->getConfigurationOption('clearCacheLevels'),
+ 0,
+ $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW)
+ ) . $theStartId
+ );
+ }
+ }
+
/**
* @inheritdoc
*/
@@ -97,4 +133,12 @@ public function showFormSubmitButton(): bool
{
return true;
}
+
+ /**
+ * @return TypoScriptFrontendController
+ */
+ protected function getTypoScriptFrontendController(): TypoScriptFrontendController
+ {
+ return $GLOBALS['TSFE'];
+ }
}
diff --git a/typo3/sysext/frontend/Classes/AdminPanel/EditModule.php b/typo3/sysext/frontend/Classes/AdminPanel/EditModule.php
index a8939a5d9d20..bb5e62b94d84 100644
--- a/typo3/sysext/frontend/Classes/AdminPanel/EditModule.php
+++ b/typo3/sysext/frontend/Classes/AdminPanel/EditModule.php
@@ -67,37 +67,35 @@ public function getContent(): string
$output[] = $this->getBackendUser()->adminPanel->ext_makeToolBar();
- if (!GeneralUtility::_GP('ADMCMD_view')) {
- $onClick = '
- if (parent.opener && parent.opener.top && parent.opener.top.TS) {
- parent.opener.top.fsMod.recentIds["web"]=' .
- (int)$this->getTypoScriptFrontendController()->page['uid'] .
- ';
- if (parent.opener.top && parent.opener.top.nav_frame && parent.opener.top.nav_frame.refresh_nav) {
- parent.opener.top.nav_frame.refresh_nav();
- }
- parent.opener.top.goToModule("' .
- $pageModule .
- '");
- parent.opener.top.focus();
- } else {
- vHWin=window.open(' .
- GeneralUtility::quoteJSvalue(BackendUtility::getBackendScript()) .
- ',\'' .
- md5('Typo3Backend-' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) .
- '\');
- vHWin.focus();
+ $onClick = '
+ if (parent.opener && parent.opener.top && parent.opener.top.TS) {
+ parent.opener.top.fsMod.recentIds["web"]=' .
+ (int)$this->getTypoScriptFrontendController()->page['uid'] .
+ ';
+ if (parent.opener.top && parent.opener.top.nav_frame && parent.opener.top.nav_frame.refresh_nav) {
+ parent.opener.top.nav_frame.refresh_nav();
}
- return false;
- ';
- $output[] = '
';
$output[] = ' ' . $this->extGetLL('adminPanelTitle') . '';
$output[] = ' ' . htmlspecialchars($this->getBackendUser()->user['username']) . '';
@@ -408,7 +270,7 @@ function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValu
}
$cssFileLocation = GeneralUtility::getFileAbsFileName('EXT:frontend/Resources/Public/Css/adminpanel.css');
$output[] = '';
- $output[] = $this->getAdminPanelHeaderData();
+ $output[] = $this->getAdminPanelStylesheet();
$output[] = '';
return implode('', $output);
@@ -436,12 +298,52 @@ protected function getHiddenFields($key, array $val)
return $out;
}
+ /**
+ * Returns true if admin panel was activated
+ * (switched "on" via GUI)
+ *
+ * @return bool
+ */
+ protected function isAdminPanelActivated(): bool
+ {
+ return $this->getBackendUser()->uc['TSFE_adminConfig']['display_top'] ?? false;
+ }
+
+ /**
+ * Save admin panel configuration to backend user UC
+ */
+ protected function saveConfiguration()
+ {
+ $input = GeneralUtility::_GP('TSFE_ADMIN_PANEL');
+ $beUser = $this->getBackendUser();
+ if (is_array($input)) {
+ // Setting
+ $beUser->uc['TSFE_adminConfig'] = array_merge(
+ !is_array($beUser->uc['TSFE_adminConfig']) ? [] : $beUser->uc['TSFE_adminConfig'],
+ $input
+ );
+ unset($beUser->uc['TSFE_adminConfig']['action']);
+
+ foreach ($this->modules as $module) {
+ if ($module->isEnabled() && $module->isOpen()) {
+ $module->onSubmit($input);
+ }
+ }
+ // Saving
+ $beUser->writeUC();
+ // Flush fluid template cache
+ $cacheManager = new CacheManager();
+ $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
+ $cacheManager->getCache('fluid_template')->flush();
+ }
+ }
+
/**
* Validates, sorts and initiates the registered modules
*
* @throws \RuntimeException
*/
- protected function validateSortAndInitiateModules(): void
+ protected function validateSortAndInitializeModules(): void
{
$modules = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['frontend']['adminPanelModules'] ?? [];
if (empty($modules)) {
@@ -484,63 +386,34 @@ protected function validateSortAndInitiateModules(): void
/*****************************************************
* Admin Panel Layout Helper functions
****************************************************/
- /**
- * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
- * It will have a plus/minus icon and a label which is linked so that it submits the form which surrounds the whole Admin Panel when clicked, alterting the TSFE_ADMIN_PANEL[display_' . $pre . '] value
- * See the functions get*Module
- *
- * @param string $sectionSuffix The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
- * @return string HTML table row.
- * @see extGetItem()
- */
- public function extGetHead($sectionSuffix)
- {
- return $this->linkSectionHeader($sectionSuffix, $this->extGetLL($sectionSuffix));
- }
/**
* Wraps a string in a link which will open/close a certain part of the Admin Panel
*
- * @param string $sectionSuffix The code for the display_ label/key
- * @param string $sectionTitle Title (HTML-escaped)
- * @param string $className The classname for the tag
- * @return string $className Linked input string
- * @see extGetHead()
+ * @param \TYPO3\CMS\Frontend\AdminPanel\AdminPanelModuleInterface $module
+ * @return string
*/
- public function linkSectionHeader($sectionSuffix, $sectionTitle, $className = '')
+ protected function getSectionOpenerLink(AdminPanelModuleInterface $module): string
{
- $onclick = 'document.TSFE_ADMIN_PANEL_FORM[' . GeneralUtility::quoteJSvalue('TSFE_ADMIN_PANEL[display_' . $sectionSuffix . ']') . '].value=' . ($this->getBackendUser()->uc['TSFE_adminConfig']['display_' . $sectionSuffix] ? '0' : '1') . ';document.TSFE_ADMIN_PANEL_FORM.submit();return false;';
+ $identifier = $module->getIdentifier();
+ $onclick = 'document.TSFE_ADMIN_PANEL_FORM[' .
+ GeneralUtility::quoteJSvalue('TSFE_ADMIN_PANEL[display_' . $identifier . ']') .
+ '].value=' .
+ ($this->getBackendUser()->uc['TSFE_adminConfig']['display_' . $identifier] ? '0' : '1') .
+ ';document.TSFE_ADMIN_PANEL_FORM.submit();return false;';
$output = [];
$output[] = '';
$output[] = '';
- $output[] = ' ' . $sectionTitle;
+ $output[] = ' ' . htmlspecialchars($module->getLabel());
$output[] = '';
- $output[] = '';
-
- return implode('', $output);
- }
+ $output[] = '';
- /**
- * Returns a row (with 4 columns) for content in a section of the Admin Panel.
- * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
- *
- * @param string $title Key to label
- * @param string $content The HTML content for the forth table cell.
- * @param string $checkbox The HTML for a checkbox or hidden fields.
- * @param string $innerDivClass The Class attribute for the td element.
- * @param string $outerDivClass The Class attribute for the tr element.
- * @return string HTML table row.
- * @see extGetHead()
- */
- public function extGetItem($title, $content = '', $checkbox = '', $outerDivClass = null, $innerDivClass = null)
- {
- $title = $title ? '' : '';
- $out = '';
- $out .= (string)$outerDivClass ? '
' : '
';
- $out .= (string)$innerDivClass ? '
' : '
';
- $out .= $checkbox . $title . $content . '
';
- return $out;
+ return implode('', $output);
}
/**
@@ -750,11 +623,205 @@ protected function getTypoScriptFrontendController()
return $GLOBALS['TSFE'];
}
+ /*****************************************************
+ * Admin Panel: Deprecated API
+ ****************************************************/
+
+ /**
+ * Add an additional stylesheet
+ *
+ * @return string
+ * @deprecated since TYPO3 v9 - implement AdminPanelModules via the new API (see AdminPanelModuleInterface)
+ */
+ public function getAdminPanelHeaderData()
+ {
+ trigger_error(
+ 'Deprecated since TYPO3 v9 - implement AdminPanelModules via the new API (see AdminPanelModuleInterface)',
+ E_USER_DEPRECATED
+ );
+ return $this->getAdminPanelStylesheet();
+ }
+
+ /**
+ * Checks if an Admin Panel section ("module") is available for the user. If so, TRUE is returned.
+ *
+ * @param string $key The module key, eg. "edit", "preview", "info" etc.
+ * @deprecated but still called in FrontendBackendUserAuthentication (will be refactored in a separate step)
+ * @return bool
+ */
+ public function isAdminModuleEnabled($key)
+ {
+ $result = false;
+ // Returns TRUE if the module checked is "preview" and the forcePreview flag is set.
+ if ($key === 'preview' && $this->ext_forcePreview) {
+ $result = true;
+ } elseif (!empty($this->getBackendUser()->extAdminConfig['enable.']['all'])) {
+ $result = true;
+ } elseif (!empty($this->getBackendUser()->extAdminConfig['enable.'][$key])) {
+ $result = true;
+ }
+ return $result;
+ }
+
/**
- * @return TimeTracker
+ * Saves any change in settings made in the Admin Panel.
+ *
+ * @deprecated since TYPO3 v9 - implement AdminPanelModules via the new API (see AdminPanelModuleInterface)
*/
- protected function getTimeTracker()
+ public function saveConfigOptions()
{
- return GeneralUtility::makeInstance(TimeTracker::class);
+ trigger_error(
+ 'Deprecated since TYPO3 v9 - implement AdminPanelModules via the new API (see AdminPanelModuleInterface)',
+ E_USER_DEPRECATED
+ );
+ $this->saveConfiguration();
+ }
+
+ /**
+ * Returns the value for an Admin Panel setting.
+ *
+ * @param string $sectionName Module key
+ * @param string $val Setting key
+ * @return mixed The setting value
+ * @deprecated Since TYPO3 v9 - implement AdminPanelModules via the new API (see AdminPanelModuleInterface)
+ */
+ public function extGetFeAdminValue($sectionName, $val = '')
+ {
+ trigger_error(
+ 'Deprecated since TYPO3 v9 - implement AdminPanelModules via the new API (see AdminPanelModuleInterface)',
+ E_USER_DEPRECATED
+ );
+ if (!$this->isAdminModuleEnabled($sectionName)) {
+ return null;
+ }
+
+ $beUser = $this->getBackendUser();
+ // Exceptions where the values can be overridden (forced) from backend:
+ // deprecated
+ if (
+ $sectionName === 'edit' && (
+ $val === 'displayIcons' && $beUser->extAdminConfig['module.']['edit.']['forceDisplayIcons'] ||
+ $val === 'displayFieldIcons' && $beUser->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons'] ||
+ $val === 'editNoPopup' && $beUser->extAdminConfig['module.']['edit.']['forceNoPopup']
+ )
+ ) {
+ return true;
+ }
+
+ // Override all settings with user TSconfig
+ if ($val && isset($beUser->extAdminConfig['override.'][$sectionName . '.'][$val])) {
+ return $beUser->extAdminConfig['override.'][$sectionName . '.'][$val];
+ }
+ if (!$val && isset($beUser->extAdminConfig['override.'][$sectionName])) {
+ return $beUser->extAdminConfig['override.'][$sectionName];
+ }
+
+ $returnValue = $val ? $beUser->uc['TSFE_adminConfig'][$sectionName . '_' . $val] : 1;
+
+ // Exception for preview
+ if ($sectionName === 'preview' && $this->ext_forcePreview) {
+ return !$val ? true : $returnValue;
+ }
+
+ // See if the menu is expanded!
+ return $this->isAdminModuleOpen($sectionName) ? $returnValue : null;
+ }
+
+ /**
+ * Enables the force preview option.
+ *
+ * @deprecated since TYPO3 v9 - see AdminPanelModule: Preview
+ */
+ public function forcePreview()
+ {
+ trigger_error('Deprecated since TYPO3 v9, see AdminPanelModule: Preview', E_USER_DEPRECATED);
+ $this->ext_forcePreview = true;
+ }
+
+ /**
+ * Returns TRUE if admin panel module is open
+ *
+ * @param string $key Module key
+ * @return bool TRUE, if the admin panel is open for the specified admin panel module key.
+ * @deprecated Since TYPO3 v9 - implement AdminPanelModules via the new API
+ */
+ public function isAdminModuleOpen($key)
+ {
+ trigger_error('since TYPO3 v9 - use new AdminPanel API instead', E_USER_DEPRECATED);
+ return $this->getBackendUser()->uc['TSFE_adminConfig']['display_top'] &&
+ $this->getBackendUser()->uc['TSFE_adminConfig']['display_' . $key];
+ }
+
+ /**
+ * Returns a row (with 4 columns) for content in a section of the Admin Panel.
+ * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
+ *
+ * @param string $title Key to label
+ * @param string $content The HTML content for the forth table cell.
+ * @param string $checkbox The HTML for a checkbox or hidden fields.
+ * @param string $innerDivClass The Class attribute for the td element.
+ * @param string $outerDivClass The Class attribute for the tr element.
+ * @return string HTML table row.
+ * @see extGetHead()
+ * @deprecated since TYPO3 v9 - use new AdminPanel API instead
+ */
+ public function extGetItem($title, $content = '', $checkbox = '', $outerDivClass = null, $innerDivClass = null)
+ {
+ trigger_error('since TYPO3 v9 - use new AdminPanel API instead', E_USER_DEPRECATED);
+ $title = $title ? '' : '';
+ $out = '';
+ $out .= (string)$outerDivClass ? '
' : '
';
+ $out .= (string)$innerDivClass ? '
' : '
';
+ $out .= $checkbox . $title . $content . '
';
+ return $out;
+ }
+
+ /**
+ * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
+ * It will have a plus/minus icon and a label which is linked so that it submits the form which surrounds the whole Admin Panel when clicked, alterting the TSFE_ADMIN_PANEL[display_' . $pre . '] value
+ * See the functions get*Module
+ *
+ * @param string $sectionSuffix The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
+ * @return string HTML table row.
+ * @see extGetItem()
+ * @deprecated since TYPO3 v9 - use new AdminPanel API instead
+ */
+ public function extGetHead($sectionSuffix)
+ {
+ trigger_error('since TYPO3 v9 - use new AdminPanel API instead', E_USER_DEPRECATED);
+ return $this->linkSectionHeader($sectionSuffix, $this->extGetLL($sectionSuffix));
+ }
+
+ /**
+ * Wraps a string in a link which will open/close a certain part of the Admin Panel
+ *
+ * @param string $sectionSuffix The code for the display_ label/key
+ * @param string $sectionTitle Title (HTML-escaped)
+ * @param string $className The classname for the tag
+ * @return string $className Linked input string
+ * @see extGetHead()
+ * @deprecated since TYPO3 v9 - use new AdminPanel API instead
+ */
+ public function linkSectionHeader($sectionSuffix, $sectionTitle, $className = '')
+ {
+ trigger_error('since TYPO3 v9 - use new AdminPanel API instead', E_USER_DEPRECATED);
+ $onclick = 'document.TSFE_ADMIN_PANEL_FORM[' .
+ GeneralUtility::quoteJSvalue('TSFE_ADMIN_PANEL[display_' . $sectionSuffix . ']') .
+ '].value=' .
+ ($this->getBackendUser()->uc['TSFE_adminConfig']['display_' . $sectionSuffix] ? '0' : '1') .
+ ';document.TSFE_ADMIN_PANEL_FORM.submit();return false;';
+
+ $output = [];
+ $output[] = '';
+ $output[] = '';
+ $output[] = ' ' . $sectionTitle;
+ $output[] = '';
+ $output[] = '';
+
+ return implode('', $output);
}
}
diff --git a/typo3/sysext/frontend/Tests/Unit/View/AdminPanelViewTest.php b/typo3/sysext/frontend/Tests/Unit/View/AdminPanelViewTest.php
index 6daf31e3b0fb..0561280d48c1 100644
--- a/typo3/sysext/frontend/Tests/Unit/View/AdminPanelViewTest.php
+++ b/typo3/sysext/frontend/Tests/Unit/View/AdminPanelViewTest.php
@@ -1,4 +1,5 @@
prophesize(IconFactory::class);
+ GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+ $beUserProphecy = $this->prophesize(BackendUserAuthentication::class);
+ $GLOBALS['BE_USER'] = $beUserProphecy->reveal();
+ }
/**
- * Set up
+ * @test
*/
- protected function setUp()
+ public function initializeCallsOnSubmitIfInputVarsAreSet()
{
- $GLOBALS['LANG'] = $this->createMock(LanguageService::class);
- $cacheManagerProphecy = $this->prophesize(CacheManager::class);
- GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
- $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
- $cacheManagerProphecy->getCache('cache_pages')->willReturn($cacheFrontendProphecy->reveal());
- $GLOBALS['TSFE'] = new TypoScriptFrontendController([], 1, 1);
- }
+ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['frontend']['adminPanelModules'] = [
+ 'fixtureOnSubmit' => [
+ 'module' => AdminPanelEnabledShownOnSubmitInitializeModuleFixture::class
+ ]
+ ];
- protected function tearDown()
- {
- GeneralUtility::purgeInstances();
- parent::tearDown();
+ $postVars = ['preview_showFluidDebug' => '1'];
+ $_GET['TSFE_ADMIN_PANEL'] = $postVars;
+
+ $this->expectExceptionCode('1519997815');
+
+ new AdminPanelView();
}
/**
* @test
*/
- public function extGetFeAdminValueReturnsTimestamp()
+ public function initializeCallsInitializeModulesForEnabledModules()
{
- $strTime = '2013-01-01 01:00:00';
- $timestamp = strtotime($strTime);
-
- $backendUser = $this->getMockBuilder(\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class)->getMock();
- $backendUser->uc['TSFE_adminConfig']['preview_simulateDate'] = $timestamp;
- unset($backendUser->extAdminConfig['override.']['preview.']);
- unset($backendUser->extAdminConfig['override.']['preview']);
- $GLOBALS['BE_USER'] = $backendUser;
-
- $adminPanelMock = $this->getMockBuilder(\TYPO3\CMS\Frontend\View\AdminPanelView::class)
- ->setMethods(['isAdminModuleEnabled', 'isAdminModuleOpen'])
- ->disableOriginalConstructor()
- ->getMock();
- $adminPanelMock->expects($this->any())->method('isAdminModuleEnabled')->will($this->returnValue(true));
- $adminPanelMock->expects($this->any())->method('isAdminModuleOpen')->will($this->returnValue(true));
+ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['frontend']['adminPanelModules'] = [
+ 'enabledModule' => [
+ 'module' => AdminPanelEnabledShownOnSubmitInitializeModuleFixture::class
+ ],
+ 'disabledModule' => [
+ 'module' => AdminPanelDisabledModuleFixture::class,
+ 'before' => ['enabledModule']
+ ]
+ ];
- $timestampReturned = $adminPanelMock->extGetFeAdminValue('preview', 'simulateDate');
- $this->assertEquals($timestamp, $timestampReturned);
+ $this->expectExceptionCode(1519999273);
+ new AdminPanelView();
}
}
diff --git a/typo3/sysext/frontend/Tests/Unit/View/Fixtures/AdminPanelDisabledModuleFixture.php b/typo3/sysext/frontend/Tests/Unit/View/Fixtures/AdminPanelDisabledModuleFixture.php
new file mode 100644
index 000000000000..e93556c006fa
--- /dev/null
+++ b/typo3/sysext/frontend/Tests/Unit/View/Fixtures/AdminPanelDisabledModuleFixture.php
@@ -0,0 +1,131 @@
+ should be initialized
+ * A module may be enabled but not shown
+ * -> only the initializeModule() method
+ * will be called
+ *
+ * @return bool
+ */
+ public function isEnabled(): bool
+ {
+ return false;
+ }
+
+ /**
+ * Module is open
+ * -> module is enabled
+ * -> module panel is shown and open
+ *
+ * @return bool
+ */
+ public function isOpen(): bool
+ {
+ return true;
+ }
+
+ /**
+ * Module is shown
+ * -> module is enabled
+ * -> module panel should be displayed
+ *
+ * @return bool
+ */
+ public function isShown(): bool
+ {
+ return true;
+ }
+
+ /**
+ * Executed on saving / submit of the configuration form
+ * Can be used to react to changed settings
+ * (for example: clearing a specific cache)
+ *
+ * @param array $input
+ */
+ public function onSubmit(array $input): void
+ {
+ }
+
+ /**
+ * Does this module need a form submit?
+ *
+ * @return bool
+ */
+ public function showFormSubmitButton(): bool
+ {
+ return true;
+ }
+}
diff --git a/typo3/sysext/frontend/Tests/Unit/View/Fixtures/AdminPanelEnabledShownOnSubmitInitializeModuleFixture.php b/typo3/sysext/frontend/Tests/Unit/View/Fixtures/AdminPanelEnabledShownOnSubmitInitializeModuleFixture.php
new file mode 100644
index 000000000000..1572fdf7dd48
--- /dev/null
+++ b/typo3/sysext/frontend/Tests/Unit/View/Fixtures/AdminPanelEnabledShownOnSubmitInitializeModuleFixture.php
@@ -0,0 +1,132 @@
+ should be initialized
+ * A module may be enabled but not shown
+ * -> only the initializeModule() method
+ * will be called
+ *
+ * @return bool
+ */
+ public function isEnabled(): bool
+ {
+ return true;
+ }
+
+ /**
+ * Module is open
+ * -> module is enabled
+ * -> module panel is shown and open
+ *
+ * @return bool
+ */
+ public function isOpen(): bool
+ {
+ return true;
+ }
+
+ /**
+ * Module is shown
+ * -> module is enabled
+ * -> module panel should be displayed
+ *
+ * @return bool
+ */
+ public function isShown(): bool
+ {
+ return true;
+ }
+
+ /**
+ * Executed on saving / submit of the configuration form
+ * Can be used to react to changed settings
+ * (for example: clearing a specific cache)
+ *
+ * @param array $input
+ */
+ public function onSubmit(array $input): void
+ {
+ throw new \RuntimeException('Catch me if you can!', 1519997815);
+ }
+
+ /**
+ * Does this module need a form submit?
+ *
+ * @return bool
+ */
+ public function showFormSubmitButton(): bool
+ {
+ return true;
+ }
+}
diff --git a/typo3/sysext/frontend/Tests/UnitDeprecated/View/AdminPanelViewTest.php b/typo3/sysext/frontend/Tests/UnitDeprecated/View/AdminPanelViewTest.php
deleted file mode 100644
index 0f548c932915..000000000000
--- a/typo3/sysext/frontend/Tests/UnitDeprecated/View/AdminPanelViewTest.php
+++ /dev/null
@@ -1,99 +0,0 @@
-createMock(LanguageService::class);
- $cacheManagerProphecy = $this->prophesize(CacheManager::class);
- GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
- $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
- $cacheManagerProphecy->getCache('cache_pages')->willReturn($cacheFrontendProphecy->reveal());
- $GLOBALS['TSFE'] = new TypoScriptFrontendController([], 1, 1);
- }
-
- protected function tearDown()
- {
- GeneralUtility::purgeInstances();
- parent::tearDown();
- }
-
- /////////////////////////////////////////////
- // Test concerning extendAdminPanel hook
- /////////////////////////////////////////////
-
- /**
- * @test
- */
- public function extendAdminPanelHookThrowsExceptionIfHookClassDoesNotImplementInterface()
- {
- $this->expectException(\UnexpectedValueException::class);
- $this->expectExceptionCode(1311942539);
- $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = \TYPO3\CMS\Frontend\Tests\Unit\Fixtures\AdminPanelHookWithoutInterfaceFixture::class;
- /** @var $adminPanelMock \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Frontend\View\AdminPanelView */
- $adminPanelMock = $this->getMockBuilder(\TYPO3\CMS\Frontend\View\AdminPanelView::class)
- ->setMethods(['dummy'])
- ->disableOriginalConstructor()
- ->getMock();
- $adminPanelMock->display();
- }
-
- /**
- * @test
- */
- public function extendAdminPanelHookCallsExtendAdminPanelMethodOfHook()
- {
- $hookClass = $this->getUniqueId('tx_coretest');
- $hookMock = $this->getMockBuilder(\TYPO3\CMS\Frontend\View\AdminPanelViewHookInterface::class)
- ->setMockClassName($hookClass)
- ->getMock();
- GeneralUtility::addInstance($hookClass, $hookMock);
- $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = $hookClass;
- /** @var $adminPanelMock \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Frontend\View\AdminPanelView */
- $adminPanelMock = $this->getMockBuilder(\TYPO3\CMS\Frontend\View\AdminPanelView::class)
- ->setMethods(['extGetLL'])
- ->disableOriginalConstructor()
- ->getMock();
- $iconFactoryProphecy = $this->prophesize(IconFactory::class);
- GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
- $iconProphecy = $this->prophesize(Icon::class);
- $iconFactoryProphecy->getIcon(Argument::cetera())->willReturn($iconProphecy->reveal());
- $iconProphecy->render(Argument::cetera())->willReturn('');
- $adminPanelMock->initialize();
- $hookMock->expects($this->once())->method('extendAdminPanel')->with($this->isType('string'), $this->isInstanceOf(\TYPO3\CMS\Frontend\View\AdminPanelView::class));
- $adminPanelMock->display();
- }
-}
diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php
index 08427a5afa8c..fdd91a7cb625 100644
--- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php
+++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php
@@ -1717,4 +1717,67 @@
'Important-83869-RemovedRequestTypeSpecificCodeInBootstrap.rst',
],
],
+ 'TYPO3\CMS\Frontend\View\AdminPanelView->getAdminPanelHeaderData' => [
+ 'numberOfMandatoryArguments' => 0,
+ 'maximumNumberOfArguments' => 0,
+ 'restFiles' => [
+ 'Deprecation-84118-VariousPublicMethodsOfAdminPanelViewDeprecated.rst',
+ ],
+ ],
+ 'TYPO3\CMS\Frontend\View\AdminPanelView->isAdminModuleEnabled' => [
+ 'numberOfMandatoryArguments' => 1,
+ 'maximumNumberOfArguments' => 1,
+ 'restFiles' => [
+ 'Deprecation-84118-VariousPublicMethodsOfAdminPanelViewDeprecated.rst',
+ ],
+ ],
+ 'TYPO3\CMS\Frontend\View\AdminPanelView->saveConfigOptions' => [
+ 'numberOfMandatoryArguments' => 0,
+ 'maximumNumberOfArguments' => 0,
+ 'restFiles' => [
+ 'Deprecation-84118-VariousPublicMethodsOfAdminPanelViewDeprecated.rst',
+ ],
+ ],
+ 'TYPO3\CMS\Frontend\View\AdminPanelView->extGetFeAdminValue' => [
+ 'numberOfMandatoryArguments' => 1,
+ 'maximumNumberOfArguments' => 2,
+ 'restFiles' => [
+ 'Deprecation-84118-VariousPublicMethodsOfAdminPanelViewDeprecated.rst',
+ ],
+ ],
+ 'TYPO3\CMS\Frontend\View\AdminPanelView->forcePreview' => [
+ 'numberOfMandatoryArguments' => 0,
+ 'maximumNumberOfArguments' => 0,
+ 'restFiles' => [
+ 'Deprecation-84118-VariousPublicMethodsOfAdminPanelViewDeprecated.rst',
+ ],
+ ],
+ 'TYPO3\CMS\Frontend\View\AdminPanelView->isAdminModuleOpen' => [
+ 'numberOfMandatoryArguments' => 1,
+ 'maximumNumberOfArguments' => 1,
+ 'restFiles' => [
+ 'Deprecation-84118-VariousPublicMethodsOfAdminPanelViewDeprecated.rst',
+ ],
+ ],
+ 'TYPO3\CMS\Frontend\View\AdminPanelView->extGetHead' => [
+ 'numberOfMandatoryArguments' => 1,
+ 'maximumNumberOfArguments' => 1,
+ 'restFiles' => [
+ 'Deprecation-84118-VariousPublicMethodsOfAdminPanelViewDeprecated.rst',
+ ],
+ ],
+ 'TYPO3\CMS\Frontend\View\AdminPanelView->linkSectionHeader' => [
+ 'numberOfMandatoryArguments' => 1,
+ 'maximumNumberOfArguments' => 1,
+ 'restFiles' => [
+ 'Deprecation-84118-VariousPublicMethodsOfAdminPanelViewDeprecated.rst',
+ ],
+ ],
+ 'TYPO3\CMS\Frontend\View\AdminPanelView->extGetItem' => [
+ 'numberOfMandatoryArguments' => 1,
+ 'maximumNumberOfArguments' => 5,
+ 'restFiles' => [
+ 'Deprecation-84118-VariousPublicMethodsOfAdminPanelViewDeprecated.rst',
+ ],
+ ],
];