Ver código fonte

#115 caption for images and some action buttons

Alex Trofimov 11 anos atrás
pai
commit
007d98752c

+ 5 - 0
inc/classes/BxDolCmts.php

@@ -477,6 +477,11 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
         return $this->_oQuery->getObjectTitle ($iObjectId ? $iObjectId : $this->getId());
     }
 
+    public function getCommentsCountAll ($iObjectId = 0)
+    {
+        return $this->_oQuery->getCommentsCountAll ($iObjectId ? $iObjectId : $this->getId());
+    }
+
     public function getCommentsCount ($iObjectId = 0, $iCmtVParentId = -1, $sFilter = '')
     {
         return $this->_oQuery->getCommentsCount ($iObjectId ? $iObjectId : $this->getId(), $iCmtVParentId, $this->_getAuthorId(), $sFilter);

+ 6 - 0
inc/classes/BxDolCmtsQuery.php

@@ -48,6 +48,12 @@ class BxDolCmtsQuery extends BxDolDb
     {
         return $this->_sTable;
     }
+    
+    function getCommentsCountAll ($iId)
+    {
+        $sQuery = $this->prepare("SELECT `{$this->_sTriggerFieldComments}` FROM `{$this->_sTriggerTable}` WHERE `{$this->_sTriggerFieldId}` = ?", $iId);
+        return (int)$this->getOne($sQuery);
+    }
 
     function getCommentsCount ($iId, $iCmtVParentId = -1, $iAuthorId = 0, $sFilter = '')
     {

+ 19 - 4
modules/base/text/classes/BxBaseModTextModule.php

@@ -364,12 +364,26 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
         return $oCmts->getCommentsBlock(0, 0, false);
     }
 
-    protected function _entitySocialSharing ($iId, $iIdForTimeline, $iIdThumb, $sTitle, $sObjectStorage, $sObjectTranscoder, $sObjectVote, $sUriViewEntry)
+    protected function _entitySocialSharing ($iId, $iIdForTimeline, $iIdThumb, $sTitle, $sObjectStorage, $sObjectTranscoder, $sObjectVote, $sUriViewEntry, $sCommentsObject = '', $bEnableSocialSharing = true)
     {
         $sUrl = BxDolPermalinks::getInstance()->permalink('page.php?i=' . $sUriViewEntry . '&id=' . $iId);
 
+        $sComments = '';
+        if ($sCommentsObject && ($oComments = BxTemplCmts::getObjectInstance($sCommentsObject, $iId))) {
+            $iNum = $oComments->getCommentsCountAll();
+            $sComments = $this->_oTemplate->parseHtmlByName('comments-item.html', array (
+                'url' => $sUrl . '#' . $oComments->getListAnchor(),
+                'bx_if:comments' => array (
+                    'condition' => $iNum,
+                    'content' => array (
+                        'num' => $iNum,
+                    ),
+                ),
+            ));
+        }
+
         $aCustomParams = false;
-        if ($iIdThumb) {
+        if ($iIdThumb && $bEnableSocialSharing) {
             if ($sObjectTranscoder)
                 $o = BxDolTranscoder::getObjectInstance($sObjectTranscoder);
             else
@@ -390,12 +404,13 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
             $sVotes = $oVotes->getElementBlock(array('show_do_vote_as_button' => true));
 
         $sShare = '';
-        if (BxDolRequest::serviceExists('bx_timeline', 'get_share_element_block'))
+        if ($iIdForTimeline && BxDolRequest::serviceExists('bx_timeline', 'get_share_element_block'))
             $sShare = BxDolService::call('bx_timeline', 'get_share_element_block', array(bx_get_logged_profile_id(), $this->_aModule['name'], 'added', $iIdForTimeline, array('show_do_share_as_button' => true)));
 
-        $sSocial = BxTemplSocialSharing::getInstance()->getCode($iId, $this->_aModule['name'], BX_DOL_URL_ROOT . $sUrl, $sTitle, $aCustomParams);
+        $sSocial = $bEnableSocialSharing ? BxTemplSocialSharing::getInstance()->getCode($iId, $this->_aModule['name'], BX_DOL_URL_ROOT . $sUrl, $sTitle, $aCustomParams) : '';
 
         return $this->_oTemplate->parseHtmlByName('entry-share.html', array(
+            'comments' => $sComments,
             'vote' => $sVotes,
             'share' => $sShare,
             'social' => $sSocial,

+ 6 - 0
modules/base/text/template/comments-item.html

@@ -0,0 +1,6 @@
+<div class="bx-base-text-comments-item bx-def-margin-right-auto bx-def-margin-thd-topbottom bx-clearfix">
+	<a class="bx-vote-do-vote bx-btn" href="__url__"><i class="sys-icon comment-o"></i></a>
+    <bx_if:comments>
+    	<div class="bx-base-text-comments-item-counter-holder bx-def-margin-sec-left">__num__</div>
+    </bx_if:comments>
+</div>

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

@@ -178,3 +178,13 @@
     display:inline-block;
     vertical-align:top;
 }
+
+.bx-base-text-comments-item {
+    float: left;
+}
+
+.bx-base-text-comments-item-counter-holder {
+    float: left;
+    font-size: 1.5rem;
+    line-height: 2.2rem;
+}

+ 1 - 1
modules/base/text/template/entry-share.html

@@ -1 +1 @@
-<div class="bx-base-text-entity-share bx-clearfix">__vote____share____social__</div>
+<div class="bx-base-text-entity-share bx-clearfix">__comments____vote____share____social__</div>

+ 2 - 2
modules/boonex/albums/classes/BxAlbumsModule.php

@@ -76,7 +76,7 @@ class BxAlbumsModule extends BxBaseModTextModule
         return $this->_serviceTemplateFunc ('mediaAuthor', $iMediaId, 'getMediaInfoById');
     }
 
-    public function serviceMediaSocialSharing ($iMediaId = 0)
+    public function serviceMediaSocialSharing ($iMediaId = 0, $bEnableCommentsBtn = false, $bEnableSocialSharing = true)
     {
         if (!$iMediaId)
             $iMediaId = bx_process_input(bx_get('id'), BX_DATA_INT);
@@ -88,7 +88,7 @@ class BxAlbumsModule extends BxBaseModTextModule
 
         $CNF = &$this->_oConfig->CNF;
 
-        return $this->_entitySocialSharing ($iMediaId, $aMediaInfo['content_id'], $aMediaInfo['file_id'], $iMediaId['title'], false, $CNF['OBJECT_IMAGES_TRANSCODER_BIG'], $CNF['OBJECT_VOTES_MEDIA'], $CNF['URI_VIEW_MEDIA']);
+        return $this->_entitySocialSharing ($iMediaId, 0, $aMediaInfo['file_id'], $iMediaId['title'], false, $CNF['OBJECT_IMAGES_TRANSCODER_BIG'], $CNF['OBJECT_VOTES_MEDIA'], $CNF['URI_VIEW_MEDIA'], $bEnableCommentsBtn ? $CNF['OBJECT_COMMENTS_MEDIA'] : '', $bEnableSocialSharing);
     }
 
     public function serviceMediaView ($iMediaId = 0, $mixedContext = false)

+ 19 - 8
modules/boonex/albums/classes/BxAlbumsTemplate.php

@@ -107,10 +107,11 @@ class BxAlbumsTemplate extends BxBaseModTextTemplate
         $aVarsTmp = $aVars['bx_if:image']['condition'] ? $aVars['bx_if:image']['content'] : $aVars['bx_if:video']['content'];
 
         $aVars = array_merge($aVars, array (
-            'title' => bx_process_output($aData['title']),
+            'title' => $this->getMediaTitle($aData),
             'module_name' => _t($CNF['T']['txt_media_single']),
             'content_url' => $aVarsTmp['url'],
             'ts' => $aFile['added'],
+            'actions' => $oModule->serviceMediaSocialSharing($aData['id'], true, false),
             'bx_if:thumb' => array (
                 'condition' => $aData['file_id'],
                 'content' => array (
@@ -145,13 +146,7 @@ class BxAlbumsTemplate extends BxBaseModTextTemplate
 
         $sUrlAlbum = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aAlbumInfo[$CNF['FIELD_ID']]);
          
-        $sText = bx_process_output($aMediaInfo['title']);
-        if (!empty($CNF['OBJECT_METATAGS_MEDIA'])) {
-            $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS_MEDIA']);
-    
-            if ($oMetatags->keywordsIsEnabled())
-                $sText = $oMetatags->keywordsParse($iMediaId, $sText);
-        }
+        $sText = $this->getMediaTitle($aMediaInfo);
 
         $iProfileId = $aAlbumInfo[$CNF['FIELD_AUTHOR']];
         $oProfile = BxDolProfile::getInstance($iProfileId);
@@ -313,6 +308,22 @@ class BxAlbumsTemplate extends BxBaseModTextTemplate
         return _t('_sys_txt_n_by', bx_time_js($aData['added'], BX_FORMAT_DATE));
     }
 
+    function getMediaTitle ($aMediaInfo)
+    {
+        $oModule = BxDolModule::getInstance($this->MODULE);
+        $CNF = &$oModule->_oConfig->CNF;
+         
+        $sText = bx_process_output($aMediaInfo['title']);
+        if (!empty($CNF['OBJECT_METATAGS_MEDIA'])) {
+            $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS_MEDIA']);
+    
+            if ($oMetatags->keywordsIsEnabled())
+                $sText = $oMetatags->keywordsParse($aMediaInfo['id'], $sText);
+        }
+
+        return $sText;
+    }
+
     function mediaExif ($aMediaInfo, $iProfileId = false, $sFuncAuthorDesc = '', $sTemplateName = 'media-exif.html') 
     {
         if (!$aMediaInfo['exif'])

+ 3 - 0
modules/boonex/albums/template/comments-item.html

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

+ 13 - 2
modules/boonex/albums/template/css/main.css

@@ -2,18 +2,29 @@
 @import url(../../../../base/text/template/css/main.css);
 
 .bx-albums-unit-size {
-    width: 300px;
     width: 18.75rem;
-    height: 300px;
     height: 18.75rem;
     object-fit: cover;
 }
+.bx-albums-media-wrapper {
+    width: 18.75rem;
+}
 
 @media (max-width:520px) {
     .bx-albums-unit-size {
         width: 100%;
         height: auto;
     }
+    .bx-albums-media-wrapper {
+        width: 100%;
+    }
+}
+
+.bx-albums-media-caption,
+.bx-albums-media-actions {
+    white-space:nowrap;
+    overflow:hidden;
+    text-overflow:ellipsis;
 }
 
 .bx-albums-unit-images-cont {

+ 15 - 11
modules/boonex/albums/template/unit_media.html

@@ -1,13 +1,17 @@
 
-<div class="bx-def-color-bg-box bx-albums-unit-size bx-def-margin-thd-right bx-def-margin-thd-bottom" style="float:left;">
-    <bx_if:image>
-        <a href="__url__" title="__title_attr__">
-            <img class="bx-albums-unit-size" src="__url_img__" alt="__title_attr__" />
-        </a>
-    </bx_if:image>
-    <bx_if:video>
-        <a href="__url__" title="__title_attr__">
-            <img class="bx-albums-unit-size" src="__url_img__" alt="__title_attr__" />
-        </a>
-    </bx_if:video>
+<div class="bx-albums-media-wrapper bx-def-color-bg-box bx-def-margin-thd-right bx-def-margin-thd-bottom" style="float:left;">
+    <div class="bx-albums-unit-size">
+        <bx_if:image>
+            <a href="__url__" title="__title_attr__">
+                <img class="bx-albums-unit-size" src="__url_img__" alt="__title_attr__" />
+            </a>
+        </bx_if:image>
+        <bx_if:video>
+            <a href="__url__" title="__title_attr__">
+                <img class="bx-albums-unit-size" src="__url_img__" alt="__title_attr__" />
+            </a>
+        </bx_if:video>
+    </div>
+    <div class="bx-albums-media-caption bx-def-margin-sec-topbottom bx-def-margin-leftright">__title__</div>
+    <div class="bx-albums-media-actions bx-def-margin-sec-bottom bx-def-margin-leftright">__actions__</div>
 </div>

+ 1 - 1
template/scripts/BxBaseCmts.php

@@ -88,7 +88,7 @@ class BxBaseCmts extends BxDolCmts
 		BxDolLiveUpdates::getInstance()->add($this->_sSystem . '_live_updates_cmts_' . $this->_iId, 1, $sServiceCall);
 		//add live update
 
-        $sCaption = _t('_cmt_block_comments_title', $this->getCommentsCount());
+        $sCaption = _t('_cmt_block_comments_title', $this->getCommentsCountAll());
         $sContent = BxDolTemplate::getInstance()->parseHtmlByName('comments_block.html', array(
             'system' => $this->_sSystem,
             'list_anchor' => $this->getListAnchor(),