Explorar o código

Ticket #1895 - Possibility to use any number of Timeline/Outline blocks on the same page.

AntonLV %!s(int64=7) %!d(string=hai) anos
pai
achega
15db0f7cfa

+ 49 - 23
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -177,33 +177,12 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         );
 
         $sHp = str_replace('_', '-', $this->_sName);
-        $sHpI = BX_TIMELINE_VIEW_ITEM;
         $sHpT = BX_TIMELINE_VIEW_TIMELINE;
         $sHpO = BX_TIMELINE_VIEW_OUTLINE;
-        $sHpS = BX_TIMELINE_VIEW_SEARCH;
         $this->_aHtmlIds = array(
             'view' => array(
                 'edit_form' => $sHp . '-edit-',
 
-                'main_' . $sHpI => $sHp . '-' . $sHpI,
-                'item_' . $sHpI => $sHp . '-item-' . $sHpI . '-',
-                'item_popup_' . $sHpI => $sHp . '-item-popup-' . $sHpI,
-                'photo_popup_' . $sHpI => $sHp . '-photo-popup-' . $sHpI,
-
-                'main_' . $sHpT => $sHp . '-' . $sHpT,
-                'item_' . $sHpT => $sHp . '-item-' . $sHpT . '-',
-                'item_popup_' . $sHpT => $sHp . '-item-popup-' . $sHpT,
-                'photo_popup_' . $sHpT => $sHp . '-photo-popup-' . $sHpT,
-
-                'main_' . $sHpO => $sHp . '-' . $sHpO,
-                'item_' . $sHpO => $sHp . '-item-' . $sHpO . '-',
-                'item_popup_' . $sHpO => $sHp . '-item-popup-' . $sHpO,
-                'photo_popup_' . $sHpO => $sHp . '-photo-popup-' . $sHpO,
-
-                'main_' . $sHpS => $sHp . '-' . $sHpS,
-                'photo_popup_' . $sHpS => $sHp . '-photo-popup-' . $sHpS,
-
-                'main_item' => $sHp . '-item',
                 'menu_popup' => $sHp . '-menu-popup-',
 
                 'video_iframe' => $sHp . '-video-iframe-',
@@ -293,6 +272,43 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         $this->_bUnhideRestored = false;
     }
 
+    protected function getNameView($aParams, $bWithOwner = false, $sGlue = '_')
+    {
+        $aAddons = array();
+        if(!empty($aParams['name']))
+            $aAddons[] = $aParams['name'];
+        else {
+            if(!empty($aParams['view']))
+                $aAddons[] = $aParams['view'];
+
+            if(!empty($aParams['type']))
+                $aAddons[] = $aParams['type'];
+        }
+
+        if($bWithOwner)
+            $aAddons[] = $aParams['owner_id'];
+
+        return !empty($aAddons) ? implode('_', $aAddons) : '';
+    }
+
+    /**
+     * Generates unique JS object name for View events block.
+     * 
+     * @param array $aParams - an array with browsing params received in View block service method
+     * @return string with JS object name
+     */
+    public function getJsObjectView($aParams = array())
+    {
+        return parent::getJsObject('view') . bx_gen_method_name($this->getNameView($aParams));
+    }
+
+    public function getHtmlIdView($sKey, $aParams, $bWhole = true)
+    {
+        $sDiv = '_';
+
+        return str_replace($sDiv, '-', $this->_sName  . $sDiv . $sKey . $sDiv . $this->getNameView($aParams) . (!$bWhole ? $sDiv : ''));
+    }
+
     public function isAllowEdit()
     {
         return $this->_bAllowEdit;
@@ -442,9 +458,9 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         ));
     }
 
-    public function getLiveUpdateKey($sType, $iOwnerId)
+    public function getLiveUpdateKey($aParams)
     {
-        return $this->getName() . '_live_update_' . $sType . '_' . $iOwnerId;
+        return $this->getName() . '_live_update_' . $this->getNameView($aParams, true);
     }
 
     public function isCommon($sType, $sAction)
@@ -488,6 +504,16 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
 
         return strncmp($sUrl1, $sUrl2, strlen($sUrl1)) === 0;
     }
+
+    public function addBrowseParams($sUrl, $aParams, $sKey = 'bp')
+    {
+        return bx_append_url_params($sUrl, array($sKey => urlencode(base64_encode(serialize($aParams)))));
+    }
+
+    public function getBrowseParams($sValue)
+    {
+        return unserialize(base64_decode(urldecode($sValue)));
+    }
 }
 
 /** @} */

+ 24 - 19
modules/boonex/timeline/classes/BxTimelineMenuItemActions.php

@@ -29,25 +29,12 @@ class BxTimelineMenuItemActions extends BxTemplMenuCustom
 
         parent::__construct($aObject, $this->_oModule->_oTemplate);
 
-        $this->_bShowTitles = false;
-
-        $this->addMarkers(array(
-            'js_object_view' => $this->_oModule->_oConfig->getJsObject('view')
-        ));
-    }
+        $this->_setBrowseParams();
 
-    public function setBrowseParams($sType, $sView)
-    {
-        $this->_sType = !empty($sType) ? $sType : BX_TIMELINE_TYPE_DEFAULT;
-        $this->_sView = !empty($sView) ? $sView : BX_TIMELINE_VIEW_DEFAULT;
-
-        $this->addMarkers(array(
-            'type' => $this->_sType,
-            'view' => $this->_sView
-        ));
+        $this->_bShowTitles = false;
     }
 
-    public function setEvent($aEvent)
+    public function setEvent($aEvent, $aBrowseParams = array())
     {
         if(empty($aEvent) || !is_array($aEvent))
             return;
@@ -55,12 +42,14 @@ class BxTimelineMenuItemActions extends BxTemplMenuCustom
         $this->_aEvent = $aEvent;
         $this->_iEvent = (int)$this->_aEvent['id'];
 
+        $this->_setBrowseParams($aBrowseParams);
+
         $iCommentsObject = 0;
         $sCommentsSystem = $sCommentsOnclick = '';
         if(isset($aEvent['comments']) && is_array($aEvent['comments']) && isset($aEvent['comments']['system'])) {
             $sCommentsSystem = $aEvent['comments']['system'];
             $iCommentsObject = $aEvent['comments']['object_id'];
-            $sCommentsOnclick = $this->_oModule->_oConfig->getJsObject('view') . ".commentItem(this, '" . $sCommentsSystem . "', " . $iCommentsObject . ")";
+            $sCommentsOnclick = bx_replace_markers("{js_object_view}.commentItem(this, '" . $sCommentsSystem . "', " . $iCommentsObject . ")", $this->_aMarkers);
         }
 
         $this->addMarkers(array(
@@ -72,7 +61,7 @@ class BxTimelineMenuItemActions extends BxTemplMenuCustom
         ));
     }
 
-    public function setEventById($iEventId)
+    public function setEventById($iEventId, $aBrowseParams = array())
     {
     	$aEvent = $this->_oModule->_oDb->getEvents(array('browse' => 'id', 'value' => $iEventId));
     	if(empty($aEvent) || !is_array($aEvent))
@@ -88,7 +77,23 @@ class BxTimelineMenuItemActions extends BxTemplMenuCustom
         $aEvent['reports'] = $aEventData['reports'];
         $aEvent['comments'] = $aEventData['comments'];
 
-    	$this->setEvent($aEvent);
+    	$this->setEvent($aEvent, $aBrowseParams);
+    }
+
+    protected function _setBrowseParams($aBrowseParams = array())
+    {
+        $this->_sType = !empty($aBrowseParams['type']) ? $aBrowseParams['type'] : BX_TIMELINE_TYPE_DEFAULT;
+        $this->_sView = !empty($aBrowseParams['view']) ? $aBrowseParams['view'] : BX_TIMELINE_VIEW_DEFAULT;
+
+        $aMarkers = array();
+        foreach($aBrowseParams as $sKey => $mixedValue)
+            if(!is_array($mixedValue))
+                $aMarkers[$sKey] = $mixedValue;
+
+        $this->addMarkers($aMarkers);
+        $this->addMarkers(array(
+            'js_object_view' => $this->_oModule->_oConfig->getJsObjectView($aBrowseParams)
+        ));
     }
 
     protected function _getMenuItemItemView($aItem)

+ 9 - 5
modules/boonex/timeline/classes/BxTimelineMenuItemManage.php

@@ -20,14 +20,18 @@ class BxTimelineMenuItemManage extends BxTimelineMenuItemActions
     {
         parent::__construct($aObject, $oTemplate);
 
+        $this->setDynamicMode(true);
+
+        $iContentId = 0;
         if(bx_get('content_id') !== false)
-            $this->setEventById((int)bx_get('content_id'));
+            $iContentId = bx_process_input(bx_get('content_id'), BX_DATA_INT);
 
-        $sType = bx_get('type') !== false ? bx_process_input(bx_get('type')) : '';
-        $sView = bx_get('view') !== false ? bx_process_input(bx_get('view')) : '';
-        $this->setBrowseParams($sType, $sView);
+        $aBrowseParams = array('name' => '', 'view' => '', 'type' => '');
+        foreach($aBrowseParams as $sKey => $sValue)
+            if(bx_get($sKey) !== false)
+                $aBrowseParams[$sKey] = bx_process_input(bx_get($sKey));
 
-        $this->setDynamicMode(true);
+        $this->setEventById($iContentId, $aBrowseParams);
 
         $this->_bShowTitles = true;
     }

+ 37 - 16
modules/boonex/timeline/classes/BxTimelineMenuItemShare.php

@@ -16,8 +16,8 @@ class BxTimelineMenuItemShare extends BxTemplMenu
 {
     protected $_oModule;
 
-	protected $_iEvent;
-	protected $_aEvent;
+    protected $_iEvent;
+    protected $_aEvent;
 
     public function __construct($aObject, $oTemplate = false)
     {
@@ -25,15 +25,25 @@ class BxTimelineMenuItemShare extends BxTemplMenu
 
         $this->_oModule = BxDolModule::getInstance('bx_timeline');
 
+        $iContentId = 0;
         if(bx_get('content_id') !== false)
-        	$this->setEventId((int)bx_get('content_id'));
+            $iContentId = bx_process_input(bx_get('content_id'), BX_DATA_INT);
+
+        $aBrowseParams = array('name' => '', 'view' => '', 'type' => '');
+        foreach($aBrowseParams as $sKey => $sValue)
+            if(bx_get($sKey) !== false)
+                $aBrowseParams[$sKey] = bx_process_input(bx_get($sKey));
+
+        $this->setEventById($iContentId, $aBrowseParams);
     }
 
-    public function setEventId($iEventId)
+    public function setEventById($iEventId, $aBrowseParams = array())
     {
     	$this->_iEvent = $iEventId;
     	$this->_aEvent = $this->_oModule->_oDb->getEvents(array('browse' => 'id', 'value' => $this->_iEvent));
 
+        $this->_setBrowseParams($aBrowseParams);
+
         $sRepostOnclick = $sEtSend = '';
         if(!empty($this->_aEvent) && is_array($this->_aEvent)) {
             $sType = $this->_aEvent['type'];
@@ -61,13 +71,11 @@ class BxTimelineMenuItemShare extends BxTemplMenu
         }
 
     	$this->addMarkers(array(
-        	'js_object_view' => $this->_oModule->_oConfig->getJsObject('view'),
-
-        	'content_id' => $this->_iEvent,
-    	    'content_url' => $this->_aEvent['url'],
+            'content_id' => $this->_iEvent,
+            'content_url' => $this->_aEvent['url'],
 
-    	    'js_onclick_repost' => $sRepostOnclick,
-    		'et_send' => $sAetSend
+            'js_onclick_repost' => $sRepostOnclick,
+            'et_send' => $sAetSend
     	));
     }
 
@@ -101,6 +109,19 @@ class BxTimelineMenuItemShare extends BxTemplMenu
         return array_merge($aItems, $oSocial->getMenuItems());
     }
 
+    protected function _setBrowseParams($aBrowseParams = array())
+    {
+        $aMarkers = array();
+        foreach($aBrowseParams as $sKey => $mixedValue)
+            if(!is_array($aMarkers))
+                $aMarkers[$sKey] = $mixedValue;
+
+        $this->addMarkers($aMarkers);
+        $this->addMarkers(array(
+            'js_object_view' => $this->_oModule->_oConfig->getJsObjectView($aBrowseParams)
+        ));
+    }
+
     /**
      * Check if menu items is visible.
      * @param $a menu item array
@@ -111,20 +132,20 @@ class BxTimelineMenuItemShare extends BxTemplMenu
         if(!parent::_isVisible($a))
             return false;
 
-		if(empty($this->_aEvent) || !is_array($this->_aEvent))
-			return false;
+        if(empty($this->_aEvent) || !is_array($this->_aEvent))
+            return false;
 
         $sCheckFuncName = '';
         $aCheckFuncParams = array();
         switch ($a['name']) {
-        	case 'item-repost':
+            case 'item-repost':
                 $sCheckFuncName = 'isAllowedRepost';
-				$aCheckFuncParams = array($this->_aEvent);
+                $aCheckFuncParams = array($this->_aEvent);
                 break;
 
-			case 'item-send':
+            case 'item-send':
                 $sCheckFuncName = 'isAllowedSend';
-				$aCheckFuncParams = array($this->_aEvent);
+                $aCheckFuncParams = array($this->_aEvent);
                 break;
         }
 

+ 381 - 194
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -91,59 +91,70 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         echoJson($this->getFormPost());
     }
 
+    //TODO: Continue from here! 'type' has event's type instead of Browsing type.
     public function actionEdit($iId)
     {
         $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
 
+        $aBrowseParams = array();
+        if(bx_get('bp') !== false)
+            $aBrowseParams = $this->_oConfig->getBrowseParams(bx_process_input(bx_get('bp')));
+
         $mixedAllowed = $this->isAllowedPost(true);
         if($mixedAllowed !== true)
             return echoJson(array('message' => strip_tags($mixedAllowed)));
 
-        echoJson($this->getFormEdit($iId, array('dynamic_mode' => true)));
+        echoJson($this->getFormEdit($iId, array('dynamic_mode' => true), $aBrowseParams));
     }
 
-	function actionPin()
+    function actionPin()
     {
-        $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
-
         $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
         $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
+        if(empty($aEvent) || !is_array($aEvent))
+            return echoJson(array('code' => 1));
 
+        $aParams = $this->_prepareParamsGet();
+        $this->_iOwnerId = $aParams['owner_id'];
+        
         $mixedAllowed = $this->{'isAllowed' . ((int)$aEvent['pinned'] == 0 ? 'Pin' : 'Unpin')}($aEvent, true);
         if($mixedAllowed !== true)
-            return echoJson(array('code' => 1, 'message' => strip_tags($mixedAllowed)));
+            return echoJson(array('code' => 2, 'message' => strip_tags($mixedAllowed)));
 
-		$aEvent['pinned'] = (int)$aEvent['pinned'] == 0 ? time() : 0;
+        $aEvent['pinned'] = (int)$aEvent['pinned'] == 0 ? time() : 0;
         if(!$this->_oDb->updateEvent(array('pinned' => $aEvent['pinned']), array('id' => $iId)))
-        	return echoJson(array('code' => 2));
+            return echoJson(array('code' => 3));
 
-		echoJson(array(
-			'code' => 0, 
-			'id' => $iId, 
-			'eval' => $this->_oConfig->getJsObject('view') . '.onPinPost(oData)'
-		));
+        echoJson(array(
+            'code' => 0, 
+            'id' => $iId, 
+            'eval' => $this->_oConfig->getJsObjectView($aParams) . '.onPinPost(oData)'
+        ));
     }
 
     function actionStick()
     {
-    	$this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
-
     	$iId = bx_process_input(bx_get('id'), BX_DATA_INT);
     	$aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
+        if(empty($aEvent) || !is_array($aEvent))
+            return echoJson(array('code' => 1));
+
+        $aParams = $this->_prepareParamsGet();
+        $this->_iOwnerId = $aParams['owner_id'];
 
     	$mixedAllowed = $this->{'isAllowed' . ((int)$aEvent['sticked'] == 0 ? 'Stick' : 'Unstick')}($aEvent, true);
     	if($mixedAllowed !== true)
-    		return echoJson(array('code' => 1, 'message' => strip_tags($mixedAllowed)));
+            return echoJson(array('code' => 2, 'message' => strip_tags($mixedAllowed)));
 
     	$aEvent['sticked'] = (int)$aEvent['sticked'] == 0 ? time() : 0;
     	if(!$this->_oDb->updateEvent(array('sticked' => $aEvent['sticked']), array('id' => $iId)))
-    		return echoJson(array('code' => 2));
+            return echoJson(array('code' => 3));
 
     	echoJson(array(
-	    	'code' => 0,
-	    	'id' => $iId,
-	    	'eval' => $this->_oConfig->getJsObject('view') . '.onStickPost(oData)'
-		));
+            'code' => 0,
+            'id' => $iId,
+            'eval' => $this->_oConfig->getJsObjectView($aParams) . '.onStickPost(oData)'
+        ));
     }
 
     function actionPromote()
@@ -169,21 +180,25 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
     function actionDelete()
     {
-        $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
+        $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
+        $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
+        if(empty($aEvent) || !is_array($aEvent))
+            return echoJson(array('code' => 1));
 
-        $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => bx_process_input(bx_get('id'), BX_DATA_INT)));
+        $aParams = $this->_prepareParamsGet();
+        $this->_iOwnerId = $aParams['owner_id'];
 
         $mixedAllowed = $this->isAllowedDelete($aEvent, true);
         if($mixedAllowed !== true)
-            return echoJson(array('code' => 1, 'message' => strip_tags($mixedAllowed)));
+            return echoJson(array('code' => 2, 'message' => strip_tags($mixedAllowed)));
 
         if(!$this->deleteEvent($aEvent))
-            return echoJson(array('code' => 2));
+            return echoJson(array('code' => 3));
 
         echoJson(array(
-        	'code' => 0, 
-        	'id' => $aEvent['id'], 
-        	'eval' => $this->_oConfig->getJsObject('view') . '.onDeletePost(oData)'
+            'code' => 0, 
+            'id' => $aEvent['id'], 
+            'eval' => $this->_oConfig->getJsObjectView($aParams) . '.onDeletePost(oData)'
         ));
     }
 
@@ -214,19 +229,18 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
     function actionGetPost()
     {
-        $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
+        $aParams = $this->_prepareParamsGet();
+        $aParams['dynamic_mode'] = true;
 
-        $sJsObject = bx_process_input(bx_get('js_object'));
+        $this->_iOwnerId = $aParams['owner_id'];
+
+        $sJsObject = ''; 
+        if(bx_get('js_object') !== false)
+            $sJsObject = bx_process_input(bx_get('js_object'));
         if(empty($sJsObject))
             $sJsObject = $this->_oConfig->getJsObject('post');
 
-        $sView = bx_process_input(bx_get('view'));
-        $sType = bx_process_input(bx_get('type'));
-        $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
-
-        $bAfpsLoading = (int)bx_get('afps_loading') === 1;
-
-        $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
+        $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => bx_process_input(bx_get('id'), BX_DATA_INT)));
         if(empty($aEvent) || !is_array($aEvent))
             return echoJson(array());
 
@@ -234,18 +248,18 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
          * Note. Disabled for now, because Own posts on Timelines of Following members 
          * became visible on posts' author Dashboard Timeline.
          */
-        //if($bAfpsLoading && $this->_iOwnerId != $aEvent['owner_id'])
-        //    return echoJson(array('message' => _t('_bx_timeline_txt_msg_posted')));
-            
+        /*
+        $bAfpsLoading = (int)bx_get('afps_loading') === 1;
+        if($bAfpsLoading && $this->_iOwnerId != $aEvent['owner_id'])
+            return echoJson(array('message' => _t('_bx_timeline_txt_msg_posted')));
+        */
+
         echoJson(array(
             'id' => $aEvent['id'],
-            'view' => $sView,
-        	'item' => $this->_oTemplate->getPost($aEvent, array(
-        		'view' => $sView, 
-        		'type' => !empty($sType) ? $sType : BX_TIMELINE_TYPE_DEFAULT,
-        		'owner_id' => $this->_iOwnerId, 
-        		'dynamic_mode' => true
-            )),
+            'name' => $aParams['name'],
+            'view' => $aParams['view'],
+            'type' => $aParams['type'],
+            'item' => $this->_oTemplate->getPost($aEvent, $aParams),
             'eval' => $sJsObject . "._onGetPost(oData)"
         ));
     }
@@ -256,12 +270,12 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         list($sItems, $sLoadMore, $sBack, $sEmpty) = $this->_oTemplate->getPosts($aParams);
 
         echoJson(array(
-        	'view' => $aParams['view'],
-        	'items' => $sItems, 
-        	'load_more' => $sLoadMore, 
-        	'back' => $sBack,
+            'view' => $aParams['view'],
+            'items' => $sItems, 
+            'load_more' => $sLoadMore, 
+            'back' => $sBack,
             'empty' => $sEmpty,
-        	'eval' => $this->_oConfig->getJsObject('view') . "._onGetPosts(oData)"
+            'eval' => $this->_oConfig->getJsObjectView($aParams) . "._onGetPosts(oData)"
         ));
     }
 
@@ -278,9 +292,10 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
     public function actionGetEditForm($iId)
     {
-        $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
+        $aParams = $this->_prepareParamsGet();
+        $this->_iOwnerId = $aParams['owner_id'];
 
-        echoJson($this->getFormEdit($iId, array('dynamic_mode' => true)));
+        echoJson($this->getFormEdit($iId, array('dynamic_mode' => true), $aParams));
     }
 
     public function actionGetComments()
@@ -354,17 +369,19 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         echo BxDolPage::getObjectInstance($this->_oConfig->getObject('page_item_brief'), $this->_oTemplate)->getCode();
     }
 
-    public function actionResumeLiveUpdate($sType, $iOwnerId)
+    public function actionResumeLiveUpdate()
     {
-    	$sKey = $this->_oConfig->getLiveUpdateKey($sType, $iOwnerId);
+        $aParams = $this->_prepareParamsGet();
+    	$sKey = $this->_oConfig->getLiveUpdateKey($aParams);
 
     	bx_import('BxDolSession');
-    	BxDolSession::getInstance()->unsetValue($sKey, $iOwnerId);
+    	BxDolSession::getInstance()->unsetValue($sKey);
     }
 
-	public function actionPauseLiveUpdate($sType, $iOwnerId)
+    public function actionPauseLiveUpdate()
     {
-    	$sKey = $this->_oConfig->getLiveUpdateKey($sType, $iOwnerId);
+        $aParams = $this->_prepareParamsGet();
+    	$sKey = $this->_oConfig->getLiveUpdateKey($aParams);
 
     	bx_import('BxDolSession');
     	BxDolSession::getInstance()->setValue($sKey, 1);
@@ -392,7 +409,16 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
                 break;
         }
 
-        $aParams = $this->_prepareParams(BX_TIMELINE_VIEW_DEFAULT, $sType, $iOwnerId, 0, $this->_oConfig->getRssLength(), '', array(), 0);
+        $aParams = $this->_prepareParams(array(
+            'view' => BX_TIMELINE_VIEW_DEFAULT,
+            'type' => $sType,
+            'owner_id' => $iOwnerId,
+            'start' => 0, 
+            'per_page' => $this->_oConfig->getRssLength(), 
+            'timeline' => 0, 
+            'filter' => '', 
+            'modules' => array()
+        ));
         $aEvents = $this->_oDb->getEvents($aParams);
 
         $aRssData = array();
@@ -723,18 +749,18 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     public function serviceGetBlockPost($iProfileId = 0)
     {
     	if(empty($iProfileId) && bx_get('profile_id') !== false)
-			$iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
+            $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
 
-		if(empty($iProfileId) && isLogged())
-			$iProfileId = bx_get_logged_profile_id();
+        if(empty($iProfileId) && isLogged())
+            $iProfileId = bx_get_logged_profile_id();
 
         if(!$iProfileId)
             return array();
 
         $sType = BX_BASE_MOD_NTFS_TYPE_OWNER;
         return $this->_getBlockPost($iProfileId, array(
-        	'type' => $sType,
-        	'form_display' => $this->_oConfig->getPostFormDisplay($sType)
+            'type' => $sType,
+            'form_display' => $this->_oConfig->getPostFormDisplay($sType)
         ));
     }
 
@@ -760,21 +786,21 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     public function serviceGetBlockPostProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0)
     {
         if(empty($sProfileModule))
-    		return array();
+            return array();
 
     	if(empty($iProfileContentId) && bx_get('id') !== false)
-    		$iProfileContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
+            $iProfileContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
 
-		$oProfile = BxDolProfile::getInstanceByContentAndType($iProfileContentId, $sProfileModule);
-		if(empty($oProfile))
-			return array();
+        $oProfile = BxDolProfile::getInstanceByContentAndType($iProfileContentId, $sProfileModule);
+        if(empty($oProfile))
+            return array();
 
         $iProfileId = $oProfile->id();
         $sType = BX_BASE_MOD_NTFS_TYPE_OWNER;
-		return $this->_getBlockPost($iProfileId, array(
-		    'type' => $sType,
-			'form_display' => $this->_oConfig->getPostFormDisplay($sType)
-		));
+        return $this->_getBlockPost($iProfileId, array(
+            'type' => $sType,
+            'form_display' => $this->_oConfig->getPostFormDisplay($sType)
+        ));
     }
 
     /**
@@ -799,7 +825,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         $iProfileId = 0;
         $sType = BX_BASE_MOD_NTFS_TYPE_PUBLIC;
         return $this->_getBlockPost($iProfileId, array(
-        	'type' => $sType,
+            'type' => $sType,
             'form_display' => $this->_oConfig->getPostFormDisplay($sType)
         ));
     }
@@ -828,10 +854,10 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $iProfileId = $this->getProfileId();
         $sType = BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS;
-		return $this->_getBlockPost($iProfileId, array(
-		    'type' => $sType,
-			'form_display' => $this->_oConfig->getPostFormDisplay($sType)
-		));
+        return $this->_getBlockPost($iProfileId, array(
+            'type' => $sType,
+            'form_display' => $this->_oConfig->getPostFormDisplay($sType)
+        ));
     }
 
     /**
@@ -854,7 +880,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
      */
     public function serviceGetBlockView($iProfileId = 0)
     {
-    	return $this->_serviceGetBlockView($iProfileId, BX_TIMELINE_VIEW_TIMELINE);
+    	return $this->_serviceGetBlockView($iProfileId, array(
+            'view' => BX_TIMELINE_VIEW_TIMELINE, 
+            'type' => BX_BASE_MOD_NTFS_TYPE_OWNER, 
+            'start' => -1, 
+            'per_page' => -1, 
+            'timeline' => -1, 
+            'filter' => '', 
+            'modules' => array()
+        ));
     }
 
     /**
@@ -877,7 +911,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
      */
     public function serviceGetBlockViewOutline($iProfileId = 0)
     {
-        return $this->_serviceGetBlockView($iProfileId, BX_TIMELINE_VIEW_OUTLINE);
+        return $this->_serviceGetBlockView($iProfileId, array(
+            'view' => BX_TIMELINE_VIEW_OUTLINE, 
+            'type' => BX_BASE_MOD_NTFS_TYPE_OWNER, 
+            'start' => -1, 
+            'per_page' => -1, 
+            'timeline' => -1, 
+            'filter' => '', 
+            'modules' => array()
+        ));
     }
 
     /**
@@ -906,9 +948,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
      */
     public function serviceGetBlockViewProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
     {
-        $sView = BX_TIMELINE_VIEW_TIMELINE;
-
-        return $this->_serviceGetBlockViewProfile($sProfileModule, $iProfileContentId, $sView, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
+        return $this->_serviceGetBlockViewProfile($sProfileModule, $iProfileContentId, array(
+            'view' => BX_TIMELINE_VIEW_TIMELINE, 
+            'type' => BX_BASE_MOD_NTFS_TYPE_OWNER, 
+            'start' => $iStart, 
+            'per_page' => $iPerPage, 
+            'timeline' => $iTimeline, 
+            'filter' => $sFilter, 
+            'modules' => $aModules
+        ));
     }
 
     /**
@@ -935,11 +983,17 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     /** 
      * @ref bx_timeline-get_block_view_profile_outline "get_block_view_profile_outline"
      */
-	public function serviceGetBlockViewProfileOutline($sProfileModule = 'bx_persons', $iProfileContentId = 0, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
+    public function serviceGetBlockViewProfileOutline($sProfileModule = 'bx_persons', $iProfileContentId = 0, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
     {
-        $sView = BX_TIMELINE_VIEW_OUTLINE;
-
-        return $this->_serviceGetBlockViewProfile($sProfileModule, $iProfileContentId, $sView, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
+        return $this->_serviceGetBlockViewProfile($sProfileModule, $iProfileContentId, array(
+            'view' => BX_TIMELINE_VIEW_OUTLINE, 
+            'type' => BX_BASE_MOD_NTFS_TYPE_OWNER, 
+            'start' => $iStart, 
+            'per_page' => $iPerPage, 
+            'timeline' => $iTimeline, 
+            'filter' => $sFilter, 
+            'modules' => $aModules
+        ));
     }
 
     /**
@@ -967,7 +1021,17 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
      */
     public function serviceGetBlockViewHome($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
     {
-        return $this->_serviceGetBlockViewHome($iProfileId, BX_TIMELINE_VIEW_TIMELINE, $iStart, $iPerPage, $this->_oConfig->getPerPage('home'), $iTimeline, $sFilter, $aModules);
+        return $this->_serviceGetBlockViewHome(array(
+            'view' => BX_TIMELINE_VIEW_TIMELINE, 
+            'type' => BX_BASE_MOD_NTFS_TYPE_PUBLIC,
+            'owner_id' => $iProfileId,
+            'start' => $iStart, 
+            'per_page' => $iPerPage, 
+            'per_page_default' => $this->_oConfig->getPerPage('home'), 
+            'timeline' => $iTimeline, 
+            'filter' => $sFilter, 
+            'modules' => $aModules
+        ));
     }
 
     /**
@@ -993,9 +1057,19 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     /** 
      * @ref bx_timeline-get_block_view_home_outline "get_block_view_home_outline"
      */
-	public function serviceGetBlockViewHomeOutline($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
-    {
-        return $this->_serviceGetBlockViewHome($iProfileId, BX_TIMELINE_VIEW_OUTLINE, $iStart, $iPerPage, $this->_oConfig->getPerPage('home'), $iTimeline, $sFilter, $aModules);
+    public function serviceGetBlockViewHomeOutline($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
+    {
+        return $this->_serviceGetBlockViewHome(array(
+            'view' => BX_TIMELINE_VIEW_OUTLINE, 
+            'type' => BX_BASE_MOD_NTFS_TYPE_PUBLIC,
+            'owner_id' => $iProfileId,
+            'start' => $iStart, 
+            'per_page' => $iPerPage, 
+            'per_page_default' => $this->_oConfig->getPerPage('home'), 
+            'timeline' => $iTimeline, 
+            'filter' => $sFilter, 
+            'modules' => $aModules
+        ));
     }
 
 	/**
@@ -1023,7 +1097,17 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
      */
     public function serviceGetBlockViewHot($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
     {
-        return $this->_serviceGetBlockViewHot($iProfileId, BX_TIMELINE_VIEW_TIMELINE, $iStart, $iPerPage, $this->_oConfig->getPerPage('home'), $iTimeline, $sFilter, $aModules);
+        return $this->_serviceGetBlockViewHot(array(
+            'view' => BX_TIMELINE_VIEW_TIMELINE, 
+            'type' => BX_TIMELINE_TYPE_HOT,
+            'owner_id' => $iProfileId,
+            'start' => $iStart, 
+            'per_page' => $iPerPage, 
+            'per_page_default' => $this->_oConfig->getPerPage('home'), 
+            'timeline' => $iTimeline, 
+            'filter' => $sFilter, 
+            'modules' => $aModules
+        ));
     }
 
     /**
@@ -1051,7 +1135,17 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
      */
 	public function serviceGetBlockViewHotOutline($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
     {
-        return $this->_serviceGetBlockViewHot($iProfileId, BX_TIMELINE_VIEW_OUTLINE, $iStart, $iPerPage, $this->_oConfig->getPerPage('home'), $iTimeline, $sFilter, $aModules);
+        return $this->_serviceGetBlockViewHot(array(
+            'view' => BX_TIMELINE_VIEW_OUTLINE, 
+            'type' => BX_TIMELINE_TYPE_HOT, 
+            'owner_id' => $iProfileId, 
+            'start' => $iStart, 
+            'per_page' => $iPerPage, 
+            'per_page_default' => $this->_oConfig->getPerPage('home'), 
+            'timeline' => $iTimeline, 
+            'filter' => $sFilter, 
+            'modules' => $aModules
+        ));
     }
 
     /**
@@ -1082,7 +1176,17 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         if(!isLogged())
             return '';
 
-        return $this->_serviceGetBlockViewByType($iProfileId, BX_TIMELINE_VIEW_TIMELINE, BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS, $iStart, $iPerPage, $this->_oConfig->getPerPage('account'), $iTimeline, $sFilter, $aModules);
+        return $this->_serviceGetBlockViewByType(array(
+            'view' => BX_TIMELINE_VIEW_TIMELINE, 
+            'type' => BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS, 
+            'owner_id' => $iProfileId, 
+            'start' => $iStart, 
+            'per_page' => $iPerPage, 
+            'per_page_default' => $this->_oConfig->getPerPage('account'), 
+            'timeline' => $iTimeline, 
+            'filter' => $sFilter, 
+            'modules' => $aModules
+        ));
     }
 
     /**
@@ -1113,7 +1217,40 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         if(!isLogged())
             return '';
 
-        return $this->_serviceGetBlockViewByType($iProfileId, BX_TIMELINE_VIEW_OUTLINE, BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS, $iStart, $iPerPage, $this->_oConfig->getPerPage('account'), $iTimeline, $sFilter, $aModules);
+        return $this->_serviceGetBlockViewByType(array(
+            'view' => BX_TIMELINE_VIEW_OUTLINE, 
+            'type' => BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS,
+            'owner_id' => $iProfileId, 
+            'start' => $iStart, 
+            'per_page' => $iPerPage, 
+            'per_page_default' => $this->_oConfig->getPerPage('account'), 
+            'timeline' => $iTimeline, 
+            'filter' => $sFilter, 
+            'modules' => $aModules
+        ));
+    }
+
+    /**
+     * @page service Service Calls
+     * @section bx_timeline Timeline
+     * @subsection bx_timeline-page_blocks Page Blocks
+     * @subsubsection bx_timeline-get_block_view_custom get_block_view_custom
+     * 
+     * @code bx_srv('bx_timeline', 'get_block_view_custom', [...]); @endcode
+     * 
+     * Get custom Timeline View block.
+     *
+     * @param $aParams (optional) an array with block parameneters.
+     * @return an array describing a block to display on the site. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
+     * 
+     * @see BxTimelineModule::serviceGetBlockViewCustom
+     */
+    /** 
+     * @ref bx_timeline-get_block_view_custom "get_block_view_custom"
+     */
+    public function serviceGetBlockViewCustom($aParams = array())
+    {
+    	return $this->_serviceGetBlockViewByType($aParams);
     }
 
     /**
@@ -1139,7 +1276,13 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         if(!$iItemId)
             return array();
 
-        return $this->_oTemplate->getItemBlock($iItemId);
+        $aParams = array(
+            'view' => BX_TIMELINE_VIEW_ITEM, 
+            'type' => BX_TIMELINE_TYPE_ITEM
+        );
+        $aParams = $this->_prepareParams($aParams);
+
+        return $this->_oTemplate->getItemBlock($iItemId, $aParams);
     }
 
     public function serviceGetBlockItemContent()
@@ -1646,7 +1789,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     /** 
      * @ref bx_timeline-get_menu_item_addon_comment "get_menu_item_addon_comment"
      */
-    public function serviceGetMenuItemAddonComment($sSystem, $iObjectId)
+    public function serviceGetMenuItemAddonComment($sSystem, $iObjectId, $aBrowseParams = array())
     {
         if(empty($sSystem) || empty($iObjectId))
             return '';
@@ -1662,7 +1805,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         return  $this->_oTemplate->parseLink('javascript:void(0)', $iCounter, array(
             'class' => 'bx-menu-item-addon',
             'title' => _t('_bx_timeline_menu_item_title_item_comment'),
-            'onclick' => "javascript:" . $this->_oConfig->getJsObject('view') . ".commentItem(this, '" . $sSystem . "', " . $iObjectId . ")" 
+            'onclick' => "javascript:" . $this->_oConfig->getJsObjectView($aBrowseParams) . ".commentItem(this, '" . $sSystem . "', " . $iObjectId . ")" 
         ));
     }
 
@@ -1737,31 +1880,32 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     /** 
      * @ref bx_timeline-get_live_updates "get_live_updates"
      */
-    public function serviceGetLiveUpdates($sType, $iOwnerId, $iProfileId, $iCount = 0, $iInit = 0)
+    public function serviceGetLiveUpdates($aBrowseParams, $iProfileId, $iCount = 0, $iInit = 0)
     {
-		$sKey = $this->_oConfig->getLiveUpdateKey($sType, $iOwnerId);
+        $sKey = $this->_oConfig->getLiveUpdateKey($aBrowseParams);
 
-		bx_import('BxDolSession');
-    	if((int)BxDolSession::getInstance()->getValue($sKey) == 1)
-    		return false;
+        bx_import('BxDolSession');
+        if((int)BxDolSession::getInstance()->getValue($sKey) == 1)
+            return false;
 
-        $aParams = $this->_prepareParams(BX_TIMELINE_VIEW_DEFAULT, $sType, $iOwnerId, false, false, BX_TIMELINE_FILTER_OTHER_VIEWER);
+        $aParams = $this->_prepareParams($aBrowseParams);
+        $aParams['filter'] = BX_TIMELINE_FILTER_OTHER_VIEWER;
         $aParams['count'] = true;
 
-		$iCountNew = $this->_oDb->getEvents($aParams);
-		if($iCountNew == $iCount)
-			return false;
+        $iCountNew = $this->_oDb->getEvents($aParams);
+        if($iCountNew == $iCount)
+            return false;
 
-		if((int)$iInit != 0)
-			return array('count' => $iCountNew);
+        if((int)$iInit != 0)
+            return array('count' => $iCountNew);
 
-    	return array(
-			'count' => $iCountNew, // required (for initialization and visualization)
-			'method' => $this->_oConfig->getJsObject('view') . '.showLiveUpdate(oData)', // required (for visualization)
-			'data' => array(
-				'code' => $this->_oTemplate->getLiveUpdateNotification($sType, $iOwnerId, $iProfileId, $iCount, $iCountNew)
-			),  // optional, may have some additional data to be passed in JS method provided using 'method' param above.
-		);
+        return array(
+            'count' => $iCountNew, // required (for initialization and visualization)
+            'method' => $this->_oConfig->getJsObjectView($aBrowseParams) . '.showLiveUpdate(oData)', // required (for visualization)
+            'data' => array(
+                'code' => $this->_oTemplate->getLiveUpdateNotification($aBrowseParams, $iProfileId, $iCount, $iCountNew)
+            ),  // optional, may have some additional data to be passed in JS method provided using 'method' param above.
+        );
     }
     
     /**
@@ -1969,9 +2113,10 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         return $this->_prepareResponse(array('form' => $oForm->getCode($bDynamicMode), 'form_id' => $oForm->id), $bAjaxMode && $oForm->isSubmitted());
     }
 
-    public function getFormEdit($iId, $aParams = array())
+    public function getFormEdit($iId, $aParams = array(), $aBrowseParams = array())
     {
         $CNF = &$this->_oConfig->CNF;
+        $sJsObjectView = $this->_oConfig->getJsObjectView($aBrowseParams);
 
         $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
         if(empty($aEvent) || !is_array($aEvent))
@@ -1981,19 +2126,22 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         if(is_array($aContent) && !empty($aContent['text']))
             $aEvent['text'] = $aContent['text'];
 
-		$bDynamicMode = isset($aParams['dynamic_mode']) ? (bool)$aParams['dynamic_mode'] : false;
+        $bDynamicMode = isset($aParams['dynamic_mode']) ? (bool)$aParams['dynamic_mode'] : false;
         $sFormObject = !empty($aParams['form_object']) ? $aParams['form_object'] : 'form_post';
         $sFormDisplay = !empty($aParams['form_display']) ? $aParams['form_display'] : 'form_display_post_edit';
         $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject($sFormObject), $this->_oConfig->getObject($sFormDisplay), $this->_oTemplate);
         $oForm->setId($this->_oConfig->getHtmlIds('view', 'edit_form') . $iId);
 
         $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'edit/' . $iId ;
+        if(!empty($aBrowseParams) && is_array($aBrowseParams))
+            $oForm->aFormAttrs['action'] = $this->_oConfig->addBrowseParams($oForm->aFormAttrs['action'], $aBrowseParams);
+
         foreach($oForm->aInputs[$CNF['FIELD_CONTROLS']] as $mixedIndex => $aInput) {
             if(!is_numeric($mixedIndex))
                 continue;
 
             $oForm->aInputs[$CNF['FIELD_CONTROLS']][$mixedIndex]['attrs'] = bx_replace_markers($aInput['attrs'], array(
-                'js_object_view' => $this->_oConfig->getJsObject('view'),
+                'js_object_view' => $sJsObjectView,
             	'content_id' => $iId
             ));
         }
@@ -2041,21 +2189,20 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
                 return array('message' => _t('_bx_timeline_txt_err_cannot_perform_action'));
 
             $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
-        	if($bText)
-				$oMetatags->metaAdd($iId, $sText);
-			$oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
+            if($bText)
+                $oMetatags->metaAdd($iId, $sText);
+            $oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
 
             return array(
-                'id' => $iId,
-            	'eval' => $this->_oConfig->getJsObject('view') . '.onEditPostSubmit(oData)'
+                'id' => $iId
             );
         }
 
         return array(
             'id' => $iId, 
-        	'form' => $oForm->getCode($bDynamicMode), 
-        	'form_id' => $oForm->id,
-        	'eval' => $this->_oConfig->getJsObject('view') . '.onEditPost(oData)'
+            'form' => $oForm->getCode($bDynamicMode), 
+            'form_id' => $oForm->id,
+            'eval' => $sJsObjectView . '.onEditPost(oData)'
         );
     }
 
@@ -2624,7 +2771,21 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
     public function getParams($sView = '', $sType = '', $iOwnerId = 0, $iStart = 0, $iPerPage = 0, $sFilter = BX_TIMELINE_FILTER_ALL, $aModules = array(), $iTimeline = 0)
     {
-        return $this->_prepareParams($sView, $sType, $iOwnerId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
+        return $this->_prepareParams(array(
+            'view' => $sView,
+            'type' => $sType,
+            'owner_id' => $iOwnerId,
+            'start' => $iStart, 
+            'per_page' => $iPerPage, 
+            'timeline' => $iTimeline, 
+            'filter' => $sFilter, 
+            'modules' => $aModules
+        ));
+    }
+
+    public function getParamsExt($aParams = array())
+    {
+        return $this->_prepareParams($aParams);
     }
 
     public function getViewsData(&$aViews)
@@ -2707,63 +2868,67 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     /**
      * Protected Methods 
      */
-    protected function _serviceGetBlockView($iProfileId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT)
+    protected function _serviceGetBlockView($iProfileId = 0, $aBrowseParams = array())
     {
         if(empty($iProfileId) && bx_get('profile_id') !== false)
-			$iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
+            $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
 
-		if(empty($iProfileId) && isLogged())
-			$iProfileId = bx_get_logged_profile_id();
+        if(empty($iProfileId) && isLogged())
+            $iProfileId = bx_get_logged_profile_id();
 
-        $aBlock = $this->_getBlockView($iProfileId, $sView);
+        $aBrowseParams['owner_id'] = $iProfileId;
+
+        $aBlock = $this->_getBlockView($aBrowseParams);
         if(!empty($aBlock))
             return $aBlock;
 
         return array('content' => MsgBox(_t('_bx_timeline_txt_msg_no_results')));
     }
 
-    protected function _serviceGetBlockViewProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
+    protected function _serviceGetBlockViewProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0, $aBrowseParams = array())
     {
-    	if(empty($sProfileModule))
-    		return array();
+        if(empty($sProfileModule))
+            return array();
 
-    	if(empty($iProfileContentId) && bx_get('id') !== false)
-    		$iProfileContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
+        if(empty($iProfileContentId) && bx_get('id') !== false)
+            $iProfileContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
+
+        $oProfile = BxDolProfile::getInstanceByContentAndType($iProfileContentId, $sProfileModule);
+        if(empty($oProfile))
+            return array();
 
-		$oProfile = BxDolProfile::getInstanceByContentAndType($iProfileContentId, $sProfileModule);
-		if(empty($oProfile))
-			return array();
+        $aBrowseParams['owner_id'] = $oProfile->id();
 
-        return $this->_getBlockView($oProfile->id(), $sView, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
+        return $this->_getBlockView($aBrowseParams);
     }
 
-    protected function _serviceGetBlockViewHome($iProfileId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $iPerPageDefault = -1,  $iTimeline = -1, $sFilter = '', $aModules = array())
+    protected function _serviceGetBlockViewHome($aBrowseParams = array())
     {
-        $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . BX_BASE_MOD_NTFS_TYPE_PUBLIC . '/';
+        $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . $aBrowseParams['type'] . '/';
         BxDolTemplate::getInstance()->addPageRssLink(_t('_bx_timeline_page_title_view_home'), $sRssUrl);
 
-        return $this->_serviceGetBlockViewByType($iProfileId, $sView, BX_BASE_MOD_NTFS_TYPE_PUBLIC, $iStart, $iPerPage, $iPerPageDefault, $iTimeline, $sFilter, $aModules);
+        return $this->_serviceGetBlockViewByType($aBrowseParams);
     }
 
-    protected function _serviceGetBlockViewHot($iProfileId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $iPerPageDefault = -1,  $iTimeline = -1, $sFilter = '', $aModules = array())
+    protected function _serviceGetBlockViewHot($aBrowseParams = array())
     {
-        $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . BX_TIMELINE_TYPE_HOT . '/';
+        $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . $aBrowseParams['type'] . '/';
         BxDolTemplate::getInstance()->addPageRssLink(_t('_bx_timeline_page_title_view_hot'), $sRssUrl);
 
-        return $this->_serviceGetBlockViewByType($iProfileId, $sView, BX_TIMELINE_TYPE_HOT, $iStart, $iPerPage, $iPerPageDefault, $iTimeline, $sFilter, $aModules);
+        return $this->_serviceGetBlockViewByType($aBrowseParams);
     }
 
-    protected function _serviceGetBlockViewByType($iProfileId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT, $sType = BX_TIMELINE_TYPE_DEFAULT, $iStart = -1, $iPerPage = -1, $iPerPageDefault = -1,  $iTimeline = -1, $sFilter = '', $aModules = array())
+    protected function _serviceGetBlockViewByType($aBrowseParams = array())
     {
-        $aParams = $this->_prepareParams($sView, $sType, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
-
-        $aParams['view'] = $sView;
-        $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : ((int)$iPerPageDefault > 0 ? $iPerPageDefault : $this->_oConfig->getPerPage());
+        $aParams = $this->_prepareParams($aBrowseParams);
+        if((int)$aParams['per_page'] <= 0)
+            $aParams['per_page'] = (int)$aBrowseParams['per_page_default'] > 0 ? $aBrowseParams['per_page_default'] : $this->_oConfig->getPerPage();
 
         $this->_iOwnerId = $aParams['owner_id'];
 
-        $sContent = $this->_oTemplate->getViewBlock($aParams);
-        return array('content' => $sContent);
+        return array(
+            'content' => $this->_oTemplate->getViewBlock($aParams)
+        );
     }
 
     protected function _getBlockPost($iProfileId, $aParams = array())
@@ -2773,18 +2938,19 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         if($this->isAllowedPost() !== true)
             return array();
 
-		$sContent = $this->_oTemplate->getPostBlock($this->_iOwnerId, $aParams);
-        return array('content' => $sContent);
+        return array(
+            'content' => $this->_oTemplate->getPostBlock($this->_iOwnerId, $aParams)
+        );
     }
 
-    protected function _getBlockView($iProfileId, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
+    protected function _getBlockView($aBrowseParams = array())
     {
-        if(!$iProfileId)
-			return array();
+        if(empty($aBrowseParams['owner_id']))
+            return array();
 
-        $aParams = $this->_prepareParams($sView, BX_BASE_MOD_NTFS_TYPE_OWNER, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
-        $aParams['view'] = $sView;
-        $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage('profile');
+        $aParams = $this->_prepareParams($aBrowseParams);
+        if(empty($aParams['per_page']))
+            $aParams['per_page'] = $this->_oConfig->getPerPage('profile');
 
         $this->_iOwnerId = $aParams['owner_id'];
         $oProfileOwner = BxDolProfile::getInstance($this->_iOwnerId);
@@ -2793,10 +2959,11 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
             return array('content' => MsgBox($mixedResult));
 
-        list($sUserName, $sUserUrl) = $this->getUserInfo($aParams['owner_id']);
+        list($sUserName) = $this->getUserInfo($aParams['owner_id']);
 
-        $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . BX_BASE_MOD_NTFS_TYPE_OWNER . '/' . $iProfileId . '/';
-        $sJsObject = $this->_oConfig->getJsObject('view');
+        $sView = $aParams['view'];
+        $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . BX_BASE_MOD_NTFS_TYPE_OWNER . '/' . $this->_iOwnerId . '/';
+        $sJsObject = $this->_oConfig->getJsObjectView($aParams);
         $aMenu = array(
             array('id' => $sView . '-view-all', 'name' => $sView . '-view-all', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_all'), 'active' => 1),
             array('id' => $sView . '-view-owner', 'name' => $sView . '-view-owner', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_owner', $sUserName)),
@@ -2806,7 +2973,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $sContent = '';
         bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view', $this->_iOwnerId, $this->getUserId(), array('override_content' => &$sContent, 'params' => &$aParams, 'menu' => &$aMenu));
-
+//TODO: Refuctor THIS!
         $oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive_vertical.html', 'menu_id'=> $sView . '-view-all', 'menu_items' => $aMenu));
         $oMenu->setSelected('', $sView . '-view-all');
 
@@ -2988,40 +3155,56 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 		$this->_oDb->deleteMedia($sType, $iId);
     }
 
-    protected function _prepareParams($sView, $sType, $iOwnerId, $iStart, $iPerPage, $sFilter = BX_TIMELINE_FILTER_ALL, $aModules = array(), $iTimeline = 0, $aBlink = array())
+    protected function _prepareParams($aParams)
     {
-         $aParams = array(
-            'view' => !empty($sView) ? $sView : BX_TIMELINE_VIEW_DEFAULT,
+        if(empty($aParams['name']))
+            $aParams['name'] = '';
+        
+        if(empty($aParams['view']))
+            $aParams['view'] = BX_TIMELINE_VIEW_DEFAULT;
 
-            'browse' => 'list',
-            'type' => !empty($sType) ? $sType : BX_TIMELINE_TYPE_DEFAULT,
-            'owner_id' => (int)$iOwnerId != 0 ? $iOwnerId : $this->getUserId(),
-            'filter' => !empty($sFilter) ? $sFilter : BX_TIMELINE_FILTER_ALL,
-            'modules' => is_array($aModules) && !empty($aModules) ? $aModules : array(),
-            'timeline' => (int)$iTimeline > 0 ? $iTimeline : 0,
-         	'blink' => is_array($aBlink) && !empty($aBlink) ? $aBlink : array(),
-            'active' => 1,
-            'hidden' => 0
-        );
+        if(empty($aParams['type']))
+            $aParams['type'] = BX_TIMELINE_TYPE_DEFAULT;
+
+        if(empty($aParams['owner_id']))
+            $aParams['owner_id'] = $this->getUserId();
+
+        if(isset($aParams['start']) && (int)$aParams['start'] < 0)
+            $aParams['start'] = 0;
 
-        if($iStart !== false)
-            $aParams['start'] = (int)$iStart > 0 ? $iStart : 0;
+        if(isset($aParams['per_page']) && (int)$aParams['per_page'] <= 0)
+            $aParams['per_page'] = $this->_oConfig->getPerPage();
 
-        if($iPerPage !== false)
-            $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage();
+        if(empty($aParams['timeline']) || (int)$aParams['timeline'] < 0)
+            $aParams['timeline'] = 0;
+
+        if(empty($aParams['filter']))
+            $aParams['filter'] = BX_TIMELINE_FILTER_ALL;
+
+        if(empty($aParams['modules']) || !is_array($aParams['modules']))
+            $aParams['modules'] = array();
+
+        if(empty($aParams['blink']) || !is_array($aParams['blink']))
+            $aParams['blink'] = array();
 
         if($this->_oConfig->isHot())
             $aParams['hot'] = $this->_oDb->getHot();
 
+        $aParams = array_merge($aParams, array(
+            'browse' => 'list',
+            'active' => 1,
+            'hidden' => 0
+        ));
+
         return $aParams;
     }
 
     protected function _prepareParamsGet()
     {
-        $aParams = array(
-            'browse' => 'list',
-            'dynamic_mode' => true,
-        );
+        $aParams = array();
+
+        $aParams['name'] = bx_get('name');
+        $aParams['name'] = $aParams['name'] !== false ? bx_process_input($aParams['name'], BX_DATA_TEXT) : '';
 
         $aParams['view'] = bx_get('view');
         $aParams['view'] = $aParams['view'] !== false ? bx_process_input($aParams['view'], BX_DATA_TEXT) : BX_TIMELINE_VIEW_DEFAULT;
@@ -3038,24 +3221,28 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         $aParams['per_page'] = bx_get('per_page');
         $aParams['per_page'] = $aParams['per_page'] !== false ? bx_process_input($aParams['per_page'], BX_DATA_INT) : $this->_oConfig->getPerPage();
 
+        $aParams['timeline'] = bx_get('timeline');
+        $aParams['timeline'] = $aParams['timeline'] !== false ? bx_process_input($aParams['timeline'], BX_DATA_INT) : 0;
+
         $aParams['filter'] = bx_get('filter');
         $aParams['filter'] = $aParams['filter'] !== false ? bx_process_input($aParams['filter'], BX_DATA_TEXT) : BX_TIMELINE_FILTER_ALL;
 
         $aParams['modules'] = bx_get('modules');
         $aParams['modules'] = $aParams['modules'] !== false ? bx_process_input($aParams['modules'], BX_DATA_TEXT) : array();
 
-        $aParams['timeline'] = bx_get('timeline');
-        $aParams['timeline'] = $aParams['timeline'] !== false ? bx_process_input($aParams['timeline'], BX_DATA_INT) : 0;
-
         $aParams['blink'] = bx_get('blink');
         $aParams['blink'] = $aParams['blink'] !== false ? explode(',', bx_process_input($aParams['blink'], BX_DATA_TEXT)) : array();
 
-        $aParams['active'] = 1;
-        $aParams['hidden'] = 0;
-
         if($this->_oConfig->isHot())
             $aParams['hot'] = $this->_oDb->getHot();
 
+        $aParams = array_merge($aParams, array(
+            'browse' => 'list',
+            'active' => 1,
+            'hidden' => 0,
+            'dynamic_mode' => true,
+        ));
+
         return $aParams;
     }
 

+ 50 - 57
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -68,8 +68,8 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         return $this->getJsCode('post', array(
             'sVideosAutoplay' => $this->_oConfig->getVideosAutoplay(),
             'oRequestParams' => array_merge(array(
-                    'type' => isset($aParams['type']) ? $aParams['type'] : BX_TIMELINE_TYPE_DEFAULT, 
-                    'owner_id' => $iOwnerId
+                'type' => isset($aParams['type']) ? $aParams['type'] : BX_TIMELINE_TYPE_DEFAULT, 
+                'owner_id' => $iOwnerId
             ), $aParams)
         ));
     }
@@ -91,17 +91,18 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $oModule = $this->getModule();
 
         //--- Add live update
-		$oModule->actionResumeLiveUpdate($aParams['type'], $aParams['owner_id']);
+        $oModule->actionResumeLiveUpdate($aParams['type'], $aParams['owner_id']);
 
-		$sServiceCall = BxDolService::getSerializedService($this->_oConfig->getName(), 'get_live_updates', array($aParams['type'], $aParams['owner_id'], $oModule->getUserId(), '{count}', '{init}'));
-		$sLiveUpdatesCode = BxDolLiveUpdates::getInstance()->add($this->_oConfig->getLiveUpdateKey($aParams['type'], $aParams['owner_id']), 1, $sServiceCall);
-		//--- Add live update
+        $sServiceCall = BxDolService::getSerializedService($this->_oConfig->getName(), 'get_live_updates', array($aParams, $oModule->getUserId(), '{count}', '{init}'));
+        $sLiveUpdatesCode = BxDolLiveUpdates::getInstance()->add($this->_oConfig->getLiveUpdateKey($aParams), 1, $sServiceCall);
+        //--- Add live update
 
         list($sContent, $sLoadMore, $sBack, $sEmpty) = $this->getPosts($aParams);
 
+        $sJsObject = $this->_oConfig->getJsObjectView($aParams);
         return $sLiveUpdatesCode . $this->parseHtmlByName('block_view.html', array(
             'style_prefix' => $this->_oConfig->getPrefix('style'),
-        	'html_id' => $this->_oConfig->getHtmlIds('view', 'main_' . $aParams['view']),
+            'html_id' => $this->_oConfig->getHtmlIdView('main', $aParams),
             'view' => $aParams['view'],
             'back' => $sBack,
             'empty' => $sEmpty, 
@@ -110,16 +111,12 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             'show_more' => $this->_getShowMore($aParams),
             'view_image_popup' => $this->_getImagePopup($aParams),
             'js_content' => $this->getJsCode('view', array(
+                'sObjName' => $sJsObject,
                 'sVideosAutoplay' => $this->_oConfig->getVideosAutoplay(),
-            	'oRequestParams' => array(
-	                'type' => $aParams['type'],
-	                'owner_id' => $aParams['owner_id'],
-	                'start' => $aParams['start'],
-	                'per_page' => $aParams['per_page'],
-	                'filter' => $aParams['filter'],
-	                'modules' => $aParams['modules'],
-	                'timeline' => $aParams['timeline'],
-        		)
+            	'oRequestParams' => $aParams
+            ), array(
+                'wrap' => true,
+                'mask_markers' => array('object' => $sJsObject)
             )) . $this->getJsCode('repost')
         ));
     }
@@ -131,25 +128,17 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
 
         return $this->parseHtmlByName('block_search.html', array(
             'style_prefix' => $this->_oConfig->getPrefix('style'),
-        	'html_id' => $this->_oConfig->getHtmlIds('view', 'main_' . $aParams['view']),
+            'html_id' => $this->_oConfig->getHtmlIdView('main', $aParams),
             'view' => $aParams['view'],
             'content' => $sContent,
-        	'view_image_popup' => $this->_getImagePopup($aParams),
+            'view_image_popup' => $this->_getImagePopup($aParams),
             'js_content' => $this->getJsCode('view', array(
-            	'oRequestParams' => array(
-	                'type' => $aParams['type'],
-	                'owner_id' => $aParams['owner_id'],
-	                'start' => $aParams['start'],
-	                'per_page' => $aParams['per_page'],
-	                'filter' => $aParams['filter'],
-	                'modules' => $aParams['modules'],
-	                'timeline' => $aParams['timeline'],
-        		)
+            	'oRequestParams' => $aParams
             ))
         ));
     }
 
-    public function getItemBlock($iId)
+    public function getItemBlock($iId, $aBrowseParams = array())
     {
         $CNF = $this->_oConfig->CNF;
 
@@ -168,11 +157,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                 return array('content' => MsgBox($mixedResult), 'designbox_id' => 13);
         }
 
-        $aParams = array(
-            'view' => BX_TIMELINE_VIEW_ITEM, 
-            'type' => BX_TIMELINE_TYPE_ITEM
-        );
-        $sContent = $this->getPost($aEvent, $aParams);
+        $sContent = $this->getPost($aEvent, $aBrowseParams);
 
         $sKey = 'allowed_view';
         if(isset($aEvent[$sKey]) && $aEvent[$sKey] !== CHECK_ACTION_RESULT_ALLOWED) 
@@ -206,15 +191,21 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         else 
             $sReferrer = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($this->_oConfig->CNF['URL_HOME']);
 
+        $sJsObject = $this->_oConfig->getJsObjectView($aBrowseParams);
         return array('content' => $this->parseHtmlByName('block_item.html', array(
             'style_prefix' => $this->_oConfig->getPrefix('style'),
-            'html_id' => $this->_oConfig->getHtmlIds('view', 'main_item'),
+            'html_id' => $this->_oConfig->getHtmlIdView('main', $aBrowseParams),
             'content' => $sContent,
-            'show_more' => $this->_getShowMore($aParams),
-            'view_image_popup' => $this->_getImagePopup($aParams),
+            'show_more' => $this->_getShowMore($aBrowseParams),
+            'view_image_popup' => $this->_getImagePopup($aBrowseParams),
             'js_content' => $this->getJsCode('view', array(
+                'sObjName' => $sJsObject,
                 'sVideosAutoplay' => $this->_oConfig->getVideosAutoplay(),
-                'sReferrer' => $sReferrer
+                'sReferrer' => $sReferrer,
+                'oRequestParams' => $aBrowseParams
+            ), array(
+                'wrap' => true,
+                'mask_markers' => array('object' => $sJsObject)
             )) . $this->getJsCode('repost')
         )));
     }
@@ -497,7 +488,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             return '';
 
         $sStylePrefix = $this->_oConfig->getPrefix('style');
-        $sJsObject = $this->_oConfig->getJsObject('view');
+        $sJsObject = $this->_oConfig->getJsObjectView($aParams);
 
         $iYearNow = date('Y', time());
         return $this->parseHtmlByName('back.html', array(
@@ -517,7 +508,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $iYearMin = $this->_oDb->getMaxDuration($aParams);
 
         $sStylePrefix = $this->_oConfig->getPrefix('style');
-        $sJsObject = $this->_oConfig->getJsObject('view');
+        $sJsObject = $this->_oConfig->getJsObjectView($aParams);
 
         $sYears = '';
         if(!empty($iYearMin)) {
@@ -916,7 +907,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         ));
     }
 
-    function getLiveUpdateNotification($sType, $iOwnerId, $iProfileId, $iCountOld = 0, $iCountNew = 0)
+    function getLiveUpdateNotification($aBrowseParams, $iProfileId, $iCountOld = 0, $iCountNew = 0)
     {
         $bShowAll = true;
         $bShowActions = false;
@@ -930,12 +921,15 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         if($iCount > $iCountMax)
             $iCount = $iCountMax;
 
-        $aParams = $oModule->getParams(BX_TIMELINE_VIEW_DEFAULT, $sType, $iOwnerId, 0, $iCount, BX_TIMELINE_FILTER_OTHER_VIEWER);
+        $aParams = $oModule->getParamsExt($aBrowseParams);
+        $aParams['start'] = 0;
+        $aParams['per_page'] = $iCount;
+        $aParams['filter'] = BX_TIMELINE_FILTER_OTHER_VIEWER;
         $aEvents = $this->_oDb->getEvents($aParams);
         if(empty($aEvents) || !is_array($aEvents))
             return '';
 
-        $sJsObject = $this->_oConfig->getJsObject('view');
+        $sJsObject = $this->_oConfig->getJsObjectView($aParams);
         $sStylePrefix = $this->_oConfig->getPrefix('style');
 
         $iUserId = $oModule->getUserId();
@@ -1003,7 +997,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
 
         $oModule = $this->getModule();
         $sStylePrefix = $this->_oConfig->getPrefix('style');
-        $sJsObject = $this->_oConfig->getJsObject('view');
+        $sJsObject = $this->_oConfig->getJsObjectView($aBrowseParams);
 
         list($sAuthorName, $sAuthorUrl, $sAuthorIcon, $sAuthorUnit, $sAuthorUnitShort) = $oModule->getUserInfo($aEvent['object_owner_id']);
         $bAuthorIcon = !empty($sAuthorIcon);
@@ -1012,7 +1006,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $aTmplVarsMenuItemActions = $this->_getTmplVarsMenuItemActions($aEvent, $aBrowseParams);
         $aTmplVarsMenuItemMeta = $this->_getTmplVarsMenuItemMeta($aEvent, $aBrowseParams);
 
-        $aTmplVarsOwnerActions = $this->_getTmplVarsOwnerActions($aEvent);
+        $aTmplVarsOwnerActions = $this->_getTmplVarsOwnerActions($aEvent, $aBrowseParams);
         $bTmplVarsOwnerActions = !empty($aTmplVarsOwnerActions); 
 
         $aTmplVarsTimelineOwner = $this->_getTmplVarsTimelineOwner($aEvent);
@@ -1055,7 +1049,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $aTmplVars = array (
             'style_prefix' => $sStylePrefix,
             'js_object' => $sJsObject,
-            'html_id' => $this->_oConfig->getHtmlIds('view', 'item_' . $aBrowseParams['view']) . $aEvent['id'],
+            'html_id' => $this->_oConfig->getHtmlIdView('item', $aBrowseParams, false) . $aEvent['id'],
             'class' => $sClass,
             'class_owner' => $sClassOwner,
             'class_content' => $bViewItem ? 'bx-def-color-bg-block' : 'bx-def-color-bg-box',
@@ -1167,16 +1161,16 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
     protected function _getShowMore($aParams)
     {
         return $this->parseHtmlByName('show_more.html', array(
-        	'style_prefix' => $this->_oConfig->getPrefix('style'),
-            'js_object' => $this->_oConfig->getJsObject('view'),
+            'style_prefix' => $this->_oConfig->getPrefix('style'),
+            'js_object' => $this->_oConfig->getJsObjectView($aParams),
         ));
     }
 
     protected function _getImagePopup($aParams)
     {
-        $sViewImagePopupId = $this->_oConfig->getHtmlIds('view', 'photo_popup_' . $aParams['view']);
+        $sViewImagePopupId = $this->_oConfig->getHtmlIdView('photo_popup', $aParams);
         $sViewImagePopupContent = $this->parseHtmlByName('popup_image.html', array(
-    		'image_url' => ''
+            'image_url' => ''
     	));
 
     	return BxTemplFunctions::getInstance()->transBox($sViewImagePopupId, $sViewImagePopupContent, true);
@@ -1194,8 +1188,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
     protected function _getTmplVarsMenuItemActions(&$aEvent, $aBrowseParams = array())
     {
         $oMenu = BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_item_actions'));
-        $oMenu->setEvent($aEvent);
-        $oMenu->setBrowseParams($aBrowseParams['type'], $aBrowseParams['view']);
+        $oMenu->setEvent($aEvent, $aBrowseParams);
         $oMenu->setDynamicMode(isset($aBrowseParams['dynamic_mode']) && $aBrowseParams['dynamic_mode'] === true);
 
         $sMenu = $oMenu->getCode();
@@ -1204,7 +1197,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
 
         return array(
             'style_prefix' => $this->_oConfig->getPrefix('style'),
-            'js_object' => $this->_oConfig->getJsObject('view'),
+            'js_object' => $this->_oConfig->getJsObjectView($aBrowseParams),
             'menu_item_actions' => $sMenu
         );
     }
@@ -1291,7 +1284,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
     {
     	$aContent = &$aEvent['content'];
         $sStylePrefix = $this->_oConfig->getPrefix('style');
-        $sJsObject = $this->_oConfig->getJsObject('view');
+        $sJsObject = $this->_oConfig->getJsObjectView($aBrowseParams);
 
         $bViewItem = isset($aBrowseParams['view']) && $aBrowseParams['view'] == BX_TIMELINE_VIEW_ITEM;
 
@@ -1551,7 +1544,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         return $aTmplVars;
     }
 
-    protected function _getTmplVarsOwnerActions(&$aEvent)
+    protected function _getTmplVarsOwnerActions(&$aEvent, $aBrowseParams = array())
     {
         $sStylePrefix = $this->_oConfig->getPrefix('style');
 
@@ -1562,13 +1555,13 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         if(!empty($iUser) && !empty($iOwner) && $iUser != $iOwner) {
             $sConnection = $this->_oConfig->getObject('conn_subscriptions');
             if(BxDolConnection::getObjectInstance($sConnection)->checkAllowedConnect($iUser, $iOwner) === CHECK_ACTION_RESULT_ALLOWED) {
-                $sJsObject = $this->_oConfig->getJsObject('view');
+                $sJsObject = $this->_oConfig->getJsObjectView($aBrowseParams);
 
                 $sContent = _t('_sys_menu_item_title_sm_subscribe');
                 $aTmplVarsActions[] = array(
                     'href' => "javascript:void(0)",
                     'onclick' => "bx_conn_action(this, '" . $sConnection . "', 'add', '" . $iOwner . "', false, function(oData, eElement) {" . $sJsObject . ".onConnect(eElement, oData);})",
-                	'title' => bx_html_attribute($sContent),
+                    'title' => bx_html_attribute($sContent),
                     'content' => $sContent,
                     'icon' => 'check'
                 );
@@ -1602,7 +1595,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $CNF = $this->_oConfig->CNF;
 
         $oModule = $this->getModule();
-        $sJsObject = $this->_oConfig->getJsObject('view');
+        $sJsObject = $this->_oConfig->getJsObjectView($aBrowseParams);
         $sPrefix = $this->_oConfig->getPrefix('common_post');
         $sType = str_replace($sPrefix, '', $aEvent['type']);
 

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

@@ -101,11 +101,11 @@ INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES
 
 INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `submenu_popup`, `visible_for_levels`, `active`, `copyable`, `editable`, `order`) VALUES
 ('bx_timeline_menu_item_actions', 'bx_timeline', 'item-view', '_bx_timeline_menu_item_title_system_item_view', '', 'javascript:void(0)', '', '', '', '', '', 0, 2147483647, 0, 0, 1, 0),
-('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:3:{i:0;s:16:"{comment_system}";i:1;s:16:"{comment_object}";i:2;s:6:"{view}";}}', '', 0, 2147483647, 1, 0, 1, 1),
+('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:3:{i:0;s:16:"{comment_system}";i:1;s:16:"{comment_object}";i:2;a:3:{s:4:"name";s:6:"{name}";s:4:"view";s:6:"{view}";s:4:"type";s:6:"{type}";}}}', '', 0, 2147483647, 1, 0, 1, 1),
 ('bx_timeline_menu_item_actions', 'bx_timeline', 'item-vote', '_bx_timeline_menu_item_title_system_item_vote', '', 'javascript:void(0)', '', '', '', '', '', 0, 2147483647, 1, 0, 1, 2),
 ('bx_timeline_menu_item_actions', 'bx_timeline', 'item-score', '_bx_timeline_menu_item_title_system_item_score', '', 'javascript:void(0)', '', '', '', '', '', 0, 2147483647, 0, 0, 1, 3),
-('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)', 'bx_menu_popup(''bx_timeline_menu_item_share'', this, {''id'':''bx_timeline_menu_item_share_{content_id}''}, {content_id:{content_id}});', '', 'share-alt', '', 'bx_timeline_menu_item_share', 1, 2147483647, 1, 0, 1, 4),
-('bx_timeline_menu_item_actions', 'bx_timeline', 'item-more', '_bx_timeline_menu_item_title_system_item_more', '_bx_timeline_menu_item_title_item_more', 'javascript:void(0)', 'bx_menu_popup(''bx_timeline_menu_item_manage'', this, {''id'':''bx_timeline_menu_item_manage_{content_id}''}, {content_id:{content_id}, type:''{type}'', view:''{view}''});', '', 'ellipsis-h', '', 'bx_timeline_menu_item_manage', 1, 2147483647, 1, 0, 1, 5);
+('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)', 'bx_menu_popup(''bx_timeline_menu_item_share'', this, {''id'':''bx_timeline_menu_item_share_{content_id}''}, {content_id:{content_id}, name:''{name}'', view:''{view}'', type:''{type}''});', '', 'share-alt', '', 'bx_timeline_menu_item_share', 1, 2147483647, 1, 0, 1, 4),
+('bx_timeline_menu_item_actions', 'bx_timeline', 'item-more', '_bx_timeline_menu_item_title_system_item_more', '_bx_timeline_menu_item_title_item_more', 'javascript:void(0)', 'bx_menu_popup(''bx_timeline_menu_item_manage'', this, {''id'':''bx_timeline_menu_item_manage_{content_id}''}, {content_id:{content_id}, name:''{name}'', view:''{view}'', type:''{type}''});', '', 'ellipsis-h', '', 'bx_timeline_menu_item_manage', 1, 2147483647, 1, 0, 1, 5);
 
 -- MENU: Item Meta Info
 INSERT INTO `sys_objects_menu` (`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES

+ 162 - 145
modules/boonex/timeline/js/main.js

@@ -12,13 +12,7 @@ function BxTimelineMain() {
     this.sIdPost = '#bx-timeline-post';
     this.sIdPostForm = 'form#bx_timeline_post';
 
-    this.sIdView = '#bx-timeline-';
-    this.sIdViewTimeline = '#bx-timeline-timeline';
-    this.sIdViewOutline = '#bx-timeline-outline';
-    this.sIdItem = '#bx-timeline-item-';
-    this.sIdItemTimeline = '#bx-timeline-item-timeline-';
-    this.sIdItemOutline = '#bx-timeline-item-outline-';
-    this.sIdItemItem = '#bx-timeline-item-item-';
+    this.sId = '#bx-timeline';
 
     this.sSP = 'bx-tl';
     this.sClassView = this.sSP + '-view';
@@ -32,13 +26,9 @@ function BxTimelineMain() {
     this.sClassItemImage = this.sSP + '-item-image';
     this.sClassBlink = this.sSP + '-blink';
 
-    this.oViewTimeline = null;
+    this.oView = null;
     this.bViewTimeline = false;
-
-    this.oViewOutline = null;
     this.bViewOutline = false;
-
-    this.oViewItem = null;
     this.bViewItem = false;
 }
 
@@ -49,216 +39,243 @@ BxTimelineMain.prototype.initVideos = function(oParent) {
 };
 
 BxTimelineMain.prototype.isMasonry = function() {
-	return $(this.sIdViewOutline + ' .' + this.sClassItems).hasClass(this.sClassMasonry);
+    return this.oView.find('.' + this.sClassItems).hasClass(this.sClassMasonry);
 };
 
 BxTimelineMain.prototype.isMasonryEmpty = function() {
-	return $(this.sIdViewOutline + ' .' + this.sClassItems + ' .' + this.sClassItem).length == 0;
+	return this.oView.find('.' + this.sClassItems + ' .' + this.sClassItem).length == 0;
 };
 
 BxTimelineMain.prototype.initMasonry = function(onComplete) {
-	var $this = this;
-	var oHolder = $(this.sIdViewOutline + ' .' + this.sClassItems);
+    var $this = this;
+    var oHolder = this.oView.find('.' + this.sClassItems);
 
-	var oItems = oHolder.find('.' + this.sClassItem);
-	if(oItems.length == 0) 
-		return;
+    var oItems = oHolder.find('.' + this.sClassItem);
+    if(oItems.length == 0) 
+        return;
 
-	oItems.resize(function(){
-		$this.reloadMasonry();
-	}).find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight(this.sSP + '-overflow', function(oElement) {
-		$this.onFindOverflow(oElement);
-	});
+    oItems.resize(function(){
+            $this.reloadMasonry();
+    }).find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight(this.sSP + '-overflow', function(oElement) {
+            $this.onFindOverflow(oElement);
+    });
 
-	oHolder.addClass(this.sClassMasonry).masonry({
-	  itemSelector: '.' + this.sClassItem,
-	  columnWidth: '.' + this.sSP + '-grid-sizer'
-	}).masonry('once', 'layoutComplete', function() {
-		if(typeof onComplete === 'function')
-			onComplete(oItems);
-	});
+    oHolder.addClass(this.sClassMasonry).masonry({
+      itemSelector: '.' + this.sClassItem,
+      columnWidth: '.' + this.sSP + '-grid-sizer'
+    }).masonry('once', 'layoutComplete', function() {
+        if(typeof onComplete === 'function')
+            onComplete(oItems);
+    });
 };
 
 BxTimelineMain.prototype.destroyMasonry = function() {
-	$(this.sIdViewOutline + ' .' + this.sClassItems).removeClass(this.sClassMasonry).masonry('destroy');
+    this.oView.find('.' + this.sClassItems).removeClass(this.sClassMasonry).masonry('destroy');
 };
 
 BxTimelineMain.prototype.appendMasonry = function(oItems, onComplete) {
-	var $this = this;
-	var oItems = $(oItems);
-	oItems.resize(function(){
-		$this.reloadMasonry();
-	}).find('iframe').load(function() {
-		$this.reloadMasonry();
-	}).find('img.' + this.sSP + '-item-image').load(function() {
-		$this.reloadMasonry();
-	});
+    var $this = this;
+    var oItems = $(oItems);
+    oItems.resize(function(){
+            $this.reloadMasonry();
+    }).find('iframe').load(function() {
+            $this.reloadMasonry();
+    }).find('img.' + this.sSP + '-item-image').load(function() {
+            $this.reloadMasonry();
+    });
 
-	var oHolder = $(this.sIdViewOutline + ' .' + this.sClassItems).masonry('layout').append(oItems);
-	if(!this.isMasonry())
-		this.initMasonry(onComplete);
-	else
-		oHolder.masonry('appended', oItems).masonry('layout').masonry('once', 'layoutComplete', function() {
-			if(typeof onComplete === 'function')
-				onComplete(oItems);
-		});
+    var oHolder = this.oView.find('.' + this.sClassItems).masonry('layout').append(oItems);
+    if(!this.isMasonry())
+        this.initMasonry(onComplete);
+    else
+        oHolder.masonry('appended', oItems).masonry('layout').masonry('once', 'layoutComplete', function() {
+            if(typeof onComplete === 'function')
+                onComplete(oItems);
+        });
 };
 
 BxTimelineMain.prototype.prependMasonry = function(oItems, onComplete) {
-	var $this = this;
-	var oItems = $(oItems);
-	oItems.resize(function(){
-		$this.reloadMasonry();
-	}).find('iframe').load(function() {
-		$this.reloadMasonry();
-	}).find('img.' + this.sSP + '-item-image').load(function() {
-		$this.reloadMasonry();
-	});
+    var $this = this;
+    var oItems = $(oItems);
+    oItems.resize(function(){
+        $this.reloadMasonry();
+    }).find('iframe').load(function() {
+        $this.reloadMasonry();
+    }).find('img.' + this.sSP + '-item-image').load(function() {
+        $this.reloadMasonry();
+    });
 
-	var oHolder = $(this.sIdViewOutline + ' .' + this.sClassItems).masonry('layout').prepend(oItems);
-	if(!this.isMasonry())
-		this.initMasonry(onComplete);
-	else
-		oHolder.masonry('prepended', oItems).masonry('layout').masonry('once', 'layoutComplete', function() {
-			if(typeof onComplete === 'function')
-				onComplete(oItems);
-		});
+    var oHolder = this.oView.find('.' + this.sClassItems).masonry('layout').prepend(oItems);
+    if(!this.isMasonry())
+        this.initMasonry(onComplete);
+    else
+        oHolder.masonry('prepended', oItems).masonry('layout').masonry('once', 'layoutComplete', function() {
+            if(typeof onComplete === 'function')
+                onComplete(oItems);
+        });
 };
 
 BxTimelineMain.prototype.removeMasonry = function(oItems, onRemove) {
-	var $this = this;
-	var oItems = $(oItems);
+    var $this = this;
+    var oItems = $(oItems);
 
-	var oHolder = $(this.sIdViewOutline + ' .' + this.sClassItems);
-	if(typeof onRemove === 'function')
-		oHolder.masonry('once', 'removeComplete', onRemove);
+    var oHolder = this.oView.find('.' + this.sClassItems);
+    if(typeof onRemove === 'function')
+        oHolder.masonry('once', 'removeComplete', onRemove);
 
-	oHolder.masonry('remove', oItems).masonry('layout');
+    oHolder.masonry('remove', oItems).masonry('layout');
 };
 
 BxTimelineMain.prototype.reloadMasonry = function() {
-	$(this.sIdViewOutline + ' .' + this.sClassItems).masonry('reloadItems').masonry('layout');
+    this.oView.find('.' + this.sClassItems).masonry('reloadItems').masonry('layout');
 };
 
 BxTimelineMain.prototype.initFlickity = function() {
-	var $this = this;
-
-	$('.' + this.sClassItem + ' .' + this.sClassItemImages).each(function() {
-		if($(this).find('div.' + $this.sClassItemImage).length <= 1)
-			return;
-
-		$(this).flickity({
-			cellSelector: 'div.' + $this.sClassItemImage,
-			cellAlign: 'left',
-			pageDots: false,
-			imagesLoaded: true
-		});
-	});
+    var $this = this;
+
+    $('.' + this.sClassItem + ' .' + this.sClassItemImages).each(function() {
+        if($(this).find('div.' + $this.sClassItemImage).length <= 1)
+            return;
+
+        $(this).flickity({
+            cellSelector: 'div.' + $this.sClassItemImage,
+            cellAlign: 'left',
+            pageDots: false,
+            imagesLoaded: true
+        });
+    });
 };
 
 BxTimelineMain.prototype.onFindOverflow = function(oElement) {
-	$(oElement).after($(oElement).parents('.' + this.sClassView + ':first').find('.' + this.sSP + '-content-show-more:hidden:first').clone().show());
+    $(oElement).after($(oElement).parents('.' + this.sClassView + ':first').find('.' + this.sSP + '-content-show-more:hidden:first').clone().show());
 };
 
 BxTimelineMain.prototype.loadingInButton = function(e, bShow) {
-	if($(e).length)
-		bx_loading_btn($(e), bShow);
-	else
-		bx_loading($('body'), bShow);	
+    if($(e).length)
+        bx_loading_btn($(e), bShow);
+    else
+        bx_loading($('body'), bShow);	
 };
 
 BxTimelineMain.prototype.loadingInItem = function(e, bShow) {
-	var oParent = $('body');
-	if($(e).length)
-		oParent = !$(e).hasClass(this.sClassItem) ? $(e).parents('.' + this.sClassItem + ':first') : $(e);
+    var oParent = $('body');
+    if($(e).length)
+        oParent = !$(e).hasClass(this.sClassItem) ? $(e).parents('.' + this.sClassItem + ':first') : $(e);
 
-	bx_loading(oParent, bShow);
+    bx_loading(oParent, bShow);
 };
 
 BxTimelineMain.prototype.loadingInBlock = function(e, bShow) {
-	var oParent = $(e).length ? $(e).parents('.bx-db-container:first') : $('body'); 
-	bx_loading(oParent, bShow);
+    var oParent = $(e).length ? $(e).parents('.bx-db-container:first') : $('body'); 
+    bx_loading(oParent, bShow);
 };
 
 BxTimelineMain.prototype.loadingInPopup = function(e, bShow) {
-	var oParent = $(e).length ? $(e).parents('.bx-popup-content:first') : $('body'); 
-	bx_loading(oParent, bShow);
+    var oParent = $(e).length ? $(e).parents('.bx-popup-content:first') : $('body'); 
+    bx_loading(oParent, bShow);
 };
 
 BxTimelineMain.prototype.loadingIn = function(e, bShow) {
-	var oElement = $(e);
-	var bElement = oElement.length > 0;
-
-	if(bElement && oElement.hasClass('bx-btn'))
-		this.loadingInButton(e, bShow);
-	else if(bElement && (oElement.hasClass(this.sClassItem) || oElement.parents('.' + this.sClassItem + ':first').length > 0))
-		this.loadingInItem(e, bShow);
-	else if(bElement && oElement.parents('.bx-popup-content:first').length > 0)
-		this.loadingInPopup(e, bShow);
-	else if(bElement && oElement.parents('.bx-db-container:first').length > 0)
-		this.loadingInBlock(e, bShow);
-	else 
-		bx_loading($('body'), bShow);
+    var oElement = $(e);
+    var bElement = oElement.length > 0;
+
+    if(bElement && oElement.hasClass('bx-btn'))
+        this.loadingInButton(e, bShow);
+    else if(bElement && (oElement.hasClass(this.sClassItem) || oElement.parents('.' + this.sClassItem + ':first').length > 0))
+        this.loadingInItem(e, bShow);
+    else if(bElement && oElement.parents('.bx-popup-content:first').length > 0)
+        this.loadingInPopup(e, bShow);
+    else if(bElement && oElement.parents('.bx-db-container:first').length > 0)
+        this.loadingInBlock(e, bShow);
+    else 
+        bx_loading($('body'), bShow);
 };
 
 BxTimelineMain.prototype._loading = function(e, bShow) {
-	var oParent = $(e).length ? $(e) : $('body'); 
-	bx_loading(oParent, bShow);
+    var oParent = $(e).length ? $(e) : $('body'); 
+    bx_loading(oParent, bShow);
+};
+
+BxTimelineMain.prototype._getViewObject = function(oElement) {
+    oElement = $(oElement);
+
+    var oView = oElement;
+    if(oView.hasClass(this.sClassView))
+        return oView;
+
+    oView = oElement.parents('.' + this.sClassView + ':first');
+    if(oView.hasClass(this.sClassView))
+        return oView;
+
+    oView = oElement.parents('.bx-page-block-container:first').find('.' + this.sClassView + ':first');
+    if(oView.hasClass(this.sClassView))
+        return oView;
+
+    return null;
 };
 
 BxTimelineMain.prototype._getView = function(oElement) {
-	oElement = $(oElement);
+    var oView = this._getViewObject(oElement);
+    if(!oView || oView.length == 0)
+        return '';
+
+    if(oView.hasClass(this.sClassView + '-item'))
+        return 'item';
 
-	var oView = oElement;
-	if(!oView.hasClass(this.sClassView))
-		oView = oElement.parents('.' + this.sClassView + ':first');
+    if(oView.hasClass(this.sClassView + '-timeline'))
+        return 'timeline';
 
-	if(!oView.hasClass(this.sClassView))
-		oView = oElement.parents('.bx-page-block-container:first').find('.' + this.sClassView + ':first');
+    if(oView.hasClass(this.sClassView + '-outline'))
+        return 'outline';
 
-	if(oView.hasClass(this.sClassView + '-item'))
-		return 'item';
+    if(oView.hasClass(this.sClassView + '-search'))
+        return 'search';
 
-	if(oView.hasClass(this.sClassView + '-timeline'))
-		return 'timeline';
+    return '';
+};
 
-	if(oView.hasClass(this.sClassView + '-outline'))
-		return 'outline';
+BxTimelineMain.prototype._getName = function(oData)
+{
+    var aAddons = [];
+    if(oData['name'])
+        aAddons.push(oData['name']);
+    else {
+        if(oData['view'])
+            aAddons.push(oData['view']);
 
-	if(oView.hasClass(this.sClassView + '-search'))
-		return 'search';
+        if(oData['type'])
+            aAddons.push(oData['type']);
+    }
 
-	return '';
+    return aAddons.length > 0 ? aAddons.join('_') : '';
 };
 
-BxTimelineMain.prototype._getDefaultData = function(oElement) {
-	var oDate = new Date();
-	var sView = oElement != undefined ? this._getView(oElement) : '';
+BxTimelineMain.prototype._getHtmlId = function(sKey, oData, bWhole)
+{
+    var sDiv = '_';
+    var sHtmlId = this.sId  + sDiv + sKey + sDiv + this._getName(oData) + (bWhole != undefined && !bWhole ? sDiv : '');
 
-    return jQuery.extend({}, this._oRequestParams[sView.length > 0 ? sView : 'general'], {
-    	view: sView,
-		_t:oDate.getTime()
-    });
+    return sHtmlId.replace(new RegExp(sDiv,'g'), '-');
+};
+
+BxTimelineMain.prototype._getDefaultData = function() {
+    var oDate = new Date();
+    return jQuery.extend({}, this._oRequestParams, {_t:oDate.getTime()});
 };
 
 
-BxTimelineMain.prototype._getPost = function(oElement, iId, sView, aParams) {
+BxTimelineMain.prototype._getPost = function(oView, iId, aParams) {
     var $this = this;
     var oData = this._getDefaultData();
-    oData['js_object'] = this._sObjName;
-    oData['view'] = sView;
-    oData['id'] = iId;
-    if(aParams != undefined)
-    	oData = jQuery.extend({}, oData, aParams);
+    oData = jQuery.extend({}, oData, {js_object: this._sObjName, id: iId}, aParams != undefined ? aParams : {});
 
-    var oElementView = $('#' + this._aHtmlIds['main_' + sView]);
-    this.loadingInBlock(oElementView, true);
+    this.loadingInBlock(oView, true);
 
     jQuery.post (
         this._sActionsUrl + 'get_post/',
         oData,
         function(oData) {
-            $this.loadingInBlock(oElementView, false);
+            $this.loadingInBlock(oView, false);
 
             processJsonData(oData);
         },

+ 180 - 183
modules/boonex/timeline/js/post.js

@@ -9,19 +9,15 @@
  */
 
 function BxTimelinePost(oOptions) {
-	this._sActionsUri = oOptions.sActionUri;
+    this._sActionsUri = oOptions.sActionUri;
     this._sActionsUrl = oOptions.sActionUrl;
     this._sObjName = oOptions.sObjName == undefined ? 'oTimelinePost' : oOptions.sObjName;
     this._iOwnerId = oOptions.iOwnerId == undefined ? 0 : parseInt(oOptions.iOwnerId);
     this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'slide' : oOptions.sAnimationEffect;
     this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
-    this._aHtmlIds = oOptions.aHtmlIds == undefined ? {} : oOptions.aHtmlIds;
     this._sVideosAutoplay = oOptions.sVideosAutoplay == undefined ? 'off' : oOptions.sVideosAutoplay;
-    this._oRequestParams = {
-    	timeline: null,
-    	outline: null,
-    	general: oOptions.oRequestParams == undefined ? {} : oOptions.oRequestParams
-    };
+    this._aHtmlIds = oOptions.aHtmlIds == undefined ? {} : oOptions.aHtmlIds;
+    this._oRequestParams = oOptions.oRequestParams == undefined ? {} : oOptions.oRequestParams;
 
     this._sPregTag = "(<([^>]+bx-tag[^>]+)>)";
     this._sPregMention = "(<([^>]+bx-mention[^>]+)>)";
@@ -35,15 +31,15 @@ function BxTimelinePost(oOptions) {
     window.glOnInitEditor.push(function (sEditorSelector) {
         var sBaseUrl = sUrlRoot + 'plugins_public/emoji/js/';
         if ('undefined' === typeof(EmojiPicker)) {
-                bx_get_scripts([
-                    sBaseUrl + 'util.js', 
-                    sBaseUrl + 'config.js',
-                    sBaseUrl + 'emoji-picker.js', 
-                    sBaseUrl + 'jquery.emojiarea.js'
-                ], function() {
-                    $this.initEmoji(sEditorSelector)
-                });
-            }
+            bx_get_scripts([
+                sBaseUrl + 'util.js', 
+                sBaseUrl + 'config.js',
+                sBaseUrl + 'emoji-picker.js', 
+                sBaseUrl + 'jquery.emojiarea.js'
+            ], function() {
+                $this.initEmoji(sEditorSelector)
+            });
+        }
         else
             $this.initEmoji(sEditorSelector);
     });
@@ -54,8 +50,8 @@ function BxTimelinePost(oOptions) {
             oPost = $($this.sIdPostForm);
 
     	oPost.each(function() {
-    		var sId = $(this).attr('id');
-    		$this.initFormPost(sId);
+            var sId = $(this).attr('id');
+            $this.initFormPost(sId);
     	});
     });
 }
@@ -68,7 +64,7 @@ BxTimelinePost.prototype.initEmoji = function(sEditorSelector)
 
     var oEmojiConf = {
         emojiable_selector: bx_editor_get_htmleditable(sEditorSelector), 
-            menu_icon: oLink  /* emoji popup menu icon */
+        menu_icon: oLink  /* emoji popup menu icon */
     };
     new EmojiPicker(oEmojiConf ).discover();  /* call init emoji function */
 };
@@ -84,10 +80,10 @@ BxTimelinePost.prototype.initFormPost = function(sFormId)
     oForm.ajaxForm({
         dataType: "json",
         beforeSubmit: function (formData, jqForm, options) {
-        	window[$this._sObjName].beforeFormPostSubmit(oForm);
+            window[$this._sObjName].beforeFormPostSubmit(oForm);
         },
         success: function (oData) {
-        	window[$this._sObjName].afterFormPostSubmit(oForm, oData);
+            window[$this._sObjName].afterFormPostSubmit(oForm, oData);
         }
     });
 
@@ -127,29 +123,28 @@ BxTimelinePost.prototype.beforeFormPostSubmit = function(oForm)
 
 BxTimelinePost.prototype.afterFormPostSubmit = function (oForm, oData)
 {
-	var $this = this;
-	var fContinue = function() {
-            if(oData && oData.form != undefined && oData.form_id != undefined) {
-                $('#' + oData.form_id).replaceWith(oData.form);
-                $this.initFormPost(oData.form_id);
-
-                return;
-            }
+    var $this = this;
+    var fContinue = function() {
+        if(oData && oData.form != undefined && oData.form_id != undefined) {
+            $('#' + oData.form_id).replaceWith(oData.form);
+            $this.initFormPost(oData.form_id);
 
-            if(oData && oData.id != undefined) {
-                var iId = parseInt(oData.id);
-                if(iId <= 0) 
-                        return;
+            return;
+        }
 
-                if($('#' + $this._aHtmlIds['main_timeline']).length)
-                        $this._getPost(oForm, iId, 'timeline', {afps_loading: 1});
+        if(oData && oData.id != undefined) {
+            var iId = parseInt(oData.id);
+            if(iId <= 0) 
+                return;
 
-                if($('#' + $this._aHtmlIds['main_outline']).length)
-                        $this._getPost(oForm, iId, 'outline', {afps_loading: 1});
-            }
+            $('.' + $this.sClassView).each(function() {
+                var oView = $(this);
+                $this._getPost(oView, iId, jQuery.extend({}, $this._oRequestParams, {view: $this._getView(oView), afps_loading: 1}));
+            });
+        }
 
-            $this._getForm(oForm);
-	};
+        $this._getForm(oForm);
+    };
 
     this.loadingInButton($(oForm).children().find(':submit'), false);
 
@@ -161,63 +156,63 @@ BxTimelinePost.prototype.afterFormPostSubmit = function (oForm, oData)
 
 BxTimelinePost.prototype.initFormAttachLink = function(sFormId)
 {
-	var $this = this;
-	var oForm = $('#' + sFormId);
+    var $this = this;
+    var oForm = $('#' + sFormId);
 
-	oForm.ajaxForm({
+    oForm.ajaxForm({
         dataType: "json",
         clearForm: true,
         beforeSubmit: function (formData, jqForm, options) {
-        	window[$this._sObjName].beforeFormAttachLinkSubmit(oForm);
+            window[$this._sObjName].beforeFormAttachLinkSubmit(oForm);
         },
         success: function (oData) {
-        	window[$this._sObjName].afterFormAttachLinkSubmit(oForm, oData);
+            window[$this._sObjName].afterFormAttachLinkSubmit(oForm, oData);
         }
     });
 };
 
 BxTimelinePost.prototype.beforeFormAttachLinkSubmit = function(oForm)
 {
-	this.loadingInButton($(oForm).children().find(':submit'), true);
+    this.loadingInButton($(oForm).children().find(':submit'), true);
 };
 
 BxTimelinePost.prototype.afterFormAttachLinkSubmit = function (oForm, oData)
 {
-	var $this = this;
-	var fContinue = function() {
-		if(oData && oData.item != undefined) {
-			$('#' + $this._aHtmlIds['attach_link_popup']).dolPopupHide({onHide: function() {
-				$(oForm).find('.bx-form-warn').hide();
-			}});
+    var $this = this;
+    var fContinue = function() {
+        if(oData && oData.item != undefined) {
+            $('#' + $this._aHtmlIds['attach_link_popup']).dolPopupHide({onHide: function() {
+                $(oForm).find('.bx-form-warn').hide();
+            }});
 
-			if(!$.trim(oData.item).length)
-				return;
+            if(!$.trim(oData.item).length)
+                return;
 
-			var oItem = $(oData.item).hide();
-			$('#' + $this._aHtmlIds['attach_link_form_field']).prepend(oItem).find('#' + oItem.attr('id')).bx_anim('show', $this._sAnimationEffect, $this._sAnimationSpeed, function() {
-			});
+            var oItem = $(oData.item).hide();
+            $('#' + $this._aHtmlIds['attach_link_form_field']).prepend(oItem).find('#' + oItem.attr('id')).bx_anim('show', $this._sAnimationEffect, $this._sAnimationSpeed);
 
-	        return;
-		}
+            return;
+        }
 
-		if(oData && oData.form != undefined && oData.form_id != undefined) {
-			$('#' + oData.form_id).replaceWith(oData.form);
-			$this.initFormAttachLink(oData.form_id);
+        if(oData && oData.form != undefined && oData.form_id != undefined) {
+            $('#' + oData.form_id).replaceWith(oData.form);
+            $this.initFormAttachLink(oData.form_id);
 
-			return;
-		}
-	};
+            return;
+        }
+    };
 
-	this.loadingInButton($(oForm).find(':submit'), false);
+    this.loadingInButton($(oForm).find(':submit'), false);
 
-	if(oData && oData.message != undefined)
+    if(oData && oData.message != undefined)
         bx_alert(oData.message, fContinue);
-	else
-		fContinue();
+    else
+        fContinue();
 };
 
-BxTimelinePost.prototype.deleteAttachLink = function(oLink, iId) {
-	var $this = this;
+BxTimelinePost.prototype.deleteAttachLink = function(oLink, iId)
+{
+    var $this = this;
     var oData = this._getDefaultData();
     oData['id'] = iId;
 
@@ -228,146 +223,148 @@ BxTimelinePost.prototype.deleteAttachLink = function(oLink, iId) {
         this._sActionsUrl + 'delete_attach_link/',
         oData,
         function(oData) {
-        	var fContinue = function() {
-        		if(oData && oData.code != undefined && oData.code == 0) {
-        			for(var sUrl in $this._oAttachedLinks)
-        				if(parseInt($this._oAttachedLinks[sUrl]) == parseInt(iId)) {
-        					delete $this._oAttachedLinks[sUrl];
-        					break;
-        				}
-
-            		oAttachLink.bx_anim('hide', $this._sAnimationEffect, $this._sAnimationSpeed, function() {
-            			$(this).remove;
-            		});
-            	}
-        	};
-
-        	bx_loading(oAttachLink, false);
-
-        	if(oData && oData.message != undefined)
+            var fContinue = function() {
+                if(oData && oData.code != undefined && oData.code == 0) {
+                    for(var sUrl in $this._oAttachedLinks)
+                        if(parseInt($this._oAttachedLinks[sUrl]) == parseInt(iId)) {
+                            delete $this._oAttachedLinks[sUrl];
+                            break;
+                        }
+
+                    oAttachLink.bx_anim('hide', $this._sAnimationEffect, $this._sAnimationSpeed, function() {
+                        $(this).remove;
+                    });
+                }
+            };
+
+            bx_loading(oAttachLink, false);
+
+            if(oData && oData.message != undefined)
                 bx_alert(oData.message, fContinue);
-        	else
-        		fContinue();
+            else
+                    fContinue();
         },
         'json'
     );
 
-	return false;
+    return false;
 };
 
-BxTimelinePost.prototype.addAttachLink = function(oElement, sUrl) {
-	if(!sUrl)
-    	return;
+BxTimelinePost.prototype.addAttachLink = function(oElement, sUrl)
+{
+    if(!sUrl)
+        return;
 
     var $this = this;
     var oData = this._getDefaultData();
     oData['url'] = sUrl;
 
     jQuery.post (
-	    this._sActionsUrl + 'add_attach_link/',
-	    oData,
-	    function(oData) {
-	    	if(!oData.id || !oData.item || !$.trim(oData.item).length)
-				return;
-
-	    	//--- Mark that 'attach link' process was finished.
-	    	$this._oAttachedLinks[sUrl] = oData.id;
-
-			var oItem = $(oData.item).hide();
-			$('#' + $this._aHtmlIds['attach_link_form_field']).prepend(oItem).find('#' + oItem.attr('id')).bx_anim('show', $this._sAnimationEffect, $this._sAnimationSpeed, function() {
-			});
-	    },
-	    'json'
-	);
+        this._sActionsUrl + 'add_attach_link/',
+        oData,
+        function(oData) {
+            if(!oData.id || !oData.item || !$.trim(oData.item).length)
+                return;
+
+            //--- Mark that 'attach link' process was finished.
+            $this._oAttachedLinks[sUrl] = oData.id;
+
+            var oItem = $(oData.item).hide();
+            $('#' + $this._aHtmlIds['attach_link_form_field']).prepend(oItem).find('#' + oItem.attr('id')).bx_anim('show', $this._sAnimationEffect, $this._sAnimationSpeed);
+        },
+        'json'
+    );
 };
 
-BxTimelinePost.prototype.showAttachLink = function(oLink) {
-	var oData = this._getDefaultData();    
+BxTimelinePost.prototype.showAttachLink = function(oLink)
+{
+    var oData = this._getDefaultData();    
 
     $(window).dolPopupAjax({
-		id: {value: this._aHtmlIds['attach_link_popup'], force: true},
-		url: bx_append_url_params(this._sActionsUri + 'get_attach_link_form/', oData),
-		closeOnOuterClick: false
-	});
+        id: {value: this._aHtmlIds['attach_link_popup'], force: true},
+        url: bx_append_url_params(this._sActionsUri + 'get_attach_link_form/', oData),
+        closeOnOuterClick: false
+    });
 
-	return false;
+    return false;
 };
 
-BxTimelinePost.prototype._getForm = function(oElement) {
+BxTimelinePost.prototype._getForm = function(oElement)
+{
     var $this = this;
     var oData = this._getDefaultData();
 
     jQuery.post (
-	    this._sActionsUrl + 'get_post_form/',
-	    oData,
-	    function(oData) {
+        this._sActionsUrl + 'get_post_form/',
+        oData,
+        function(oData) {
             if(oData && oData.form != undefined && oData.form_id != undefined) {
                 $('#' + oData.form_id).replaceWith(oData.form);
                 $this.initFormPost(oData.form_id);
             }
-	    },
-	    'json'
-	);
+        },
+        'json'
+    );
 };
 
-BxTimelinePost.prototype._onGetPost = function(oData) {
-	var $this = this;
-	var fContinue = function(oData) {
-		if(!$.trim(oData.item).length) 
-			return;
-
-		var oView = $('#' + $this._aHtmlIds['main_' + oData.view]);
-
-		var oLoadMore = oView.find('.' + $this.sSP + '-load-more');
-		if(!oLoadMore.is(':visible'))
-			oLoadMore.show();
-
-		var oEmpty = oView.find('.' + $this.sSP + '-empty');
-		if(oEmpty.is(':visible'))
-			oEmpty.hide();
-
-		var oContent = $(oData.item).bxProcessHtml();
-		switch(oData.view) {
-			case 'timeline':
-				var oTimeline = $('#' + $this._aHtmlIds['main_timeline']);
-				var oItems = oTimeline.find('.' + $this.sClassItems);
-				var oDivider  = oItems.find('.' + $this.sClassDividerToday);
-				var bDivider = oDivider.length > 0;
-
-				if(bDivider && !oDivider.is(':visible'))
-					oDivider.show();
-
-				oContent.hide();
-
-				var oItem = bDivider ? oDivider.after(oContent).next('.' + $this.sClassItem + ':hidden') : oContent.prependTo(oItems);
-				oItem.bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
-					$(this).find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight($this.sSP + '-overflow', function(oElement) {
-						$this.onFindOverflow(oElement);
-					});
-
-					$this.initFlickity();
-				});
-
-				if($this._sVideosAutoplay != 'off')
-					$this.initVideos(oTimeline);
-				break;
-
-			case 'outline':
-				$this.prependMasonry(oContent, function(oItems) {
-					$(oItems).find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight($this.sSP + '-overflow', function(oElement) {
-						$this.onFindOverflow(oElement);
-					});
-
-					$this.initFlickity();
-				});
-				break;
-		}
-	};
-
-	if(oData && oData.message != undefined && oData.message.length != 0)
-		bx_alert(oData.message, function() {
-			fContinue(oData);
-		});
-	else
-		fContinue(oData);	
+BxTimelinePost.prototype._onGetPost = function(oData)
+{
+    var $this = this;
+    var fContinue = function(oData) {
+        if(!$.trim(oData.item).length) 
+            return;
+
+        $this.oView = $($this._getHtmlId('main', oData));
+
+        var oLoadMore = $this.oView.find('.' + $this.sSP + '-load-more');
+        if(!oLoadMore.is(':visible'))
+            oLoadMore.show();
+
+        var oEmpty = $this.oView.find('.' + $this.sSP + '-empty');
+        if(oEmpty.is(':visible'))
+            oEmpty.hide();
+
+        var oContent = $(oData.item).bxProcessHtml();
+        switch(oData.view) {
+            case 'timeline':
+                var oItems = $this.oView.find('.' + $this.sClassItems);
+                var oDivider  = oItems.find('.' + $this.sClassDividerToday);
+                var bDivider = oDivider.length > 0;
+
+                if(bDivider && !oDivider.is(':visible'))
+                    oDivider.show();
+
+                oContent.hide();
+
+                var oItem = bDivider ? oDivider.after(oContent).next('.' + $this.sClassItem + ':hidden') : oContent.prependTo(oItems);
+                oItem.bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+                    $(this).find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight($this.sSP + '-overflow', function(oElement) {
+                        $this.onFindOverflow(oElement);
+                    });
+
+                    $this.initFlickity();
+                });
+
+                if($this._sVideosAutoplay != 'off')
+                    $this.initVideos($this.oView);
+                break;
+
+            case 'outline':
+                $this.prependMasonry(oContent, function(oItems) {
+                    $(oItems).find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight($this.sSP + '-overflow', function(oElement) {
+                        $this.onFindOverflow(oElement);
+                    });
+
+                    $this.initFlickity();
+                });
+                break;
+        }
+    };
+
+    if(oData && oData.message != undefined && oData.message.length != 0)
+        bx_alert(oData.message, function() {
+                fContinue(oData);
+        });
+    else
+        fContinue(oData);
 };

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 407 - 473
modules/boonex/timeline/js/view.js


+ 7 - 7
modules/boonex/timeline/template/item_outline.html

@@ -2,13 +2,13 @@
     <a name="timeline-event-__id__"></a>
 	<div class="__style_prefix__-item-ind bx-def-padding-sec">
 	    <div class="__style_prefix__-item-cnt bx-def-box bx-def-padding-topbottom bx-def-round-corners __class_content__">
-            <div class="__style_prefix__-blink-plate"></div>
-            <bx_if:show_note>
-	            <div class="__style_prefix__-item-note bx-def-margin-leftright">
-	                <div class="__style_prefix__-in-text bx-def-font-grayed<bx_if:show_note_color> col-__item_note_color__</bx_if:show_note_color>">__item_note__</div>
-	                <div class="__style_prefix__-in-divider bx-def-hr bx-def-margin-sec-topbottom"></div>
-	            </div>
-	        </bx_if:show_note>
+                <div class="__style_prefix__-blink-plate"></div>
+                <bx_if:show_note>
+                    <div class="__style_prefix__-item-note bx-def-margin-leftright">
+                        <div class="__style_prefix__-in-text bx-def-font-grayed<bx_if:show_note_color> col-__item_note_color__</bx_if:show_note_color>">__item_note__</div>
+                        <div class="__style_prefix__-in-divider bx-def-hr bx-def-margin-sec-topbottom"></div>
+                    </div>
+                </bx_if:show_note>
 	    	<div class="__style_prefix__-item-owner bx-def-margin-leftright __class_owner__"> 
                     <div class="__style_prefix__-owner-avatar bx-def-thumb-size">__item_owner_unit__</div>
                         <div class="__style_prefix__-owner-info bx-def-thumb-size-min-height bx-def-thumb-size-left-indent">

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio