2011-02-28 16:08:15 +00:00
|
|
|
<?php
|
2012-10-17 17:21:35 -04:00
|
|
|
if (! isset( $_REQUEST['action'] )) {
|
|
|
|
|
$res['success'] = false;
|
2013-03-14 15:15:04 -04:00
|
|
|
$res['error'] = $res['message'] = G::LoadTranslation('ID_REQUEST_ACTION');
|
2011-07-26 12:34:16 -04:00
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
print G::json_encode( $res );
|
|
|
|
|
die();
|
2011-02-28 16:08:15 +00:00
|
|
|
}
|
2014-05-07 16:49:51 -04:00
|
|
|
if (! function_exists( $_REQUEST['action'] ) || !G::isUserFunction($_REQUEST['action'])) {
|
2012-10-17 17:21:35 -04:00
|
|
|
$res['success'] = false;
|
2013-03-14 15:15:04 -04:00
|
|
|
$res['error'] = $res['message'] = G::LoadTranslation('ID_REQUEST_ACTION_NOT_EXIST');
|
2011-07-26 12:34:16 -04:00
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
print G::json_encode( $res );
|
|
|
|
|
die();
|
2011-02-28 16:08:15 +00:00
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
$restrictedFunctions = array ('copy_skin_folder','addTarFolder'
|
|
|
|
|
);
|
|
|
|
|
if (in_array( $_REQUEST['action'], $restrictedFunctions )) {
|
|
|
|
|
$res['success'] = false;
|
2013-03-14 15:15:04 -04:00
|
|
|
$res['error'] = $res['message'] = G::LoadTranslation('ID_REQUEST_ACTION_NOT_EXIST');
|
2012-10-17 17:21:35 -04:00
|
|
|
print G::json_encode( $res );
|
|
|
|
|
die();
|
2011-07-26 12:34:16 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
$functionName = $_REQUEST['action'];
|
|
|
|
|
$functionParams = isset( $_REQUEST['params'] ) ? $_REQUEST['params'] : array ();
|
2011-07-20 17:15:47 -04:00
|
|
|
|
2011-07-26 12:34:16 -04:00
|
|
|
$functionName();
|
2011-07-20 17:15:47 -04:00
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
function updatePageSize ()
|
2012-07-06 11:22:39 -04:00
|
|
|
{
|
2012-10-17 17:21:35 -04:00
|
|
|
G::LoadClass( 'configuration' );
|
2012-07-06 11:22:39 -04:00
|
|
|
$c = new Configurations();
|
|
|
|
|
$arr['pageSize'] = $_REQUEST['size'];
|
2012-10-17 17:21:35 -04:00
|
|
|
$arr['dateSave'] = date( 'Y-m-d H:i:s' );
|
|
|
|
|
$config = Array ();
|
2012-07-06 11:22:39 -04:00
|
|
|
$config[] = $arr;
|
|
|
|
|
$c->aConfig = $config;
|
2012-10-17 17:21:35 -04:00
|
|
|
$c->saveConfig( 'skinsList', 'pageSize', '', $_SESSION['USER_LOGGED'] );
|
2012-07-06 11:22:39 -04:00
|
|
|
echo '{success: true}';
|
2011-07-20 17:15:47 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
function skinList ()
|
2012-07-06 11:22:39 -04:00
|
|
|
{
|
2012-10-17 17:21:35 -04:00
|
|
|
G::loadClass( 'system' );
|
2011-08-09 11:51:25 -04:00
|
|
|
|
2012-07-20 16:03:39 -04:00
|
|
|
$skinList = System::getSkingList();
|
2012-10-04 11:44:15 -04:00
|
|
|
$wildcard = '';
|
2012-10-17 17:21:35 -04:00
|
|
|
if (isset( $_REQUEST['activeskin'] )) {
|
2012-10-04 11:44:15 -04:00
|
|
|
$wildcard = '@';
|
|
|
|
|
}
|
2013-04-24 10:40:51 -04:00
|
|
|
|
2013-05-28 22:04:49 -04:00
|
|
|
$filterList = array();
|
2013-04-19 19:30:41 +00:00
|
|
|
if (defined('PARTNER_FLAG')) {
|
2013-05-28 22:04:49 -04:00
|
|
|
$filterList = array(
|
|
|
|
|
'00000000000000000000000000000001',
|
|
|
|
|
'00000000000000000000000000000002'
|
|
|
|
|
);
|
2013-04-19 19:30:41 +00:00
|
|
|
}
|
2013-04-24 10:40:51 -04:00
|
|
|
|
2012-07-20 16:03:39 -04:00
|
|
|
foreach ($skinList['skins'] as $key => $value) {
|
2013-05-28 22:04:49 -04:00
|
|
|
if (! isset($value['SKIN_ID']) || ! in_array($value['SKIN_ID'], $filterList)) {
|
2013-04-19 19:30:41 +00:00
|
|
|
if ($value['SKIN_FOLDER_ID'] != 'simplified' && $value['SKIN_FOLDER_ID'] != 'uxs' && $value['SKIN_FOLDER_ID'] != 'uxmodern') {
|
|
|
|
|
if ($skinList['currentSkin'] == $value['SKIN_FOLDER_ID']) {
|
|
|
|
|
$value['SKIN_STATUS'] = $wildcard . G::LoadTranslation( 'ID_ACTIVE' );
|
|
|
|
|
$value['SKIN_NAME'] = $wildcard . $value['SKIN_NAME'];
|
|
|
|
|
$value['SKIN_WORKSPACE'] = $wildcard . $value['SKIN_WORKSPACE'];
|
|
|
|
|
$value['SKIN_DESCRIPTION'] = $wildcard . $value['SKIN_DESCRIPTION'];
|
|
|
|
|
$value['SKIN_AUTHOR'] = $wildcard . $value['SKIN_AUTHOR'];
|
|
|
|
|
$value['SKIN_CREATEDATE'] = $wildcard . $value['SKIN_CREATEDATE'];
|
|
|
|
|
$value['SKIN_MODIFIEDDATE'] = $wildcard . $value['SKIN_MODIFIEDDATE'];
|
|
|
|
|
} else {
|
|
|
|
|
$value['SKIN_STATUS'] = G::LoadTranslation( 'ID_INACTIVE' );
|
|
|
|
|
}
|
2013-04-26 13:15:36 -04:00
|
|
|
|
2013-04-19 19:30:41 +00:00
|
|
|
$skinListArray['skins'][] = $value;
|
2012-10-03 20:09:06 -04:00
|
|
|
}
|
2012-07-20 16:03:39 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$skinListArray['currentSkin'] = $skinList['currentSkin'];
|
2012-10-17 17:21:35 -04:00
|
|
|
echo G::json_encode( $skinListArray );
|
2011-07-20 17:15:47 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
function newSkin ($baseSkin = 'classic')
|
2012-07-06 11:22:39 -04:00
|
|
|
{
|
2012-10-17 17:21:35 -04:00
|
|
|
$skinBase = $baseSkin != "" ? strtolower( $baseSkin ) : 'classic';
|
|
|
|
|
if ((isset( $_REQUEST['skinBase'] )) && ($_REQUEST['skinBase'] != "")) {
|
|
|
|
|
$skinBase = strtolower( $_REQUEST['skinBase'] );
|
2011-07-26 12:34:16 -04:00
|
|
|
}
|
|
|
|
|
|
2012-07-06 11:22:39 -04:00
|
|
|
try {
|
2012-10-17 17:21:35 -04:00
|
|
|
if (! (isset( $_REQUEST['skinName'] ))) {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_NAME_REQUIRED' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
if (! (isset( $_REQUEST['skinFolder'] ))) {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_FOLDER_REQUIRED' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
|
|
|
|
//Should validate skin folder name here
|
|
|
|
|
//if....
|
2011-07-26 12:34:16 -04:00
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
|
2012-07-06 11:22:39 -04:00
|
|
|
$skinName = $_REQUEST['skinName'];
|
|
|
|
|
$skinFolder = $_REQUEST['skinFolder'];
|
2012-10-17 17:21:35 -04:00
|
|
|
$skinDescription = isset( $_REQUEST['skinDescription'] ) ? $_REQUEST['skinDescription'] : '';
|
|
|
|
|
$skinAuthor = isset( $_REQUEST['skinAuthor'] ) ? $_REQUEST['skinAuthor'] : 'ProcessMaker Team';
|
2011-07-26 12:34:16 -04:00
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
if (is_dir( PATH_CUSTOM_SKINS . $skinFolder )) {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_ALREADY_EXISTS' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
if (strtolower( $skinFolder ) == 'classic') {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_ALREADY_EXISTS' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2011-07-26 12:34:16 -04:00
|
|
|
|
2012-07-06 11:22:39 -04:00
|
|
|
//All validations OK then create skin
|
|
|
|
|
switch ($skinBase) {
|
|
|
|
|
//Validate skin base
|
|
|
|
|
case 'uxmodern':
|
2012-10-17 17:21:35 -04:00
|
|
|
copy_skin_folder( G::ExpandPath( "skinEngine" ) . 'uxmodern' . PATH_SEP, PATH_CUSTOM_SKINS . $skinFolder, array ("config.xml"
|
|
|
|
|
) );
|
|
|
|
|
$pathBase = G::ExpandPath( "skinEngine" ) . 'base' . PATH_SEP;
|
2012-07-06 11:22:39 -04:00
|
|
|
break;
|
|
|
|
|
case 'classic':
|
|
|
|
|
//Special Copy of this dir + xmlreplace
|
2012-10-17 17:21:35 -04:00
|
|
|
copy_skin_folder( G::ExpandPath( "skinEngine" ) . 'base' . PATH_SEP, PATH_CUSTOM_SKINS . $skinFolder, array ("config.xml","baseCss"
|
|
|
|
|
) );
|
|
|
|
|
$pathBase = G::ExpandPath( "skinEngine" ) . 'base' . PATH_SEP;
|
2012-07-06 11:22:39 -04:00
|
|
|
break;
|
2013-05-09 13:46:23 -04:00
|
|
|
case 'neoclassic':
|
|
|
|
|
//Special Copy of this dir + xmlreplace
|
|
|
|
|
copy_skin_folder( G::ExpandPath( "skinEngine" ) . 'neoclassic' . PATH_SEP, PATH_CUSTOM_SKINS . $skinFolder, array ("config.xml","baseCss"
|
|
|
|
|
) );
|
|
|
|
|
$pathBase = G::ExpandPath( "skinEngine" ) . 'neoclassic' . PATH_SEP;
|
|
|
|
|
break;
|
2012-07-06 11:22:39 -04:00
|
|
|
default:
|
|
|
|
|
//Commmon copy/paste of a folder + xmlrepalce
|
2012-10-17 17:21:35 -04:00
|
|
|
copy_skin_folder( PATH_CUSTOM_SKINS . $skinBase, PATH_CUSTOM_SKINS . $skinFolder, array ("config.xml"
|
|
|
|
|
) );
|
2013-04-10 14:35:27 -04:00
|
|
|
$pathBase = PATH_CUSTOM_SKINS . $skinBase . PATH_SEP;
|
2012-07-06 11:22:39 -04:00
|
|
|
break;
|
|
|
|
|
}
|
2013-04-10 14:35:27 -04:00
|
|
|
|
2012-07-06 11:22:39 -04:00
|
|
|
//ReBuild config file
|
|
|
|
|
//TODO: Improve this pre_replace lines
|
2013-04-10 14:35:27 -04:00
|
|
|
$configFileOriginal = $pathBase . "config.xml";
|
2012-07-06 11:22:39 -04:00
|
|
|
$configFileFinal = PATH_CUSTOM_SKINS . $skinFolder . PATH_SEP . 'config.xml';
|
2013-04-26 13:15:36 -04:00
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
$xmlConfiguration = file_get_contents( $configFileOriginal );
|
2012-10-26 17:46:16 -04:00
|
|
|
|
|
|
|
|
$workspace = ($_REQUEST['workspace'] == 'global') ? '' : SYS_SYS;
|
2013-04-10 14:35:27 -04:00
|
|
|
|
|
|
|
|
$xmlConfigurationObj = G::xmlParser($xmlConfiguration);
|
|
|
|
|
$skinInformationArray = $xmlConfigurationObj->result["skinConfiguration"]["__CONTENT__"]["information"]["__CONTENT__"];
|
|
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
$xmlConfiguration = preg_replace( '/(<id>)(.+?)(<\/id>)/i', '<id>' . G::generateUniqueID() . '</id><!-- $2 -->', $xmlConfiguration );
|
2013-04-10 14:35:27 -04:00
|
|
|
|
2013-04-26 13:15:36 -04:00
|
|
|
if (isset($skinInformationArray["workspace"]["__VALUE__"])) {
|
|
|
|
|
$workspace = ($workspace != "" && !empty($skinInformationArray["workspace"]["__VALUE__"]))? $skinInformationArray["workspace"]["__VALUE__"] . "|" . $workspace : $workspace;
|
2013-04-10 14:35:27 -04:00
|
|
|
|
|
|
|
|
$xmlConfiguration = preg_replace("/(<workspace>)(.*)(<\/workspace>)/i", "<workspace>" . $workspace . "</workspace><!-- $2 -->", $xmlConfiguration);
|
|
|
|
|
$xmlConfiguration = preg_replace("/(<name>)(.*)(<\/name>)/i", "<name>" . $skinName . "</name><!-- $2 -->", $xmlConfiguration);
|
2012-10-26 17:46:16 -04:00
|
|
|
} else {
|
2013-04-10 14:35:27 -04:00
|
|
|
$xmlConfiguration = preg_replace("/(<name>)(.*)(<\/name>)/i", "<name>" . $skinName . "</name><!-- $2 -->\n<workspace>" . $workspace . "</workspace>", $xmlConfiguration);
|
2012-10-26 17:46:16 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
$xmlConfiguration = preg_replace( "/(<description>)(.+?)(<\/description>)/i", "<description>" . $skinDescription . "</description><!-- $2 -->", $xmlConfiguration );
|
|
|
|
|
$xmlConfiguration = preg_replace( "/(<author>)(.+?)(<\/author>)/i", "<author>" . $skinAuthor . "</author><!-- $2 -->", $xmlConfiguration );
|
|
|
|
|
$xmlConfiguration = preg_replace( "/(<createDate>)(.+?)(<\/createDate>)/i", "<createDate>" . date( "Y-m-d H:i:s" ) . "</createDate><!-- $2 -->", $xmlConfiguration );
|
|
|
|
|
$xmlConfiguration = preg_replace( "/(<modifiedDate>)(.+?)(<\/modifiedDate>)/i", "<modifiedDate>" . date( "Y-m-d H:i:s" ) . "</modifiedDate><!-- $2 -->", $xmlConfiguration );
|
2012-07-06 11:22:39 -04:00
|
|
|
|
2012-10-26 17:46:16 -04:00
|
|
|
file_put_contents( $configFileFinal, $xmlConfiguration );
|
2012-07-06 11:22:39 -04:00
|
|
|
$response['success'] = true;
|
2012-10-17 17:21:35 -04:00
|
|
|
$response['message'] = G::LoadTranslation( 'ID_SKIN_SUCCESS_CREATE' );
|
|
|
|
|
print_r( G::json_encode( $response ) );
|
2012-07-06 11:22:39 -04:00
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$response['success'] = false;
|
|
|
|
|
$response['message'] = $e->getMessage();
|
|
|
|
|
$response['error'] = $e->getMessage();
|
2012-10-17 17:21:35 -04:00
|
|
|
print_r( G::json_encode( $response ) );
|
2011-07-26 12:34:16 -04:00
|
|
|
}
|
2011-07-20 17:15:47 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
function importSkin ()
|
2012-07-06 11:22:39 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2012-10-17 17:21:35 -04:00
|
|
|
if (! isset( $_FILES['uploadedFile'] )) {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_FILE_REQUIRED' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
$uploadedInstances = count( $_FILES['uploadedFile']['name'] );
|
2012-07-06 11:22:39 -04:00
|
|
|
$sw_error = false;
|
2012-10-17 17:21:35 -04:00
|
|
|
$sw_error_exists = isset( $_FILES['uploadedFile']['error'] );
|
2012-07-06 11:22:39 -04:00
|
|
|
$emptyInstances = 0;
|
2012-10-17 17:21:35 -04:00
|
|
|
$quequeUpload = array ();
|
2012-07-06 11:22:39 -04:00
|
|
|
|
|
|
|
|
// upload files & check for errors
|
|
|
|
|
$tmp = $_FILES['uploadedFile']['tmp_name'];
|
2012-10-17 17:21:35 -04:00
|
|
|
$items = stripslashes( $_FILES['uploadedFile']['name'] );
|
2012-07-06 11:22:39 -04:00
|
|
|
if ($sw_error_exists) {
|
|
|
|
|
$up_err = $_FILES['uploadedFile']['error'];
|
|
|
|
|
} else {
|
2012-10-17 17:21:35 -04:00
|
|
|
$up_err = (file_exists( $tmp ) ? 0 : 4);
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2011-07-21 18:37:03 -04:00
|
|
|
|
2012-07-06 11:22:39 -04:00
|
|
|
if ($items == "" || $up_err == 4) {
|
2012-10-17 17:21:35 -04:00
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_FILE_REQUIRED' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
|
|
|
|
if ($up_err == 1 || $up_err == 2) {
|
2012-10-17 17:21:35 -04:00
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_FILE_TOO_BIG' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
//$errors[$i]='miscfilesize';
|
|
|
|
|
}
|
|
|
|
|
if ($up_err == 3) {
|
2012-10-17 17:21:35 -04:00
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
//$errors[$i]='miscfilepart';
|
|
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
if (! @is_uploaded_file( $tmp )) {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
//$errors[$i]='uploadfile';
|
|
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
$fileInfo = pathinfo( $items );
|
|
|
|
|
$validType = array ('tar','gz'
|
|
|
|
|
);
|
2011-07-21 18:37:03 -04:00
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
if (! in_array( $fileInfo['extension'], $validType )) {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_FILE_UPLOAD_INCORRECT_EXTENSION' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
//$errors[$i]='wrongtype';
|
|
|
|
|
}
|
2011-07-21 18:37:03 -04:00
|
|
|
|
2012-07-06 11:22:39 -04:00
|
|
|
$filename = $items;
|
|
|
|
|
$tempPath = PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP;
|
2012-10-17 17:21:35 -04:00
|
|
|
G::verifyPath( $tempPath, true );
|
2012-07-06 11:22:39 -04:00
|
|
|
$tempName = $tmp;
|
2012-10-17 17:21:35 -04:00
|
|
|
G::uploadFile( $tempName, $tempPath, $filename );
|
|
|
|
|
G::LoadThirdParty( 'pear/Archive', 'Tar' );
|
|
|
|
|
$tar = new Archive_Tar( $tempPath . $filename );
|
2012-07-06 11:22:39 -04:00
|
|
|
$aFiles = $tar->listContent();
|
|
|
|
|
$swConfigFile = false;
|
|
|
|
|
|
|
|
|
|
foreach ($aFiles as $key => $val) {
|
2012-10-17 17:21:35 -04:00
|
|
|
if (basename( $val['filename'] ) == 'config.xml') {
|
|
|
|
|
$skinName = dirname( $val['filename'] );
|
|
|
|
|
$skinArray = explode( "/", $skinName );
|
|
|
|
|
if (count( $skinArray ) == 1) {
|
2012-07-06 11:22:39 -04:00
|
|
|
$swConfigFile = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-21 18:37:03 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
if (! $swConfigFile) {
|
|
|
|
|
@unlink( PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP . $filename );
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_CONFIGURATION_MISSING' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2011-07-21 18:37:03 -04:00
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
if (is_dir( PATH_CUSTOM_SKINS . $skinName )) {
|
|
|
|
|
if ((isset( $_REQUEST['overwrite_files'] )) && ($_REQUEST['overwrite_files'] == 'on')) {
|
|
|
|
|
G::rm_dir( PATH_CUSTOM_SKINS . $skinName, false );
|
2012-07-06 11:22:39 -04:00
|
|
|
} else {
|
2012-10-17 17:21:35 -04:00
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_ALREADY_EXISTS' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
|
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
$res = $tar->extract( PATH_CUSTOM_SKINS );
|
|
|
|
|
if (! $res) {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_ERROR_EXTRACTING' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2012-10-26 17:46:16 -04:00
|
|
|
|
|
|
|
|
$configFileOriginal = PATH_CUSTOM_SKINS . $skinName . PATH_SEP . 'config.xml';
|
|
|
|
|
$configFileFinal = PATH_CUSTOM_SKINS . $skinName . PATH_SEP . 'config.xml';
|
|
|
|
|
$xmlConfiguration = file_get_contents( $configFileOriginal );
|
|
|
|
|
|
|
|
|
|
$workspace = ($_REQUEST['workspace'] == 'global') ? '' : SYS_SYS;
|
2013-04-10 14:35:27 -04:00
|
|
|
|
|
|
|
|
$xmlConfigurationObj = G::xmlParser($xmlConfiguration);
|
|
|
|
|
$skinInformationArray = $xmlConfigurationObj->result["skinConfiguration"]["__CONTENT__"]["information"]["__CONTENT__"];
|
|
|
|
|
|
2013-04-26 13:15:36 -04:00
|
|
|
if (isset($skinInformationArray["workspace"]["__VALUE__"])) {
|
|
|
|
|
$workspace = ($workspace != "" && !empty($skinInformationArray["workspace"]["__VALUE__"]))? $skinInformationArray["workspace"]["__VALUE__"] . "|" . $workspace : $workspace;
|
2013-04-10 14:35:27 -04:00
|
|
|
|
|
|
|
|
$xmlConfiguration = preg_replace("/(<workspace>)(.*)(<\/workspace>)/i", "<workspace>" . $workspace . "</workspace><!-- $2 -->", $xmlConfiguration);
|
2012-10-26 17:46:16 -04:00
|
|
|
} else {
|
2013-04-10 14:35:27 -04:00
|
|
|
$xmlConfiguration = preg_replace("/(<name>)(.*)(<\/name>)/i", "<name>" . $skinName . "</name><!-- $2 -->\n<workspace>" . $workspace . "</workspace>", $xmlConfiguration);
|
2012-10-26 17:46:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
file_put_contents( $configFileFinal, $xmlConfiguration );
|
|
|
|
|
|
2012-07-06 11:22:39 -04:00
|
|
|
//Delete Temporal
|
2012-10-17 17:21:35 -04:00
|
|
|
@unlink( PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP . $filename );
|
2012-07-06 11:22:39 -04:00
|
|
|
|
|
|
|
|
$response['success'] = true;
|
2012-10-17 17:21:35 -04:00
|
|
|
$response['message'] = G::LoadTranslation( 'ID_SKIN_SUCCESSFUL_IMPORTED' );
|
|
|
|
|
print_r( G::json_encode( $response ) );
|
2012-07-06 11:22:39 -04:00
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$response['success'] = false;
|
|
|
|
|
$response['message'] = $e->getMessage();
|
|
|
|
|
$response['error'] = $e->getMessage();
|
2012-10-17 17:21:35 -04:00
|
|
|
print_r( G::json_encode( $response ) );
|
2011-07-21 18:37:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
function exportSkin ($skinToExport = "")
|
2012-07-06 11:22:39 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2012-10-17 17:21:35 -04:00
|
|
|
if (! isset( $_REQUEST['SKIN_FOLDER_ID'] )) {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_NAME_REQUIRED' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2011-07-20 17:15:47 -04:00
|
|
|
|
2012-07-06 11:22:39 -04:00
|
|
|
$skinName = $_REQUEST['SKIN_FOLDER_ID'];
|
2011-07-20 17:15:47 -04:00
|
|
|
|
2012-07-06 11:22:39 -04:00
|
|
|
$skinFolderBase = PATH_CUSTOM_SKINS . $skinName;
|
|
|
|
|
$skinFolder = $skinFolderBase . PATH_SEP;
|
|
|
|
|
$skinTar = PATH_CUSTOM_SKINS . $skinName . '.tar';
|
2012-10-17 17:21:35 -04:00
|
|
|
if (! is_dir( $skinFolder )) {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_DOESNT_EXIST' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
if (! file_exists( $skinFolder . "config.xml" )) {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_CONFIGURATION_MISSING' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2011-07-20 17:15:47 -04:00
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
if (file_exists( $skinTar )) {
|
2012-07-06 11:22:39 -04:00
|
|
|
//try to delete
|
2012-10-17 17:21:35 -04:00
|
|
|
if (! unlink( $skinTar )) {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_FOLDER_PERMISSIONS' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
|
|
|
|
}
|
2011-07-20 17:15:47 -04:00
|
|
|
|
2012-07-06 11:22:39 -04:00
|
|
|
//Try to generate tar file
|
2012-10-17 17:21:35 -04:00
|
|
|
G::LoadThirdParty( 'pear/Archive', 'Tar' );
|
|
|
|
|
$tar = new Archive_Tar( $skinTar );
|
2012-07-06 11:22:39 -04:00
|
|
|
$tar->_compress = false;
|
2011-07-21 18:37:03 -04:00
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
addTarFolder( $tar, $skinFolder, PATH_CUSTOM_SKINS );
|
2011-07-20 17:15:47 -04:00
|
|
|
|
2012-07-06 11:22:39 -04:00
|
|
|
$response['success'] = true;
|
|
|
|
|
$response['message'] = $skinTar;
|
2011-07-20 17:15:47 -04:00
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
print_r( G::json_encode( $response ) );
|
2012-07-06 11:22:39 -04:00
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$response['success'] = false;
|
|
|
|
|
$response['message'] = $e->getMessage();
|
2012-10-17 17:21:35 -04:00
|
|
|
print_r( G::json_encode( $response ) );
|
2011-07-26 12:34:16 -04:00
|
|
|
}
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
|
|
|
|
|
function deleteSkin ()
|
2012-07-06 11:22:39 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2012-10-17 17:21:35 -04:00
|
|
|
if (! (isset( $_REQUEST['SKIN_FOLDER_ID'] ))) {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_FOLDER_REQUIRED' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
if (($_REQUEST['SKIN_FOLDER_ID']) == "classic") {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_FOLDER_NOT_DELETEABLE' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
$folderId = $_REQUEST['SKIN_FOLDER_ID'];
|
|
|
|
|
if (! is_dir( PATH_CUSTOM_SKINS . $folderId )) {
|
|
|
|
|
throw (new Exception( G::LoadTranslation( 'ID_SKIN_NOT_EXISTS' ) ));
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
|
|
|
|
//Delete
|
2012-10-17 17:21:35 -04:00
|
|
|
G::rm_dir( PATH_CUSTOM_SKINS . $folderId );
|
2012-07-06 11:22:39 -04:00
|
|
|
$response['success'] = true;
|
|
|
|
|
$response['message'] = "$folderId deleted";
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$response['success'] = false;
|
2012-10-17 17:21:35 -04:00
|
|
|
$response['error'] = $response['message'] = $e->getMessage();
|
|
|
|
|
print_r( G::json_encode( $response ) );
|
2011-07-26 12:34:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
|
|
|
|
|
function streamSkin ()
|
2012-07-06 11:22:39 -04:00
|
|
|
{
|
|
|
|
|
$skinTar = $_REQUEST['file'];
|
|
|
|
|
$bDownload = true;
|
2012-10-17 17:21:35 -04:00
|
|
|
G::streamFile( $skinTar, $bDownload, basename( $skinTar ) );
|
|
|
|
|
@unlink( $fileTar );
|
2011-07-20 17:15:47 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
function addTarFolder ($tar, $pathBase, $pluginHome)
|
2012-07-06 11:22:39 -04:00
|
|
|
{
|
2012-10-17 17:21:35 -04:00
|
|
|
$aux = explode( PATH_SEP, $pathBase );
|
|
|
|
|
if ($aux[count( $aux ) - 2] == '.svn') {
|
2012-07-06 11:22:39 -04:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
if ($handle = opendir( $pathBase )) {
|
|
|
|
|
while (false !== ($file = readdir( $handle ))) {
|
|
|
|
|
if (is_file( $pathBase . $file )) {
|
2012-07-06 11:22:39 -04:00
|
|
|
//print "file $file \n";
|
2012-10-17 17:21:35 -04:00
|
|
|
$tar->addModify( $pathBase . $file, '', $pluginHome );
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
if (is_dir( $pathBase . $file ) && $file != '..' && $file != '.') {
|
2012-07-06 11:22:39 -04:00
|
|
|
//print "dir $pathBase$file \n";
|
2012-10-17 17:21:35 -04:00
|
|
|
addTarFolder( $tar, $pathBase . $file . PATH_SEP, $pluginHome );
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
|
|
|
|
}
|
2012-10-17 17:21:35 -04:00
|
|
|
closedir( $handle );
|
2011-02-28 16:08:15 +00:00
|
|
|
}
|
2011-07-26 12:34:16 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-17 17:21:35 -04:00
|
|
|
function copy_skin_folder ($path, $dest, $exclude = array())
|
2012-07-06 11:22:39 -04:00
|
|
|
{
|
2012-10-17 17:21:35 -04:00
|
|
|
$defaultExcluded = array (".",".."
|
|
|
|
|
);
|
|
|
|
|
$excludedItems = array_merge( $defaultExcluded, $exclude );
|
|
|
|
|
if (is_dir( $path )) {
|
|
|
|
|
@mkdir( $dest );
|
|
|
|
|
$objects = scandir( $path );
|
|
|
|
|
if (sizeof( $objects ) > 0) {
|
2012-07-06 11:22:39 -04:00
|
|
|
foreach ($objects as $file) {
|
2012-10-17 17:21:35 -04:00
|
|
|
if (in_array( $file, $excludedItems )) {
|
2012-07-06 11:22:39 -04:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// go on
|
2012-10-17 17:21:35 -04:00
|
|
|
if (is_dir( $path . PATH_SEP . $file )) {
|
|
|
|
|
copy_skin_folder( $path . PATH_SEP . $file, $dest . PATH_SEP . $file, $exclude );
|
2012-07-06 11:22:39 -04:00
|
|
|
} else {
|
2012-10-17 17:21:35 -04:00
|
|
|
copy( $path . PATH_SEP . $file, $dest . PATH_SEP . $file );
|
2012-07-06 11:22:39 -04:00
|
|
|
}
|
|
|
|
|
}
|
2011-07-26 12:34:16 -04:00
|
|
|
}
|
2012-07-06 11:22:39 -04:00
|
|
|
return true;
|
2012-10-17 17:21:35 -04:00
|
|
|
} elseif (is_file( $path )) {
|
|
|
|
|
return copy( $path, $dest );
|
2012-07-06 11:22:39 -04:00
|
|
|
} else {
|
|
|
|
|
return false;
|
2011-07-26 12:34:16 -04:00
|
|
|
}
|
2012-07-06 11:06:20 -04:00
|
|
|
}
|
2012-07-06 11:22:39 -04:00
|
|
|
|