2 /***************************************************************
5 * (c) 2007 Ingo Renner <ingo@typo3.org>
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
30 * class to render the menu for the cache clearing actions
34 * @author Ingo Renner <ingo@typo3.org>
38 class ClearCacheMenu
implements backend_toolbarItem
{
40 private $cacheActions;
43 * reference back to the backend object
47 private $backendReference;
54 public function __construct() {
55 $this->cacheActions
= array();
57 // Clear cache for ALL tables!
58 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCache_all');
59 $this->cacheActions
[] = array(
62 'href' => $this->backPath
.'tce_db.php?vC='.$GLOBALS['BE_USER']->veriCode().'&cacheCmd=all',
63 'icon' => '<img'.t3lib_iconWorks
::skinImg($this->backPath
, 'gfx/lightning_red.png', 'width="16" height="16"').' title="'.htmlspecialchars($title).'" alt="" />'
66 // Clear cache for either ALL pages
67 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCache_pages');
68 $this->cacheActions
[] = array(
71 'href' => $this->backPath
.'tce_db.php?vC='.$GLOBALS['BE_USER']->veriCode().'&cacheCmd=pages',
72 'icon' => '<img'.t3lib_iconWorks
::skinImg($this->backPath
, 'gfx/lightning.png', 'width="16" height="16"').' title="'.htmlspecialchars($title).'" alt="" />'
75 // Clearing of cache-files in typo3conf/ + menu
76 if ($GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache']) {
77 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCache_allTypo3Conf');
78 $this->cacheActions
[] = array(
79 'id' => 'temp_CACHED',
81 'href' => $this->backPath
.'tce_db.php?vC='.$GLOBALS['BE_USER']->veriCode().'&cacheCmd=temp_CACHED',
82 'icon' => '<img'.t3lib_iconWorks
::skinImg($this->backPath
, 'gfx/lightning_green.png', 'width="16" height="16"').' title="'.htmlspecialchars($title).'" alt="" />'
90 * sets the backend reference
92 * @param TYPO3backend backend object reference
94 public function setBackend(&$backendReference) {
95 $this->backendReference
= $backendReference;
99 * Creates the selector for workspaces
101 * @return string workspace selector as HTML select
103 public function render() {
104 $this->addJavascriptToBackend();
105 $cacheMenu = array();
107 $cacheMenu[] = '<a href="#" class="toolbar-item"><img'.t3lib_iconWorks
::skinImg($this->backPath
, 'gfx/lightning.png', 'width="16" height="16"').' title="Clear Cache" alt="" /></a>';
109 $cacheMenu[] = '<ul class="toolbar-item-menu" style="display: none;">';
111 foreach($this->cacheActions
as $actionKey => $cacheAction) {
112 $cacheMenu[] = '<li><a href="'.htmlspecialchars($cacheAction['href']).'">'.$cacheAction['icon'].' '.$cacheAction['title'].'</a></li>';
115 $cacheMenu[] = '</ul>';
117 return implode("\n", $cacheMenu);
121 * adds the neccessary javascript ot the backend
125 private function addJavascriptToBackend() {
126 $this->backendReference
->addJavascriptFile('typo3/js/clearcachemenu.js');
130 * returns additional attributes for the list item in the toolbar
132 * @return string list item HTML attibutes
134 public function getAdditionalAttributes() {
135 return ' id="clear-cache-actions-menu"';
140 if(defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/classes/class.clearcachemenu.php']) {
141 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/classes/class.clearcachemenu.php']);