Просмотр исходного кода

Ticket #3920 - Artificer: Add Mark image support.

AntonLV 4 лет назад
Родитель
Сommit
8b85fa32fd

+ 43 - 2
inc/classes/BxDolDesigns.php

@@ -10,6 +10,7 @@
 class BxDolDesigns extends BxDolFactory implements iBxDolSingleton
 {
     public static $fLogoAspectRatioDefault = 1.0;
+    public static $fMarkAspectRatioDefault = 1.0;
 
     protected $sDesign;
     protected $oDesign;
@@ -65,14 +66,19 @@ class BxDolDesigns extends BxDolFactory implements iBxDolSingleton
     	if($this->oDesign instanceof BxDolModule && method_exists($this->oDesign->_oConfig, 'getLogoParams')) {
             list(
                 $this->aParams['logo'], 
+                $this->aParams['mark'], 
                 $this->aParams['logo_alt']
             ) = $this->oDesign->_oConfig->getLogoParams();
 
             list(
                 $this->aValues['logo_width'], 
                 $this->aValues['logo_height'],
-                $this->aValues['logo_aspect_ratio']
-            ) = $this->oDesign->_oConfig->getLogoValues($this->getSiteLogoUrl(), $this->getSiteLogoInfo());
+                $this->aValues['logo_aspect_ratio'],
+
+                $this->aValues['mark_width'],
+                $this->aValues['mark_height'],
+                $this->aValues['mark_aspect_ratio']
+            ) = $this->oDesign->_oConfig->getLogoValues($this->getSiteLogoUrl(), $this->getSiteLogoInfo(), $this->getSiteMarkUrl(), $this->getSiteMarkInfo());
         }
     }
 
@@ -106,6 +112,21 @@ class BxDolDesigns extends BxDolFactory implements iBxDolSingleton
         return !empty($sFileUrl) ? $sFileUrl : false;
     }
 
+    public function getSiteMark()
+    {
+    	return $this->getSiteLogoParam('mark');
+    }
+
+    public function getSiteMarkUrl($iFileId = 0, $bOriginal = true)
+    {
+        if(!$iFileId)
+            $iFileId = (int)$this->getSiteMark();
+        if(!$iFileId) 
+            return false;
+        
+        return $this->getSiteLogoUrl($iFileId, $bOriginal);
+    }
+
     public function getSiteLogoInfo($iFileId = 0)
     {
         if(!$iFileId)
@@ -116,6 +137,16 @@ class BxDolDesigns extends BxDolFactory implements iBxDolSingleton
         return BxDolStorage::getObjectInstance($this->sLogoStorage)->getFile($iFileId);
     }
 
+    public function getSiteMarkInfo($iFileId = 0)
+    {
+        if(!$iFileId)
+            $iFileId = (int)$this->getSiteMark();
+        if(!$iFileId) 
+            return false;
+
+        return BxDolStorage::getObjectInstance($this->sLogoStorage)->getFile($iFileId);
+    }
+
     public function getSiteLogoAlt()
     {
     	return $this->getSiteLogoParam('logo_alt');
@@ -131,6 +162,16 @@ class BxDolDesigns extends BxDolFactory implements iBxDolSingleton
         return ($iResult = $this->getSiteLogoValue('logo_height')) !== false ? $iResult : 0;
     }
 
+    public function getSiteMarkWidth()
+    {
+    	return ($iResult = $this->getSiteLogoValue('mark_width')) !== false ? $iResult : 0;
+    }
+
+    public function getSiteMarkHeight()
+    {
+        return ($iResult = $this->getSiteLogoValue('mark_height')) !== false ? $iResult : 0;
+    }
+
     protected function getSiteLogoParam($sName, $bGetSystem = false)
     {
     	if(!empty($this->aParams[$sName]) && !$bGetSystem) {

+ 44 - 10
modules/base/template/classes/BxBaseModTemplateConfig.php

@@ -22,8 +22,14 @@ class BxBaseModTemplateConfig extends BxBaseModGeneralConfig
     protected $_iLogoHeight;
     protected $_fLogoAspectRatio;
     protected $_fLogoAspectRatioDefault;
+    
+    protected $_iMarkWidth;
+    protected $_iMarkHeight;
+    protected $_fMarkAspectRatio;
+    protected $_fMarkAspectRatioDefault;
 
     protected $_sKeyLogoAspectRatio;
+    protected $_sKeyMarkAspectRatio;
 
     function __construct($aModule)
     {
@@ -32,6 +38,10 @@ class BxBaseModTemplateConfig extends BxBaseModGeneralConfig
         $this->_iLogoWidth = 0;
         $this->_iLogoHeight = 0;
         $this->_fLogoAspectRatioDefault = BxDolDesigns::$fLogoAspectRatioDefault;
+
+        $this->_iMarkWidth = 0;
+        $this->_iMarkHeight = 0;
+        $this->_fMarkAspectRatioDefault = BxDolDesigns::$fMarkAspectRatioDefault;
     }
 
     public function init(&$oDb)
@@ -40,10 +50,15 @@ class BxBaseModTemplateConfig extends BxBaseModGeneralConfig
         $sPrefix = $this->getPrefix('option');
 
         $this->_sKeyLogoAspectRatio = $sPrefix . 'site_logo_aspect_ratio';
+        $this->_sKeyMarkAspectRatio = $sPrefix . 'site_mark_aspect_ratio';
 
         $this->_iLogo = (int)$this->_oDb->getParam($sPrefix . 'site_logo');
-        $this->_sLogoAlt = $this->_oDb->getParam($sPrefix . 'site_logo_alt');
         $this->_fLogoAspectRatio = (float)$this->_oDb->getParam($this->_sKeyLogoAspectRatio);
+
+        $this->_iMark = (int)$this->_oDb->getParam($sPrefix . 'site_mark');
+        $this->_fMarkAspectRatio = (float)$this->_oDb->getParam($this->_sKeyMarkAspectRatio);
+
+        $this->_sLogoAlt = $this->_oDb->getParam($sPrefix . 'site_logo_alt');
     }
 
     public function getLogoParams()
@@ -52,24 +67,41 @@ class BxBaseModTemplateConfig extends BxBaseModGeneralConfig
 
     	return [
             $sPrefix . 'site_logo',
+            $sPrefix . 'site_mark',
             $sPrefix . 'site_logo_alt'
     	];
     }
 
-    public function getLogoValues($sUrl, $aInfo)
+    public function getLogoValues($sUrlLogo, $aInfoLogo, $sUrlMark = '', $aInfoMark = [])
     {
+        $iDefaultHeight = $this->_calculateValuesHeight();
+
         if(empty($this->_iLogoHeight))
-            $this->_iLogoHeight = $this->_calculateLogoValuesHeight();
+            $this->_iLogoHeight = $iDefaultHeight;
 
         if(!$this->_fLogoAspectRatio)
-            $this->_fLogoAspectRatio = $this->_calculateLogoValuesAspectRatio($sUrl, $aInfo);
+            $this->_fLogoAspectRatio = $this->_calculateValuesAspectRatio('logo', $sUrlLogo, $aInfoLogo);
 
         $this->_iLogoWidth = (int)ceil($this->_iLogoHeight * $this->_fLogoAspectRatio);
 
+        if(!empty($sUrlMark) && !empty($aInfoMark)) {
+            if(empty($this->_iMarkHeight))
+                $this->_iMarkHeight = $iDefaultHeight;
+
+            if(!$this->_fMarkAspectRatio)
+                $this->_fMarkAspectRatio = $this->_calculateValuesAspectRatio('mark', $sUrlMark, $aInfoMark);
+
+            $this->_iMarkWidth = (int)ceil($this->_iMarkHeight * $this->_fMarkAspectRatio);
+        }
+
         return [
             $this->_iLogoWidth,
             $this->_iLogoHeight,
-            $this->_fLogoAspectRatio
+            $this->_fLogoAspectRatio,
+
+            $this->_iMarkWidth,
+            $this->_iMarkHeight,
+            $this->_fMarkAspectRatio
         ];
     }
 
@@ -93,7 +125,7 @@ class BxBaseModTemplateConfig extends BxBaseModGeneralConfig
     	return $this->_iLogoHeight;
     }
     
-    protected function _calculateLogoValuesHeight()
+    protected function _calculateValuesHeight()
     {
         $sPrefix = $this->getPrefix('option');
 
@@ -129,10 +161,12 @@ class BxBaseModTemplateConfig extends BxBaseModGeneralConfig
         return $iHeaderHeight - $iPTop - $iPBottom;
     }
     
-    protected function _calculateLogoValuesAspectRatio($sUrl, $aInfo)
+    protected function _calculateValuesAspectRatio($sType, $sUrl, $aInfo)
     {
+        $sTypeUc = ucfirst($sType);
+
         if(!$sUrl)
-            return $this->_fLogoAspectRatioDefault;
+            return $this->{'_f' . $sTypeUc . 'AspectRatioDefault'};
 
         $iWidth = $iHeight = 0;
         if(strpos($sUrl, '.svg') !== false)
@@ -141,10 +175,10 @@ class BxBaseModTemplateConfig extends BxBaseModGeneralConfig
             list($iWidth, $iHeight) = getimagesize($sUrl);
 
         if(!$iHeight) 
-            return $this->_fLogoAspectRatioDefault;
+            return $this->{'_f' . $sTypeUc . 'AspectRatioDefault'};
 
         $fResult = $iWidth / $iHeight;
-        $this->_oDb->setParam($this->_sKeyLogoAspectRatio, $fResult);
+        $this->_oDb->setParam($this->{'_sKey' . $sTypeUc . 'AspectRatio'}, $fResult);
 
         return $fResult;
     }

+ 10 - 0
modules/boonex/artificer/classes/BxArtificerAlertsResponse.php

@@ -29,6 +29,16 @@ class BxArtificerAlertsResponse extends BxBaseModTemplateAlertsResponse
         setParam($sPrefix . 'site_logo_aspect_ratio', '');
     }
 
+    protected function _processSystemChangeMark($oAlert)
+    {
+        $sPrefix = $this->_oModule->_oConfig->getPrefix('option');
+
+        if(!in_array($oAlert->aExtras['option'], ['sys_site_mark', $sPrefix . 'site_mark']))
+            return;
+
+        setParam($sPrefix . 'site_mark_aspect_ratio', '');
+    }
+
     protected function _processSystemGetObject($oAlert)
     {
         if(!$this->_isActive())

+ 12 - 0
modules/boonex/artificer/classes/BxArtificerConfig.php

@@ -24,6 +24,7 @@ class BxArtificerConfig extends BxBaseModTemplateConfig
         parent::__construct($aModule);
 
         $this->_iLogoHeight = 48;
+        $this->_iMarkHeight = 48;
 
         $this->_aPrefixes = [
             'option' => 'bx_artificer_'
@@ -47,6 +48,17 @@ class BxArtificerConfig extends BxBaseModTemplateConfig
         
     }
 
+    public function getLogoParams()
+    {
+    	$sPrefix = $this->getPrefix('option');
+
+    	return [
+            $sPrefix . 'site_logo',
+            $sPrefix . 'site_mark',
+            $sPrefix . 'site_logo_alt'
+    	];
+    }
+
     public function getReplacements()
     {
         return $this->_aReplacements;

+ 1 - 1
modules/boonex/artificer/data/template/system/logo_main.html

@@ -1,5 +1,5 @@
 <a __attrs__>
     <bx_if:show_title><span>__logo__</span></bx_if:show_title>
     <bx_if:show_image><img class="__class__" style="__style__" src="__src__" id="bx-logo" alt="__alt__" /></bx_if:show_image>
-    <bx_if:show_image_mini><img class="__class__" style="__style__" src="__src__" id="bx-logo" alt="__alt__" /></bx_if:show_image_mini>
+    <bx_if:show_image_mini><img class="__class__" style="__style__" src="__src__" id="bx-mark" alt="__alt__" /></bx_if:show_image_mini>
 </a>

+ 33 - 20
modules/boonex/artificer/data/template/system/scripts/BxTemplFunctions.php

@@ -32,6 +32,7 @@ class BxTemplFunctions extends BxBaseFunctions
         $aTmplVarsShowImage = [];
         $aTmplVarsShowImageMini = [];
 
+        //--- Logo image
         $bDefault = false;
         if(($sFileUrl = $this->getMainLogoUrl()) !== false || ($bDefault = (!$bTitle && ($sFileUrl = $this->_oTemplate->getImageUrl('logo-generic.svg')) != ''))) {
             $bTmplVarsShowTitle = false;
@@ -43,39 +44,51 @@ class BxTemplFunctions extends BxBaseFunctions
             ];
 
             $iLogoHeight = (int)$oDesigns->getSiteLogoHeight();
-            $sHeight = $iLogoHeight > 0 ? 'height:' . round($iLogoHeight/16, 3) . 'rem;' : '';
+            $sLogoHeight = $iLogoHeight > 0 ? 'height:' . round($iLogoHeight/16, 3) . 'rem;' : '';
 
+            //--- Default Logo
             if($bDefault) {
-                //--- Default Logo
                 list($iDlWidth, $iDlHeight) = bx_get_svg_image_size($sFileUrl);
                 $fDlAspectRation = $iDlHeight ? $iDlWidth / $iDlHeight : BxDolDesigns::$fLogoAspectRatioDefault;
 
                 $iLogoWidth = $iLogoHeight * $fDlAspectRation;
+            }
+            else
+                $iLogoWidth = $oDesigns->getSiteLogoWidth();
+
+            $sLogoWidth = $iLogoWidth > 0 ? 'width:' . round($iLogoWidth/16, 3) . 'rem;' : '';
 
-                //--- Default Logo Mini
-                $aTmplVarsShowImage['class'] = 'hidden lg:block';
+            $aTmplVarsShowImage['style'] = $sLogoWidth . ' ' . $sLogoHeight;
+        }
+
+        //--- Mark image
+        $bDefault = false;
+        if(($sFileUrl = $this->getMainMarkUrl()) !== false || ($bDefault = (!$bTitle && ($sFileUrl = $this->_oTemplate->getImageUrl('mark-generic.svg')) != ''))) {
+            $aTmplVarsShowImage['class'] = 'hidden lg:block';
 
-                if(($sFileUrl = $this->_oTemplate->getImageUrl('mark-generic.svg')) != '') {
-                    list($iMlWidth, $iMlHeight) = bx_get_svg_image_size($sFileUrl);
-                    $fMlAspectRation = $iMlHeight ? $iMlWidth / $iMlHeight : BxDolDesigns::$fLogoAspectRatioDefault;
+            $aTmplVarsShowImageMini = [
+                'class' => 'block lg:hidden',
+                'style' => '',
+                'src' => $sFileUrl,
+                'alt' => $sAltAttr
+            ];
+
+            $iMarkHeight = (int)$oDesigns->getSiteMarkHeight();
+            $sMarkHeight = $iMarkHeight > 0 ? 'height:' . round($iMarkHeight/16, 3) . 'rem;' : '';
+
+            //--- Default Mark
+            if($bDefault) {
+                list($iDmWidth, $iDmHeight) = bx_get_svg_image_size($sFileUrl);
+                $fDmAspectRation = $iDmHeight ? $iDmWidth / $iDmHeight : BxDolDesigns::$fMarkAspectRatioDefault;
                     
-                    $imlLogoWidth = $iLogoHeight * $fMlAspectRation;
-                    $sMlWidth = $imlLogoWidth > 0 ? 'width:' . round($imlLogoWidth/16, 3) . 'rem;' : '';
-
-                    $aTmplVarsShowImageMini = [
-                        'class' => 'block lg:hidden',
-                        'style' => $sMlWidth . ' ' . $sHeight,
-                        'src' => $sFileUrl,
-                        'alt' => $sAltAttr
-                    ];
-                }
+                $iMarkWidth = $iMarkHeight * $fDmAspectRation;
             }
             else
-                $iLogoWidth = $oDesigns->getSiteLogoWidth();
+                $iMarkWidth = $oDesigns->getSiteMarkWidth();
 
-            $sWidth = $iLogoWidth > 0 ? 'width:' . round($iLogoWidth/16, 3) . 'rem;' : '';
+            $sMarkWidth = $iMarkWidth > 0 ? 'width:' . round($iMarkWidth/16, 3) . 'rem;' : '';
 
-            $aTmplVarsShowImage['style'] = $sWidth . ' ' . $sHeight;
+            $aTmplVarsShowImageMini['style'] = $sMarkWidth . ' ' . $sMarkHeight;
         }
 
         $aAttrs = [

+ 1 - 0
modules/boonex/artificer/install/sql/enable.sql

@@ -24,6 +24,7 @@ SET @iHandler := LAST_INSERT_ID();
 
 INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
 ('system', 'change_logo', @iHandler),
+('system', 'change_mark', @iHandler),
 ('system', 'get_object', @iHandler),
 ('profile', 'unit', @iHandler);
 

+ 4 - 2
modules/boonex/artificer/install/sql/install.sql

@@ -29,8 +29,10 @@ SET @iSystemCategoryId = (SELECT IFNULL(`id`, @iCategoryId) FROM `sys_options_ca
 SET @iSystemCategoryOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_options` WHERE `category_id`=@iSystemCategoryId LIMIT 1);
 INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `extra`, `check`, `check_error`, `order`) VALUES
 (@iSystemCategoryId, CONCAT(@sName, '_site_logo'), '', '0', 'digit', '', '', '', @iSystemCategoryOrder + 1),
-(@iSystemCategoryId, CONCAT(@sName, '_site_logo_alt'), '', '', 'text', '', '', '', @iSystemCategoryOrder + 2),
-(@iSystemCategoryId, CONCAT(@sName, '_site_logo_aspect_ratio'), '', '', 'digit', '', '', '', @iSystemCategoryOrder + 3);
+(@iSystemCategoryId, CONCAT(@sName, '_site_mark'), '', '0', 'digit', '', '', '', @iSystemCategoryOrder + 2),
+(@iSystemCategoryId, CONCAT(@sName, '_site_logo_alt'), '', '', 'text', '', '', '', @iSystemCategoryOrder + 3),
+(@iSystemCategoryId, CONCAT(@sName, '_site_logo_aspect_ratio'), '', '', 'digit', '', '', '', @iSystemCategoryOrder + 4),
+(@iSystemCategoryId, CONCAT(@sName, '_site_mark_aspect_ratio'), '', '', 'digit', '', '', '', @iSystemCategoryOrder + 5);
 
 
 -- STUDIO PAGE & WIDGET

+ 3 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -659,6 +659,7 @@
 	<string name="_adm_dsg_err_remove_old_cover"><![CDATA[Cannot remove current cover image.]]></string>
 	<string name="_adm_dsg_err_remove_old_icon"><![CDATA[Cannot remove current icon.]]></string>
 	<string name="_adm_dsg_err_remove_old_logo"><![CDATA[Cannot remove current logo image.]]></string>
+        <string name="_adm_dsg_err_remove_old_mark"><![CDATA[Cannot remove current mark image.]]></string>
 	<string name="_adm_dsg_err_save"><![CDATA[Cannot save: ]]></string>
 	<string name="_adm_dsg_err_save_changes"><![CDATA[Cannot save changes.]]></string>
 	<string name="_adm_dsg_scs_save"><![CDATA[The changes were successfully saved]]></string>
@@ -677,6 +678,8 @@
 	<string name="_adm_dsg_txt_upload_icon"><![CDATA[Upload New Site Icon]]></string>
 	<string name="_adm_dsg_txt_upload_image"><![CDATA[Upload New Logo Image]]></string>
 	<string name="_adm_dsg_txt_upload_image_preview"><![CDATA[Current Logo Image]]></string>
+        <string name="_adm_dsg_txt_upload_mark"><![CDATA[Upload New Mark Image]]></string>
+	<string name="_adm_dsg_txt_upload_mark_preview"><![CDATA[Current Mark Image]]></string>
 	<string name="_adm_dsg_txt_inj_head"><![CDATA[&lt;HEAD&gt; injection]]></string>
 	<string name="_adm_dsg_txt_inj_head_inf"><![CDATA[Code to insert before closing HEAD tag]]></string>
 	<string name="_adm_dsg_txt_inj_body"><![CDATA[&lt;BODY&gt; injection]]></string>

+ 3 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -658,6 +658,7 @@
 	<string name="_adm_dsg_err_remove_old_cover"><![CDATA[Невозможно удалить текущее изображение обложки.]]></string>
 	<string name="_adm_dsg_err_remove_old_icon"><![CDATA[Невозможно удалить текущую иконку.]]></string>
 	<string name="_adm_dsg_err_remove_old_logo"><![CDATA[Невозможно удалить текущую лого-картинку.]]></string>
+        <string name="_adm_dsg_err_remove_old_mark"><![CDATA[Невозможно удалить текущую марку.]]></string>
 	<string name="_adm_dsg_err_save"><![CDATA[Невозможно сохранить: ]]></string>
 	<string name="_adm_dsg_err_save_changes"><![CDATA[Невозможно сохранить изменения.]]></string>
 	<string name="_adm_dsg_scs_save"><![CDATA[Изменения удачно сохранены]]></string>
@@ -676,6 +677,8 @@
 	<string name="_adm_dsg_txt_upload_icon"><![CDATA[Загрузить новую иконку сайта]]></string>
 	<string name="_adm_dsg_txt_upload_image"><![CDATA[Загрузить новую лого-картинку]]></string>
 	<string name="_adm_dsg_txt_upload_image_preview"><![CDATA[Текущая лого-картинка]]></string>
+        <string name="_adm_dsg_txt_upload_mark"><![CDATA[Загрузить новую марку]]></string>
+	<string name="_adm_dsg_txt_upload_mark_preview"><![CDATA[Текущая марка]]></string>
 	<string name="_adm_dsg_txt_inj_head"><![CDATA[&lt;HEAD&gt; инъекция]]></string>
 	<string name="_adm_dsg_txt_inj_head_inf"><![CDATA[Код для вставки перед закрывающим HEAD тагом]]></string>
 	<string name="_adm_dsg_txt_inj_body"><![CDATA[&lt;BODY&gt; инъекция]]></string>

+ 9 - 1
studio/classes/BxDolStudioDesign.php

@@ -46,11 +46,19 @@ class BxDolStudioDesign extends BxTemplStudioModule
             case 'delete_logo':
                 $oPage = $this->getObjectDesigner();
 
-                $aResult = array('code' => 0, 'message' => '');
+                $aResult = array('code' => 0, 'message' => '', 'reload' => 1);
                 if(!$oPage->deleteLogo())
                     $aResult = array('code' => 2, 'message' => _t('_adm_dsg_err_remove_old_logo'));
                 break;
 
+            case 'delete_mark':
+                $oPage = $this->getObjectDesigner();
+
+                $aResult = array('code' => 0, 'message' => '', 'reload' => 1);
+                if(!$oPage->deleteMark())
+                    $aResult = array('code' => 2, 'message' => _t('_adm_dsg_err_remove_old_mark'));
+                break;
+
             default:
                 $aResult = parent::checkAction();
         }

+ 71 - 22
studio/classes/BxDolStudioDesigner.php

@@ -25,6 +25,7 @@ class BxDolStudioDesigner extends BxTemplStudioWidget
     protected $sParamPrefix;
 
     protected $sParamLogo;
+    protected $sParamMark;
     protected $sParamLogoAlt;
 
     protected $aCovers;
@@ -43,6 +44,7 @@ class BxDolStudioDesigner extends BxTemplStudioWidget
         $this->sParamPrefix = 'dsg';
 
         $this->sParamLogo = 'sys_site_logo';
+        $this->sParamMark = '';
         $this->sParamLogoAlt = 'sys_site_logo_alt';
 
         $this->aCovers = array(
@@ -72,11 +74,17 @@ class BxDolStudioDesigner extends BxTemplStudioWidget
         $aResult = array('code' => 1, 'message' => _t('_adm_dsg_err_cannot_process_action'));
         switch($sAction) {
             case 'delete_logo':
-                $aResult = array('code' => 0, 'message' => '');
+                $aResult = array('code' => 0, 'message' => '', 'reload' => 1);
                 if(!$this->deleteLogo())
                     $aResult = array('code' => 2, 'message' => _t('_adm_dsg_err_remove_old_logo'));
                 break;
 
+            case 'delete_mark':
+                $aResult = array('code' => 0, 'message' => '', 'reload' => 1);
+                if(!$this->deleteMark())
+                    $aResult = array('code' => 2, 'message' => _t('_adm_dsg_err_remove_old_mark'));
+                break;
+
             case 'delete_cover':
                 $sValue = bx_process_input(bx_get($this->sParamPrefix . '_value'));
 
@@ -116,7 +124,15 @@ class BxDolStudioDesigner extends BxTemplStudioWidget
 
     function setLogoParams($aParams)
     {
-        list($this->sParamLogo, $this->sParamLogoAlt) = $aParams;
+        switch(count($aParams)) {
+            case 2:
+                list($this->sParamLogo, $this->sParamLogoAlt) = $aParams;
+                break;
+
+            case 3:
+                list($this->sParamLogo, $this->sParamMark, $this->sParamLogoAlt) = $aParams;
+                break;
+        }
     }
 
     function makeDefault()
@@ -129,12 +145,12 @@ class BxDolStudioDesigner extends BxTemplStudioWidget
         return $this->oDb->setParam('template', $sValue);
     }
 
-    function submitLogo(&$oForm)
+    public function submitLogo(&$oForm)
     {
         $iProfileId = getLoggedId();
-        $iValuePrior = $this->oDb->getParam($this->sParamLogo);
 
         if(!empty($_FILES['image']['tmp_name'])) {
+            $iValuePrior = $this->oDb->getParam($this->sParamLogo);
             $oStorage = BxDolStorage::getObjectInstance('sys_images_custom');
 
             if(!$this->deleteLogo())
@@ -156,29 +172,41 @@ class BxDolStudioDesigner extends BxTemplStudioWidget
             ]);
         }
 
-        $this->oDb->setParam($this->sParamLogoAlt, $oForm->getCleanValue('alt'));
-        return $this->getJsResult('_adm_dsg_scs_save', true, true, bx_append_url_params($this->sManageUrl, array('page' => BX_DOL_STUDIO_DSG_TYPE_LOGO)));
-    }
+        if(!empty($this->sParamMark) && !empty($_FILES['mark']['tmp_name'])) {
+            $iValuePrior = $this->oDb->getParam($this->sParamMark);
+            $oStorage = BxDolStorage::getObjectInstance('sys_images_custom');
 
-    function deleteLogo()
-    {
-        $iProfileId = getLoggedId();
+            if(!$this->deleteMark())
+                return $this->getJsResult('_adm_dsg_err_remove_old_mark');
 
-        $oStorage = BxDolStorage::getObjectInstance('sys_images_custom');
+            $iId = $oStorage->storeFileFromForm($_FILES['mark'], false, $iProfileId);
+            if($iId === false) {
+                $this->oDb->setParam($this->sParamMark, 0);
+                return $this->getJsResult(_t('_adm_dsg_err_save') . $oStorage->getErrorString(), false);
+            }
 
-        $iId = (int)getParam($this->sParamLogo);
-        if($iId != 0 && !$oStorage->deleteFile($iId, $iProfileId))
-            return false;
+            $this->oDb->setParam($this->sParamMark, $iId);
+            $oStorage->afterUploadCleanup($iId, $iProfileId);
 
-        $this->oDb->setParam($this->sParamLogo, 0);
+            bx_alert('system', 'change_mark', 0, 0, [
+                'option' => $this->sParamMark, 
+                'value' => $iId,
+                'value_prior' => $iValuePrior
+            ]);
+        }
 
-        bx_alert('system', 'change_logo', 0, 0, [
-            'option' => $this->sParamLogo, 
-            'value' => 0,
-            'value_prior' => $iId
-        ]);
+        $this->oDb->setParam($this->sParamLogoAlt, $oForm->getCleanValue('alt'));
+        return $this->getJsResult('_adm_dsg_scs_save', true, true, bx_append_url_params($this->sManageUrl, array('page' => BX_DOL_STUDIO_DSG_TYPE_LOGO)));
+    }
 
-        return true;
+    public function deleteLogo()
+    {
+        return $this->_deleteImage('logo');
+    }
+
+    public function deleteMark()
+    {
+        return $this->_deleteImage('mark');
     }
 
     function submitIcon(&$oForm)
@@ -203,7 +231,7 @@ class BxDolStudioDesigner extends BxTemplStudioWidget
         return $this->getJsResult('_adm_dsg_scs_save', true, true, BX_DOL_URL_STUDIO . 'designer.php?page=' . BX_DOL_STUDIO_DSG_TYPE_ICON);
     }
 
-	function submitCover(&$oForm)
+    function submitCover(&$oForm)
     {
         $iProfile = bx_get_logged_profile_id();
         $oStorage = BxDolStorage::getObjectInstance($this->sCoverStorage);
@@ -262,6 +290,27 @@ class BxDolStudioDesigner extends BxTemplStudioWidget
 
         return $this->getJsResult($sResult, true, true, BX_DOL_URL_STUDIO . 'designer.php?page=' . BX_DOL_STUDIO_DSG_TYPE_INJECTIONS);
     }
+
+    protected function _deleteImage($sType)
+    {
+        $iProfileId = getLoggedId();
+        $sParamByType = 'sParam' . ucfirst($sType);
+        $oStorage = BxDolStorage::getObjectInstance('sys_images_custom');
+
+        $iId = (int)getParam($this->$sParamByType);
+        if($iId != 0 && !$oStorage->deleteFile($iId, $iProfileId))
+            return false;
+
+        $this->oDb->setParam($this->$sParamByType, 0);
+
+        bx_alert('system', 'change_' . $sType, 0, 0, [
+            'option' => $this->$sParamByType, 
+            'value' => 0,
+            'value_prior' => $iId
+        ]);
+
+        return true;
+    }
 }
 
 /** @} */

+ 15 - 6
studio/js/designer.js

@@ -55,7 +55,6 @@ BxDolStudioDesigner.prototype.makeDefault = function(sUri) {
 };
 
 BxDolStudioDesigner.prototype.deleteLogo = function() {
-    var $this = this;
     var oDate = new Date();
     var aParams = {_t: oDate.getTime()};
     aParams[this.sParamPrefix + '_action'] = 'delete_logo';
@@ -64,12 +63,22 @@ BxDolStudioDesigner.prototype.deleteLogo = function() {
         this.sActionsUrl,
         aParams,
         function(oData) {
-            if(oData.code != 0 && oData.message.length > 0) {
-                bx_alert(oData.message);
-                return;
-            }
+            processJsonData(oData);
+        },
+        'json'
+    );
+};
 
-            document.location.href = document.location.href; 
+BxDolStudioDesigner.prototype.deleteMark = function() {
+    var oDate = new Date();
+    var aParams = {_t: oDate.getTime()};
+    aParams[this.sParamPrefix + '_action'] = 'delete_mark';
+
+    $.post(
+        this.sActionsUrl,
+        aParams,
+        function(oData) {
+            processJsonData(oData);
         },
         'json'
     );

+ 16 - 1
studio/template/scripts/BxBaseStudioDesigner.php

@@ -130,6 +130,7 @@ class BxBaseStudioDesigner extends BxDolStudioDesigner
 
     protected function getLogo()
     {
+        $sJsObject = $this->getPageJsObject();
         $oTemplate = BxDolStudioTemplate::getInstance();
 
         $aForm = array(
@@ -161,10 +162,19 @@ class BxBaseStudioDesigner extends BxDolStudioDesigner
                     'name' => 'image',
                     'caption' => _t('_adm_dsg_txt_upload_image'),
                     'caption_preview' => _t('_adm_dsg_txt_upload_image_preview'),
-                    'ajax_action_delete' => $this->getPageJsObject() . '.deleteLogo()',
+                    'ajax_action_delete' => $sJsObject . '.deleteLogo()',
                     'storage_object' => 'sys_images_custom',
                     'value' => (int)getParam($this->sParamLogo),
                 ),
+                'mark' => array(
+                    'type' => 'image_uploader',
+                    'name' => 'mark',
+                    'caption' => _t('_adm_dsg_txt_upload_mark'),
+                    'caption_preview' => _t('_adm_dsg_txt_upload_mark_preview'),
+                    'ajax_action_delete' => $sJsObject . '.deleteMark()',
+                    'storage_object' => 'sys_images_custom',
+                    'value' => '',
+                ),
                 'alt' => array(
                     'type' => 'text',
                     'name' => 'alt',
@@ -188,6 +198,11 @@ class BxBaseStudioDesigner extends BxDolStudioDesigner
             )
         );
 
+        if(!empty($this->sParamMark))
+            $aForm['inputs']['mark']['value'] = (int)getParam($this->sParamMark);
+        else
+            unset($aForm['inputs']['mark']);
+
         $oForm = new BxTemplStudioFormView($aForm);
         $oForm->initChecker();
 

+ 9 - 0
template/scripts/BxBaseFunctions.php

@@ -527,6 +527,15 @@ class BxBaseFunctions extends BxDolFactory implements iBxDolSingleton
         return BxDolDesigns::getInstance()->getSiteLogoUrl();
     }
 
+    /**
+     * Get mark URL.
+     * @return string
+     */
+    function getMainMarkUrl()
+    {
+        return BxDolDesigns::getInstance()->getSiteMarkUrl();
+    }
+
     /**
      * Get logo HTML.
      * @return string