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:
Erik Amaru Ortiz
2012-05-06 18:51:34 -04:00
parent 12d3787c55
commit 4a025e4382
4 changed files with 81 additions and 88 deletions

View File

@@ -556,34 +556,34 @@ class G
* *
* @return void * @return void
*/ */
function rm_dir($dirName) { function rm_dir($dirName)
if(empty($dirName)) { {
return; if (!is_writable($dirName)) {
return false;
} }
if(file_exists($dirName)) {
$dir = dir($dirName); if (is_dir($dirName)) {
while($file = $dir->read()) { foreach(glob($dirName . '/*') as $file) {
if($file != '.' && $file != '..') { if(is_dir($file)) {
if(is_dir($dirName.'/'.$file)) { G::rm_dir($file);
G::rm_dir($dirName.'/'.$file);
} else { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
@unlink($dirName.'/'.$file) or die('File '.$dirName.'/'.$file.' couldn\'t be deleted!'); 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')
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { exec('DEL /F /S /Q %' . $dirName . '%', $res);
$exit = array(); else
exec('DEL /F /S /Q %'.$dirName.'/'.$file.'%', $exit); rmdir($file);
if (!empty($exit)) die('Folder '.$dirName.'/'.$file.' couldn\'t be deleted!'); }
} else {
else { unlink($dirName);
@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.';
} }
} }

View File

@@ -1,26 +1,30 @@
<?php <?php
try { try {
if ( (isset($_POST['javascriptCache'])) || (isset($_POST['metadataCache'])) || (isset($_POST['htmlCache']))) { 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'])) {
G::rm_dir(PATH_C . 'ExtJs');
$response->javascript = true; $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; $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->smarty = true;
} }
$response->success = true; $response->success = true;
//$response->path = $path; }
}else{ else{
$response->success = false; $response->success = false;
} }
} }
catch ( Exception $e ) { catch (Exception $e) {
$response->success = false; $response->success = false;
$response->message = $e->getMessage();
} }
echo G::json_encode($response); echo G::json_encode($response);

View File

@@ -9,9 +9,10 @@ Ext.onReady(function() {
fieldLabel : 'Terms of Use', fieldLabel : 'Terms of Use',
hideLabel : true, hideLabel : true,
id : 'javascriptCache', id : 'javascriptCache',
style : 'margin-top:15px', boxLabel : _('ID_JAVASCRIPT_CACHE'),
boxLabel : _('ID_JAVASCRIPT_CACHE') listeners : {
check : enableBtn
}
}, },
{ {
xtype : 'checkbox', xtype : 'checkbox',
@@ -19,9 +20,10 @@ Ext.onReady(function() {
fieldLabel : 'Terms of Use', fieldLabel : 'Terms of Use',
hideLabel : true, hideLabel : true,
id : 'metadataCache', id : 'metadataCache',
style : 'margin-top:15px', boxLabel : _('ID_FORMS_METADATA_CACHE'),
boxLabel : _('ID_FORMS_METADATA_CACHE') listeners : {
check : enableBtn
}
}, },
{ {
xtype : 'checkbox', xtype : 'checkbox',
@@ -29,15 +31,17 @@ Ext.onReady(function() {
fieldLabel : 'Terms of Use', fieldLabel : 'Terms of Use',
hideLabel : true, hideLabel : true,
id : 'htmlCache', id : 'htmlCache',
style : 'margin-top:15px', boxLabel : _('ID_FORMS_HTML_CACHE'),
boxLabel : _('ID_FORMS_HTML_CACHE') listeners : {
check : enableBtn
}
} }
], ],
buttons : [{ buttons : [{
id : 'btn_save',
text : _('ID_CLEAR'), text : _('ID_CLEAR'),
handler : clearCache disabled: true,
handler : clearCache
}] }]
}); });
@@ -60,44 +64,45 @@ Ext.onReady(function() {
items : [ cacheFields ] items : [ cacheFields ]
}); });
//render to process-panel
// frm.render('processes-panel');
frm.render(document.body); 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', url : 'clearCompiledAjax',
waitMsg : _('ID_SAVING_PROCESS'), waitMsg : _('ID_SAVING_PROCESS'),
timeout : 36000, timeout : 36000,
success : function(obj, resp) { success : function(obj, resp) {
message = '';
response = Ext.decode(resp.response.responseText); 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) { 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);
} }
}); });
} }

View File

@@ -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>';
?>