فهرست منبع

Ticket #4558 - Build-in API support: Different.

AntonLV 1 سال پیش
والد
کامیت
6b614d653b

+ 15 - 8
modules/boonex/timeline/classes/BxTimelineMenuItemShare.php

@@ -68,15 +68,22 @@ class BxTimelineMenuItemShare extends BxTemplMenu
             $sRepostToOnclick = $this->_oModule->serviceGetRepostToJsClick($iOwnerId, $sType, $sAction, $iObjectId);
 
             //--- Send item
-    	    $sAetSend = urlencode(base64_encode(serialize(array(
-    	        'name' => 'bx_timeline_send',
-    	        'params' => array(
-    	            'ViewLink' => $this->_aEvent['url']
-    	        )
-    	    )))); 
+            $sAetSend = urlencode(base64_encode(serialize([
+                'name' => 'bx_timeline_send',
+                'params' => [
+                    'ViewLink' => $this->_aEvent['url']
+                ]
+            ]))); 
         }
 
-    	$this->addMarkers(array(
+        if($this->_bIsApi && ($sRootUrl = bx_api_get_base_url()) !== false) {
+            if(substr(BX_DOL_URL_ROOT, -1) == '/' && substr($sRootUrl, -1) != '/')
+                $sRootUrl .= '/';
+
+            $this->_aEvent['url'] = str_replace(BX_DOL_URL_ROOT, $sRootUrl, $this->_aEvent['url']);
+        }
+
+        $this->addMarkers([
             'content_id' => $this->_iEvent,
             'content_url' => $this->_aEvent['url'],
 
@@ -87,7 +94,7 @@ class BxTimelineMenuItemShare extends BxTemplMenu
             'repost_to_onclick' => $sRepostToOnclick,
 
             'et_send' => $sAetSend
-    	));
+        ]);
     }
 
     public function getMenuItems ()

+ 5 - 3
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -721,13 +721,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     
     public function serviceGetEditForm($iId)
     {
-        $aFrm = $this->getFormEdit($iId)['form'];
-        $aFrm['inputs']['tlb_do_submit'] = $aFrm['inputs']['controls'][0];
+        $aForm = $this->getFormEdit($iId)['form'];
+        $aForm['inputs']['tlb_do_submit'] = $aForm['inputs']['controls'][0];
         unset($aForm['inputs']['controls']);
-        $aRv['form'] = ['id' => 'bx_timeline', 'type' => 'form', 'name' => 'feed_edit', 'data' => $aFrm, 'request' => ['immutable' => true]];
+
+        $aRv['form'] = ['id' => 'bx_timeline', 'type' => 'form', 'name' => 'feed_edit', 'data' => $aForm, 'request' => ['immutable' => true]];
         $aItemData = $this->getItemData($iId);
         if(is_array($aItemData) && !empty($aItemData['event']))
             $aRv['item'] = $this->_oTemplate->getPostApi($aItemData['event']);
+
         return $aRv;
     }
 

+ 4 - 1
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -748,6 +748,9 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
     {
         $CNF = &$this->_oConfig->CNF;
 
+        if(empty($aEvent) || !is_array($aEvent))
+            return '';
+
         $iEventId = (int)$aEvent[$CNF['FIELD_ID']];
         $iViewerId = isset($aBrowseParams['viewer_id']) ? (int)$aBrowseParams['viewer_id'] : bx_get_logged_profile_id();
 
@@ -2054,7 +2057,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         
         $aEvent['menu_manage'] = $oMenuManage !== false && $oMenuManage->setEvent($aEvent) ? $oMenuManage->getShortCodeAPI() : [];
 
-        if ($aParams['type'] != 'owner')
+        if(!isset($aParams['type']) || $aParams['type'] != 'owner')
             $aEvent['owners'] = $this->_getTmplVarsTimelineOwner($aEvent);
 
         if(($oCmts = $oModule->getCmtsObject($aEvent['comments']['system'], $aEvent['comments']['object_id'])) !== false) {

+ 1 - 1
template/scripts/BxBaseMenu.php

@@ -204,7 +204,7 @@ class BxBaseMenu extends BxDolMenu
                 'image' => $sIconUrl ? $sIconUrl : '',
                 'submenu' => !empty($a['submenu_object']) ? $a['submenu_object'] : '',
                 'addon' => $this->_bDisplayAddons ? $this->_getMenuAddon($a) : '',
-                'primary' => $a['primary'],
+                'primary' => isset($a['primary']) ? $a['primary'] : 0,
             ];
 
             if(($aMarkers = $this->_getMenuMarkers($a)) && is_array($aMarkers))