AntonLV 9 vuotta sitten
vanhempi
sitoutus
955d9b892a

+ 2 - 1
inc/classes/BxDolCmtsQuery.php

@@ -288,7 +288,8 @@ class BxDolCmtsQuery extends BxDolDb
         $sQuery = "SELECT 
         		`tf2e`.*,
         		`tf`.`file_name` AS `file_name`,
-        		`tf`.`mime_type` AS `mime_type` 
+        		`tf`.`mime_type` AS `mime_type`,
+        		`tf`.`size` AS `size` 
         	FROM `{$this->_sTableFiles2Entries}` AS `tf2e` 
         	LEFT JOIN `{$this->_sTableFiles}` AS `tf` ON (`tf2e`.`image_id` = `tf`.`id`) " . $sJoin . " 
         	WHERE 1 " . $sWhere;

+ 1 - 1
inc/js/classes/BxDolCmts.js

@@ -302,7 +302,7 @@ BxDolCmts.prototype.showMore = function(oLink)
 };
 
 BxDolCmts.prototype.showImage = function(oLink, sUrl) {
-	$(this._sRootId + '-view-image-popup').dolPopupImage(sUrl, $(oLink).parent());
+	$(this._sRootId + '-view-image-popup').dolPopupImage(sUrl, $(oLink).parents('.cmt-attached:first'));
 };
 
 BxDolCmts.prototype.toggleReply = function(e, iCmtParentId)

+ 1 - 1
modules/boonex/forum/classes/BxForumCmts.php

@@ -19,7 +19,7 @@ class BxForumCmts extends BxTemplCmts
     	$this->MODULE = 'bx_forum';
     	$this->_oModule = BxDolModule::getInstance($this->MODULE);
 
-        parent::__construct($sSystem, $iId, $iInit);
+        parent::__construct($sSystem, $iId, $iInit, $this->_oModule->_oTemplate);
 
         $this->setTableNameFiles('bx_forum_files');
     }

+ 12 - 0
modules/boonex/forum/template/comment_attachments.html

@@ -0,0 +1,12 @@
+<bx_repeat:attached>
+	<div class="__style_prefix__-attached-preview bx-forum-attached-preview bx-def-round-corners bx-def-padding-thd">
+		<bx_if:show_image>
+			<img src="<bx_image_url:spacer.gif />" style="background-image:url(__preview__)" />
+			<a href="javascript:void(0)" onclick="__js_object__.showImage(this, '__file__'); return false;" title="<bx_text_attribute:_cmt_view_attached_image />">__file_name__ <span class="bx-def-font-grayed">__file_size__</span></a>
+		</bx_if:show_image>
+		<bx_if:show_file>
+			<i class="sys-icon __file_icon__"></i>
+			<a href="__file__" title="<bx_text_attribute:_cmt_download_attached_file />">__file_name__ <span class="bx-def-font-grayed">__file_size__</span></a>
+		</bx_if:show_file>
+	</div>
+</bx_repeat:attached>

+ 24 - 1
modules/boonex/forum/template/css/main.css

@@ -23,7 +23,30 @@
 /*-- Replies --*/
 .cmt.bx-def-box .cmts.cmts-margin {
 	margin-top: 0px;
-} 
+}
+.cmt-attached-preview.bx-forum-attached-preview {
+	display: block;
+	float: none;
+
+	width: auto;
+	height: 2rem;
+	line-height: 2rem;
+}
+.cmt-attached-preview.bx-forum-attached-preview a,
+.cmt-attached-preview.bx-forum-attached-preview img,
+.cmt-attached-preview.bx-forum-attached-preview .sys-icon {
+	display: inline-block;
+	vertical-align: middle;
+}
+.cmt-attached-preview.bx-forum-attached-preview img,
+.cmt-attached-preview.bx-forum-attached-preview .sys-icon {
+	width: 2rem;
+	height: 2rem;
+}
+.cmt-attached-preview.bx-forum-attached-preview .sys-icon {
+	text-align: center;
+	font-size: 1.25rem;
+}
 
 /*-- Preview --*/
 .bx-forum-preview {

+ 1 - 16
template/comment.html

@@ -36,22 +36,7 @@
 						__text__<bx_if:show_more><span class="__style_prefix__-body-see-more">... <a class="bx-def-font-small" href="javascript:void(0)" onclick="__js_object__.showMore(this);"><bx_text:_see_more /></a></span><span style="display:none;"> __text_more__</span></bx_if:show_more>
 					</div>
 					<bx_if:show_attached>
-						<div class="__style_prefix__-attached bx-def-margin-thd-leftright-neg bx-clearfix">
-							<bx_repeat:attached>
-								<div class="__style_prefix__-attached-preview bx-def-round-corners bx-def-margin-thd">
-									<bx_if:show_image>
-										<a href="javascript:void(0)" onclick="__js_object__.showImage(this, '__file__'); return false;" title="<bx_text_attribute:_cmt_view_attached_image />">
-											<img src="<bx_image_url:spacer.gif />" style="background-image:url(__preview__)" />
-										</a>
-									</bx_if:show_image>
-									<bx_if:show_file>
-										<a href="__file__" title="<bx_text_attribute:_cmt_download_attached_file />">
-											<img src="<bx_image_url:spacer.gif />" style="background-image:url(__preview__)" />
-										</a>
-									</bx_if:show_file>
-								</div>
-							</bx_repeat:attached>
-						</div>
+						<div class="__style_prefix__-attached bx-def-margin-thd-leftright-neg bx-clearfix">__attached__</div>
 					</bx_if:show_attached>
 				</div>
 			</div>

+ 14 - 0
template/comment_attachments.html

@@ -0,0 +1,14 @@
+<bx_repeat:attached>
+	<div class="__style_prefix__-attached-preview bx-def-round-corners bx-def-margin-thd">
+		<bx_if:show_image>
+			<a href="javascript:void(0)" onclick="__js_object__.showImage(this, '__file__'); return false;" title="<bx_text_attribute:_cmt_view_attached_image />">
+				<img src="<bx_image_url:spacer.gif />" style="background-image:url(__preview__)" />
+			</a>
+		</bx_if:show_image>
+		<bx_if:show_file>
+			<a href="__file__" title="<bx_text_attribute:_cmt_download_attached_file />">
+				<img src="<bx_image_url:spacer.gif />" style="background-image:url(__preview__)" />
+			</a>
+		</bx_if:show_file>
+	</div>
+</bx_repeat:attached>

+ 1 - 0
template/css/cmts.css

@@ -140,6 +140,7 @@
 	div.cmt-attached-preview img {
 		background-position: center center;
 		background-repeat: no-repeat;
+		background-size: contain;
 	}
 	
     /*--- Comment Actions ---*/

+ 52 - 43
template/scripts/BxBaseCmts.php

@@ -214,47 +214,7 @@ class BxBaseCmts extends BxDolCmts
             );
         }
 
-        $aTmplImages = array();
-        if($this->isAttachImageEnabled()) {
-            $aFiles = $this->_oQuery->getFiles($this->_aSystem['system_id'], $aCmt['cmt_id']);
-            if(!empty($aFiles) && is_array($aFiles)) {
-        		$oStorage = BxDolStorage::getObjectInstance($this->getStorageObjectName());
-                $oTranscoder = BxDolTranscoderImage::getObjectInstance($this->getTranscoderPreviewName());
-
-                foreach($aFiles as $aFile) {
-                	$bImage = strncmp($aFile['mime_type'], 'image/', 6) === 0;
-                	$bVideo = strncmp($aFile['mime_type'], 'video/', 6) === 0;
-
-                	$sPreview = '';
-                	if($oTranscoder && ($bImage || $bVideo))
-                		$sPreview = $oTranscoder->getFileUrl($aFile['image_id']);
-
-            		if(!$sPreview)
-                		$sPreview = $this->_oTemplate->getIconUrl($oStorage->getIconNameByFileName($aFile['file_name']));
-
-					$sFile = $oStorage->getFileUrlById($aFile['image_id']);
-
-                    $aTmplImages[] = array(
-                        'style_prefix' => $this->_sStylePrefix,
-                    	'bx_if:show_image' => array(
-                    		'condition' => $bImage,
-                    		'content' => array(
-								'js_object' => $this->_sJsObjName,
-								'preview' => $sPreview,
-								'file' => $sFile
-                    		)
-                    	),
-                        'bx_if:show_file' => array(
-                    		'condition' => !$bImage,
-                    		'content' => array(
-								'preview' => $sPreview,
-								'file' => $sFile
-                    		)
-                    	),
-                    );
-                }
-            }
-        }
+        $sAttachments = $this->_getAttachments($aCmt);
 
         $sReplies = '';
         if((int)$aCmt['cmt_replies'] > 0 && !empty($aDp) && $aDp['type'] == BX_CMT_DISPLAY_THREADED) {
@@ -290,10 +250,10 @@ class BxBaseCmts extends BxDolCmts
                 )
             ),
             'bx_if:show_attached' => array(
-                'condition' => !empty($aTmplImages),
+                'condition' => !empty($sAttachments),
                 'content' => array(
                     'style_prefix' => $this->_sStylePrefix,
-                    'bx_repeat:attached' => $aTmplImages
+                    'attached' => $sAttachments
                 )
             ),
             'actions' => $sActions,
@@ -759,6 +719,55 @@ class BxBaseCmts extends BxDolCmts
     	return BxTemplFunctions::getInstance()->transBox($sViewImagePopupId, $sViewImagePopupContent, true);
     }
 
+    protected function _getAttachments($aCmt)
+    {
+        $aTmplImages = array();
+        if(!$this->isAttachImageEnabled())
+            return ''; 
+
+        $aFiles = $this->_oQuery->getFiles($this->_aSystem['system_id'], $aCmt['cmt_id']);
+        if(!empty($aFiles) && is_array($aFiles)) {
+    		$oStorage = BxDolStorage::getObjectInstance($this->getStorageObjectName());
+            $oTranscoder = BxDolTranscoderImage::getObjectInstance($this->getTranscoderPreviewName());
+
+            foreach($aFiles as $aFile) {
+            	$bImage = strncmp($aFile['mime_type'], 'image/', 6) === 0;
+
+            	$sPreview = '';
+            	if($oTranscoder && $bImage)
+            		$sPreview = $oTranscoder->getFileUrl($aFile['image_id']);
+
+        		if(!$sPreview)
+            		$sPreview = $this->_oTemplate->getIconUrl($oStorage->getIconNameByFileName($aFile['file_name']));
+
+				$aTmplVarsFile = array(
+				    'js_object' => $this->_sJsObjName,
+					'preview' => $sPreview,
+					'file' => $oStorage->getFileUrlById($aFile['image_id']),
+        			'file_name' => $aFile['file_name'],
+                    'file_icon' => $oStorage->getFontIconNameByFileName($aFile['file_name']),
+				    'file_size' => _t_format_size($aFile['size']),
+				);
+
+                $aTmplImages[] = array(
+                    'style_prefix' => $this->_sStylePrefix,
+                	'bx_if:show_image' => array(
+                		'condition' => $bImage,
+                		'content' => $aTmplVarsFile
+                	),
+                    'bx_if:show_file' => array(
+                		'condition' => !$bImage,
+                		'content' => $aTmplVarsFile
+                	),
+                );
+            }
+        }
+
+        return $this->_oTemplate->parseHtmlByName('comment_attachments.html', array(
+            'bx_repeat:attached' => $aTmplImages
+        ));
+    }
+
     protected function _getTmplVarsAuthor($aCmt)
     {
     	list($sAuthorName, $sAuthorLink, $sAuthorIcon) = $this->_getAuthorInfo($aCmt['cmt_author_id']);