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

#31 - Font icons support in builders.

AntonLV 13 лет назад
Родитель
Сommit
fbb57e6da3

+ 8 - 2
modules/boonex/english/data/langs/system.xml

@@ -1896,8 +1896,14 @@ Please click "Continue" below to navigate to the home page of the site.]]></stri
     <string name="_adm_prm_dsc_level_name"><![CDATA[Short name for the membership level (i.e Premium, Gold, Newcomer, etc.)]]></string>
     <string name="_adm_prm_err_level_name"><![CDATA[You need to enter name(3, 100) for membership level]]></string>
     <string name="_adm_prm_txt_level_icon"><![CDATA[Icon]]></string>
-    <string name="_adm_prm_err_level_icon"><![CDATA[Cannot upload icon: ]]></string>
-    <string name="_adm_prm_err_level_icon_remove"><![CDATA[Cannot remove icon]]></string>
+    <string name="_adm_prm_dsc_level_icon"><![CDATA[You may use font icon here]]></string>
+    <string name="_adm_prm_err_level_icon"><![CDATA[You need to enter font icon name here.]]></string>
+    <string name="_adm_prm_txt_level_icon_image"><![CDATA[]]></string>
+    <string name="_adm_prm_txt_level_icon_image_old"><![CDATA[Current Icon]]></string>
+    <string name="_adm_prm_txt_level_icon_image_new"><![CDATA[]]></string>
+    <string name="_adm_prm_dsc_level_icon_image"><![CDATA[or upload an image.]]></string>    
+    <string name="_adm_prm_err_level_icon_image"><![CDATA[Cannot upload icon: ]]></string>
+    <string name="_adm_prm_err_level_icon_image_remove"><![CDATA[Cannot remove icon]]></string>
     <string name="_adm_prm_txt_level_description"><![CDATA[Description]]></string>
     <string name="_adm_prm_dsc_level_description"><![CDATA[Brief overview of terms and advantages of this level.]]></string>
     <string name="_adm_prm_txt_level_quota_size"><![CDATA[Storage Limit(Mb)]]></string>

+ 7 - 0
studio/js/navigation_items.js

@@ -90,4 +90,11 @@ BxDolStudioNavigationItems.prototype.reloadGrid = function(sModule, sSet) {
 BxDolStudioNavigationItems.prototype.onChangeVisibleFor = function(oSelect) {
 	$('#bx-form-element-visible_for_levels').bx_anim($(oSelect).val() == 'all' ? 'hide' : 'show', this.sAnimationEffect, this.iAnimationSpeed);
 };
+
+BxDolStudioNavigationItems.prototype.onDeleteIcon = function(oData) {
+	if (oData && oData.preview != undefined) {
+		var sPreviewId = $(oData.preview).attr('id');
+		$('#' + sPreviewId).replaceWith(oData.preview);
+	}
+};
 /** @} */

+ 24 - 0
studio/js/permissions_levels.js

@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinStudio Dolphin Studio
+ * @{
+ */
+function BxDolStudioPermissionsLevels(oOptions) {
+	this.sActionsUrl = oOptions.sActionUrl;
+	this.sPageUrl = oOptions.sPageUrl;
+	this.sObjNameGrid = oOptions.sObjNameGrid;
+    this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioPermissionsLevels' : oOptions.sObjName;
+    this.sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
+    this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
+    this.sParamsDivider = oOptions.sParamsDivider == undefined ? '#-#' : oOptions.sParamsDivider;
+}
+
+BxDolStudioPermissionsLevels.prototype.onDeleteIcon = function(oData) {
+	if (oData && oData.preview != undefined) {
+		var sPreviewId = $(oData.preview).attr('id');
+		$('#' + sPreviewId).replaceWith(oData.preview);
+	}
+};
+/** @} */

+ 12 - 14
studio/template/nav_item_icon_preview.html

@@ -1,20 +1,18 @@
-<bx_if:show_icon_empty>
-    <div class="bx-nav-item-icon-preview-empty bx-def-font-small bx-def-color-ft-gray-l3">
-        <bx_text:_adm_nav_dsc_items_icon_image_current />
-    </div>
-</bx_if:show_icon_empty>
-<bx_if:show_icon_image>
-    <div class="bx-nav-item-icon-preview">
+<div id="bx-nav-item-icon-preview-__id__" class="bx-nav-item-icon-preview">
+	<bx_if:show_icon_empty>
+	    <span class="bx-def-font-small bx-def-color-ft-gray-l3">
+	        <bx_text:_adm_nav_dsc_items_icon_image_current />
+	    </span>
+	</bx_if:show_icon_empty>
+	<bx_if:show_icon_image>
         <img src="__url__" />
         <p>
-            <button class="bx_btn" bx_grid_action_single="delete_icon" bx_grid_action_data="__id__">
+            <button type="button" class="bx_btn" bx_grid_action_single="delete_icon" bx_grid_action_data="__id__">
                 <bx_text:_adm_nav_btn_current_icon_image_delete />
             </button>
         </p>
-    </div>
-</bx_if:show_icon_image>
-<bx_if:show_icon_font>
-	<div class="bx-nav-item-icon-preview">
+	</bx_if:show_icon_image>
+	<bx_if:show_icon_font>
 		<i class="sys-icon __icon__"></i>
-	</div>
-</bx_if:show_icon_font>
+	</bx_if:show_icon_font>
+</div>

+ 3 - 0
studio/template/prm_add_level.html

@@ -3,6 +3,9 @@
         __form__
         <script type="text/javascript">
             $(document).ready(function () {
+            	if($("[bx_grid_action_single = 'delete_icon']").length > 0)
+            	    glGrids.__object__._bindActionsSingle($("#__form_id__"));
+
                 $("#__form_id__").ajaxForm({ 
                     dataType: "json",
                     beforeSubmit: function (formData, jqForm, options) {

+ 18 - 0
studio/template/prm_level_icon_preview.html

@@ -0,0 +1,18 @@
+<div id="bx-nav-item-icon-preview-__id__" class="bx-nav-item-icon-preview">
+	<bx_if:show_icon_empty>
+	    <span class="bx-def-font-small bx-def-color-ft-gray-l3">
+	        <bx_text:_adm_nav_dsc_items_icon_image_current />
+	    </span>
+	</bx_if:show_icon_empty>
+	<bx_if:show_icon_image>
+        <img src="__url__" />
+        <p>
+            <button type="button" class="bx_btn" bx_grid_action_single="delete_icon" bx_grid_action_data="__id__">
+                <bx_text:_adm_nav_btn_current_icon_image_delete />
+            </button>
+        </p>
+	</bx_if:show_icon_image>
+	<bx_if:show_icon_font>
+		<i class="sys-icon __icon__"></i>
+	</bx_if:show_icon_font>
+</div>

+ 10 - 0
studio/template/prm_levels.html

@@ -0,0 +1,10 @@
+__content__
+<script type="text/javascript">
+    var __js_object__ = new BxDolStudioPermissionsLevels({
+        sActionUrl: '<bx_url_root />grid.php',
+        sPageUrl: '__page_url__',
+        sObjNameGrid: '__grid_object__',
+        sParamsDivider: '__params_divider__',
+        sTextSearchInput: '<bx_text_js:_sys_grid_search />'
+    });
+</script>

+ 62 - 47
studio/template/scripts/BxBaseStudioNavigationItems.php

@@ -210,7 +210,6 @@ class BxBaseStudioNavigationItems extends BxDolStudioNavigationItems {
         $oForm->initChecker();
 
         if($oForm->isSubmittedAndValid()) {
-            $mixedIcon = '';
             if(!empty($_FILES['icon_image']['tmp_name'])) {
                 bx_import('BxDolStorage');
                 $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
@@ -222,12 +221,8 @@ class BxBaseStudioNavigationItems extends BxDolStudioNavigationItems {
                 }
 
                 $oStorage->afterUploadCleanup($mixedIcon, 0);
-            }
-
-            if(empty($mixedIcon))
-            	$mixedIcon = $oForm->getCleanValue('icon');
-
-			BxDolForm::setSubmittedValue('icon', $mixedIcon, $aForm['form_attrs']['method']);
+                BxDolForm::setSubmittedValue('icon', $mixedIcon, $aForm['form_attrs']['method']);
+            }		
 
             bx_import('BxDolPermalinks');
             $oPermalinks = BxDolPermalinks::getInstance();
@@ -480,7 +475,7 @@ class BxBaseStudioNavigationItems extends BxDolStudioNavigationItems {
 
         $sIconImage = $sIconFont = "";
         if(!empty($aItem['icon'])) {
-            if((int)$aItem['icon'] != 0) {
+            if(is_numeric($aItem['icon']) && (int)$aItem['icon'] != 0) {
                 bx_import('BxDolStorage');
                 $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
 
@@ -492,54 +487,45 @@ class BxBaseStudioNavigationItems extends BxDolStudioNavigationItems {
             }
         }
 
-        $bIconImage = !empty($sIconImage);
-		$bIconFont = !empty($sIconFont);
-        $aTmplVars = array(
-            'bx_if:show_icon_empty' => array(
-                'condition' => !$bIconImage && !$bIconFont,
-                'content' => array()
-            ),
-            'bx_if:show_icon_image' => array(
-                'condition' => $bIconImage,
-                'content' => array(
-            		'js_object' => $this->getJsObject(),
-                    'url' => $sIconImage,
-					'id' => $aItem['id']
-            	)
-            ),
-            'bx_if:show_icon_font' => array(
-                'condition' => $bIconFont,
-                'content' => array(
-            		'icon' => $sIconFont
-            	)
-            )
-        );
-
-        $aForm['inputs']['icon_preview']['content'] = $this->_oTemplate->parseHtmlByName('nav_item_icon_preview.html', $aTmplVars);
+        $aForm['inputs']['icon_preview']['content'] = $this->_getIconPreview($aItem['id'], $sIconImage, $sIconFont);
 
         $oForm = new BxTemplStudioFormView($aForm);
         $oForm->initChecker();
 
         if($oForm->isSubmittedAndValid()) {
-            $mixedIcon = 0;
-            if(!empty($_FILES['icon_image']['tmp_name'])) {
-                bx_import('BxDolStorage');
+        	$bIconImageCur = is_numeric($aItem['icon']) && (int)$aItem['icon'] != 0;
+        	$bIconImageNew = !empty($_FILES['icon_image']['tmp_name']);
+
+        	$sIconFont = $oForm->getCleanValue('icon');
+        	$bIconFont = !empty($sIconFont);
+
+			if($bIconImageCur && ($bIconImageNew || $bIconFont)) {
+				bx_import('BxDolStorage');
                 $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
-    
-                if(is_numeric($aItem['icon']) && (int)$aItem['icon'] != 0 && !$oStorage->deleteFile((int)$aItem['icon'], 0)) {
+                if(!$oStorage->deleteFile((int)$aItem['icon'], 0)) {
                     $this->_echoResultJson(array('msg' => _t('_adm_nav_err_items_icon_image_remove')), true);
                     return;
                 }
+			}
 
-                if(($mixedIcon = $oStorage->storeFileFromForm($_FILES['icon_image'], false, 0)) === false) {
+			$sIcon = $sIconFont;
+        	if($bIconImageNew) {
+        		bx_import('BxDolStorage');
+                $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
+        		$sIcon = $oStorage->storeFileFromForm($_FILES['icon_image'], false, 0);
+                if($sIcon === false) {
                     $this->_echoResultJson(array('msg' => _t('_adm_nav_err_items_icon_image') . $oStorage->getErrorString()), true);
                     return;
                 }
 
-                $oStorage->afterUploadCleanup($mixedIcon, 0);
-            }
+                $oStorage->afterUploadCleanup($sIcon, 0);
+        	}
+        	else if($bIconImageCur && !$bIconFont)
+        		$sIcon = $aItem['icon'];
 
-            bx_import('BxDolPermalinks');
+			BxDolForm::setSubmittedValue('icon', $sIcon, $aForm['form_attrs']['method']);
+
+			bx_import('BxDolPermalinks');
             $sLink = $oForm->getCleanValue('link');
             $sLink = BxDolPermalinks::getInstance()->unpermalink($sLink);
             BxDolForm::setSubmittedValue('link', $sLink, $aForm['form_attrs']['method']);
@@ -560,7 +546,7 @@ class BxBaseStudioNavigationItems extends BxDolStudioNavigationItems {
             if($sTarget === false && !in_array($aItem['target'], array('', '_blank'))) 
                 unset($oForm->aInputs['target']);
 
-            if($oForm->update($iId, (int)$mixedIcon != 0 ? array('icon' => $mixedIcon) : array()) !== false)
+            if($oForm->update($iId) !== false)
                 $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
             else
                 $aRes = array('msg' => _t('_adm_nav_err_items_edit'));
@@ -740,11 +726,13 @@ class BxBaseStudioNavigationItems extends BxDolStudioNavigationItems {
         $sAction = 'delete_icon';
 
         $aIds = bx_get('ids');
-        if(!isset($aIds[0]) || ($iId = (int)$aIds[0]) == 0) {
+        if(empty($aIds[0])) {
             $this->_echoResultJson(array());
             exit;
         }
 
+        $iId = (int)$aIds[0];
+
         $aItem = array();
         $iItem = $this->oDb->getItems(array('type' => 'by_id', 'value' => $iId), $aItem);
         if($iItem != 1 || empty($aItem)){
@@ -761,14 +749,14 @@ class BxBaseStudioNavigationItems extends BxDolStudioNavigationItems {
         }
 
         if($this->oDb->updateItem($aItem['id'], array('icon' => '')) !== false)
-            $this->performActionEdit(true);
+            $this->_echoResultJson(array('grid' => $this->getCode(false), 'blink' => $iId, 'preview' => $this->_getIconPreview($aItem['id']), 'eval' => $this->getJsObject() . ".onDeleteIcon(oData)"), true);
     }
 
-    function getJsObject() {
+    public function getJsObject() {
         return 'oBxDolStudioNavigationItems';
     }
 
-    function getSetsSelector($sModule = '') {
+    public function getSetsSelector($sModule = '') {
         bx_import('BxTemplStudioFormView');
         $oForm = new BxTemplStudioFormView(array());
 
@@ -802,7 +790,7 @@ class BxBaseStudioNavigationItems extends BxDolStudioNavigationItems {
         return $oForm->genRow($aInputSets);
     }
 
-    function getCode($isDisplayHeader = true) {
+    public function getCode($isDisplayHeader = true) {
         return $this->_oTemplate->parseHtmlByName('nav_items.html', array(
             'content' => parent::getCode($isDisplayHeader),
             'js_object' => $this->getJsObject(),
@@ -948,5 +936,32 @@ class BxBaseStudioNavigationItems extends BxDolStudioNavigationItems {
 
         return $sContent;
     }
+
+    protected function _getIconPreview($iId, $sIconImage = '', $sIconFont = '') {
+    	$bIconImage = !empty($sIconImage);
+		$bIconFont = !empty($sIconFont);
+
+        return $this->_oTemplate->parseHtmlByName('nav_item_icon_preview.html', array(
+        	'id' => $iId,
+            'bx_if:show_icon_empty' => array(
+                'condition' => !$bIconImage && !$bIconFont,
+                'content' => array()
+            ),
+            'bx_if:show_icon_image' => array(
+                'condition' => $bIconImage,
+                'content' => array(
+            		'js_object' => $this->getJsObject(),
+                    'url' => $sIconImage,
+					'id' => $iId
+            	)
+            ),
+            'bx_if:show_icon_font' => array(
+                'condition' => $bIconFont,
+                'content' => array(
+            		'icon' => $sIconFont
+            	)
+            )
+        ));
+    }
 }
 /** @} */

+ 174 - 21
studio/template/scripts/BxBaseStudioPermissionsLevels.php

@@ -15,12 +15,17 @@ bx_import('BxTemplStudioFormView');
 class BxBaseStudioPermissionsLevels extends BxDolStudioPermissionsLevels {
     public static $iBinMB = 1048576;
 
+    protected $sUrlPage;
+
     function __construct($aOptions, $oTemplate = false) {
         parent::__construct($aOptions, $oTemplate);
 
         $this->_aOptions['actions_single']['edit']['attr']['title'] = _t('_adm_prm_btn_level_edit');
         $this->_aOptions['actions_single']['delete']['attr']['title'] = _t('_adm_prm_btn_level_delete');
+
+        $this->sUrlPage = BX_DOL_URL_STUDIO . 'builder_permissions.php?page=levels';
     }
+
     public function performActionAdd() {
         $sAction = 'add';
 
@@ -140,16 +145,33 @@ class BxBaseStudioPermissionsLevels extends BxDolStudioPermissionsLevels {
                     ),
                 ),
                 'Icon' => array(
-                    'type' => 'file',
+                    'type' => 'text',
                     'name' => 'Icon',
                     'caption' => _t('_adm_prm_txt_level_icon'),
+                    'info' => _t('_adm_prm_dsc_level_icon'),
                     'value' => '',
+                    'required' => '0',
+                    'db' => array (
+                        'pass' => 'Xss',
+                    ),
                     'checker' => array (
                         'func' => '',
-                        'params' => '',
+                        'params' => array(),
                         'error' => _t('_adm_prm_err_level_icon'),
                     ),
                 ),
+                'Icon_image' => array(
+                    'type' => 'file',
+                    'name' => 'Icon_image',
+                    'caption' => _t('_adm_prm_txt_level_icon_image'),
+                	'info' => _t('_adm_prm_dsc_level_icon_image'),
+                    'value' => '',
+                    'checker' => array (
+                        'func' => '',
+                        'params' => '',
+                        'error' => _t('_adm_prm_err_level_icon_image'),
+                    ),
+                ),
                 'controls' => array(
                     'name' => 'controls', 
                     'type' => 'input_set',
@@ -180,20 +202,28 @@ class BxBaseStudioPermissionsLevels extends BxDolStudioPermissionsLevels {
                 return;
             }
 
-            $mixedIcon = 'acl-unconfirmed.png';
-            if(!empty($_FILES['Icon']['tmp_name'])) {
+            $mixedIcon = '';
+            if(!empty($_FILES['Icon_image']['tmp_name'])) {
                 bx_import('BxDolStorage');
                 $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
     
-                $mixedIcon = $oStorage->storeFileFromForm($_FILES['Icon'], false, 0); 
+                $mixedIcon = $oStorage->storeFileFromForm($_FILES['Icon_image'], false, 0); 
                 if($mixedIcon === false) {
-                    $this->_echoResultJson(array('msg' => _t('_adm_prm_err_level_icon') . $oStorage->getErrorString()), true);
+                    $this->_echoResultJson(array('msg' => _t('_adm_prm_err_level_icon_image') . $oStorage->getErrorString()), true);
                     return;
                 }
 
                 $oStorage->afterUploadCleanup($mixedIcon, 0);
             }
 
+            if(empty($mixedIcon))
+            	$mixedIcon = $oForm->getCleanValue('Icon');
+
+			if(empty($mixedIcon))
+				$mixedIcon = 'acl-unconfirmed.png';
+
+			BxDolForm::setSubmittedValue('Icon', $mixedIcon, $aForm['form_attrs']['method']);
+
             $fQuotaSize = round($oForm->getCleanValue('QuotaSize'), 1);
             BxDolForm::setSubmittedValue('QuotaSize', self::$iBinMB * $fQuotaSize, $aForm['form_attrs']['method']);
 
@@ -328,16 +358,39 @@ class BxBaseStudioPermissionsLevels extends BxDolStudioPermissionsLevels {
                     ),
                 ),
                 'Icon' => array(
-                    'type' => 'file',
+                    'type' => 'text',
                     'name' => 'Icon',
                     'caption' => _t('_adm_prm_txt_level_icon'),
+                    'info' => _t('_adm_prm_dsc_level_icon'),
                     'value' => '',
+                    'required' => '0',
+                    'db' => array (
+                        'pass' => 'Xss',
+                    ),
                     'checker' => array (
                         'func' => '',
-                        'params' => '',
+                        'params' => array(),
                         'error' => _t('_adm_prm_err_level_icon'),
                     ),
                 ),
+                'Icon_image' => array(
+                    'type' => 'file',
+                    'name' => 'Icon_image',
+                    'caption' => _t('_adm_prm_txt_level_icon_image_new'),
+                	'info' => _t('_adm_prm_dsc_level_icon_image'),
+                    'value' => '',
+                    'checker' => array (
+                        'func' => '',
+                        'params' => '',
+                        'error' => _t('_adm_prm_err_level_icon_image'),
+                    ),
+                ),
+                'Icon_preview' => array(
+                    'type' => 'custom',
+                    'name' => 'Icon_preview',
+                	'caption' => _t('_adm_prm_txt_level_icon_image_old'),
+                    'content' => ''
+                ),
                 'controls' => array(
                     'name' => 'controls', 
                     'type' => 'input_set',
@@ -359,29 +412,58 @@ class BxBaseStudioPermissionsLevels extends BxDolStudioPermissionsLevels {
             )
         );
 
+        $sIconImage = $sIconFont = "";
+        if(!empty($aLevel['icon'])) {
+            if(is_numeric($aLevel['icon']) && (int)$aLevel['icon'] != 0) {
+                bx_import('BxDolStorage');
+                $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
+
+                $sIconImage = $oStorage->getFileUrlById((int)$aLevel['icon']);
+            }
+            else {
+                $sIconFont = $aLevel['icon'];
+                $aForm['inputs']['Icon']['value'] = $sIconFont;
+            }
+        }
+
+        $aForm['inputs']['Icon_preview']['content'] = $this->_getIconPreview($aLevel['id'], $sIconImage, $sIconFont);
+
         bx_import('BxTemplStudioFormView');
         $oForm = new BxTemplStudioFormView($aForm);
         $oForm->initChecker();
 
         if($oForm->isSubmittedAndValid()) {
-            $mixedIcon = 0;
-            if(!empty($_FILES['Icon']['tmp_name'])) {
-                bx_import('BxDolStorage');
-                $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
+        	$bIconImageCur = is_numeric($aLevel['icon']) && (int)$aLevel['icon'] != 0;
+        	$bIconImageNew = !empty($_FILES['Icon_image']['tmp_name']);
+
+        	$sIconFont = $oForm->getCleanValue('Icon');
+        	$bIconFont = !empty($sIconFont);
 
-                if(is_numeric($aLevel['icon']) && (int)$aLevel['icon'] != 0 && !$oStorage->deleteFile((int)$aLevel['icon'], 0)) {
-                    $this->_echoResultJson(array('msg' => _t('_adm_prm_err_level_icon_remove')), true);
+			if($bIconImageCur && ($bIconImageNew || $bIconFont)) {
+				bx_import('BxDolStorage');
+                $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
+                if(!$oStorage->deleteFile((int)$aLevel['icon'], 0)) {
+                    $this->_echoResultJson(array('msg' => _t('_adm_prm_err_level_icon_image_remove')), true);
                     return;
                 }
+			}
 
-                $mixedIcon = $oStorage->storeFileFromForm($_FILES['Icon'], false, 0); 
-                if($mixedIcon === false) {
-                    $this->_echoResultJson(array('msg' => _t('_adm_prm_err_level_icon') . $oStorage->getErrorString()), true);
+			$sIcon = $sIconFont;
+        	if($bIconImageNew) {
+        		bx_import('BxDolStorage');
+                $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
+        		$sIcon = $oStorage->storeFileFromForm($_FILES['Icon_image'], false, 0);
+                if($sIcon === false) {
+                    $this->_echoResultJson(array('msg' => _t('_adm_prm_err_level_icon_image') . $oStorage->getErrorString()), true);
                     return;
                 }
 
-                $oStorage->afterUploadCleanup($mixedIcon, 0);
-            }
+                $oStorage->afterUploadCleanup($sIcon, 0);
+        	}
+        	else if($bIconImageCur && !$bIconFont)
+        		$sIcon = $aLevel['icon'];
+
+			BxDolForm::setSubmittedValue('Icon', $sIcon, $aForm['form_attrs']['method']);
 
             $fQuotaSize = round($oForm->getCleanValue('QuotaSize'), 1);
             BxDolForm::setSubmittedValue('QuotaSize', self::$iBinMB * $fQuotaSize, $aForm['form_attrs']['method']);
@@ -389,7 +471,7 @@ class BxBaseStudioPermissionsLevels extends BxDolStudioPermissionsLevels {
             $fQuotaMaxFileSize = round($oForm->getCleanValue('QuotaMaxFileSize'), 1);
             BxDolForm::setSubmittedValue('QuotaMaxFileSize', self::$iBinMB * $fQuotaMaxFileSize, $aForm['form_attrs']['method']);
 
-            if($oForm->update($iId, (int)$mixedIcon != 0 ? array('Icon' => $mixedIcon) : array()) !== false)
+            if($oForm->update($iId) !== false)
                 $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
             else
                 $aRes = array('msg' => _t('_adm_prm_err_level_edit'));
@@ -429,9 +511,53 @@ class BxBaseStudioPermissionsLevels extends BxDolStudioPermissionsLevels {
         $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t('_adm_prm_err_level_delete')));
     }
 
+    public function performActionDeleteIcon() {
+        $sAction = 'delete_icon';
+
+        $aIds = bx_get('ids');
+        if(empty($aIds[0])) {
+            $this->_echoResultJson(array());
+            exit;
+        }
+
+        $iId = (int)$aIds[0];
+
+        $aLevel = array();
+        $iLevel = $this->oDb->getLevels(array('type' => 'by_id', 'value' => $iId), $aLevel);
+        if($iLevel != 1 || empty($aLevel)){
+            $this->_echoResultJson(array());
+            exit;
+        }
+
+        if(is_numeric($aLevel['icon']) && (int)$aLevel['icon'] != 0) {
+            bx_import('BxDolStorage');
+            if(!BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES)->deleteFile((int)$aLevel['icon'], 0)) {
+                $this->_echoResultJson(array());
+                exit;
+            }
+        }
+
+        if($this->oDb->updateLevels($aLevel['id'], array('icon' => '')) !== false)
+            $this->_echoResultJson(array('grid' => $this->getCode(false), 'blink' => $iId, 'preview' => $this->_getIconPreview($aLevel['id']), 'eval' => $this->getJsObject() . ".onDeleteIcon(oData)"), true);
+    }
+
+	public function getJsObject() {
+        return 'oBxDolStudioPermissionsLevels';
+    }
+
+	public function getCode($isDisplayHeader = true) {
+        return $this->_oTemplate->parseHtmlByName('prm_levels.html', array(
+            'content' => parent::getCode($isDisplayHeader),
+            'js_object' => $this->getJsObject(),
+        	'page_url' => $this->sUrlPage,
+            'grid_object' => $this->_sObject,
+            'params_divider' => $this->sParamsDivider
+        ));
+    }
+
     protected function _addJsCss() {
         parent::_addJsCss();
-        $this->_oTemplate->addJs(array('jquery.form.js'));
+        $this->_oTemplate->addJs(array('jquery.form.js', 'permissions_levels.js'));
 
         bx_import('BxTemplStudioFormView');
         $oForm = new BxTemplStudioFormView(array());
@@ -482,6 +608,33 @@ class BxBaseStudioPermissionsLevels extends BxDolStudioPermissionsLevels {
         return  parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
     }
 
+	protected function _getIconPreview($iId, $sIconImage = '', $sIconFont = '') {
+    	$bIconImage = !empty($sIconImage);
+		$bIconFont = !empty($sIconFont);
+
+        return $this->_oTemplate->parseHtmlByName('prm_level_icon_preview.html', array(
+        	'id' => $iId,
+            'bx_if:show_icon_empty' => array(
+                'condition' => !$bIconImage && !$bIconFont,
+                'content' => array()
+            ),
+            'bx_if:show_icon_image' => array(
+                'condition' => $bIconImage,
+                'content' => array(
+            		'js_object' => $this->getJsObject(),
+                    'url' => $sIconImage,
+					'id' => $iId
+            	)
+            ),
+            'bx_if:show_icon_font' => array(
+                'condition' => $bIconFont,
+                'content' => array(
+            		'icon' => $sIconFont
+            	)
+            )
+        ));
+    }
+
     protected function getAvailableId() {
         $aLevels = array();
         $this->oDb->getLevels(array('type' =>'all_order_id'), $aLevels, false);

+ 1 - 3
template/css/common.css

@@ -113,8 +113,6 @@ blockquote {
 
     border-bottom: 2px solid #383d66;
 
-    background-image: url(../images/bg-toolbar.png);
-    background-repeat: repeat-x;
     background-color:#0764a7;
 }
 
@@ -124,8 +122,8 @@ blockquote {
 
 .bx-popup-header h2 {
     margin:0;
-    text-shadow: #000 0px 1px 2px;
     text-align:center;
+    color:#FFFFFF;
 }
 
 .bx-popup-box-pointer {