TYPO3 API  SVNRelease
class.tx_rtehtmlarea_clearrtecache.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2008-2011 Steffen Kamper <info@sk-typo3.de>
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Class to clear temp files of htmlArea RTE
00029  *
00030  * @author  Steffen kamper <info@sk-typo3.de>
00031  * @package TYPO3
00032  */
00033 class tx_rtehtmlarea_clearrtecache {
00034     public static function clearTempDir() {
00035             // Delete all files in typo3temp/rtehtmlarea
00036         $tempPath = t3lib_div::resolveBackPath(PATH_typo3.'../typo3temp/rtehtmlarea/');
00037         $handle = @opendir($tempPath);
00038         if ($handle !== FALSE) {
00039             while (($file = readdir($handle)) !== FALSE) {
00040                 if ($file != '.' && $file != '..') {
00041                     $tempFile = $tempPath . $file;
00042                     if (is_file($tempFile)) {
00043                         unlink($tempFile);
00044                     }
00045                 }
00046             }
00047             closedir($handle);
00048         }
00049             // Delete all files in typo3temp/compressor with names that start with "htmlarea"
00050         $tempPath = t3lib_div::resolveBackPath(PATH_typo3.'../typo3temp/compressor/');
00051         $handle = @opendir($tempPath);
00052         if ($handle !== FALSE) {
00053             while (($file = readdir($handle)) !== FALSE) {
00054                 if (substr($file, 0, 8) === 'htmlarea') {
00055                     $tempFile = $tempPath . $file;
00056                     if (is_file($tempFile)) {
00057                         unlink($tempFile);
00058                     }
00059                 }
00060             }
00061             closedir($handle);
00062         }
00063             // Log the action
00064         $GLOBALS['BE_USER']->writelog(3, 1, 0, 0, 'htmlArea RTE: User %s has cleared the RTE cache', array($GLOBALS['BE_USER']->user['username']));
00065     }
00066 }
00067 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/hooks/clearrtecache/class.tx_rtehtmlarea_clearrtecache.php'])) {
00068     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/hooks/clearrtecache/class.tx_rtehtmlarea_clearrtecache.php']);
00069 }
00070 ?>