[BUGFIX] Improvement of LanguageCacheClearer
[Packages/TYPO3.CMS.git] / typo3 / sysext / lang / Classes / LanguageCacheClearer.php
1 <?php
2 namespace TYPO3\CMS\Lang;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2008-2013 Dominique Feyer <dominique.feyer@reelpeek.net>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Class to clear temp files of htmlArea RTE
31 *
32 * @author Dominique Feyer <dominique.feyer@reelpeek.net>
33 */
34 class LanguageCacheClearer {
35
36 /**
37 * @var \TYPO3\CMS\Core\Cache\Frontend\StringFrontend
38 */
39 protected $cacheInstance;
40
41 /**
42 * Constructor
43 */
44 public function __construct() {
45 $this->initializeCache();
46 }
47
48 /**
49 * Initialize cache instance to be ready to use
50 *
51 * @return void
52 */
53 protected function initializeCache() {
54 $this->cacheInstance = $GLOBALS['typo3CacheManager']->getCache('t3lib_l10n');
55 }
56
57 /**
58 * Flush the l10n cache if the clear cache command "all" or "temp_cached" is given.
59 *
60 * @param array $parameters Parameters as defined in DataHandler
61 * @return void
62 */
63 public function clearCache(array $parameters) {
64 $isValidCall = (
65 !empty($parameters['cacheCmd'])
66 && \TYPO3\CMS\Core\Utility\GeneralUtility::inList('all,temp_cached', $parameters['cacheCmd'])
67 );
68
69 if (isset($GLOBALS['BE_USER']) && $isValidCall) {
70 $GLOBALS['BE_USER']->writelog(3, 1, 0, 0, '[lang]: User %s has cleared the language cache', array($GLOBALS['BE_USER']->user['username']));
71 $this->cacheInstance->flush();
72 }
73 }
74
75 }
76
77
78 ?>