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

Ticket #3668 - Allow add photo in video storage for timeline.

AntonLV пре 4 година
родитељ
комит
aa2530ad75

+ 6 - 1
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -125,8 +125,10 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
             'OBJECT_STORAGE_VIDEOS' => $this->_sName . '_videos',
             'OBJECT_STORAGE_FILES' => $this->_sName . '_files',
             'OBJECT_IMAGES_TRANSCODER_PREVIEW' => $this->_sName . '_photos_preview',
+            'OBJECT_VIDEOS_TRANSCODER_PREVIEW' => $this->_sName . '_proxy_preview',
             'OBJECT_VIDEOS_TRANSCODERS' => array(
-                'poster' => 'bx_timeline_videos_poster', 
+                'poster' => 'bx_timeline_videos_poster_view', 
+                'poster_preview' => 'bx_timeline_videos_poster_preview', 
             	'mp4' => 'bx_timeline_videos_mp4', 
             	'mp4_hd' => 'bx_timeline_videos_mp4_hd'
             ),
@@ -221,9 +223,12 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
             'transcoder_photos_view' => $this->_sName . '_photos_view',
             'transcoder_photos_medium' => $this->_sName . '_photos_medium',
             'transcoder_photos_big' => $this->_sName . '_photos_big',
+            'transcoder_videos_preview' => $this->CNF['OBJECT_VIDEOS_TRANSCODER_PREVIEW'],
             'transcoder_videos_poster' => $this->CNF['OBJECT_VIDEOS_TRANSCODERS']['poster'],
             'transcoder_videos_mp4' => $this->CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4'],
             'transcoder_videos_mp4_hd' => $this->CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4_hd'],
+            'transcoder_videos_photo_view' => $this->_sName . '_videos_photo_view',
+            'transcoder_videos_photo_big' => $this->_sName . '_videos_photo_big',
 
             'page_item_brief' => $this->_sName . '_item_brief',
 

+ 1 - 1
modules/boonex/timeline/classes/BxTimelineFormPost.php

@@ -224,7 +224,7 @@ class BxTimelineFormPost extends BxBaseModGeneralFormEntry
                 );
 
             $this->aInputs[$CNF['FIELD_VIDEO']]['storage_object'] = $sStorage;
-            $this->aInputs[$CNF['FIELD_VIDEO']]['images_transcoder'] = $this->_oModule->_oConfig->getObject('transcoder_videos_poster');
+            $this->aInputs[$CNF['FIELD_VIDEO']]['images_transcoder'] = $this->_oModule->_oConfig->getObject('transcoder_videos_preview');
             $this->aInputs[$CNF['FIELD_VIDEO']]['uploaders_id'] = $sUploadersId;
             $this->aInputs[$CNF['FIELD_VIDEO']]['uploaders'] = $aUploaders;
             $this->aInputs[$CNF['FIELD_VIDEO']]['upload_buttons_titles'] = array('Simple' => 'video');

+ 35 - 16
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -4534,8 +4534,8 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     {
         $CNF = &$this->_oConfig->CNF;
 
-        $aVideos = $this->_oDb->getMedia($CNF['FIELD_VIDEO'], $iEventId);
-        if(empty($aVideos) || !is_array($aVideos))
+        $aMediaIds = $this->_oDb->getMedia($CNF['FIELD_VIDEO'], $iEventId);
+        if(empty($aMediaIds) || !is_array($aMediaIds))
             return array();
 
         $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_videos'));
@@ -4544,21 +4544,40 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         $oTranscoderMp4 = BxDolTranscoderVideo::getObjectInstance($this->_oConfig->getObject('transcoder_videos_mp4'));
         $oTranscoderMp4Hd = BxDolTranscoderVideo::getObjectInstance($this->_oConfig->getObject('transcoder_videos_mp4_hd'));
 
+        $oTranscoderPhoto = BxDolTranscoderImage::getObjectInstance($this->_oConfig->getObject('transcoder_videos_photo_view'));
+        $oTranscoderPhotoBig = BxDolTranscoderImage::getObjectInstance($this->_oConfig->getObject('transcoder_videos_photo_big'));
+
         $aResult = array();
-        foreach($aVideos as $iVideoId) {
-            $sVideoUrl = $oStorage->getFileUrlById($iVideoId);
-            $aVideoFile = $oStorage->getFile($iVideoId);
-
-            $sVideoUrlHd = '';
-            if (!empty($aVideoFile['dimensions']) && $oTranscoderMp4Hd->isProcessHD($aVideoFile['dimensions']))
-                $sVideoUrlHd = $oTranscoderMp4Hd->getFileUrl($iVideoId);
-
-            $aResult[$iVideoId] = array(
-                'id' => $iVideoId,
-                'src_poster' => $oTranscoderPoster->getFileUrl($iVideoId),
-                'src_mp4' => $oTranscoderMp4->getFileUrl($iVideoId),
-                'src_mp4_hd' => $sVideoUrlHd,
-            );
+        foreach($aMediaIds as $iMediaId) {
+            $aMediaFile = $oStorage->getFile($iMediaId);
+
+            $bVideoFile = strncmp('video/', $aMediaFile['mime_type'], 6) === 0 && $oTranscoderPoster->isMimeTypeSupported($aMediaFile['mime_type']);
+            if($bVideoFile) {
+                $sVideoUrlHd = '';
+                if (!empty($aMediaFile['dimensions']) && $oTranscoderMp4Hd->isProcessHD($aMediaFile['dimensions']))
+                    $sVideoUrlHd = $oTranscoderMp4Hd->getFileUrl($iMediaId);
+
+                $aResult[$iMediaId] = array(
+                    'id' => $iMediaId,
+                    'src_poster' => $oTranscoderPoster->getFileUrl($iMediaId),
+                    'src_mp4' => $oTranscoderMp4->getFileUrl($iMediaId),
+                    'src_mp4_hd' => $sVideoUrlHd,
+                );
+            }
+
+            $bImageFile = strncmp('image/', $aMediaFile['mime_type'], 6) === 0 && $oTranscoderPhoto->isMimeTypeSupported($aMediaFile['mime_type']);
+            if($bImageFile) {
+                $sPhotoSrc = $oTranscoderPhoto->getFileUrl($iMediaId);
+                $sPhotoSrcBig = $oTranscoderPhotoBig->getFileUrl($iMediaId);
+                if(empty($sPhotoSrcBig) && !empty($sPhotoSrc))
+                    $sPhotoSrcBig = $sPhotoSrc;
+
+                $aResult[$iMediaId] = array(
+                    'id' => $iMediaId,
+                    'src' => $sPhotoSrc,
+                    'src_orig' => $sPhotoSrcBig,
+                );
+            }
         }
 
         return $aResult;

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

@@ -2619,6 +2619,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             $iTotal = count($aVideos);
 
         $sStylePrefix = $this->_oConfig->getPrefix('style');
+        $sJsObject = $this->_oConfig->getJsObjectView($aBrowseParams);
         $aTmplVarsVideos = array();
 
         /*
@@ -2671,14 +2672,30 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                     )) 
                 );
             else {
-                if($bMain || $sDisplay == BX_TIMELINE_ML_GALLERY || ($bAttachFirst && $iVideo == $iVideoFirst))
+                if($bMain || $sDisplay == BX_TIMELINE_ML_GALLERY || ($bAttachFirst && $iVideo == $iVideoFirst)) {
+                    $sItem = '';
+                    if(isset($aVideo['src'], $aVideo['src_orig'])) {
+                        $sItem = $this->parseImage($aVideo['src'], array(
+                            'class' => $sStylePrefix . '-item-image'
+                        ));
+
+                        $aAttrs = array();
+                        if(!empty($aVideo['src_orig']))
+                            $aAttrs['onclick'] = 'return ' . $sJsObject . '.showItem(this, \'' . $aEvent['id'] . '\', \'photo\', ' . json_encode(array('src' => base64_encode($aVideo['src_orig']))) . ')'; 
+
+                        $sItem = $this->parseLinkByName('image_link.html', isset($aVideo['url']) ? $aVideo['url'] : 'javascript:void(0)', $sItem, $aAttrs);
+                    }
+                    else 
+                        $sItem = BxTemplFunctions::getInstance()->videoPlayer($aVideo['src_poster'], $aVideo['src_mp4'], $aVideo['src_mp4_hd'], array(
+                            'preload' => $this->_oConfig->getVideosPreload(),
+                        ), '', $aBrowseParams['dynamic_mode']);
+
                     $aTmplVarsVideos[] = array(
                         'style_prefix' => $sStylePrefix,
                         'class' => '',
-                        'item' => BxTemplFunctions::getInstance()->videoPlayer($aVideo['src_poster'], $aVideo['src_mp4'], $aVideo['src_mp4_hd'], array(
-                            'preload' => $this->_oConfig->getVideosPreload(),
-                        ), '', $aBrowseParams['dynamic_mode'])
+                        'item' => $sItem
                     );
+                }
                 else {
                     $bUrl = !empty($aVideo['url']);
                     $sUrl = $bUrl ? $aVideo['url'] : '';

+ 8 - 1
modules/boonex/timeline/install/config.php

@@ -71,8 +71,15 @@ $aConfig = array(
     'transcoders' => array(
     	'bx_timeline_photos_preview',
     	'bx_timeline_photos_view',
+        'bx_timeline_photos_medium',
         'bx_timeline_photos_big',
-    	'bx_timeline_videos_poster',
+
+        'bx_timeline_videos_photo_preview',
+        'bx_timeline_videos_photo_view',
+        'bx_timeline_videos_photo_big',
+        'bx_timeline_videos_poster_preview',
+    	'bx_timeline_videos_poster_view',
+        'bx_timeline_videos_poster_big',
     	'bx_timeline_videos_mp4',
     	'bx_timeline_videos_mp4_hd'
     ),

+ 19 - 4
modules/boonex/timeline/install/sql/install.sql

@@ -374,7 +374,7 @@ INSERT INTO `sys_objects_storage` (`object`, `engine`, `params`, `token_life`, `
 ('bx_timeline_photos', @sStorageEngine, '', 360, 2592000, 3, 'bx_timeline_photos', 'allow-deny', 'jpg,jpeg,jpe,gif,png', '', 0, 0, 0, 0, 0, 0),
 ('bx_timeline_photos_processed', @sStorageEngine, '', 360, 2592000, 3, 'bx_timeline_photos_processed', 'allow-deny', 'jpg,jpeg,jpe,gif,png', '', 0, 0, 0, 0, 0, 0),
 
-('bx_timeline_videos', @sStorageEngine, 'a:1:{s:6:"fields";a:1:{s:10:"dimensions";s:17:"getFileDimensions";}}', 360, 2592000, 3, 'bx_timeline_videos', 'allow-deny', 'avi,flv,mpg,mpeg,wmv,mp4,m4v,mov,qt,divx,xvid,3gp,3g2,webm,mkv,ogv,ogg,rm,rmvb,asf,drc', '', 0, 0, 0, 0, 0, 0),
+('bx_timeline_videos', @sStorageEngine, 'a:1:{s:6:"fields";a:1:{s:10:"dimensions";s:17:"getFileDimensions";}}', 360, 2592000, 3, 'bx_timeline_videos', 'allow-deny', 'jpg,jpeg,jpe,gif,png,avi,flv,mpg,mpeg,wmv,mp4,m4v,mov,qt,divx,xvid,3gp,3g2,webm,mkv,ogv,ogg,rm,rmvb,asf,drc', '', 0, 0, 0, 0, 0, 0),
 ('bx_timeline_videos_processed', @sStorageEngine, '', 360, 2592000, 3, 'bx_timeline_videos_processed', 'allow-deny', 'jpg,jpeg,jpe,gif,png,avi,flv,mpg,mpeg,wmv,mp4,m4v,mov,qt,divx,xvid,3gp,3g2,webm,mkv,ogv,ogg,rm,rmvb,asf,drc', '', 0, 0, 0, 0, 0, 0),
 
 ('bx_timeline_files', @sStorageEngine, '', 360, 2592000, 3, 'bx_timeline_files', 'deny-allow', '', 'jpg,jpeg,jpe,gif,png,action,apk,app,bat,bin,cmd,com,command,cpl,csh,exe,gadget,inf,ins,inx,ipa,isu,job,jse,ksh,lnk,msc,msi,msp,mst,osx,out,paf,pif,prg,ps1,reg,rgs,run,sct,shb,shs,u3p,vb,vbe,vbs,vbscript,workflow,ws,wsf', 0, 0, 0, 0, 0, 0);
@@ -385,9 +385,18 @@ INSERT INTO `sys_objects_transcoder` (`object`, `storage_object`, `source_type`,
 ('bx_timeline_photos_medium', 'bx_timeline_photos_processed', 'Storage', 'a:1:{s:6:"object";s:18:"bx_timeline_photos";}', 'no', '1', '2592000', '0', '', ''),
 ('bx_timeline_photos_big', 'bx_timeline_photos_processed', 'Storage', 'a:1:{s:6:"object";s:18:"bx_timeline_photos";}', 'no', '1', '2592000', '0', '', ''),
 
-('bx_timeline_videos_poster', 'bx_timeline_videos_processed', 'Storage', 'a:1:{s:6:"object";s:18:"bx_timeline_videos";}', 'no', '0', '0', '0', 'BxDolTranscoderVideo', ''),
+('bx_timeline_videos_photo_preview', 'bx_timeline_videos_processed', 'Storage', 'a:1:{s:6:"object";s:18:"bx_timeline_videos";}', 'no', '1', '2592000', '0', '', ''),
+('bx_timeline_videos_photo_view', 'bx_timeline_videos_processed', 'Storage', 'a:1:{s:6:"object";s:18:"bx_timeline_videos";}', 'no', '1', '2592000', '0', '', ''),
+('bx_timeline_videos_photo_big', 'bx_timeline_videos_processed', 'Storage', 'a:1:{s:6:"object";s:18:"bx_timeline_videos";}', 'no', '1', '2592000', '0', '', ''),
+('bx_timeline_videos_poster_preview', 'bx_timeline_videos_processed', 'Storage', 'a:1:{s:6:"object";s:18:"bx_timeline_videos";}', 'no', '0', '0', '0', 'BxDolTranscoderVideo', ''),
+('bx_timeline_videos_poster_view', 'bx_timeline_videos_processed', 'Storage', 'a:1:{s:6:"object";s:18:"bx_timeline_videos";}', 'no', '0', '0', '0', 'BxDolTranscoderVideo', ''),
+('bx_timeline_videos_poster_big', 'bx_timeline_videos_processed', 'Storage', 'a:1:{s:6:"object";s:18:"bx_timeline_videos";}', 'no', '0', '0', '0', 'BxDolTranscoderVideo', ''),
 ('bx_timeline_videos_mp4', 'bx_timeline_videos_processed', 'Storage', 'a:1:{s:6:"object";s:18:"bx_timeline_videos";}', 'no', '0', '0', '0', 'BxDolTranscoderVideo', ''),
-('bx_timeline_videos_mp4_hd', 'bx_timeline_videos_processed', 'Storage', 'a:1:{s:6:"object";s:18:"bx_timeline_videos";}', 'no', '0', '0', '0', 'BxDolTranscoderVideo', '');
+('bx_timeline_videos_mp4_hd', 'bx_timeline_videos_processed', 'Storage', 'a:1:{s:6:"object";s:18:"bx_timeline_videos";}', 'no', '0', '0', '0', 'BxDolTranscoderVideo', ''),
+
+('bx_timeline_proxy_preview', 'bx_timeline_videos_processed', 'Proxy', 'a:4:{s:6:"object";s:18:"bx_timeline_videos";s:5:"image";s:32:"bx_timeline_videos_photo_preview";s:12:"video_poster";s:33:"bx_timeline_videos_poster_preview";s:5:"video";a:4:{i:0;s:22:"bx_timeline_videos_mp4";i:1;s:25:"bx_timeline_videos_mp4_hd";i:2;s:30:"bx_timeline_videos_poster_view";i:3;s:29:"bx_timeline_videos_poster_big";}}', 'no', 0, 0, 0, 'BxDolTranscoderProxy', ''),
+('bx_timeline_proxy_view', 'bx_timeline_videos_processed', 'Proxy', 'a:4:{s:6:"object";s:18:"bx_timeline_videos";s:5:"image";s:29:"bx_timeline_videos_photo_view";s:12:"video_poster";s:30:"bx_timeline_videos_poster_view";s:5:"video";a:2:{i:0;s:22:"bx_timeline_videos_mp4";i:1;s:25:"bx_timeline_videos_mp4_hd";}}', 'no', 0, 0, 0, 'BxDolTranscoderProxy', ''),
+('bx_timeline_proxy_big', 'bx_timeline_videos_processed', 'Proxy', 'a:4:{s:6:"object";s:18:"bx_timeline_videos";s:5:"image";s:28:"bx_timeline_videos_photo_big";s:12:"video_poster";s:29:"bx_timeline_videos_poster_big";s:5:"video";a:2:{i:0;s:22:"bx_timeline_videos_mp4";i:1;s:25:"bx_timeline_videos_mp4_hd";}}', 'no', 0, 0, 0, 'BxDolTranscoderProxy', '');
 
 INSERT INTO `sys_transcoder_filters` (`transcoder_object`, `filter`, `filter_params`, `order`) VALUES
 ('bx_timeline_photos_preview', 'Resize', 'a:3:{s:1:"w";s:3:"100";s:1:"h";s:3:"100";s:13:"square_resize";s:1:"1";}', '0'),
@@ -395,7 +404,13 @@ INSERT INTO `sys_transcoder_filters` (`transcoder_object`, `filter`, `filter_par
 ('bx_timeline_photos_medium', 'Resize', 'a:1:{s:1:"w";s:3:"600";}', '0'),
 ('bx_timeline_photos_big', 'Resize', 'a:2:{s:1:"w";s:4:"1200";s:1:"h";s:4:"1200";}', '0'),
 
-('bx_timeline_videos_poster', 'Poster', 'a:2:{s:1:"h";s:3:"318";s:10:"force_type";s:3:"jpg";}', 0),
+('bx_timeline_videos_photo_preview', 'Resize', 'a:3:{s:1:"w";s:3:"300";s:1:"h";s:3:"300";s:13:"square_resize";s:1:"1";}', '0'),
+('bx_timeline_videos_photo_view', 'Resize', 'a:1:{s:1:"w";s:3:"480";}', '0'),
+('bx_timeline_videos_photo_big', 'Resize', 'a:2:{s:1:"w";s:4:"1200";s:1:"h";s:4:"1200";}', '0'),
+('bx_timeline_videos_poster_preview', 'Poster', 'a:2:{s:1:"h";s:3:"480";s:10:"force_type";s:3:"jpg";}', 0),
+('bx_timeline_videos_poster_preview', 'Resize', 'a:3:{s:1:"w";s:3:"300";s:1:"h";s:3:"300";s:13:"square_resize";s:1:"1";}', 10),
+('bx_timeline_videos_poster_view', 'Poster', 'a:2:{s:1:"h";s:3:"480";s:10:"force_type";s:3:"jpg";}', 0),
+('bx_timeline_videos_poster_big', 'Poster', 'a:2:{s:1:"h";s:3:"480";s:10:"force_type";s:3:"jpg";}', 0),
 ('bx_timeline_videos_mp4', 'Mp4', 'a:2:{s:1:"h";s:3:"318";s:10:"force_type";s:3:"mp4";}', 0),
 ('bx_timeline_videos_mp4_hd', 'Mp4', 'a:3:{s:1:"h";s:3:"720";s:13:"video_bitrate";s:4:"1536";s:10:"force_type";s:3:"mp4";}', 0);
 

+ 11 - 2
modules/boonex/timeline/template/css/view.css

@@ -792,17 +792,26 @@ div.bx-tl-view div.bx-tl-item-videos.bx-tl-iv-single div.bx-tl-item-video video
 }
 
 /*+++ Item Attachment +++*/
+div.bx-tl-view-timeline div.bx-tl-item-attachments,
+div.bx-tl-view-outline div.bx-tl-item-attachments,
+div.bx-tl-view-item div.bx-tl-item-attachments,
+div.bx-tl-view-search div.bx-tl-item-attachments {
+    position: relative;
+    white-space: nowrap;
+    overflow-x: auto;
+}
 div.bx-tl-view-timeline div.bx-tl-item-attachment,
 div.bx-tl-view-outline div.bx-tl-item-attachment,
 div.bx-tl-view-item div.bx-tl-item-attachment,
 div.bx-tl-view-search div.bx-tl-item-attachment {
     position: relative;
-    display: -webkit-flex;
-    display: flex;
+    display: -webkit-inline-flex;
+    display: inline-flex;
     -webkit-justify-content: center;
     justify-content: center;  
 
     width: 100%;
+    vertical-align: middle;
 }
 div.bx-tl-view-timeline div.bx-tl-item-attachments.bx-tl-ia-gallery div.bx-tl-item-attachment img,
 div.bx-tl-view-item div.bx-tl-item-attachments.bx-tl-ia-gallery div.bx-tl-item-attachment img,