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

+ 36 - 60
modules/boonex/timeline/classes/BxTimelineMenuItem.php

@@ -35,36 +35,54 @@ class BxTimelineMenuItem extends BxTemplMenu {
 
 
     	$this->_aEvent = $aEvent;
     	$this->_aEvent = $aEvent;
 
 
-    	$sVotesOnclick = '';
-    	if(isset($aEvent['votes']) && is_array($aEvent['votes']) && isset($aEvent['votes']['system']))
-    		$sVotesOnclick = $this->_oModule->getVoteObject($aEvent['votes']['system'], $aEvent['votes']['object_id'])->getJsClick();
-
-    	$sCommentsSystem = '';
-    	if(isset($aEvent['comments']) && is_array($aEvent['comments']) && isset($aEvent['comments']['system']))
+    	$iVotesObject = 0;
+    	$sVotesSystem = $sVotesOnclick = '';
+    	if(isset($aEvent['votes']) && is_array($aEvent['votes']) && isset($aEvent['votes']['system'])) {
+    		$sVotesSystem = $aEvent['votes']['system'];
+    		$iVotesObject = $aEvent['votes']['object_id'];
+    		$sVotesOnclick = $this->_oModule->getVoteObject($sVotesSystem, $iVotesObject)->getJsClick();
+    	}
+
+    	$iCommentsObject = 0; 
+    	$sCommentsSystem = $sCommentsOnclick = '';
+    	if(isset($aEvent['comments']) && is_array($aEvent['comments']) && isset($aEvent['comments']['system'])) {
     		$sCommentsSystem = $aEvent['comments']['system'];
     		$sCommentsSystem = $aEvent['comments']['system'];
+    		$iCommentsObject = $aEvent['comments']['object_id'];
+    		$sCommentsOnclick = $this->_oModule->_oConfig->getJsObject('view') . ".commentItem(this, '" . $sCommentsSystem . "', " . $iCommentsObject . ")";
+    	}
 
 
     	$iOwnerId = $this->_oModule->getUserId(); //--- in whose timeline the content will be shared
     	$iOwnerId = $this->_oModule->getUserId(); //--- in whose timeline the content will be shared
-		$sType = $aEvent['type'];
-		$sAction = $aEvent['action'];
+		$sShareType = $sReshareType = $aEvent['type'];
+		$sShareAction = $sReshareAction = $aEvent['action'];
 
 
-		if($this->_oModule->_oConfig->isSystem($sType, $sAction))
-			$iObjectId = $aEvent['object_id'];
+		if($this->_oModule->_oConfig->isSystem($sShareType, $sShareAction))
+			$iShareObject = $iReshareObject = $aEvent['object_id'];
 		else {
 		else {
-			$iObjectId = $aEvent['id'];
+			$iShareObject = $iReshareObject = $aEvent['id'];
 
 
 			$sCommonPrefix = $this->_oModule->_oConfig->getPrefix('common_post');
 			$sCommonPrefix = $this->_oModule->_oConfig->getPrefix('common_post');
-			if(str_replace($sCommonPrefix, '', $sType) == BX_TIMELINE_PARSE_TYPE_SHARE) {
-				$sType = $aEvent['content']['type'];
-				$sAction = $aEvent['content']['action'];
-				$iObjectId = $aEvent['content']['object_id'];
+			if(str_replace($sCommonPrefix, '', $sShareType) == BX_TIMELINE_PARSE_TYPE_SHARE) {
+				$sReshareType = $aEvent['content']['type'];
+				$sReshareAction = $aEvent['content']['action'];
+				$iReshareObject = $aEvent['content']['object_id'];
 			}
 			}
 		}
 		}
 
 
     	$this->addMarkers(array(
     	$this->addMarkers(array(
     		'content_id' => $aEvent['id'],
     		'content_id' => $aEvent['id'],
-    		'comment_onclick' => $this->_oModule->_oConfig->getJsObject('view') . ".commentItem(this, '" . $this->_aEvent['comments']['system'] . "', " . $this->_aEvent['id'] . ")",
-    		'share_onclick' => $this->_oModule->serviceGetShareJsClick($iOwnerId, $sType, $sAction, $iObjectId),
-    		'vote_onclick' => $sVotesOnclick
+
+    		'comment_system' => $sCommentsSystem,
+    		'comment_object' => $iCommentsObject,
+    		'comment_onclick' => $sCommentsOnclick,
+
+    		'vote_system' => $sVotesSystem,
+    		'vote_object' => $iVotesObject,
+    		'vote_onclick' => $sVotesOnclick,
+
+    		'share_type' => $sShareType,
+	    	'share_action' => $sShareAction,
+	    	'share_object' => $iShareObject,
+    		'share_onclick' => $this->_oModule->serviceGetShareJsClick($iOwnerId, $sReshareType, $sReshareAction, $iReshareObject),
 		));    	
 		));    	
     }
     }
 
 
@@ -110,48 +128,6 @@ class BxTimelineMenuItem extends BxTemplMenu {
  
  
 		return call_user_func_array(array($this->_oModule, $sCheckFuncName), $aCheckFuncParams) === true;
 		return call_user_func_array(array($this->_oModule, $sCheckFuncName), $aCheckFuncParams) === true;
     }
     }
-
-    /** 
-     * Get menu items array, which are ready to pass to template.
-     * @return array
-     */
-    protected function _getMenuItems() {
-    	$aItems = parent::_getMenuItems();
-
-    	foreach($aItems as $iKey => $aItem)
-    		switch($aItem['name']) {
-    			case 'item-comment':
-    				if(isset($this->_aEvent['comments']) && is_array($this->_aEvent['comments']) && isset($this->_aEvent['comments']['system'])) {
-			    		$aItems[$iKey]['addon'] = $this->_oModule->_oTemplate->parseHtmlByName('bx_a.html', array(
-			    			'href' => 'javascript:void(0)',
-			    			'title' => _t('_bx_timeline_menu_item_title_item_comment'),
-				    		'bx_repeat:attrs' => array(
-		    					array('key' => 'onclick', 'value' => "javascript:" . $this->_oModule->_oConfig->getJsObject('view') . ".commentItem(this, '" . $this->_aEvent['comments']['system'] . "', " . $this->_aEvent['id'] . ")")
-		    				),
-			    			'content' => (int)$this->_aEvent['comments']['count'] > 0 ? (int)$this->_aEvent['comments']['count'] : ''
-			    		));
-			    	}
-    				break;
-
-    			case 'item-vote':
-    				if(isset($this->_aEvent['votes']) && is_array($this->_aEvent['votes']) && isset($this->_aEvent['votes']['system'])) {
-			    		$oVote = $this->_oModule->getVoteObject($this->_aEvent['votes']['system'], $this->_aEvent['votes']['object_id']);
-
-			    		$aItems[$iKey]['addon'] = $oVote->getCounter();
-			    	}
-    				break;
-
-    			case 'item-share':
-    				$sType = $this->_aEvent['type'];
-					$sAction = $this->_aEvent['action'];
-					$iObjectId = $this->_oModule->_oConfig->isSystem($sType, $sAction) ? $this->_aEvent['object_id'] : $this->_aEvent['id'];
-
-    				$aItems[$iKey]['addon'] = $this->_oModule->serviceGetShareCounter($sType, $sAction, $iObjectId);
-    				break;
-    		}
-
-		return $aItems;
-    }
 }
 }
 
 
 /** @} */
 /** @} */

+ 40 - 0
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -436,6 +436,46 @@ class BxTimelineModule extends BxDolModule
     	return $this->_oTemplate->getShareJsClick($iOwnerId, $sType, $sAction, $iObjectId);
     	return $this->_oTemplate->getShareJsClick($iOwnerId, $sType, $sAction, $iObjectId);
     }
     }
 
 
+    public function serviceGetMenuItemAddonComment($sSystem, $iObjectId)
+    {
+		if(empty($sSystem) || empty($iObjectId))
+			return '';
+
+		$oCmts = $this->getCmtsObject($sSystem, $iObjectId);
+		if($oCmts === false)
+			return '';
+
+		$iCounter = (int)$oCmts->getCommentsCount();
+		return  $this->_oTemplate->parseHtmlByName('bx_a.html', array(
+			'href' => 'javascript:void(0)',
+			'title' => _t('_bx_timeline_menu_item_title_item_comment'),
+			'bx_repeat:attrs' => array(
+    			array('key' => 'onclick', 'value' => "javascript:" . $this->_oConfig->getJsObject('view') . ".commentItem(this, '" . $sSystem . "', " . $iObjectId . ")")
+    		),
+	    	'content' => $iCounter > 0 ? $iCounter : ''
+		));		
+    }
+
+    public function serviceGetMenuItemAddonVote($sSystem, $iObjectId)
+    {
+    	if(empty($sSystem) || empty($iObjectId))
+    		return '';
+
+    	$oVote = $this->getVoteObject($sSystem, $iObjectId);
+    	if($oVote === false)
+    		return '';
+
+   		return $oVote->getCounter();		
+    }
+
+    public function serviceGetMenuItemAddonShare($sType, $sAction, $iObjectId)
+    {
+    	if(empty($sType) || empty($iObjectId))
+    		return '';
+
+		return $this->serviceGetShareCounter($sType, $sAction, $iObjectId);
+    }
+
     /*
     /*
      * COMMON METHODS 
      * COMMON METHODS 
      */
      */

+ 4 - 4
modules/boonex/timeline/install/sql/enable.sql

@@ -39,10 +39,10 @@ INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `templat
 INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES 
 INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES 
 ('bx_timeline_menu_item_actions', 'bx_timeline', '_bx_timeline_menu_set_title_item_actions', 0);
 ('bx_timeline_menu_item_actions', 'bx_timeline', '_bx_timeline_menu_set_title_item_actions', 0);
 
 
-INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
-('bx_timeline_menu_item_actions', 'bx_timeline', 'item-comment', '_bx_timeline_menu_item_title_system_item_comment', '_bx_timeline_menu_item_title_item_comment', 'javascript:void(0)', 'javascript:{comment_onclick}', '_self', 'comment', '', 2147483647, 1, 0, 1),
-('bx_timeline_menu_item_actions', 'bx_timeline', 'item-vote', '_bx_timeline_menu_item_title_system_item_vote', '_bx_timeline_menu_item_title_item_vote', 'javascript:void(0)', 'javascript:{vote_onclick}', '_self', 'plus', '', 2147483647, 1, 0, 2),
-('bx_timeline_menu_item_actions', 'bx_timeline', 'item-share', '_bx_timeline_menu_item_title_system_item_share', '_bx_timeline_menu_item_title_item_share', 'javascript:void(0)', 'javascript:{share_onclick}', '_self', 'share', '', 2147483647, 1, 0, 3);
+INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
+('bx_timeline_menu_item_actions', 'bx_timeline', 'item-comment', '_bx_timeline_menu_item_title_system_item_comment', '_bx_timeline_menu_item_title_item_comment', 'javascript:void(0)', 'javascript:{comment_onclick}', '_self', 'comment', 'a:3:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:27:"get_menu_item_addon_comment";s:6:"params";a:2:{i:0;s:16:"{comment_system}";i:1;s:16:"{comment_object}";}}', '', 2147483647, 1, 0, 1),
+('bx_timeline_menu_item_actions', 'bx_timeline', 'item-vote', '_bx_timeline_menu_item_title_system_item_vote', '_bx_timeline_menu_item_title_item_vote', 'javascript:void(0)', 'javascript:{vote_onclick}', '_self', 'plus', 'a:3:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:24:"get_menu_item_addon_vote";s:6:"params";a:2:{i:0;s:13:"{vote_system}";i:1;s:13:"{vote_object}";}}', '', 2147483647, 1, 0, 2),
+('bx_timeline_menu_item_actions', 'bx_timeline', 'item-share', '_bx_timeline_menu_item_title_system_item_share', '_bx_timeline_menu_item_title_item_share', 'javascript:void(0)', 'javascript:{share_onclick}', '_self', 'share', 'a:3:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:25:"get_menu_item_addon_share";s:6:"params";a:3:{i:0;s:12:"{share_type}";i:1;s:14:"{share_action}";i:2;s:14:"{share_object}";}}', '', 2147483647, 1, 0, 3);
 
 
 -- MENU: Account Settings
 -- MENU: Account Settings
 SET @iMIOrder = (SELECT MAX(`order`) FROM `sys_menu_items` WHERE `set_name`='sys_account_settings' LIMIT 1);
 SET @iMIOrder = (SELECT MAX(`order`) FROM `sys_menu_items` WHERE `set_name`='sys_account_settings' LIMIT 1);

+ 0 - 5
template/scripts/BxBaseCmts.php

@@ -318,11 +318,6 @@ class BxBaseCmts extends BxDolCmts {
         return BxTemplStudioFunctions::getInstance()->transBox($this->_sSystem . '-attached-image', $sContent, true);
         return BxTemplStudioFunctions::getInstance()->transBox($this->_sSystem . '-attached-image', $sContent, true);
     }
     }
 
 
-    public function serviceGetMenuItemAddonVote($iCmtId)
-    {
-    	echo 111; exit;
-    }
-
     /**
     /**
      * private functions
      * private functions
      */
      */