BUG 8856 "Migrate the Clear cache Interface from master branch" UPDATE 1
- problem found on G::rm_dir() - fixed problem & WIN compatibility fixed too
This commit is contained in:
@@ -556,34 +556,34 @@ class G
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rm_dir($dirName) {
|
||||
if(empty($dirName)) {
|
||||
return;
|
||||
function rm_dir($dirName)
|
||||
{
|
||||
if (!is_writable($dirName)) {
|
||||
return false;
|
||||
}
|
||||
if(file_exists($dirName)) {
|
||||
$dir = dir($dirName);
|
||||
while($file = $dir->read()) {
|
||||
if($file != '.' && $file != '..') {
|
||||
if(is_dir($dirName.'/'.$file)) {
|
||||
G::rm_dir($dirName.'/'.$file);
|
||||
} else {
|
||||
@unlink($dirName.'/'.$file) or die('File '.$dirName.'/'.$file.' couldn\'t be deleted!');
|
||||
}
|
||||
|
||||
if (is_dir($dirName)) {
|
||||
foreach(glob($dirName . '/*') as $file) {
|
||||
if(is_dir($file)) {
|
||||
G::rm_dir($file);
|
||||
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
|
||||
exec('DEL /F /S /Q %' . $dirName . '%', $res);
|
||||
else
|
||||
rmdir($file);
|
||||
}
|
||||
else {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
$folder = opendir($dirName. PATH_SEP .$file);
|
||||
closedir($folder);
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
$exit = array();
|
||||
exec('DEL /F /S /Q %'.$dirName.'/'.$file.'%', $exit);
|
||||
if (!empty($exit)) die('Folder '.$dirName.'/'.$file.' couldn\'t be deleted!');
|
||||
}
|
||||
else {
|
||||
@rmdir($dirName.'/'.$file) or die('Folder '.$dirName.'/'.$file.' couldn\'t be deleted!');
|
||||
}
|
||||
@rmdir($dirName.'/'.$file) or die('Folder '.$dirName.'/'.$file.' couldn\'t be deleted!');
|
||||
} else {
|
||||
echo 'Folder "<b>'.$dirName.'</b>" doesn\'t exist.';
|
||||
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
|
||||
exec('DEL /F /S /Q %' . $dirName . '%', $res);
|
||||
else
|
||||
rmdir($file);
|
||||
}
|
||||
else {
|
||||
unlink($dirName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
<?php
|
||||
try {
|
||||
if ( (isset($_POST['javascriptCache'])) || (isset($_POST['metadataCache'])) || (isset($_POST['htmlCache']))) {
|
||||
if ((isset($_POST['javascriptCache'])) && (@chdir(PATH_C.'/ExtJs/'))) {
|
||||
G::rm_dir(PATH_C.'/ExtJs/');
|
||||
if (isset($_POST['javascriptCache']) || isset($_POST['metadataCache']) || isset($_POST['htmlCache'])) {
|
||||
|
||||
if (isset($_POST['javascriptCache'])) {
|
||||
G::rm_dir(PATH_C . 'ExtJs');
|
||||
$response->javascript = true;
|
||||
}
|
||||
if ((isset($_POST['metadataCache'])) && (@chdir(PATH_C.'/xmlform/'))) {
|
||||
G::rm_dir(PATH_C.'/xmlform/');
|
||||
|
||||
if (isset($_POST['metadataCache'])) {
|
||||
G::rm_dir(PATH_C . 'xmlform');
|
||||
$response->xmlform = true;
|
||||
}
|
||||
if((isset($_POST['htmlCache'])) && (@chdir(PATH_C.'/smarty/'))) {
|
||||
G::rm_dir(PATH_C.'/smarty/');
|
||||
|
||||
if (isset($_POST['htmlCache'])) {
|
||||
G::rm_dir(PATH_C . 'smarty');
|
||||
$response->smarty = true;
|
||||
}
|
||||
|
||||
$response->success = true;
|
||||
//$response->path = $path;
|
||||
}else{
|
||||
}
|
||||
else{
|
||||
$response->success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( Exception $e ) {
|
||||
catch (Exception $e) {
|
||||
$response->success = false;
|
||||
$response->message = $e->getMessage();
|
||||
}
|
||||
echo G::json_encode($response);
|
||||
|
||||
@@ -9,9 +9,10 @@ Ext.onReady(function() {
|
||||
fieldLabel : 'Terms of Use',
|
||||
hideLabel : true,
|
||||
id : 'javascriptCache',
|
||||
style : 'margin-top:15px',
|
||||
boxLabel : _('ID_JAVASCRIPT_CACHE')
|
||||
|
||||
boxLabel : _('ID_JAVASCRIPT_CACHE'),
|
||||
listeners : {
|
||||
check : enableBtn
|
||||
}
|
||||
},
|
||||
{
|
||||
xtype : 'checkbox',
|
||||
@@ -19,9 +20,10 @@ Ext.onReady(function() {
|
||||
fieldLabel : 'Terms of Use',
|
||||
hideLabel : true,
|
||||
id : 'metadataCache',
|
||||
style : 'margin-top:15px',
|
||||
boxLabel : _('ID_FORMS_METADATA_CACHE')
|
||||
|
||||
boxLabel : _('ID_FORMS_METADATA_CACHE'),
|
||||
listeners : {
|
||||
check : enableBtn
|
||||
}
|
||||
},
|
||||
{
|
||||
xtype : 'checkbox',
|
||||
@@ -29,15 +31,17 @@ Ext.onReady(function() {
|
||||
fieldLabel : 'Terms of Use',
|
||||
hideLabel : true,
|
||||
id : 'htmlCache',
|
||||
style : 'margin-top:15px',
|
||||
boxLabel : _('ID_FORMS_HTML_CACHE')
|
||||
|
||||
boxLabel : _('ID_FORMS_HTML_CACHE'),
|
||||
listeners : {
|
||||
check : enableBtn
|
||||
}
|
||||
}
|
||||
|
||||
],
|
||||
buttons : [{
|
||||
id : 'btn_save',
|
||||
text : _('ID_CLEAR'),
|
||||
handler : clearCache
|
||||
disabled: true,
|
||||
handler : clearCache
|
||||
}]
|
||||
});
|
||||
|
||||
@@ -60,44 +64,45 @@ Ext.onReady(function() {
|
||||
items : [ cacheFields ]
|
||||
|
||||
});
|
||||
//render to process-panel
|
||||
// frm.render('processes-panel');
|
||||
|
||||
frm.render(document.body);
|
||||
});
|
||||
|
||||
function clearCache () {
|
||||
function enableBtn() {
|
||||
Ext.getCmp('btn_save').enable();
|
||||
}
|
||||
|
||||
Ext.getCmp('frmCache').getForm().submit( {
|
||||
function clearCache () {
|
||||
Ext.getCmp('frmCache').getForm().submit({
|
||||
url : 'clearCompiledAjax',
|
||||
waitMsg : _('ID_SAVING_PROCESS'),
|
||||
timeout : 36000,
|
||||
success : function(obj, resp) {
|
||||
message = '';
|
||||
response = Ext.decode(resp.response.responseText);
|
||||
if (response.javascript) {
|
||||
var message1 = _('ID_JAVASCRIPT_CACHE') + '<br />';
|
||||
}
|
||||
else {
|
||||
var message1 = '';
|
||||
}
|
||||
if (response.xmlform) {
|
||||
var message2 = _('ID_FORMS_METADATA_CACHE') + '<br />';
|
||||
}
|
||||
else {
|
||||
var message2 = '';
|
||||
}
|
||||
if (response.smarty) {
|
||||
var message3 = _('ID_FORMS_HTML_CACHE') + '<br />';
|
||||
}
|
||||
else {
|
||||
var message3 = '';
|
||||
}
|
||||
|
||||
parent.PMExt.notify(_('ID_CLEAR_CACHE'), message1 + message2 + message3 + _('ID_HAS_BEEN_DELETED'));
|
||||
if (response.javascript) {
|
||||
message += _('ID_JAVASCRIPT_CACHE') + '<br />';
|
||||
}
|
||||
|
||||
if (response.xmlform) {
|
||||
message += _('ID_FORMS_METADATA_CACHE') + '<br />';
|
||||
}
|
||||
|
||||
if (response.smarty) {
|
||||
message += _('ID_FORMS_HTML_CACHE') + '<br />';
|
||||
}
|
||||
|
||||
PMExt.notify(_('ID_CLEAR_CACHE'), message + _('ID_HAS_BEEN_DELETED'));
|
||||
|
||||
setTimeout(function() {
|
||||
window.location.href = window.location.href;
|
||||
}, 1500);
|
||||
},
|
||||
failure : function(obj, resp) {
|
||||
Ext.Msg.alert( _('ID_ERROR'), _('ID_SELECT_ONE_OPTION'));
|
||||
if (typeof resp.response.responseText != 'undefined')
|
||||
PMExt.error(_('ID_ERROR'), resp.response.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
echo '<div class="grid" style="width:80%">
|
||||
<div class="boxTop"><div class="a"></div><div class="b"></div><div class="c"></div></div>
|
||||
<div class="content" style="">
|
||||
<table >
|
||||
<tbody><tr>
|
||||
<td valign="top">
|
||||
<span class="treeNode">'.G::LoadTranslation('ID_CLEAR_CACHE_MSG2').' ('.PATH_C .')</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</div>
|
||||
<div class="boxBottom"><div class="a"></div><div class="b"></div><div class="c"></div></div>
|
||||
</div>';
|
||||
?>
|
||||
Reference in New Issue
Block a user