AntonLV 8 лет назад
Родитель
Сommit
1c683b2bb5

+ 57 - 28
modules/boonex/videos/classes/BxVideosTemplate.php

@@ -23,7 +23,58 @@ class BxVideosTemplate extends BxBaseModTextTemplate
         parent::__construct($oConfig, $oDb);
     }
 
+    public function entryText ($aData, $sTemplateName = 'entry-text.html')
+    {
+        $mixedResult = parent::entryText($aData, $sTemplateName);
+        if($mixedResult === false)
+            return $this->entryVideo($aData);
+
+        $mixedVideo = $this->getVideo($aData);
+        if($mixedVideo === false)
+            return $mixedResult;
+
+        return $this->parseHtmlByContent($mixedResult, array(
+            'entry_video' => $mixedVideo['player'] 
+        ));
+    }
+
     public function entryVideo ($aContentInfo, $mixedContext = false)
+    {
+        $aTmplVars = array(
+            'video_title' => bx_process_output($aContentInfo['title']),
+            'video_title_attr' => bx_html_attribute($aContentInfo['title']),
+            'video_poster_url' => '',
+            'video' => ''
+        );
+
+        $mixedVideo = $this->getVideo($aContentInfo);
+        if($mixedVideo !== false)
+            $aTmplVars = array_merge($aTmplVars, array(
+                'video_poster_url' => $mixedVideo['poster_url'],
+                'video' => $mixedVideo['player']
+            ));
+
+        return $this->parseHtmlByName('entry-video.html', $aTmplVars);
+    }
+
+    public function entryRating($aData)
+    {
+        $CNF = &$this->getModule()->_oConfig->CNF;
+
+    	$sVotes = '';
+        $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_STARS'], $aData['id']);
+        if($oVotes) {
+			$sVotes = $oVotes->getElementBlock(array('show_counter' => true, 'show_legend' => true));
+			if(!empty($sVotes))
+				$sVotes = $this->parseHtmlByName('entry-rating.html', array(
+		    		'content' => $sVotes,
+		    	));
+        }
+
+    	return $sVotes; 
+    }
+
+    public function getVideo($aContentInfo)
     {
         $CNF = &$this->getModule()->_oConfig->CNF;
 
@@ -40,47 +91,25 @@ class BxVideosTemplate extends BxBaseModTextTemplate
         $iFile = (int)$aContentInfo[$CNF['FIELD_VIDEO']];
         $aFile = $oStorage->getFile($iFile);
         if(empty($aFile) || !is_array($aFile) || strncmp('video/', $aFile['mime_type'], 6) !== 0)
-            return '';
-
-        $sTitle = bx_process_output($aContentInfo['title']);
-        $sTitleAttr = bx_html_attribute($aContentInfo['title']);
+            return false;
 
         $this->_checkDuration($aContentInfo);
 
-		$sPosterSrc = !empty($CNF['FIELD_POSTER']) ? $CNF['FIELD_POSTER'] : $CNF['FIELD_THUMB'];
+        $sPosterSrc = !empty($CNF['FIELD_POSTER']) ? $CNF['FIELD_POSTER'] : $CNF['FIELD_THUMB'];
         if(!empty($sPosterSrc) && !empty($aContentInfo[$sPosterSrc]))
             $sPoster = BxDolTranscoder::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_POSTER'])->getFileUrl($aContentInfo[$sPosterSrc]);
         else 
             $sPoster = $aTranscodersVideo['poster']->getFileUrl($iFile);
 
-        return $this->parseHtmlByName('entry-video.html', array(
-            'img_title' => $sTitle,
-            'img_title_attr' => $sTitleAttr,
-            'img_src' => $aTranscodersVideo['poster']->getFileUrl($iFile),
-            'video' => BxTemplFunctions::getInstance()->videoPlayer(
+        return array(
+            'poster_url' => $aTranscodersVideo['poster']->getFileUrl($iFile),
+            'player' => BxTemplFunctions::getInstance()->videoPlayer(
                 $sPoster, 
                 $aTranscodersVideo['mp4']->getFileUrl($iFile), 
                 $aTranscodersVideo['webm']->getFileUrl($iFile),
                 false, 'max-height:' . $CNF['OBJECT_VIDEO_TRANSCODER_HEIGHT']
             )
-        ));
-    }
-
-    public function entryRating($aData)
-    {
-        $CNF = &$this->getModule()->_oConfig->CNF;
-
-    	$sVotes = '';
-        $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_STARS'], $aData['id']);
-        if($oVotes) {
-			$sVotes = $oVotes->getElementBlock(array('show_counter' => true, 'show_legend' => true));
-			if(!empty($sVotes))
-				$sVotes = $this->parseHtmlByName('entry-rating.html', array(
-		    		'content' => $sVotes,
-		    	));
-        }
-
-    	return $sVotes; 
+        );
     }
 
     public function getUnitImages ($aData)

+ 15 - 14
modules/boonex/videos/install/sql/enable.sql

@@ -42,22 +42,23 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designb
 
 -- PAGE: view entry
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
-('bx_videos_view_entry', '_bx_videos_page_title_sys_view_entry', '_bx_videos_page_title_view_entry', 'bx_videos', 10, 2147483647, 1, 'view-video', '', '', '', '', 0, 1, 0, 'BxVideosPageEntry', 'modules/boonex/videos/classes/BxVideosPageEntry.php');
+('bx_videos_view_entry', '_bx_videos_page_title_sys_view_entry', '_bx_videos_page_title_view_entry', 'bx_videos', 12, 2147483647, 1, 'view-video', '', '', '', '', 0, 1, 0, 'BxVideosPageEntry', 'modules/boonex/videos/classes/BxVideosPageEntry.php');
 
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES
-('bx_videos_view_entry', 1, 'bx_videos', '', '_bx_videos_page_block_title_entry_video', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:18:"entity_video_block";}', 0, 0, 1, 0),
-('bx_videos_view_entry', 1, 'bx_videos', '', '_bx_videos_page_block_title_entry_text', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:17:"entity_text_block";}', 0, 0, 1, 1),
-('bx_videos_view_entry', 2, 'bx_videos', '', '_bx_videos_page_block_title_entry_author', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:13:"entity_author";}', 0, 0, 1, 0),
-('bx_videos_view_entry', 2, 'bx_videos', '_bx_videos_page_block_title_sys_entry_context', '_bx_videos_page_block_title_entry_context', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:9:\"bx_videos\";s:6:\"method\";s:14:\"entity_context\";}', 0, 0, 1, 1),
-('bx_videos_view_entry', 2, 'bx_videos', '', '_bx_videos_page_block_title_entry_rating', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:13:"entity_rating";}', 0, 0, 1, 1),
-('bx_videos_view_entry', 3, 'bx_videos', '', '_bx_videos_page_block_title_entry_info', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:11:"entity_info";}', 0, 0, 1, 1),
-('bx_videos_view_entry', 3, 'bx_videos', '', '_bx_videos_page_block_title_entry_location', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:15:"entity_location";}', 0, 0, 0, 2),
-('bx_videos_view_entry', 4, 'bx_videos', '', '_bx_videos_page_block_title_entry_all_actions', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:18:"entity_all_actions";}', 0, 0, 1, 0),
-('bx_videos_view_entry', 4, 'bx_videos', '', '_bx_videos_page_block_title_entry_actions', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:14:"entity_actions";}', 0, 0, 0, 1),
-('bx_videos_view_entry', 4, 'bx_videos', '', '_bx_videos_page_block_title_entry_social_sharing', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:21:"entity_social_sharing";}', 0, 0, 0, 2),
-('bx_videos_view_entry', 4, 'bx_videos', '', '_bx_videos_page_block_title_entry_attachments', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:18:"entity_attachments";}', 0, 0, 0, 3),
-('bx_videos_view_entry', 4, 'bx_videos', '', '_bx_videos_page_block_title_entry_comments', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:15:"entity_comments";}', 0, 0, 1, 4),
-('bx_videos_view_entry', 4, 'bx_videos', '', '_bx_videos_page_block_title_entry_location', 3, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:13:"locations_map";s:6:"params";a:2:{i:0;s:9:"bx_videos";i:1;s:4:"{id}";}s:5:"class";s:20:"TemplServiceMetatags";}', 0, 0, 1, 5);
+('bx_videos_view_entry', 2, 'bx_videos', '', '_bx_videos_page_block_title_entry_video', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:18:"entity_video_block";}', 0, 0, 0, 0),
+('bx_videos_view_entry', 2, 'bx_videos', '', '_bx_videos_page_block_title_entry_text', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:17:"entity_text_block";}', 0, 0, 1, 1),
+('bx_videos_view_entry', 2, 'bx_videos', '', '_bx_videos_page_block_title_entry_author', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:13:"entity_author";}', 0, 0, 1, 3),
+('bx_videos_view_entry', 3, 'bx_videos', '_bx_videos_page_block_title_sys_entry_context', '_bx_videos_page_block_title_entry_context', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:9:\"bx_videos\";s:6:\"method\";s:14:\"entity_context\";}', 0, 0, 1, 1),
+('bx_videos_view_entry', 2, 'bx_videos', '', '_bx_videos_page_block_title_entry_rating', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:13:"entity_rating";}', 0, 0, 0, 0),
+('bx_videos_view_entry', 3, 'bx_videos', '', '_bx_videos_page_block_title_entry_info', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:11:"entity_info";}', 0, 0, 1, 2),
+('bx_videos_view_entry', 3, 'bx_videos', '', '_bx_videos_page_block_title_entry_location', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:15:"entity_location";}', 0, 0, 0, 0),
+('bx_videos_view_entry', 2, 'bx_videos', '', '_bx_videos_page_block_title_entry_all_actions', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:18:"entity_all_actions";}', 0, 0, 1, 2),
+('bx_videos_view_entry', 4, 'bx_videos', '', '_bx_videos_page_block_title_entry_actions', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:14:"entity_actions";}', 0, 0, 0, 0),
+('bx_videos_view_entry', 4, 'bx_videos', '', '_bx_videos_page_block_title_entry_social_sharing', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:21:"entity_social_sharing";}', 0, 0, 0, 0),
+('bx_videos_view_entry', 4, 'bx_videos', '', '_bx_videos_page_block_title_entry_attachments', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:18:"entity_attachments";}', 0, 0, 0, 0),
+('bx_videos_view_entry', 2, 'bx_videos', '', '_bx_videos_page_block_title_entry_comments', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_videos";s:6:"method";s:15:"entity_comments";}', 0, 0, 1, 4),
+('bx_videos_view_entry', 3, 'bx_videos', '', '_bx_videos_page_block_title_entry_location', 3, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:13:"locations_map";s:6:"params";a:2:{i:0;s:9:"bx_videos";i:1;s:4:"{id}";}s:5:"class";s:20:"TemplServiceMetatags";}', 0, 0, 1, 3),
+('bx_videos_view_entry', 3, 'bx_videos', '', '_bx_videos_page_block_title_featured_entries_view_extended', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:9:"bx_videos";s:6:"method";s:15:"browse_featured";s:6:"params";a:1:{i:0;s:8:"extended";}}', 0, 1, 1, 4);
 
 -- PAGE: view entry comments
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 

+ 5 - 1
modules/boonex/videos/template/entry-text.html

@@ -1 +1,5 @@
-<div class="bx-base-text-entity-content bx-def-constraint-list bx-def-constraint-pre bx-def-constraint-object bx-def-constraint-iframe bx-def-constraint-img">__entry_text__</div>
+<div class="bx-base-text-entity-content bx-def-constraint-list bx-def-constraint-pre bx-def-constraint-object bx-def-constraint-iframe bx-def-constraint-img">
+    <p class="bx-def-font-align-center">__entry_video__</p>
+    <h1>__entry_title__</h1>
+    __entry_text__
+</div>

+ 4 - 4
modules/boonex/videos/template/entry-video.html

@@ -1,4 +1,4 @@
-<div class="bx-videos-entity-video  bx-def-font-align-center">
-    <h1>__img_title__</h1>
-    __video__
-</div>
+<div class="bx-videos-entity-video">
+    <p class="bx-def-font-align-center">__video__</p>
+    <h1>__video_title__</h1>
+</div>