Преглед изворни кода

Tickets #2776 - Get service for Timeline.

AntonLV пре 6 година
родитељ
комит
ec094e79a6

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

@@ -2447,6 +2447,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         return $oSearch->getNum();
     }
 
+    public function serviceGet($aParams)
+    {
+        $aParams = $this->_prepareParams($aParams);
+
+        $aParams['return_data_type'] = 'array';
+        return $this->_oTemplate->getPosts($aParams);
+
+    }
+
     public function serviceAdd($aValues)
     {
         return $this->getFormPost(array(

+ 16 - 6
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -471,6 +471,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
 
     public function getPosts($aParams)
     {
+        $bReturnArray = isset($aParams['return_data_type']) && $aParams['return_data_type'] == 'array';
         $bViewTimeline = $aParams['view'] == BX_TIMELINE_VIEW_TIMELINE;
 
         $iStart = $aParams['start'];
@@ -555,7 +556,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         }
 
         $bFirst = true;
-        $sEvents = '';
+        $mixedEvents = $bReturnArray ? array() : '';
         foreach($aEvents as $aEvent) {
             $iEvent = (int)$aEvent['id'];
 
@@ -563,18 +564,27 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             if(empty($sEvent))
                 continue;
 
+            if($bReturnArray) {
+                $mixedEvents[] = $aEvent;
+                continue;
+            }
+
             if($bFirst && $bViewTimeline) {
-                $sEvents .= $this->getDividerToday($aEvent);
+                $mixedEvents .= $this->getDividerToday($aEvent);
 
                 $bFirst = false;
             }
 
-            $sEvents .= $bViewTimeline ? $this->getDivider($iDays, $aEvent) : '';
-            $sEvents .= $sEvent;
+            $mixedEvents .= $bViewTimeline ? $this->getDivider($iDays, $aEvent) : '';
+            $mixedEvents .= $sEvent;
         }
-        $sContent .= $sEvents;
 
-        $bEvents = !empty($sEvents);
+        if($bReturnArray)
+            return $mixedEvents;
+
+        $sContent .= $mixedEvents;
+
+        $bEvents = !empty($mixedEvents);
 
         $sBack = $this->getBack($aParams);