Просмотр исходного кода

Ticket #4971 - Build-in API support: Issues in Videos module.

AntonLV 9 месяцев назад
Родитель
Сommit
9d387e2a2b
2 измененных файлов с 28 добавлено и 1 удалено
  1. 1 1
      inc/classes/BxDolForm.php
  2. 27 0
      modules/boonex/videos/classes/BxVideosModule.php

+ 1 - 1
inc/classes/BxDolForm.php

@@ -1031,7 +1031,7 @@ class BxDolForm extends BxDol implements iBxDolReplaceable
             $oRv =  $oChecker->get ($sName);
 
         // process comma separated string for api values
-        if ($this->_bIsApi && isset($this->aInputs[$sName]['type']) && !empty($oRv) && (in_array($this->aInputs[$sName]['type'], ['checkbox_set', 'files', 'select_multiple']) || in_array($sName, ['labels'])))
+        if ($this->_bIsApi && isset($this->aInputs[$sName]['type']) && !empty($oRv) && is_string($oRv) && (in_array($this->aInputs[$sName]['type'], ['checkbox_set', 'files', 'select_multiple']) || in_array($sName, ['labels'])))
             $oRv = explode(',', $oRv);
 
         return $oRv;

+ 27 - 0
modules/boonex/videos/classes/BxVideosModule.php

@@ -177,7 +177,34 @@ class BxVideosModule extends BxBaseModFilesModule
             'src_mp4_hd' => $sVideoUrlHd
         ];
     }
+
+    public function serviceGetTimelinePost($aEvent, $aBrowseParams = [])
+    {
+        $mixedResult = parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
+
+        if($this->_bIsApi && $mixedResult && is_array($mixedResult)) {
+            $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
             
+            switch($aContentInfo['video_source']) {
+                case 'embed':
+                    if(($sKey = 'video_embed') && !empty($aContentInfo[$sKey]))
+                        $mixedResult['content'] = array_merge($mixedResult['content'], [
+                            'embed' => $aContentInfo[$sKey],
+                            'images' => []
+                        ]);
+                    break;
+
+                case 'upload':
+                    $aCnt = $mixedResult['content'];
+                    if($aCnt['videos'] && is_array($aCnt['videos']))
+                        $mixedResult['content']['images'] = [];
+                    break;
+            }
+        }
+        
+        return $mixedResult;
+    }
+
     protected function _getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams = array())
     {
         $aResult = parent::_getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams);