Bläddra i källkod

Ticket #2229 - Remove from history.

AntonLV 7 år sedan
förälder
incheckning
e0c05581fe

+ 43 - 1
studio/classes/BxDolStudioMenuTop.php

@@ -72,7 +72,7 @@ class BxDolStudioMenuTop extends BxDol
             )
         );
 
-        $aHistory = BxDolSession::getInstance()->getValue(self::$sHistorySessionKey);
+        $aHistory = self::historyGetList();
         if(!empty($aHistory) && is_array($aHistory))
             $this->aItems[BX_DOL_STUDIO_MT_LEFT]['menu_items'] = bx_array_insert_before(array_reverse($aHistory), $this->aItems[BX_DOL_STUDIO_MT_LEFT]['menu_items'], 'site');
 
@@ -112,6 +112,48 @@ class BxDolStudioMenuTop extends BxDol
         );
     }
 
+    public static function historyGetList()
+    {
+        return BxDolSession::getInstance()->getValue(self::$sHistorySessionKey);
+    }
+    
+    public static function historyAdd($aPage)
+    {
+        $oSession = BxDolSession::getInstance();
+        $aHistory = $oSession->getValue(self::$sHistorySessionKey);
+        if(!empty($aHistory) && isset($aHistory[$aPage['name']]))
+            return;
+
+        $aHistory[$aPage['name']] = array(
+            'name' => $aPage['name'],
+            'icon' => $aPage['wid_icon'],
+            'link' => $aPage['wid_url'],
+            'onclick' => $aPage['wid_click'],
+            'title' => $aPage['wid_caption']
+        );
+        if(count($aHistory) > BxTemplStudioMenuTop::$iHistoryLength)
+            $aHistory = array_slice($aHistory, -BxTemplStudioMenuTop::$iHistoryLength);
+        $oSession->setValue(self::$sHistorySessionKey, $aHistory);
+    }
+
+    public static function historyDelete($mixedPage)
+    {
+        if(is_array($mixedPage)) {
+            if(!isset($mixedPage['name']))
+                return;
+
+            $mixedPage = $mixedPage['name'];
+        }
+
+        $oSession = BxDolSession::getInstance();
+        $aHistory = $oSession->getValue(self::$sHistorySessionKey);
+        if(empty($aHistory) || !isset($aHistory[$mixedPage]))
+            return;
+
+        unset($aHistory[$mixedPage]);
+        $oSession->setValue(self::$sHistorySessionKey, $aHistory);
+    }
+
     public function setContent($sPosition, $mixedContent)
     {
         $this->aItems[$sPosition] = $mixedContent;

+ 3 - 0
studio/classes/BxDolStudioModules.php

@@ -60,6 +60,9 @@ class BxDolStudioModules extends BxDol
                     $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'uninstall', array('html_response' => true));
                     if(!empty($aResult['message']))
                         $aResult['message'] = $this->getPopupResult($aResult['message']);
+
+                    if($aResult['code'] == BX_DOL_STUDIO_IU_RC_SUCCESS)
+                        BxTemplStudioMenuTop::historyDelete($sPageName);
                     break;
             }
 

+ 2 - 19
studio/classes/BxDolStudioPage.php

@@ -152,30 +152,13 @@ class BxDolStudioPage extends BxDol
     {
         return BxDolStudioUtils::getModules($bShowCustom, $bShowSystem);
     }
-    
+
     protected function updateHistory()
     {
         if(empty($this->aPage['wid_id'])) 
             return;
 
-        $sHistorySessionKey = BxTemplStudioMenuTop::$sHistorySessionKey;
-        $iHistoryLength = BxTemplStudioMenuTop::$iHistoryLength;
-
-        $oSession = BxDolSession::getInstance();
-        $aHistory = $oSession->getValue($sHistorySessionKey);
-        if(!empty($aHistory) && isset($aHistory[$this->aPage['name']]))
-            return;
-
-        $aHistory[$this->aPage['name']] = array(
-            'name' => $this->aPage['name'],
-            'icon' => $this->aPage['wid_icon'],
-            'link' => $this->aPage['wid_url'],
-            'onclick' => $this->aPage['wid_click'],
-            'title' => $this->aPage['wid_caption']
-        );
-        if(count($aHistory) > $iHistoryLength)
-            $aHistory = array_slice($aHistory, -$iHistoryLength);
-        $oSession->setValue($sHistorySessionKey, $aHistory);
+        BxTemplStudioMenuTop::historyAdd($this->aPage);
     }
 }
 

+ 26 - 22
studio/js/modules.js

@@ -6,50 +6,54 @@
  * @{
  */
 function BxDolStudioModules(oOptions) {
-	this.sActionsUrl = oOptions.sActionUrl;
+    this.sActionsUrl = oOptions.sActionUrl;
     this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioModules' : oOptions.sObjName;
     this.sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
     this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
 }
 
 BxDolStudioModules.prototype.uninstall = function(iId, sValue, iConfirm) {
-	var $this = this;
-	var oDate = new Date();
-	var sAction = 'uninstall'; 
+    var $this = this;
+    var oDate = new Date();
+    var sAction = 'uninstall'; 
 
-	if(!sValue)
+    if(!sValue)
         return false;
 
-	$('.bx-popup-applied:visible').dolPopupHide();
+    $('.bx-popup-applied:visible').dolPopupHide();
 
-	$.post(
+    $.post(
     	sUrlStudio + 'modules.php',
     	{
-    		mod_action: sAction,
-    		mod_page_name: sValue,
-    		mod_widget_id: iId,
-    		mod_confirmed: parseInt(iConfirm),
-    		_t:oDate.getTime()
+            mod_action: sAction,
+            mod_page_name: sValue,
+            mod_widget_id: iId,
+            mod_confirmed: parseInt(iConfirm),
+            _t:oDate.getTime()
     	},
     	function (oData) {
-    		if(oData.message.length > 0)
-    			$this.popup(sAction, oData.message);
-
-    		if(oData.code == 0) {
-    			$('#bx-std-widget-' + iId).bx_anim('hide', $this.sAnimationEffect, $this.iAnimationSpeed, function() {
-    				$(this).remove();
-    			});
-    		}
+            if(oData.message.length > 0)
+                $this.popup(sAction, oData.message);
+
+            if(oData.code == 0) {
+                $('#bx-menu-item-' + sValue).bx_anim('hide', $this.sAnimationEffect, $this.iAnimationSpeed, function() {
+                    $(this).remove();
+                });
+
+                $('#bx-std-widget-' + iId).bx_anim('hide', $this.sAnimationEffect, $this.iAnimationSpeed, function() {
+                    $(this).remove();
+                });
+            }
     	},
     	'json'
     );
 };
 
 BxDolStudioModules.prototype.popup = function(sType, sValue) {
-	var sId = 'bx-std-mod-popup-' + sType;
+    var sId = 'bx-std-mod-popup-' + sType;
 
     $('#' + sId).remove();
     $('<div id="' + sId + '" style="display: none;"></div>').prependTo('body').html(sValue);
     $('#' + sId).dolPopup({});
 };
-/** @} */
+/** @} */

+ 1 - 1
studio/template/menu_floating_blocks.html

@@ -1,5 +1,5 @@
 <ul class="bx-menu-floating-blocks bx-menu-object-__object__ bx-clearfix">
-    <bx_repeat:menu_items><li class="bx-def-color-bg-hl-hover bx-def-box-sizing __class_add__">
+    <bx_repeat:menu_items><li id="bx-menu-item-__name__" class="bx-def-color-bg-hl-hover bx-def-box-sizing __class_add__">
         <a href="__link__" target="__target__" onclick="__onclick__" title="__title_attr__">
             <bx_if:icon><i class="sys-icon __icon__"></i></bx_if:icon>
             <bx_if:image><img style="background-image:url(__icon_url__)" src="<bx_icon_url:spacer.gif />" /></bx_if:image>