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

Ticket #1447 - Don't use custom cover in Text based modules. Posts and Videos.

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

+ 19 - 0
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -1096,6 +1096,25 @@ class BxBaseModGeneralModule extends BxDolModule
 
 	// ====== COMMON METHODS
 
+    public function getEntryImageData($aContentInfo)
+    {
+        $CNF = &$this->_oConfig->CNF;
+        if(empty($CNF['FIELD_THUMB']) || empty($aContentInfo[$CNF['FIELD_THUMB']]) || empty($CNF['OBJECT_STORAGE']))
+            return false;
+
+        $iId = (int)$aContentInfo[$CNF['FIELD_THUMB']];
+        if(!empty($CNF['OBJECT_TRANSCODER_COVER']))
+            return array('id' => $iId, 'transcoder' => $CNF['OBJECT_TRANSCODER_COVER']);
+
+        if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_COVER']))
+            return array('id' => $iId, 'transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_COVER']);
+
+        if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']))
+            return array('id' => $iId, 'transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']);
+
+        return array('id' => $iId, 'object' => $CNF['OBJECT_STORAGE']);
+    }
+
     public function getProfileId()
     {
     	return bx_get_logged_profile_id();

+ 1 - 15
modules/base/general/classes/BxBaseModGeneralPageEntry.php

@@ -108,21 +108,7 @@ class BxBaseModGeneralPageEntry extends BxTemplPage
 
     protected function _getThumbForMetaObject ()
     {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-        if(empty($CNF['FIELD_THUMB']) || empty($this->_aContentInfo[$CNF['FIELD_THUMB']]) || empty($CNF['OBJECT_STORAGE']))
-            return false;
-
-        $iId = (int)$this->_aContentInfo[$CNF['FIELD_THUMB']];
-        if(!empty($CNF['OBJECT_TRANSCODER_COVER']))
-            return array('id' => $iId, 'transcoder' => $CNF['OBJECT_TRANSCODER_COVER']);
-
-        if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_COVER']))
-            return array('id' => $iId, 'transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_COVER']);
-
-        if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']))
-            return array('id' => $iId, 'transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']);
-
-        return array('id' => $iId, 'object' => $CNF['OBJECT_STORAGE']);
+        return $this->_oModule->getEntryImageData($this->_aContentInfo);
     }
 
     protected function _getPageCacheParams ()

+ 10 - 3
modules/base/general/classes/BxBaseModGeneralTemplate.php

@@ -106,7 +106,7 @@ class BxBaseModGeneralTemplate extends BxDolModuleTemplate
         ));
     }
 
-	function entryText ($aData, $sTemplateName = 'entry-text.html')
+    public function getTmplVarsText($aData)
     {
         $CNF = &$this->getModule()->_oConfig->CNF;
 
@@ -135,10 +135,17 @@ class BxBaseModGeneralTemplate extends BxDolModuleTemplate
             $aVars['location'] = $oMetatags->locationsIsEnabled() ? $oMetatags->locationsString($aData[$CNF['FIELD_ID']]) : '';
         }
 
+        unset($aVars['recipients']);
+
+        return $aVars;
+    }
+
+    function entryText ($aData, $sTemplateName = 'entry-text.html')
+    {
+        $aVars = $this->getTmplVarsText($aData);
+
         if (empty($aVars['entry_text']))
             return false;
-
-        unset($aVars['recipients']);
         
         return $this->parseHtmlByName($sTemplateName, $aVars);
     }

+ 5 - 1
modules/base/text/classes/BxBaseModTextPageEntry.php

@@ -81,8 +81,12 @@ class BxBaseModTextPageEntry extends BxBaseModGeneralPageEntry
         if (false !== strpos($aBlock['content'], 'entity_comments') && substr_compare($this->_sObject, $sTest, strlen($this->_sObject) - strlen($sTest), strlen($sTest)) === 0)
             unset($a['title']);            
         return $a;
-    }    
+    }
 
+    protected function _getImageForPageCover ()
+    {
+        return false;
+    }
 }
 
 /** @} */

+ 26 - 0
modules/base/text/classes/BxBaseModTextTemplate.php

@@ -103,6 +103,32 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
         return $this->parseHtmlByName($sTemplateName, $aVars);
     }
 
+    public function getTmplVarsText($aData)
+    {
+        $aVars = parent::getTmplVarsText($aData);
+        
+        $sImage = '';
+        $mixedImage = $this->getModule()->getEntryImageData($aData);
+        if($mixedImage !== false) {
+            if(!empty($mixedImage['object']))
+                $o = BxDolStorage::getObjectInstance($mixedImage['object']);
+            else if(!empty($mixedImage['transcoder']))
+                $o = BxDolTranscoder::getObjectInstance($mixedImage['transcoder']);
+
+            if($o)
+                $sImage = $o->getFileUrlById($mixedImage['id']);
+        }
+
+        $aVars['bx_if:show_image'] = array(
+            'condition' => !empty($sImage),
+            'content' => array(
+                'entry_image' => $sImage
+            )
+        );
+
+        return $aVars;
+    }
+
     function getAuthorDesc ($aData)
     {
         return '';

+ 4 - 0
modules/base/text/template/css/main.css

@@ -211,6 +211,10 @@ div.bx-base-text-breadcrumb i {
 }
 
 /* view page */
+.bx-base-text-entity-image img {
+    max-width: 100%;
+}
+
 .bx-base-text-entity-content,
 .bx-base-text-entity-content p,
 .bx-base-text-entity-content h1,

+ 6 - 3
modules/base/text/template/entry-text.html

@@ -1,6 +1,9 @@
-
+<bx_if:show_image>
+    <div class="bx-base-text-entity-image bx-def-margin-bottom bx-def-font-align-center">
+        <img class="bx-def-border-radius-block" src="__entry_image__" />
+    </div>
+</bx_if:show_image>
 <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">
     <h1>__entry_title__</h1>
     __entry_text__
-</div>
-
+</div>

+ 3 - 0
modules/boonex/decorous/data/template/system/css/default.less

@@ -411,6 +411,9 @@ a.bx-def-font-h3:hover {
 
 	.radius(@bx-border-radius-block);
 }
+.bx-def-border-radius-block {
+    .radius(@bx-border-radius-block);
+}
 .bx-db-header {
 	padding: @bx-title-padding-block;
 

+ 13 - 12
modules/boonex/posts/install/sql/enable.sql

@@ -50,20 +50,21 @@ 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_posts_view_entry', '_bx_posts_page_title_sys_view_entry', '_bx_posts_page_title_view_entry', 'bx_posts', 10, 2147483647, 1, 'view-post', '', '', '', '', 0, 1, 0, 'BxPostsPageEntry', 'modules/boonex/posts/classes/BxPostsPageEntry.php');
+('bx_posts_view_entry', '_bx_posts_page_title_sys_view_entry', '_bx_posts_page_title_view_entry', 'bx_posts', 12, 2147483647, 1, 'view-post', '', '', '', '', 0, 1, 0, 'BxPostsPageEntry', 'modules/boonex/posts/classes/BxPostsPageEntry.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_posts_view_entry', 1, 'bx_posts', '', '_bx_posts_page_block_title_entry_text', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:17:\"entity_text_block\";}', 0, 0, 1, 0),
-('bx_posts_view_entry', 2, 'bx_posts', '', '_bx_posts_page_block_title_entry_author', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:13:\"entity_author\";}', 0, 0, 1, 0),
-('bx_posts_view_entry', 2, 'bx_posts', '_bx_posts_page_block_title_sys_entry_context', '_bx_posts_page_block_title_entry_context', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:14:\"entity_context\";}', 0, 0, 1, 1),
-('bx_posts_view_entry', 3, 'bx_posts', '', '_bx_posts_page_block_title_entry_info', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:11:\"entity_info\";}', 0, 0, 1, 1),
-('bx_posts_view_entry', 3, 'bx_posts', '', '_bx_posts_page_block_title_entry_location', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:15:\"entity_location\";}', 0, 0, 0, 2),
-('bx_posts_view_entry', 4, 'bx_posts', '', '_bx_posts_page_block_title_entry_all_actions', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:18:\"entity_all_actions\";}', 0, 0, 1, 0),
-('bx_posts_view_entry', 4, 'bx_posts', '', '_bx_posts_page_block_title_entry_actions', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:14:\"entity_actions\";}', 0, 0, 0, 1),
-('bx_posts_view_entry', 4, 'bx_posts', '', '_bx_posts_page_block_title_entry_social_sharing', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:21:\"entity_social_sharing\";}', 0, 0, 0, 2),
-('bx_posts_view_entry', 4, 'bx_posts', '', '_bx_posts_page_block_title_entry_attachments', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:18:\"entity_attachments\";}', 0, 0, 0, 3),
-('bx_posts_view_entry', 4, 'bx_posts', '', '_bx_posts_page_block_title_entry_comments', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:15:\"entity_comments\";}', 0, 0, 1, 4),
-('bx_posts_view_entry', 4, 'bx_posts', '', '_bx_posts_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:8:\"bx_posts\";i:1;s:4:\"{id}\";}s:5:\"class\";s:20:\"TemplServiceMetatags\";}', 0, 0, 1, 5);
+('bx_posts_view_entry', 2, 'bx_posts', '', '_bx_posts_page_block_title_entry_text', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:17:\"entity_text_block\";}', 0, 0, 1, 2),
+('bx_posts_view_entry', 2, 'bx_posts', '', '_bx_posts_page_block_title_entry_author', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:13:\"entity_author\";}', 0, 0, 1, 1),
+('bx_posts_view_entry', 3, 'bx_posts', '_bx_posts_page_block_title_sys_entry_context', '_bx_posts_page_block_title_entry_context', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:14:\"entity_context\";}', 0, 0, 1, 1),
+('bx_posts_view_entry', 3, 'bx_posts', '', '_bx_posts_page_block_title_entry_info', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:11:\"entity_info\";}', 0, 0, 1, 2),
+('bx_posts_view_entry', 3, 'bx_posts', '', '_bx_posts_page_block_title_entry_location', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:15:\"entity_location\";}', 0, 0, 0, 0),
+('bx_posts_view_entry', 2, 'bx_posts', '', '_bx_posts_page_block_title_entry_all_actions', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:18:\"entity_all_actions\";}', 0, 0, 1, 3),
+('bx_posts_view_entry', 4, 'bx_posts', '', '_bx_posts_page_block_title_entry_actions', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:14:\"entity_actions\";}', 0, 0, 0, 0),
+('bx_posts_view_entry', 4, 'bx_posts', '', '_bx_posts_page_block_title_entry_social_sharing', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:21:\"entity_social_sharing\";}', 0, 0, 0, 0),
+('bx_posts_view_entry', 4, 'bx_posts', '', '_bx_posts_page_block_title_entry_attachments', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:18:\"entity_attachments\";}', 0, 0, 0, 0),
+('bx_posts_view_entry', 2, 'bx_posts', '', '_bx_posts_page_block_title_entry_comments', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:15:\"entity_comments\";}', 0, 0, 1, 4),
+('bx_posts_view_entry', 3, 'bx_posts', '', '_bx_posts_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:8:\"bx_posts\";i:1;s:4:\"{id}\";}s:5:\"class\";s:20:\"TemplServiceMetatags\";}', 0, 0, 1, 3),
+('bx_posts_view_entry', 3, 'bx_posts', '', '_bx_posts_page_block_title_featured_entries_view_extended', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:8:"bx_posts";s:6:"method";s:15:"browse_featured";s:6:"params";a:1:{i:0;s:8:"extended";}}', 0, 0, 1, 4);
 
 
 -- PAGE: view entry comments

+ 1 - 3
modules/boonex/posts/template/entry-text.html

@@ -1,3 +1 @@
-
-<bx_include_base:../modules/base/text/template/entry-text.html />
-
+<bx_include_base:../modules/base/text/template/entry-text.html />

+ 3 - 0
modules/boonex/protean/data/template/system/css/default.less

@@ -398,6 +398,9 @@ a.bx-def-font-h3:hover {
 	border-radius: @bx-border-radius-block;
 	background-clip: padding-box;    
 }
+.bx-def-border-radius-block {
+    .radius(@bx-border-radius-block);
+}
 .bx-db-header {
 	padding: @bx-title-padding-block;
 

+ 0 - 8
modules/boonex/videos/classes/BxVideosConfig.php

@@ -11,7 +11,6 @@
 
 class BxVideosConfig extends BxBaseModTextConfig
 {
-	protected $_bViewPageCover;
 
     function __construct($aModule)
     {
@@ -159,14 +158,7 @@ class BxVideosConfig extends BxBaseModTextConfig
         	'common' => $this->CNF['OBJECT_GRID_COMMON'],
         	'administration' => $this->CNF['OBJECT_GRID_ADMINISTRATION']
         );
-
-        $this->_bViewPageCover = false;
     }
-
-    public function isViewPageCover()
-    {
-    	return $this->_bViewPageCover;
-    } 
 }
 
 /** @} */

+ 0 - 16
modules/boonex/videos/classes/BxVideosPageEntry.php

@@ -27,22 +27,6 @@ class BxVideosPageEntry extends BxBaseModTextPageEntry
     	)));
     }
 
-    protected function _getImageForPageCover ()
-    {
-    	if(!$this->_oModule->_oConfig->isViewPageCover())
-    		return false;
-
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        if(!empty($CNF['FIELD_THUMB']) && !empty($this->_aContentInfo[$CNF['FIELD_THUMB']]))
-            return array('id' => $this->_aContentInfo[$CNF['FIELD_THUMB']], 'transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_COVER']);
-
-        if(!empty($CNF['FIELD_VIDEO']) && !empty($this->_aContentInfo[$CNF['FIELD_VIDEO']]))
-            return array('id' => $this->_aContentInfo[$CNF['FIELD_VIDEO']], 'transcoder' => $CNF['OBJECT_VIDEOS_TRANSCODERS']['poster']);
-
-        return false;
-    }
-
     protected function _getThumbForMetaObject ()
     {
         $CNF = &$this->_oModule->_oConfig->CNF;

+ 1 - 1
modules/boonex/videos/install/sql/enable.sql

@@ -58,7 +58,7 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `t
 ('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);
+('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, 0, 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