BUG 6212 Way to Export Skins 2.0
Implemented a way to export Skins in 2.0
This commit is contained in:
@@ -1247,6 +1247,8 @@ $output = $outputHeader.$output;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 'tar':
|
||||
G::sendHeaders ( $filename , 'application/x-tar', $download, $downloadFileName ); break;
|
||||
default :
|
||||
//throw new Exception ( "Unknown type of file '$file'. " );
|
||||
G::sendHeaders ( $filename , 'application/octet-stream', $download, $downloadFileName ); break;
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
<?php
|
||||
|
||||
if (! isset ( $_REQUEST ['action'] )) {
|
||||
if (!isset($_REQUEST ['action'])) {
|
||||
$res ['success'] = 'failure';
|
||||
$res ['message'] = 'You may request an action';
|
||||
print G::json_encode ( $res);
|
||||
print G::json_encode($res);
|
||||
die ();
|
||||
}
|
||||
if (! function_exists ( $_REQUEST ['action'] )) {
|
||||
if (!function_exists($_REQUEST ['action'])) {
|
||||
$res ['success'] = 'failure';
|
||||
$res ['message'] = 'The requested action doesn\'t exists';
|
||||
print G::json_encode ( $res );
|
||||
print G::json_encode($res);
|
||||
die ();
|
||||
}
|
||||
|
||||
$functionName = $_REQUEST ['action'];
|
||||
$functionParams = isset ( $_REQUEST ['params'] ) ? $_REQUEST ['params'] : array ();
|
||||
$functionParams = isset($_REQUEST ['params']) ? $_REQUEST ['params'] : array();
|
||||
|
||||
$functionName ( $functionParams );
|
||||
$functionName($functionParams);
|
||||
|
||||
function updatePageSize(){
|
||||
function updatePageSize() {
|
||||
G::LoadClass('configuration');
|
||||
$c = new Configurations();
|
||||
$arr['pageSize'] = $_REQUEST['size'];
|
||||
@@ -26,27 +26,119 @@ function updatePageSize(){
|
||||
$config = Array();
|
||||
$config[] = $arr;
|
||||
$c->aConfig = $config;
|
||||
$c->saveConfig('calendarList', 'pageSize','',$_SESSION['USER_LOGGED']);
|
||||
$c->saveConfig('skinsList', 'pageSize', '', $_SESSION['USER_LOGGED']);
|
||||
echo '{success: true}';
|
||||
}
|
||||
function skinList(){
|
||||
|
||||
function skinList() {
|
||||
//Get Skin Config files
|
||||
$skinListArray=array();
|
||||
$customSkins=glob(PATH_CUSTOM_SKINS."*/config.xml");
|
||||
$configurationFile = G::ExpandPath( "skinEngine" ).'base'.PATH_SEP.'config.xml';
|
||||
array_unshift($customSkins,$configurationFile);
|
||||
$skinListArray = array();
|
||||
$customSkins = glob(PATH_CUSTOM_SKINS . "*/config.xml");
|
||||
$configurationFile = G::ExpandPath("skinEngine") . 'base' . PATH_SEP . 'config.xml';
|
||||
array_unshift($customSkins, $configurationFile);
|
||||
|
||||
//Read and parse each Configuration File
|
||||
foreach($customSkins as $key => $configInformation){
|
||||
$xmlConfiguration = file_get_contents ( $configInformation );
|
||||
$xmlConfigurationObj=G::xmlParser($xmlConfiguration);
|
||||
$skinInformationArray=$skinFilesArray=$xmlConfigurationObj->result['skinConfiguration']['__CONTENT__']['information']['__CONTENT__'];
|
||||
foreach ($customSkins as $key => $configInformation) {
|
||||
|
||||
$res=array();
|
||||
foreach($skinInformationArray as $keyInfo => $infoValue){
|
||||
$res['SKIN_'.strtoupper($keyInfo)]=$infoValue['__VALUE__'];
|
||||
$folderId = str_replace(G::ExpandPath("skinEngine") . 'base', "", str_replace(PATH_CUSTOM_SKINS, "", str_replace("/config.xml", "", $configInformation)));
|
||||
if ($folderId == "")
|
||||
$folderId = "classic";
|
||||
$xmlConfiguration = file_get_contents($configInformation);
|
||||
$xmlConfigurationObj = G::xmlParser($xmlConfiguration);
|
||||
$skinInformationArray = $skinFilesArray = $xmlConfigurationObj->result['skinConfiguration']['__CONTENT__']['information']['__CONTENT__'];
|
||||
|
||||
$res = array();
|
||||
$res['SKIN_FOLDER_ID'] = strtolower($folderId);
|
||||
foreach ($skinInformationArray as $keyInfo => $infoValue) {
|
||||
$res['SKIN_' . strtoupper($keyInfo)] = $infoValue['__VALUE__'];
|
||||
}
|
||||
$skinListArray['skins'][]=$res;
|
||||
$skinListArray['skins'][] = $res;
|
||||
}
|
||||
print_r(G::json_encode($skinListArray));
|
||||
}
|
||||
|
||||
function createSkin($baseSkin='classic') {
|
||||
|
||||
}
|
||||
|
||||
function exportSkin($skinToExport) {
|
||||
try {
|
||||
if (!isset($_REQUEST['SKIN_FOLDER_ID'])) {
|
||||
throw ( new Exception(G::LoadTranslation('ID_SKIN_NAME_REUIRED')) );
|
||||
}
|
||||
|
||||
$skinName = $_REQUEST['SKIN_FOLDER_ID'];
|
||||
|
||||
$customSkins = glob(PATH_CUSTOM_SKINS . "*/config.xml");
|
||||
|
||||
$skinFolderBase = PATH_CUSTOM_SKINS . $skinName;
|
||||
$skinFolder = $skinFolderBase . PATH_SEP;
|
||||
$skinTar = PATH_CUSTOM_SKINS . $skinName . '.tar';
|
||||
if (!is_dir($skinFolder)) {
|
||||
throw ( new Exception(G::LoadTranslation('ID_SKIN_DOESNT_EXIST')) );
|
||||
}
|
||||
if (!file_exists($skinFolder . "config.xml")) {
|
||||
throw ( new Exception(G::LoadTranslation('ID_SKIN_CONFIGFILE_DOESNT_EXIST')) );
|
||||
}
|
||||
|
||||
if (file_exists($skinTar)) {
|
||||
//try to delete
|
||||
if (!unlink($skinTar)) {
|
||||
throw ( new Exception(G::LoadTranslation('ID_SKIN_FOLDER_PERMISSIONS')) );
|
||||
}
|
||||
}
|
||||
|
||||
//Try to generate tar file
|
||||
|
||||
G::LoadThirdParty('pear/Archive', 'Tar');
|
||||
$tar = new Archive_Tar($skinTar);
|
||||
$tar->_compress = false;
|
||||
|
||||
addTarFolder($tar, $skinFolder, PATH_CUSTOM_SKINS);
|
||||
// $aFiles = $tar->listContent();
|
||||
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
$response['success'] = true;
|
||||
$response['message'] = $skinTar;
|
||||
|
||||
|
||||
print_r(G::json_encode($response));
|
||||
} catch (Exception $e) {
|
||||
$response['success'] = false;
|
||||
$response['message'] = $e->getMessage();
|
||||
print_r(G::json_encode($response));
|
||||
}
|
||||
}
|
||||
|
||||
function streamSkin() {
|
||||
$skinTar = $_REQUEST['file'];
|
||||
$bDownload = true;
|
||||
G::streamFile($skinTar, $bDownload, basename($skinTar));
|
||||
@unlink($fileTar);
|
||||
}
|
||||
|
||||
function addTarFolder($tar, $pathBase, $pluginHome) {
|
||||
$aux = explode(PATH_SEP, $pathBase);
|
||||
if ($aux[count($aux) - 2] == '.svn')
|
||||
return;
|
||||
|
||||
if ($handle = opendir($pathBase)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (is_file($pathBase . $file)) {
|
||||
//print "file $file \n";
|
||||
$tar->addModify($pathBase . $file, '', $pluginHome);
|
||||
}
|
||||
if (is_dir($pathBase . $file) && $file != '..' && $file != '.') {
|
||||
//print "dir $pathBase$file \n";
|
||||
addTarFolder($tar, $pathBase . $file . PATH_SEP, $pluginHome);
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
//Keyboard Events
|
||||
new Ext.KeyMap(document, [
|
||||
{
|
||||
{
|
||||
key: Ext.EventObject.F5,
|
||||
fn: function(keycode, e) {
|
||||
if (! e.ctrlKey) {
|
||||
@@ -20,9 +20,9 @@ new Ext.KeyMap(document, [
|
||||
Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5');
|
||||
}
|
||||
}
|
||||
}
|
||||
,
|
||||
{
|
||||
}
|
||||
,
|
||||
{
|
||||
key: Ext.EventObject.DELETE,
|
||||
fn: function(k,e){
|
||||
iGrid = Ext.getCmp('infoGrid');
|
||||
@@ -31,8 +31,8 @@ new Ext.KeyMap(document, [
|
||||
DeleteButtonAction();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
},
|
||||
{
|
||||
key: Ext.EventObject.F2,
|
||||
fn: function(k,e){
|
||||
iGrid = Ext.getCmp('infoGrid');
|
||||
@@ -41,8 +41,8 @@ new Ext.KeyMap(document, [
|
||||
EditCalendarAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
]);
|
||||
}
|
||||
]);
|
||||
|
||||
var store;
|
||||
var cmodel;
|
||||
@@ -107,7 +107,7 @@ Ext.onReady(function(){
|
||||
exportButton = new Ext.Action({
|
||||
text: _('ID_EXPORT'),
|
||||
iconCls: 'button_menu_ext ss_sprite ss_basket_go',
|
||||
//handler: CopyButtonAction,
|
||||
handler: exportSkin,
|
||||
disabled: true
|
||||
});
|
||||
searchButton = new Ext.Action({
|
||||
@@ -149,9 +149,12 @@ Ext.onReady(function(){
|
||||
singleSelect: true,
|
||||
listeners:{
|
||||
rowselect: function(sm){
|
||||
//exportButton.enable();
|
||||
exportButton.disable();
|
||||
rowSelected = infoGrid.getSelectionModel().getSelected();
|
||||
if((rowSelected.data.SKIN_FOLDER_ID)&&((rowSelected.data.SKIN_FOLDER_ID!="classic"))){
|
||||
exportButton.enable();
|
||||
}else{
|
||||
exportButton.disable();
|
||||
}
|
||||
},
|
||||
rowdeselect: function(sm){
|
||||
exportButton.disable();
|
||||
@@ -167,13 +170,37 @@ Ext.onReady(function(){
|
||||
root: 'skins',
|
||||
totalProperty: 'total_skins',
|
||||
fields : [
|
||||
{name : 'SKIN_ID'},
|
||||
{name : 'SKIN_NAME'},
|
||||
{name : 'SKIN_DESCRIPTION'},
|
||||
{name : 'SKIN_AUTHOR'},
|
||||
{name : 'SKIN_CREATEDATE'},
|
||||
{name : 'SKIN_MODIFIEDDATE'},
|
||||
{name : 'SKIN_STATUS'}
|
||||
{
|
||||
name : 'SKIN_ID'
|
||||
},
|
||||
|
||||
{
|
||||
name : 'SKIN_FOLDER_ID'
|
||||
},
|
||||
|
||||
{
|
||||
name : 'SKIN_NAME'
|
||||
},
|
||||
|
||||
{
|
||||
name : 'SKIN_DESCRIPTION'
|
||||
},
|
||||
|
||||
{
|
||||
name : 'SKIN_AUTHOR'
|
||||
},
|
||||
|
||||
{
|
||||
name : 'SKIN_CREATEDATE'
|
||||
},
|
||||
|
||||
{
|
||||
name : 'SKIN_MODIFIEDDATE'
|
||||
},
|
||||
|
||||
{
|
||||
name : 'SKIN_STATUS'
|
||||
}
|
||||
]
|
||||
})
|
||||
});
|
||||
@@ -184,12 +211,49 @@ Ext.onReady(function(){
|
||||
sortable: true
|
||||
},
|
||||
columns: [
|
||||
{id:'SKIN_UID', dataIndex: 'SKIN_UID', hidden:true, hideable:false},
|
||||
{header: _('ID_NAME'), dataIndex: 'SKIN_NAME', width: 100, align:'left'},
|
||||
{header: _('ID_DESCRIPTION'), dataIndex: 'SKIN_DESCRIPTION', width: 200, align:'left'},
|
||||
{header: _('ID_OWNER'), dataIndex: 'SKIN_AUTHOR', width: 69, align:'center'},
|
||||
{header: _('ID_CREATE'), dataIndex: 'SKIN_CREATEDATE', width: 69, align:'center', renderer: showdate},
|
||||
{header: _('ID_UPDATE_DATE'), dataIndex: 'SKIN_MODIFIEDDATE', width: 69, align:'center', renderer: showdate}
|
||||
{
|
||||
id:'SKIN_UID',
|
||||
dataIndex: 'SKIN_UID',
|
||||
hidden:true,
|
||||
hideable:false
|
||||
},
|
||||
|
||||
{
|
||||
header: _('ID_NAME'),
|
||||
dataIndex: 'SKIN_NAME',
|
||||
width: 100,
|
||||
align:'left'
|
||||
},
|
||||
|
||||
{
|
||||
header: _('ID_DESCRIPTION'),
|
||||
dataIndex: 'SKIN_DESCRIPTION',
|
||||
width: 200,
|
||||
align:'left'
|
||||
},
|
||||
|
||||
{
|
||||
header: _('ID_OWNER'),
|
||||
dataIndex: 'SKIN_AUTHOR',
|
||||
width: 69,
|
||||
align:'center'
|
||||
},
|
||||
|
||||
{
|
||||
header: _('ID_CREATE'),
|
||||
dataIndex: 'SKIN_CREATEDATE',
|
||||
width: 69,
|
||||
align:'center',
|
||||
renderer: showdate
|
||||
},
|
||||
|
||||
{
|
||||
header: _('ID_UPDATE_DATE'),
|
||||
dataIndex: 'SKIN_MODIFIEDDATE',
|
||||
width: 69,
|
||||
align:'center',
|
||||
renderer: showdate
|
||||
}
|
||||
//{header: _('ID_STATUS'), dataIndex: 'SKIN_STATUS', width: 130, align:'center', renderer: render_status},
|
||||
]
|
||||
});
|
||||
@@ -250,7 +314,9 @@ Ext.onReady(function(){
|
||||
store: store,
|
||||
cm: cmodel,
|
||||
sm: smodel,
|
||||
tbar: [newButton, '-', importButton,exportButton, {xtype: 'tbfill'}, searchText,clearTextButton,searchButton],
|
||||
tbar: [newButton, '-', importButton,exportButton, {
|
||||
xtype: 'tbfill'
|
||||
}, searchText,clearTextButton,searchButton],
|
||||
bbar: bbarpaging,
|
||||
listeners: {
|
||||
rowdblclick: DoNothing
|
||||
@@ -269,7 +335,9 @@ Ext.onReady(function(){
|
||||
this
|
||||
);
|
||||
|
||||
infoGrid.on('contextmenu', function(evt){evt.preventDefault();}, this);
|
||||
infoGrid.on('contextmenu', function(evt){
|
||||
evt.preventDefault();
|
||||
}, this);
|
||||
infoGrid.addListener('rowcontextmenu',onMessageContextMenu, this);
|
||||
infoGrid.store.load();
|
||||
|
||||
@@ -282,6 +350,7 @@ Ext.onReady(function(){
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//Function format dates
|
||||
showdate = function (value){
|
||||
return _DF(value);
|
||||
@@ -297,6 +366,51 @@ onMessageContextMenu = function (grid, rowIndex, e) {
|
||||
//Do Nothing Function
|
||||
DoNothing = function(){};
|
||||
|
||||
exportSkin = function(){
|
||||
viewport.getEl().mask(_('ID_SKIN_EXPORTING'));
|
||||
rowSelected = infoGrid.getSelectionModel().getSelected();
|
||||
if((rowSelected.data.SKIN_FOLDER_ID)&&((rowSelected.data.SKIN_FOLDER_ID!="classic"))){
|
||||
Ext.Ajax.request({
|
||||
url: 'skin_Ajax',
|
||||
params: {
|
||||
action: 'exportSkin',
|
||||
SKIN_FOLDER_ID: rowSelected.data.SKIN_FOLDER_ID
|
||||
},
|
||||
success: function(r,o){
|
||||
viewport.getEl().unmask();
|
||||
var resp = Ext.util.JSON.decode(r.responseText);
|
||||
if (resp.success){
|
||||
try {
|
||||
Ext.destroy(Ext.get('downloadIframe'));
|
||||
}
|
||||
catch(e) {}
|
||||
Ext.DomHelper.append(document.body, {
|
||||
tag: 'iframe',
|
||||
id:'downloadIframe',
|
||||
frameBorder: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
css: 'display:none;visibility:hidden;height:0px;',
|
||||
src: 'skin_Ajax?action=streamSkin&file='+resp.message
|
||||
});
|
||||
viewport.getEl().unmask();
|
||||
}else{
|
||||
viewport.getEl().unmask();
|
||||
Ext.Msg.alert('Alert', resp.message);
|
||||
//PMExt.error(_('ID_SKINS'),_('ID_MSG_CANNOT_EXPORT_SKIN'));
|
||||
}
|
||||
},
|
||||
failure: function(r,o){
|
||||
viewport.getEl().unmask();
|
||||
PMExt.error(_('ID_SKINS'),_('ID_MSG_CANNOT_EXPORT_SKIN'));
|
||||
}
|
||||
});
|
||||
}else{
|
||||
PMExt.error(_('ID_SKINS'),_('ID_MSG_CANNOT_EXPORT_DEFAULT_SKIN'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Open New Calendar
|
||||
NewCalendarAction = function(){
|
||||
location.href = 'calendarEdit';
|
||||
@@ -310,7 +424,11 @@ GridByDefault = function(){
|
||||
|
||||
//Do Search Function
|
||||
DoSearch = function(){
|
||||
infoGrid.store.load({params: {textFilter: searchText.getValue()}});
|
||||
infoGrid.store.load({
|
||||
params: {
|
||||
textFilter: searchText.getValue()
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//Edit Calendar Action
|
||||
@@ -327,7 +445,10 @@ DeleteButtonAction = function(){
|
||||
viewport.getEl().mask(_('ID_PROCESSING'));
|
||||
Ext.Ajax.request({
|
||||
url: 'calendar_Ajax',
|
||||
params: {action: 'canDeleteCalendar', CAL_UID: rowSelected.data.CALENDAR_UID},
|
||||
params: {
|
||||
action: 'canDeleteCalendar',
|
||||
CAL_UID: rowSelected.data.CALENDAR_UID
|
||||
},
|
||||
success: function(r,o){
|
||||
viewport.getEl().unmask();
|
||||
var resp = Ext.util.JSON.decode(r.responseText);
|
||||
@@ -338,7 +459,10 @@ DeleteButtonAction = function(){
|
||||
viewport.getEl().mask(_('ID_PROCESSING'));
|
||||
Ext.Ajax.request({
|
||||
url: 'calendar_Ajax',
|
||||
params: {action: 'deleteCalendar', CAL_UID: rowSelected.data.CALENDAR_UID},
|
||||
params: {
|
||||
action: 'deleteCalendar',
|
||||
CAL_UID: rowSelected.data.CALENDAR_UID
|
||||
},
|
||||
success: function(r,o){
|
||||
viewport.getEl().unmask();
|
||||
editButton.disable();
|
||||
@@ -367,9 +491,17 @@ DeleteButtonAction = function(){
|
||||
//Render Status
|
||||
render_status = function(v){
|
||||
switch(v){
|
||||
case 'ACTIVE': return '<font color="green">' + _('ID_ACTIVE') + '</font>'; break;
|
||||
case 'INACTIVE': return '<font color="red">' + _('ID_INACTIVE') + '</font>';; break;
|
||||
case 'VACATION': return '<font color="blue">' + _('ID_VACATION') + '</font>';; break;
|
||||
case 'ACTIVE':
|
||||
return '<font color="green">' + _('ID_ACTIVE') + '</font>';
|
||||
break;
|
||||
case 'INACTIVE':
|
||||
return '<font color="red">' + _('ID_INACTIVE') + '</font>';
|
||||
;
|
||||
break;
|
||||
case 'VACATION':
|
||||
return '<font color="blue">' + _('ID_VACATION') + '</font>';
|
||||
;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -385,6 +517,9 @@ CopyButtonAction = function(){
|
||||
UpdatePageConfig = function(pageSize){
|
||||
Ext.Ajax.request({
|
||||
url: 'calendar_Ajax',
|
||||
params: {action:'updatePageSize', size: pageSize}
|
||||
params: {
|
||||
action:'updatePageSize',
|
||||
size: pageSize
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user