Browse Source

Ticket #4422 - Timeline: Add possibility to select content with media: Related changes in Files.

AntonLV 3 years ago
parent
commit
0b229497f0

+ 23 - 21
modules/boonex/files/classes/BxFilesModule.php

@@ -243,43 +243,45 @@ class BxFilesModule extends BxBaseModTextModule
         if ($aFiles) foreach ($aFiles as $sFile) @unlink($sFile);
     }
 
-    protected function _getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams = array())
+    protected function _getFilesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
     {
-        $aResult = parent::_getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams);
+        $CNF = &$this->_oConfig->CNF;
 
         $aFile = $this->getContentFile($aContentInfo);
-        if (!$aFile['is_image']) {
-            $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->CNF['OBJECT_STORAGE']);
-            $sIcon = $oStorage ? $oStorage->getFontIconNameByFileName($aFile['file_name']) : 'far file';
-
-            $aResult['raw'] = $this->_oTemplate->parseHtmlByName('timeline_post.html', array(
-                'title' => $aResult['title'],
-                'title_attr' => bx_html_attribute($aResult['title']),
-                'url' => $aResult['url'],
-                'icon' => $sIcon,
-            ));
-            $aResult['title'] = '';
-        }
-
-        return $aResult;
+        if(!$aFile || $aFile['is_image'])
+            return [];
+
+        $sIconSrc = '';
+        if(($oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE'])) !== false)
+            $sIconSrc = $this->_oTemplate->getIconUrl($oStorage->getIconNameByFileName($aFile['file_name']));
+
+        return [[
+            'id' => $aFile['id'],
+            'src' => $sIconSrc,
+            'src_medium' => $sIconSrc,
+            'src_orig' => '',
+            'url' => $sUrl
+        ]];
     }
 
     protected function _getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
     {
         $aFile = $this->getContentFile($aContentInfo);
         if (!$aFile)
-            return array();
+            return [];
 
         if (!$aFile['is_image'])
-            return array();
+            return [];
 
         $sPhotoThumb = '';
         if ($oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($this->_oConfig->CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']))
             $sPhotoThumb = $oImagesTranscoder->getFileUrl($aFile['id']);
 
-        return array(
-            array('id' => $aFile['id'], 'url' => $sUrl, 'src' => $sPhotoThumb),
-        );
+        return [[
+            'id' => $aFile['id'], 
+            'url' => $sUrl, 
+            'src' => $sPhotoThumb
+        ]];
     }
 
     public function actionBookmark($iContentId) {

+ 2 - 2
modules/boonex/timeline/template/type_post.html

@@ -16,9 +16,9 @@
     </div>
 </bx_if:show_videos>
 <bx_if:show_files>
-    <div class="__style_prefix__-item-files __style_prefix__-if-main __style_prefix__-if-__display__ mx-1 mt-2 rounded">
+    <div class="__style_prefix__-item-files __style_prefix__-if-main __style_prefix__-if-__display__ mt-3 md:mt-4 rounded">
         <bx_repeat:items>
-            <div class="__style_prefix__-item-file rounded">__item__</div>
+            <div class="__style_prefix__-item-file flex-shrink-0 px-4 rounded">__item__</div>
         </bx_repeat:items>
     </div>
 </bx_if:show_files>