00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 class ClearCacheMenu implements backend_toolbarItem {
00039
00040 protected $cacheActions;
00041
00042
00043
00044
00045
00046
00047 protected $backendReference;
00048
00049
00050
00051
00052
00053
00054 public function __construct(TYPO3backend &$backendReference = null) {
00055 $this->backendReference = $backendReference;
00056 $this->cacheActions = array();
00057
00058
00059 if($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.all')) {
00060 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCacheMenu_all', true);
00061 $this->cacheActions[] = array(
00062 'id' => 'all',
00063 'title' => $title,
00064 'href' => $this->backPath.'tce_db.php?vC='.$GLOBALS['BE_USER']->veriCode().'&cacheCmd=all',
00065 'icon' => '<img'.t3lib_iconWorks::skinImg($this->backPath, 'gfx/lightning_red.png', 'width="16" height="16"').' title="'.$title.'" alt="'.$title.'" />'
00066 );
00067 }
00068
00069
00070 if($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.pages')) {
00071 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCacheMenu_pages', true);
00072 $this->cacheActions[] = array(
00073 'id' => 'pages',
00074 'title' => $title,
00075 'href' => $this->backPath.'tce_db.php?vC='.$GLOBALS['BE_USER']->veriCode().'&cacheCmd=pages',
00076 'icon' => '<img'.t3lib_iconWorks::skinImg($this->backPath, 'gfx/lightning.png', 'width="16" height="16"').' title="'.$title.'" alt="'.$title.'" />'
00077 );
00078 }
00079
00080
00081 if($GLOBALS['BE_USER']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache']) {
00082 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCacheMenu_allTypo3Conf', true);
00083 $this->cacheActions[] = array(
00084 'id' => 'temp_CACHED',
00085 'title' => $title,
00086 'href' => $this->backPath.'tce_db.php?vC='.$GLOBALS['BE_USER']->veriCode().'&cacheCmd=temp_CACHED',
00087 'icon' => '<img'.t3lib_iconWorks::skinImg($this->backPath, 'gfx/lightning_green.png', 'width="16" height="16"').' title="'.$title.'" alt="'.$title.'" />'
00088 );
00089 }
00090
00091 }
00092
00093
00094
00095
00096
00097
00098 public function checkAccess() {
00099 return (
00100 $GLOBALS['BE_USER']->isAdmin()
00101 || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.pages')
00102 || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.all')
00103 );
00104 }
00105
00106
00107
00108
00109
00110
00111 public function render() {
00112 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCache_clearCache', true);
00113 $this->addJavascriptToBackend();
00114 $cacheMenu = array();
00115
00116 $cacheMenu[] = '<a href="#" class="toolbar-item"><img'.t3lib_iconWorks::skinImg($this->backPath, 'gfx/lightning.png', 'width="16" height="16"').' title="'.$title.'" alt="'.$title.'" /></a>';
00117
00118 $cacheMenu[] = '<ul class="toolbar-item-menu" style="display: none;">';
00119
00120 foreach($this->cacheActions as $actionKey => $cacheAction) {
00121 $cacheMenu[] = '<li><a href="'.htmlspecialchars($cacheAction['href']).'">'.$cacheAction['icon'].' '.$cacheAction['title'].'</a></li>';
00122 }
00123
00124 $cacheMenu[] = '</ul>';
00125
00126 return implode("\n", $cacheMenu);
00127 }
00128
00129
00130
00131
00132
00133
00134 protected function addJavascriptToBackend() {
00135 $this->backendReference->addJavascriptFile('js/clearcachemenu.js');
00136 }
00137
00138
00139
00140
00141
00142
00143 public function getAdditionalAttributes() {
00144 return ' id="clear-cache-actions-menu"';
00145 }
00146
00147 }
00148
00149 if(defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/classes/class.clearcachemenu.php']) {
00150 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/classes/class.clearcachemenu.php']);
00151 }
00152
00153 ?>