mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-13 13:11:31 +00:00
put ClearCache into controller, add hooks when clearing the cache
This commit is contained in:
parent
eebc1de5aa
commit
991268a18b
51
controllers/class.ClearCache.php
Normal file
51
controllers/class.ClearCache.php
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Implementation of ClearCache controller
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @license GPL 2
|
||||||
|
* @version @version@
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class which does the busines logic for clearing the cache
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
class SeedDMS_Controller_ClearCache extends SeedDMS_Controller_Common {
|
||||||
|
|
||||||
|
public function run() {
|
||||||
|
$dms = $this->params['dms'];
|
||||||
|
$user = $this->params['user'];
|
||||||
|
$settings = $this->params['settings'];
|
||||||
|
$post = $this->params['post'];
|
||||||
|
|
||||||
|
$ret = '';
|
||||||
|
if(!empty($post['preview'])) {
|
||||||
|
$cmd = 'rm -rf '.$settings->_cacheDir.'/[1-9]*';
|
||||||
|
system($cmd, $ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($post['js'])) {
|
||||||
|
$cmd = 'rm -rf '.$settings->_cacheDir.'/js/*';
|
||||||
|
system($cmd, $ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(false === $this->callHook('clear', $post)) {
|
||||||
|
if(empty($this->errormsg))
|
||||||
|
$this->errormsg = 'hook_clear_failed';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -24,8 +24,12 @@ include("../inc/inc.Init.php");
|
||||||
include("../inc/inc.Extension.php");
|
include("../inc/inc.Extension.php");
|
||||||
include("../inc/inc.DBInit.php");
|
include("../inc/inc.DBInit.php");
|
||||||
include("../inc/inc.ClassUI.php");
|
include("../inc/inc.ClassUI.php");
|
||||||
|
include("../inc/inc.ClassController.php");
|
||||||
include("../inc/inc.Authentication.php");
|
include("../inc/inc.Authentication.php");
|
||||||
|
|
||||||
|
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||||
|
$controller = Controller::factory($tmp[1], array('dms'=>$dms, 'user'=>$user));
|
||||||
|
|
||||||
/* Check if the form data comes from a trusted request */
|
/* Check if the form data comes from a trusted request */
|
||||||
if(!checkFormKey('clearcache')) {
|
if(!checkFormKey('clearcache')) {
|
||||||
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
|
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
|
||||||
|
@ -38,19 +42,8 @@ if(!is_dir($settings->_cacheDir)) {
|
||||||
UI::exitError(getMLText("admin_tools"),getMLText("error_cleared_cache"));
|
UI::exitError(getMLText("admin_tools"),getMLText("error_cleared_cache"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($_POST['preview'])) {
|
$controller->setParam('post', $_POST);
|
||||||
$cmd = 'rm -rf '.$settings->_cacheDir.'/[1-9]*';
|
if(!$controller->run())
|
||||||
$ret = null;
|
|
||||||
system($cmd, $ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!empty($_POST['js'])) {
|
|
||||||
$cmd = 'rm -rf '.$settings->_cacheDir.'/js/*';
|
|
||||||
$ret = null;
|
|
||||||
system($cmd, $ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($ret)
|
|
||||||
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('error_cleared_cache')));
|
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('error_cleared_cache')));
|
||||||
else
|
else
|
||||||
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_cleared_cache')));
|
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_cleared_cache')));
|
||||||
|
|
|
@ -54,6 +54,13 @@ class SeedDMS_View_ClearCache extends SeedDMS_Bootstrap_Style {
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<input type="checkbox" name="js" value="1" checked> <?php printMLText('temp_jscode'); ?>
|
<input type="checkbox" name="js" value="1" checked> <?php printMLText('temp_jscode'); ?>
|
||||||
|
<?php
|
||||||
|
$addcache = array();
|
||||||
|
if($addcache = $this->callHook('additionalCache', $addcache)) {
|
||||||
|
foreach($addcache as $c)
|
||||||
|
echo "<p><input type=\"checkbox\" name=\"".$c[0]."\" value=\"1\" checked> ".$c[1]."</p>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
<p><button type="submit" class="btn"><i class="icon-remove"></i> <?php printMLText("clear_cache");?></button></p>
|
<p><button type="submit" class="btn"><i class="icon-remove"></i> <?php printMLText("clear_cache");?></button></p>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
|
|
Loading…
Reference in New Issue
Block a user