Bläddra i källkod

#24 - Manage menu rebuild.

AntonLV 12 år sedan
förälder
incheckning
8b841a2b2c

+ 7 - 6
modules/base/text/classes/BxBaseModTextModule.php

@@ -247,6 +247,12 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
                 $sImage = $oStorage->getFileUrlById($aContentInfo[$CNF['FIELD_THUMB']]);
         }
 
+        $aImages = array();
+        if(!empty($sImage))
+        	$aImages = array(
+				array('url' => $sUrl, 'src' => $sImage)
+			);
+
         //--- Votes
         bx_import('BxDolVote');
         $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $aEvent['object_id']);
@@ -278,12 +284,7 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
                 'url' => $sUrl,
                 'title' => isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...'),
                 'text' => $aContentInfo[$CNF['FIELD_TEXT']],
-                'images' => array(
-                    array(
-                        'url' => $sUrl,
-                        'src' => $sImage
-                    )
-                )
+                'images' => $aImages,
             ), //a string to display or array to parse default template before displaying.
             'votes' => $aVotes,
             'comments' => $aComments,

+ 3 - 1
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -91,7 +91,9 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         $sHtmlPrefix = str_replace('_', '-', $this->_sName);
         $this->_aHtmlIds = array(
             'view' => array(
-                'item_popup' => $sHtmlPrefix . '-item-popup-',
+        		'main' => $sHtmlPrefix,
+        		'item' => $sHtmlPrefix . '-item-',
+                'menu_popup' => $sHtmlPrefix . '-menu-popup-',
                 'photo_popup' => $sHtmlPrefix . '-photo-popup',
             ),
             'post' => array(

+ 16 - 0
modules/boonex/timeline/classes/BxTimelineMenuItem.php

@@ -88,6 +88,22 @@ class BxTimelineMenuItem extends BxTemplMenu
         ));
     }
 
+    public function isVisible()
+    {
+    	if(!isset($this->_aObject['menu_items']))
+			$this->_aObject['menu_items'] = $this->_oQuery->getMenuItems();
+
+    	$bVisible = false;
+    	foreach ($this->_aObject['menu_items'] as $a) {
+    		if((isset($a['active']) && !$a['active']) || (isset($a['visible_for_levels']) && !$this->_isVisible($a)))
+				continue;
+			
+			$bVisible = true;
+			break;
+    	}
+
+    	return $bVisible;
+    }
     /**
      * Check if menu items is visible.
      * @param $a menu item array

+ 13 - 2
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -176,13 +176,13 @@ class BxTimelineModule extends BxBaseModNotificationsModule
         $this->_echoResultJson(array('content' => $sComments));
     }
 
-    public function actionGetPostPopup()
+    public function actionGetManageMenuPopup()
     {
         $iItemId = bx_process_input(bx_get('id'), BX_DATA_INT);
         if(!$iItemId)
             return;
 
-        echo $this->_oTemplate->getViewItemPopup($iItemId);
+        echo $this->getManageMenuObject($iItemId)->getCode();
     }
 
     public function actionAddAttachLink()
@@ -598,6 +598,17 @@ class BxTimelineModule extends BxBaseModNotificationsModule
         return $oVote;
     }
 
+    public function getManageMenuObject($mixedEvent)
+    {
+    	if(!is_array($mixedEvent))
+    		$mixedEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => (int)$mixedEvent));
+
+        bx_import('BxDolMenu');
+        $oMenu = BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_item_manage'));
+        $oMenu->setEvent($mixedEvent);
+        return $oMenu;
+    }
+
     //--- Check permissions methods ---//
     public function isAllowedPost($bPerform = false)
     {

+ 10 - 29
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -57,6 +57,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
 
         return $this->parseHtmlByName('block_view.html', array(
             'style_prefix' => $this->_oConfig->getPrefix('style'),
+        	'html_id' => $this->_oConfig->getHtmlIds('view', 'main'),
             'back' => $sBack,
             'content' => $sContent,
             'load_more' =>  $sLoadMore,
@@ -86,11 +87,6 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         return $sContent;
     }
 
-    public function getItemPopup($iId)
-    {
-        return $this->getItemBlock($iId);
-    }
-
     public function getPost(&$aEvent, $aBrowseParams = array())
     {
         $aResult = $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? $this->_getSystemData($aEvent) : $this->_getCommonData($aEvent);
@@ -438,7 +434,6 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         list($sAuthorName, $sAuthorUrl, $sAuthorIcon) = $oModule->getUserInfo($aEvent['object_owner_id']);
         $bAuthorIcon = !empty($sAuthorIcon);
 
-        $aTmplVarsMenuItemManage = $this->_getTmplVarsMenuItemManage($aEvent, $aBrowseParams);
         $aTmplVarsMenuItemActions = $this->_getTmplVarsMenuItemActions($aEvent, $aBrowseParams);
 
         $aTmplVarsTimelineOwner = array();
@@ -450,11 +445,15 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $aTmplVars = array (
             'style_prefix' => $sStylePrefix,
             'js_object' => $sJsObject,
+        	'html_id' => $this->_oConfig->getHtmlIds('view', 'item') . $aEvent['id'],
             'class' => $bBrowseItem ? 'bx-tl-view-sizer' : 'bx-tl-grid-sizer',
-            'id' => $aEvent['id'],
             'bx_if:show_menu_item_manage' => array(
-                'condition' => !empty($aTmplVarsMenuItemManage),
-                'content' => $aTmplVarsMenuItemManage
+                'condition' => $oModule->getManageMenuObject($aEvent)->isVisible(),
+                'content' => array(
+        			'style_prefix' => $sStylePrefix,
+		            'js_object' => $sJsObject,
+		        	'id' => $aEvent['id'],
+        		)
             ),
             'bx_if:show_icon' => array(
                 'condition' => $bAuthorIcon,
@@ -492,8 +491,8 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         if(!method_exists($this, $sMethod))
             return '';
 
-           $aTmplVars = $this->$sMethod($aContent, $aBrowseParams);
-           return $this->parseHtmlByName('type_' . $sType . '.html', $aTmplVars);
+		$aTmplVars = $this->$sMethod($aContent, $aBrowseParams);
+		return $this->parseHtmlByName('type_' . $sType . '.html', $aTmplVars);
     }
 
     protected function _getComments($aComments)
@@ -533,24 +532,6 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
     	return BxTemplFunctions::getInstance()->transBox($sViewImagePopupId, $sViewImagePopupContent, true);
     }
 
-    protected function _getTmplVarsMenuItemManage(&$aEvent)
-    {
-        bx_import('BxDolMenu');
-        $oMenu = BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_item_manage'));
-        $oMenu->setEvent($aEvent);
-
-        bx_import('BxTemplFunctions');
-        $sMenu = BxTemplFunctions::getInstance()->designBoxMenu($oMenu);
-        if(empty($sMenu))
-            return array();
-
-        return array(
-            'style_prefix' => $this->_oConfig->getPrefix('style'),
-            'js_object' => $this->_oConfig->getJsObject('view'),
-            'menu_item_manage' => $sMenu
-        );
-    }
-
     protected function _getTmplVarsMenuItemActions(&$aEvent)
     {
         bx_import('BxDolMenu');

+ 8 - 11
modules/boonex/timeline/js/view.js

@@ -85,19 +85,16 @@ BxTimelineView.prototype.showMoreContent = function(oLink) {
 	this.reloadMasonry();
 };
 
-BxTimelineView.prototype.showItemMenu = function(oLink) {
-	var sId = $(oLink).parents('.bx-tl-item-menu:first').children('.bx-popup-wrapper:hidden').attr('id');
-	if(sId)
-		bx_menu_popup_inline('#' + sId, oLink);
-};
-
-BxTimelineView.prototype.showItem = function(oLink, iId) {
-    var oData = this._getDefaultData();    
+BxTimelineView.prototype.showManageMenu = function(oLink, iId) {
+	var oData = this._getDefaultData();    
     oData['id'] = iId;
 
-    $(window).dolPopupAjax({
-		id: this._aHtmlIds['item_popup'] + iId,
-		url: bx_append_url_params(this._sActionsUri + 'get_post_popup/', oData)
+    $(this.sIdView).dolPopupAjax({
+		id: this._aHtmlIds['menu_popup'] + iId,
+		url: bx_append_url_params(this._sActionsUri + 'get_manage_menu_popup/', oData),
+		pointer:{
+			el:$(oLink)
+		}
 	});
 
 	return false;

+ 1 - 1
modules/boonex/timeline/template/block_view.html

@@ -1,4 +1,4 @@
-<div id="bx-timeline" class="__style_prefix__-view bx-def-bc-margin">
+<div id="__html_id__" class="__style_prefix__-view bx-def-bc-margin">
 	<div class="__style_prefix__-cnt">
         <div class="__style_prefix__-back-holder">
             __back__

+ 5 - 11
modules/boonex/timeline/template/css/view.css

@@ -44,9 +44,7 @@ div.bx-tl-item-cnt {
 
 /*+++ Item Menu +++*/
 div.bx-tl-item-menu {
-	position: absolute;
-	top: 0px;
-	right: 0px;
+	float: left;
 }
 div.bx-tl-item-menu .bx-menu-ver li {
 	white-space: nowrap;
@@ -60,13 +58,7 @@ div.bx-tl-item-menu-button {
 	line-height: 1.2rem;
 	text-align: center;
 }
-div.bx-tl-item-menu-button a {
-	color: rgba(56, 120, 119, 0.5);
-}
-div.bx-tl-item-menu-button a:hover {
-	text-decoration: none;
-	color: rgba(56, 120, 119, 1.0);
-}
+
 div.bx-tl-item-menu-button i.sys-icon {
 	display: inline-block;
 }
@@ -117,7 +109,9 @@ div.bx-tl-shared div.bx-tl-content {
 }
 
 /*+++ Item Actions +++*/
-div.bx-tl-item-actions {}
+div.bx-tl-item-actions {
+	float: left;
+}
 
 
 /*--- Empty Style ---*/

+ 12 - 11
modules/boonex/timeline/template/item.html

@@ -1,4 +1,4 @@
-<div id="bx-timeline-item-__id__" class="__style_prefix__-item __class__">
+<div id="__html_id__" class="__style_prefix__-item __class__">
 	<div class="__style_prefix__-item-ind bx-def-padding-sec">
 	    <div class="__style_prefix__-item-cnt bx-def-padding bx-def-round-corners bx-def-color-bg-sec">
 	    	<div class="__style_prefix__-item-owner bx-def-margin-bottom"> 
@@ -22,23 +22,24 @@
 						<a class="__style_prefix__-date" href="__item_view_url__">__item_date__</a>
 					</div>
 				</div>
+			</div>
+			__content__
+			<div class="__style_prefix__-activity bx-clearfix">
 				<bx_if:show_menu_item_manage>
-					<div class="__style_prefix__-item-menu">
-						__menu_item_manage__
+					<div class="__style_prefix__-item-menu bx-def-margin-left-auto bx-def-margin-top">
 						<div class="__style_prefix__-item-menu-button bx-def-font-large">
-				   			<a href="javascript:void(0)" onclick="javascript:__js_object__.showItemMenu(this);">
-								<i class="sys-icon chevron-down"></i>
+				   			<a href="javascript:void(0)" onclick="javascript:__js_object__.showManageMenu(this, __id__);">
+								<i class="sys-icon ellipsis-h"></i>
 							</a>
 						</div>
 					</div>
 			   	</bx_if:show_menu_item_manage>
+				<bx_if:show_menu_item_actions>
+					<div class="__style_prefix__-item-actions bx-def-margin-left-auto bx-def-margin-top">
+						__menu_item_actions__
+					</div>
+				</bx_if:show_menu_item_actions>
 			</div>
-			__content__
-			<bx_if:show_menu_item_actions>
-				<div class="__style_prefix__-item-actions bx-def-margin-top">
-					__menu_item_actions__
-				</div>
-			</bx_if:show_menu_item_actions>
 			__comments__
 			__votes__
 		</div>

+ 1 - 1
template/scripts/BxBaseFunctions.php

@@ -229,7 +229,7 @@ class BxBaseFunctions extends BxDol implements iBxDolSingleton
             if ($sMenu) {
                 $sId = 'bx-menu-db-' . time() . rand(0, PHP_INT_MAX);
                 $sCode .= BxTemplFunctions::getInstance()->transBox($sId, '<div class="bx-def-padding bx-def-color-bg-block">' . $sMenu . '</div>', true);
-                $aButtonMenu = array ('icon' => 'reorder', 'onclick' => "bx_menu_popup_inline('#" . $sId . "', this)");
+                $aButtonMenu = array ('icon' => 'ellipsis-h', 'onclick' => "bx_menu_popup_inline('#" . $sId . "', this)");
             }
 
         }