Commit 1dc3e9e2 authored by Daniel Windloff's avatar Daniel Windloff Committed by Tobi Kretschmann
Browse files

[TASK] Invoke "Clear Page cache" in page and list module via ajax

* Add a message for the user
* Adjust context menu to new route
* Split functionality in an own controller class

Resolves: #88718
Releases: master
Change-Id: Ibb96e4f5770004be54fee0f50a335db8f3282759
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61245


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarSteffen Frese <steffenf14@gmail.com>
Tested-by: default avatarJörg Bösche <typo3@joergboesche.de>
Tested-by: default avatarTobi Kretschmann <tobi@tobishome.de>
Reviewed-by: default avatarSteffen Frese <steffenf14@gmail.com>
Reviewed-by: default avatarJörg Bösche <typo3@joergboesche.de>
Reviewed-by: default avatarTobi Kretschmann <tobi@tobishome.de>
parent 84d663b9
......@@ -17,6 +17,7 @@ import InfoWindow = require('./InfoWindow');
import Modal = require('./Modal');
import ModuleMenu = require('./ModuleMenu');
import Viewport = require('./Viewport');
import Notification = require('TYPO3/CMS/Backend/Notification');
/**
* @exports TYPO3/CMS/Backend/ContextMenuActions
......@@ -291,9 +292,23 @@ class ContextMenuActions {
* @param {number} uid uid of the page
*/
public static clearCache(table: string, uid: number): void {
const url = top.TYPO3.settings.WebLayout.moduleUrl
+ '&id=' + uid + '&clear_cache=1';
$.ajax(url);
$.ajax({
url: TYPO3.settings.ajaxUrls.web_list_clearpagecache + '&id=' + uid,
cache: false,
dataType: 'json',
success: (data: any): void => {
if (data.success === true) {
Notification.success(data.title, data.message, 1);
} else {
Notification.error(data.title, data.message, 1);
}
},
error: (): void => {
Notification.error(
'Clearing page caches went wrong on the server side.',
);
},
});
}
/**
......
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
import * as $ from 'jquery';
import Notification = require('TYPO3/CMS/Backend/Notification');
/**
* Module: TYPO3/CMS/Recordlist/ClearCache
* Folder selection
* @exports TYPO3/CMS/Recordlist/ClearCache
*/
class ClearCache {
constructor() {
$(() => {
$('.t3js-clear-page-cache').on('click', (event: JQueryEventObject): void => {
event.preventDefault();
const $me = $(event.currentTarget);
const id = $me.data('id');
$.ajax({
url: TYPO3.settings.ajaxUrls.web_list_clearpagecache + '&id=' + id,
cache: false,
dataType: 'json',
success: (data: any): void => {
if (data.success === true) {
Notification.success(data.title, data.message, 1);
} else {
Notification.error(data.title, data.message, 1);
}
},
error: (): void => {
Notification.error(
'Clearing page caches went wrong on the server side.',
);
},
});
});
});
}
}
export = new ClearCache();
......@@ -29,7 +29,6 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
......@@ -99,13 +98,6 @@ class PageLayoutController
*/
protected $returnUrl;
/**
* Clear-cache flag - if set, clears page cache for current id.
*
* @var bool
*/
protected $clear_cache;
/**
* PopView id - for opening a window with the page
*
......@@ -264,7 +256,6 @@ class PageLayoutController
{
$GLOBALS['SOBE'] = $this;
$this->init($request);
$this->clearCache();
$this->main($request);
return new HtmlResponse($this->moduleTemplate->renderContent());
}
......@@ -293,7 +284,6 @@ class PageLayoutController
$this->id = (int)($parsedBody['id'] ?? $queryParams['id'] ?? 0);
$this->pointer = $parsedBody['pointer'] ?? $queryParams['pointer'] ?? null;
$this->imagemode = $parsedBody['imagemode'] ?? $queryParams['imagemode'] ?? null;
$this->clear_cache = $parsedBody['clear_cache'] ?? $queryParams['clear_cache'] ?? null;
$this->popView = $parsedBody['popView'] ?? $queryParams['popView'] ?? null;
$this->search_field = $parsedBody['search_field'] ?? $queryParams['search_field'] ?? null;
$this->search_levels = $parsedBody['search_levels'] ?? $queryParams['search_levels'] ?? null;
......@@ -463,18 +453,6 @@ class PageLayoutController
$this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($actionMenu);
}
/**
* Clears page cache for the current id, $this->id
*/
protected function clearCache(): void
{
if ($this->clear_cache && !empty($this->pageinfo)) {
$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
$dataHandler->start([], []);
$dataHandler->clear_cacheCmd($this->id);
}
}
/**
* Generate the flashmessages for current pid
*
......@@ -670,6 +648,7 @@ class PageLayoutController
*/
protected function main(ServerRequestInterface $request): void
{
$this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Recordlist/ClearCache');
$lang = $this->getLanguageService();
// Access check...
// The page will show only if there is a valid page and if this page may be viewed by the user
......@@ -949,7 +928,9 @@ class PageLayoutController
// Cache
if (empty($this->modTSconfig['properties']['disableAdvanced'])) {
$clearCacheButton = $this->buttonBar->makeLinkButton()
->setHref((string)$uriBuilder->buildUriFromRoute($this->moduleName, ['id' => $this->pageinfo['uid'], 'clear_cache' => '1']))
->setHref('#')
->setDataAttributes(['id' => $this->pageinfo['uid']])
->setClasses('t3js-clear-page-cache')
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clear_cache'))
->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
$this->buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT, 1);
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","./Enum/Severity","jquery","./InfoWindow","./Modal","./ModuleMenu","./Viewport"],function(e,t,n,o,a,r,i,s){"use strict";return function(){function e(){}return e.getReturnUrl=function(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)},e.editRecord=function(t,n){var a="",r=o(this).data("pages-language-uid");r&&(a="&overrideVals[pages][sys_language_uid]="+r),s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"]["+n+"]=edit"+a+"&returnUrl="+e.getReturnUrl())},e.viewRecord=function(e,t){var n=o(this).data("preview-url");n&&window.open(n,"newTYPO3frontendWindow").focus()},e.openInfoPopUp=function(e,t){a.showItem(e,t)},e.mountAsTreeRoot=function(e,t){"pages"===e&&s.NavigationContainer.PageTree.setTemporaryMountPoint(t)},e.newPageWizard=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.NewRecord.moduleUrl+"&id="+n+"&pagesOnly=1&returnUrl="+e.getReturnUrl())},e.newContentWizard=function(t,a){var i=o(this),s=i.data("new-wizard-url");s&&(s+="&returnUrl="+e.getReturnUrl(),r.advanced({title:i.data("title"),type:r.types.ajax,size:r.sizes.medium,content:s,severity:n.SeverityEnum.notice}))},e.newRecord=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"][-"+n+"]=new&returnUrl="+e.getReturnUrl())},e.openHistoryPopUp=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.RecordHistory.moduleUrl+"&element="+t+":"+n+"&returnUrl="+e.getReturnUrl())},e.openListModule=function(e,t){var n="pages"===e?t:o(this).data("page-uid");i.App.showModule("web_list","id="+n)},e.pagesSort=function(e,t){var n=o(this).data("pages-sort-url");n&&s.ContentContainer.setUrl(n)},e.pagesNewMultiple=function(e,t){var n=o(this).data("pages-new-multiple-url");n&&s.ContentContainer.setUrl(n)},e.disableRecord=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+n+"][hidden]=1&redirect="+e.getReturnUrl()).done(function(){s.NavigationContainer.PageTree.refreshTree()})},e.enableRecord=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+n+"][hidden]=0&redirect="+e.getReturnUrl()).done(function(){s.NavigationContainer.PageTree.refreshTree()})},e.deleteRecord=function(e,t){var a=o(this);r.confirm(a.data("title"),a.data("message"),n.SeverityEnum.warning,[{text:o(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",function(n){if("delete"===n.target.getAttribute("name")){var a=top.TYPO3.settings.RecordCommit.moduleUrl+"&cmd["+e+"]["+t+"][delete]=1";o.ajax({url:a,success:function(){if("pages"===e&&s.NavigationContainer.PageTree){if(t===top.fsMod.recentIds.web){var n=s.NavigationContainer.PageTree.instance.nodes[0];s.NavigationContainer.PageTree.selectNode(n)}s.NavigationContainer.PageTree.refreshTree()}}})}r.dismiss()})},e.copy=function(t,n){var a=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=1&CB[setCopyMode]=1";o.ajax(a).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.clipboardRelease=function(t,n){var a=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=0";o.ajax(a).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.cut=function(t,n){var a=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=1&CB[setCopyMode]=0";o.ajax(a).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.triggerRefresh=function(e){-1===e.indexOf("record%2Fedit")&&s.ContentContainer.refresh(!0)},e.clearCache=function(e,t){var n=top.TYPO3.settings.WebLayout.moduleUrl+"&id="+t+"&clear_cache=1";o.ajax(n)},e.pasteAfter=function(t,n){e.pasteInto.bind(o(this))(t,-n)},e.pasteInto=function(t,a){var i=o(this),l=function(){var n="&CB[paste]="+t+"%7C"+a+"&CB[pad]=normal&redirect="+e.getReturnUrl();s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+n).done(function(){"pages"===t&&s.NavigationContainer.PageTree&&s.NavigationContainer.PageTree.refreshTree()})};i.data("title")?r.confirm(i.data("title"),i.data("message"),n.SeverityEnum.warning,[{text:o(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",function(e){"ok"===e.target.getAttribute("name")&&l(),r.dismiss()}):l()},e}()});
\ No newline at end of file
define(["require","exports","./Enum/Severity","jquery","./InfoWindow","./Modal","./ModuleMenu","./Viewport","TYPO3/CMS/Backend/Notification"],function(e,t,n,r,a,o,i,s,l){"use strict";return function(){function e(){}return e.getReturnUrl=function(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)},e.editRecord=function(t,n){var a="",o=r(this).data("pages-language-uid");o&&(a="&overrideVals[pages][sys_language_uid]="+o),s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"]["+n+"]=edit"+a+"&returnUrl="+e.getReturnUrl())},e.viewRecord=function(e,t){var n=r(this).data("preview-url");n&&window.open(n,"newTYPO3frontendWindow").focus()},e.openInfoPopUp=function(e,t){a.showItem(e,t)},e.mountAsTreeRoot=function(e,t){"pages"===e&&s.NavigationContainer.PageTree.setTemporaryMountPoint(t)},e.newPageWizard=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.NewRecord.moduleUrl+"&id="+n+"&pagesOnly=1&returnUrl="+e.getReturnUrl())},e.newContentWizard=function(t,a){var i=r(this),s=i.data("new-wizard-url");s&&(s+="&returnUrl="+e.getReturnUrl(),o.advanced({title:i.data("title"),type:o.types.ajax,size:o.sizes.medium,content:s,severity:n.SeverityEnum.notice}))},e.newRecord=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"][-"+n+"]=new&returnUrl="+e.getReturnUrl())},e.openHistoryPopUp=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.RecordHistory.moduleUrl+"&element="+t+":"+n+"&returnUrl="+e.getReturnUrl())},e.openListModule=function(e,t){var n="pages"===e?t:r(this).data("page-uid");i.App.showModule("web_list","id="+n)},e.pagesSort=function(e,t){var n=r(this).data("pages-sort-url");n&&s.ContentContainer.setUrl(n)},e.pagesNewMultiple=function(e,t){var n=r(this).data("pages-new-multiple-url");n&&s.ContentContainer.setUrl(n)},e.disableRecord=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+n+"][hidden]=1&redirect="+e.getReturnUrl()).done(function(){s.NavigationContainer.PageTree.refreshTree()})},e.enableRecord=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+n+"][hidden]=0&redirect="+e.getReturnUrl()).done(function(){s.NavigationContainer.PageTree.refreshTree()})},e.deleteRecord=function(e,t){var a=r(this);o.confirm(a.data("title"),a.data("message"),n.SeverityEnum.warning,[{text:r(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:r(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",function(n){if("delete"===n.target.getAttribute("name")){var a=top.TYPO3.settings.RecordCommit.moduleUrl+"&cmd["+e+"]["+t+"][delete]=1";r.ajax({url:a,success:function(){if("pages"===e&&s.NavigationContainer.PageTree){if(t===top.fsMod.recentIds.web){var n=s.NavigationContainer.PageTree.instance.nodes[0];s.NavigationContainer.PageTree.selectNode(n)}s.NavigationContainer.PageTree.refreshTree()}}})}o.dismiss()})},e.copy=function(t,n){var a=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=1&CB[setCopyMode]=1";r.ajax(a).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.clipboardRelease=function(t,n){var a=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=0";r.ajax(a).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.cut=function(t,n){var a=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=1&CB[setCopyMode]=0";r.ajax(a).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.triggerRefresh=function(e){-1===e.indexOf("record%2Fedit")&&s.ContentContainer.refresh(!0)},e.clearCache=function(e,t){r.ajax({url:TYPO3.settings.ajaxUrls.web_list_clearpagecache+"&id="+t,cache:!1,dataType:"json",success:function(e){!0===e.success?l.success(e.title,e.message,1):l.error(e.title,e.message,1)},error:function(){l.error("Clearing page caches went wrong on the server side.")}})},e.pasteAfter=function(t,n){e.pasteInto.bind(r(this))(t,-n)},e.pasteInto=function(t,a){var i=r(this),l=function(){var n="&CB[paste]="+t+"%7C"+a+"&CB[pad]=normal&redirect="+e.getReturnUrl();s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+n).done(function(){"pages"===t&&s.NavigationContainer.PageTree&&s.NavigationContainer.PageTree.refreshTree()})};i.data("title")?o.confirm(i.data("title"),i.data("message"),n.SeverityEnum.warning,[{text:r(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:r(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",function(e){"ok"===e.target.getAttribute("name")&&l(),o.dismiss()}):l()},e}()});
\ No newline at end of file
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Recordlist\Controller;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class ClearPageCacheController
*
* Allows to clear the page cache of a given page uid
*/
class ClearPageCacheController
{
/**
* @var DataHandler
*/
protected $dataHandler;
/**
* ClearPageCacheController constructor.
*/
public function __construct()
{
$this->dataHandler = GeneralUtility::makeInstance(DataHandler::class);
}
/**
* Clear page cache
*
* @param ServerRequestInterface $request
* @return ResponseInterface
*/
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$parsedBody = $request->getParsedBody();
$queryParams = $request->getQueryParams();
$pageUid = (int)($parsedBody['id'] ?? $queryParams['id'] ?? 0);
$message = $this->getLanguageService()->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:clearcache.message.error');
$success = false;
$permissionClause = $this->getBackendUserAuthentication()->getPagePermsClause(Permission::PAGE_SHOW);
$pageRow = BackendUtility::readPageAccess($pageUid, $permissionClause);
if ($pageUid !== 0 && $this->getBackendUserAuthentication()->doesUserHaveAccess($pageRow, Permission::PAGE_SHOW)) {
$this->dataHandler->start([], []);
$this->dataHandler->clear_cacheCmd($pageUid);
$message = $this->getLanguageService()->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:clearcache.message.success');
$success = true;
}
return new JsonResponse([
'success' => $success,
'title' => $this->getLanguageService()->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:clearcache.title'),
'message' => $message
]);
}
/**
* @return BackendUserAuthentication
*/
protected function getBackendUserAuthentication(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
}
/**
* Returns LanguageService
*
* @return \TYPO3\CMS\Core\Localization\LanguageService
*/
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
}
......@@ -95,13 +95,6 @@ class RecordListController
*/
protected $returnUrl;
/**
* Clear-cache flag - if set, clears page cache for current id.
*
* @var bool
*/
protected $clear_cache;
/**
* Command: Eg. "delete" or "setCB" (for DataHandler / clipboard operations)
*
......@@ -201,6 +194,7 @@ class RecordListController
$this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf');
$this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Recordlist/FieldSelectBox');
$this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Recordlist/Recordlist');
$this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Recordlist/ClearCache');
}
/**
......@@ -222,7 +216,6 @@ class RecordListController
$this->search_levels = (int)GeneralUtility::_GP('search_levels');
$this->showLimit = GeneralUtility::_GP('showLimit');
$this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
$this->clear_cache = GeneralUtility::_GP('clear_cache');
$this->cmd = GeneralUtility::_GP('cmd');
$this->cmd_table = GeneralUtility::_GP('cmd_table');
$sessionData['search_field'] = $this->search_field;
......@@ -249,18 +242,6 @@ class RecordListController
$this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), 'web_list');
}
/**
* Clears page cache for the current id, $this->id
*/
protected function clearCache()
{
if ($this->clear_cache) {
$tce = GeneralUtility::makeInstance(DataHandler::class);
$tce->start([], []);
$tce->clear_cacheCmd($this->id);
}
}
/**
* Main function, starting the rendering of the list.
*
......@@ -593,7 +574,6 @@ class RecordListController
// @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0. Can be removed along with $this->doc. Still used in DatabaseRecordList
$GLOBALS['SOBE'] = $this;
$this->init();
$this->clearCache();
$this->main($request);
$this->moduleTemplate->setContent($this->content);
return new HtmlResponse($this->moduleTemplate->renderContent());
......
......@@ -705,7 +705,7 @@ class DatabaseRecordList
}
}
// Cache
$buttons['cache'] = '<a href="' . htmlspecialchars($this->listURL() . '&clear_cache=1') . '" title="'
$buttons['cache'] = '<a href="#" data-id="' . $this->id . '" class="t3js-clear-page-cache" title="'
. htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clear_cache')) . '">'
. $this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL)->render() . '</a>';
if ($this->table && (!isset($module->modTSconfig['properties']['noExportRecordsLinks'])
......@@ -839,11 +839,15 @@ class DatabaseRecordList
}
}
// Cache
$clearCacheButton = $buttonBar->makeLinkButton()
->setHref($this->listURL() . '&clear_cache=1')
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clear_cache'))
->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
$buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT);
if ($this->id !== 0) {
$clearCacheButton = $buttonBar->makeLinkButton()
->setHref('#')
->setDataAttributes(['id' => $this->id])
->setClasses('t3js-clear-page-cache')
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clear_cache'))
->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
$buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT);
}
if ($this->table && (!isset($module->modTSconfig['properties']['noExportRecordsLinks'])
|| (isset($module->modTSconfig['properties']['noExportRecordsLinks'])
&& !$module->modTSconfig['properties']['noExportRecordsLinks']))
......
<?php
/**
* Definitions of routes
*/
return [
'web_list_clearpagecache' => [
'path' => '/web/list/clearpagecache',
'target' => \TYPO3\CMS\Recordlist\Controller\ClearPageCacheController::class . '::mainAction'
],
];
......@@ -6,6 +6,15 @@
<trans-unit id="error.linkHandlerTitleMissing">
<source>[title missing]</source>
</trans-unit>
<trans-unit id="clearcache.title">
<source>Page cache</source>
</trans-unit>
<trans-unit id="clearcache.message.success">
<source>Successfully cleared page cache</source>
</trans-unit>
<trans-unit id="clearcache.message.error">
<source>Page cache could not cleared</source>
</trans-unit>
</body>
</file>
</xliff>
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery","TYPO3/CMS/Backend/Notification"],function(e,r,c,t){"use strict";return new function(){c(function(){c(".t3js-clear-page-cache").on("click",function(e){e.preventDefault();var r=c(e.currentTarget).data("id");c.ajax({url:TYPO3.settings.ajaxUrls.web_list_clearpagecache+"&id="+r,cache:!1,dataType:"json",success:function(e){!0===e.success?t.success(e.title,e.message,1):t.error(e.title,e.message,1)},error:function(){t.error("Clearing page caches went wrong on the server side.")}})})})}});
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment