|
|
@@ -19,6 +19,13 @@ class BxDolStudioDesigner extends BxTemplStudioPage
|
|
|
{
|
|
|
protected $sPage;
|
|
|
|
|
|
+ protected $sManageUrl;
|
|
|
+
|
|
|
+ protected $sParamLogo;
|
|
|
+ protected $sParamLogoAlt;
|
|
|
+ protected $sParamLogoWidth;
|
|
|
+ protected $sParamLogoHeight;
|
|
|
+
|
|
|
function __construct($sPage = "")
|
|
|
{
|
|
|
parent::__construct('designer');
|
|
|
@@ -29,39 +36,57 @@ class BxDolStudioDesigner extends BxTemplStudioPage
|
|
|
if(is_string($sPage) && !empty($sPage))
|
|
|
$this->sPage = $sPage;
|
|
|
|
|
|
- //--- Check actions ---//
|
|
|
- if(($sAction = bx_get('dsg_action')) !== false) {
|
|
|
- $sAction = bx_process_input($sAction);
|
|
|
-
|
|
|
- $aResult = array('code' => 1, 'message' => _t('_adm_dsg_err_cannot_process_action'));
|
|
|
- switch($sAction) {
|
|
|
- case 'delete_logo':
|
|
|
- $aResult = array('code' => 0, 'message' => '');
|
|
|
- if(!$this->deleteLogo())
|
|
|
- $aResult = array('code' => 2, 'message' => _t('_adm_dsg_err_remove_old_logo'));
|
|
|
- break;
|
|
|
-
|
|
|
- case 'make_default':
|
|
|
- $aResult = array('code' => 0, 'message' => '');
|
|
|
- if(!$this->makeDefault())
|
|
|
- $aResult = array('code' => 2, 'message' => _t('_adm_dsg_err_make_default'));
|
|
|
- break;
|
|
|
-
|
|
|
- case 'get-page-by-type':
|
|
|
- $sValue = bx_process_input(bx_get('dsg_value'));
|
|
|
- if(empty($sValue))
|
|
|
- break;
|
|
|
-
|
|
|
- $this->sPage = $sValue;
|
|
|
- $aResult = array('code' => 0, 'content' => $this->getPageCode());
|
|
|
- break;
|
|
|
- }
|
|
|
+ $this->sManageUrl = BX_DOL_URL_STUDIO . 'designer.php';
|
|
|
|
|
|
- echo json_encode($aResult);
|
|
|
- exit;
|
|
|
- }
|
|
|
+ $this->sParamLogo = 'sys_site_logo';
|
|
|
+ $this->sParamLogoAlt = 'sys_site_logo_alt';
|
|
|
+ $this->sParamLogoWidth = 'sys_site_logo_width';
|
|
|
+ $this->sParamLogoHeight = 'sys_site_logo_height';
|
|
|
}
|
|
|
|
|
|
+ function checkAction()
|
|
|
+ {
|
|
|
+ $sAction = bx_get('dsg_action');
|
|
|
+ if($sAction === false)
|
|
|
+ return;
|
|
|
+
|
|
|
+ $sAction = bx_process_input($sAction);
|
|
|
+
|
|
|
+ $aResult = array('code' => 1, 'message' => _t('_adm_dsg_err_cannot_process_action'));
|
|
|
+ switch($sAction) {
|
|
|
+ case 'delete_logo':
|
|
|
+ $aResult = array('code' => 0, 'message' => '');
|
|
|
+ if(!$this->deleteLogo())
|
|
|
+ $aResult = array('code' => 2, 'message' => _t('_adm_dsg_err_remove_old_logo'));
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'make_default':
|
|
|
+ $aResult = array('code' => 0, 'message' => '');
|
|
|
+ if(!$this->makeDefault())
|
|
|
+ $aResult = array('code' => 2, 'message' => _t('_adm_dsg_err_make_default'));
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'get-page-by-type':
|
|
|
+ $sValue = bx_process_input(bx_get('dsg_value'));
|
|
|
+ if(empty($sValue))
|
|
|
+ break;
|
|
|
+
|
|
|
+ $this->sPage = $sValue;
|
|
|
+ $aResult = array('code' => 0, 'content' => $this->getPageCode());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ echo json_encode($aResult);
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ function setManageUrl($sUrl)
|
|
|
+ {
|
|
|
+ $this->sManageUrl = $sUrl;
|
|
|
+ }
|
|
|
+ function setLogoParams($aParams)
|
|
|
+ {
|
|
|
+ list($this->sParamLogo, $this->sParamLogoAlt, $this->sParamLogoWidth, $this->sParamLogoHeight) = $aParams;
|
|
|
+ }
|
|
|
function makeDefault()
|
|
|
{
|
|
|
$sValue = bx_get('dsg_value');
|
|
|
@@ -84,18 +109,18 @@ class BxDolStudioDesigner extends BxTemplStudioPage
|
|
|
|
|
|
$iId = $oStorage->storeFileFromForm($_FILES['image'], false, $iProfileId);
|
|
|
if($iId === false) {
|
|
|
- $this->oDb->setParam('sys_site_logo', 0);
|
|
|
+ $this->oDb->setParam($this->sParamLogo, 0);
|
|
|
return $this->getJsResult(_t('_adm_dsg_err_save') . $oStorage->getErrorString(), false);
|
|
|
}
|
|
|
|
|
|
- $this->oDb->setParam('sys_site_logo', $iId);
|
|
|
+ $this->oDb->setParam($this->sParamLogo, $iId);
|
|
|
$oStorage->afterUploadCleanup($iId, $iProfileId);
|
|
|
}
|
|
|
|
|
|
- $this->oDb->setParam('sys_site_logo_alt', $oForm->getCleanValue('alt'));
|
|
|
- $this->oDb->setParam('sys_site_logo_width', $oForm->getCleanValue('width'));
|
|
|
- $this->oDb->setParam('sys_site_logo_height', $oForm->getCleanValue('height'));
|
|
|
- return $this->getJsResult('_adm_dsg_scs_save', true, true, BX_DOL_URL_STUDIO . 'designer.php?page=' . BX_DOL_STUDIO_DSG_TYPE_LOGO);
|
|
|
+ $this->oDb->setParam($this->sParamLogoAlt, $oForm->getCleanValue('alt'));
|
|
|
+ $this->oDb->setParam($this->sParamLogoWidth, $oForm->getCleanValue('width'));
|
|
|
+ $this->oDb->setParam($this->sParamLogoHeight, $oForm->getCleanValue('height'));
|
|
|
+ return $this->getJsResult('_adm_dsg_scs_save', true, true, bx_append_url_params($this->sManageUrl, array('page' => BX_DOL_STUDIO_DSG_TYPE_LOGO)));
|
|
|
}
|
|
|
|
|
|
function deleteLogo()
|
|
|
@@ -104,11 +129,11 @@ class BxDolStudioDesigner extends BxTemplStudioPage
|
|
|
|
|
|
$oStorage = BxDolStorage::getObjectInstance('sys_images_custom');
|
|
|
|
|
|
- $iId = (int)getParam('sys_site_logo');
|
|
|
+ $iId = (int)getParam($this->sParamLogo);
|
|
|
if($iId != 0 && !$oStorage->deleteFile($iId, $iProfileId))
|
|
|
return false;
|
|
|
|
|
|
- $this->oDb->setParam('sys_site_logo', 0);
|
|
|
+ $this->oDb->setParam($this->sParamLogo, 0);
|
|
|
return true;
|
|
|
}
|
|
|
|