AntonLV 13 лет назад
Родитель
Сommit
c1beb60efe

+ 10 - 1
inc/classes/BxDolCmts.php

@@ -492,7 +492,7 @@ class BxDolCmts extends BxDol
         if (!$this->isEnabled())
            return '';
 
-        $iCmtId= isset($_REQUEST['CmtId']) ? bx_process_input($_REQUEST['CmtId'], BX_DATA_INT) : 0;
+        $iCmtId = isset($_REQUEST['CmtId']) ? bx_process_input($_REQUEST['CmtId'], BX_DATA_INT) : 0;
         return $this->getPlusedBy($iCmtId);
     }
 
@@ -525,6 +525,15 @@ class BxDolCmts extends BxDol
         return $this->getComments(array('vparent_id' => $iCmtVParentId, 'start' => $iCmtStart, 'per_view' => $iCmtPerView, 'type' => $sCmtBrowse), array('type' => $sCmtDisplay));
     }
 
+	function actionGetImage ()
+    {
+    	if (!$this->isEnabled())
+           return '';
+
+		$iImgId = bx_process_input(bx_get('ImgId'), BX_DATA_INT);
+        return $this->getImage($iImgId);
+    }
+
     function actionSubmitPostForm()
     {
         if(!$this->isEnabled() || !$this->isPostReplyAllowed()) {

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

@@ -281,6 +281,38 @@ BxDolCmts.prototype.showMore = function(oLink)
 	$(oLink).parent('span').next('span').show().prev('span').remove();
 };
 
+BxDolCmts.prototype.showImage = function(oLink, iId) {
+	var $this = this;
+
+    var oData = this._getDefaultActions();
+    oData['action'] = 'GetImage';
+    oData['ImgId'] = iId;
+
+    if(oLink)
+    	this._loadingInContent(oLink, true);
+
+    jQuery.post (
+        this._sActionsUrl,
+        oData,
+        function (s) {
+        	if(oLink)
+        		$this._loadingInContent(oLink, false);
+
+        	var oPopup = $(s).hide(); 
+
+	    	$('#' + oPopup.attr('id')).remove();
+	        oPopup.prependTo('body').find('img').bind('load', function() {
+	        	$(this).parents('.cmt-attached-image').dolPopup({
+		        	fog: {
+						color: '#fff',
+						opacity: .7
+		            }
+		        });	        	
+	        });	        
+        }
+    );
+};
+
 BxDolCmts.prototype.toggleReply = function(e, iCmtParentId)
 {
 	var $this = this;
@@ -464,7 +496,7 @@ BxDolCmts.prototype._getForm = function (e, iCmtParentId, onLoad)
             if(typeof onLoad == 'function')
     			onLoad(s);
         }
-    );	
+    );
 };
 
 BxDolCmts.prototype._cmtsAppend = function(sIdTo, sContent)

+ 1 - 0
modules/boonex/english/data/langs/system.xml

@@ -1182,6 +1182,7 @@ Please click "Continue" below to navigate to the home page of the site.]]></stri
 	<string name="_cmt_page_view_header"><![CDATA[Comment to {0}]]></string>
 	<string name="_cmt_page_view_title"><![CDATA[Comment to <a href="{0}">{1}</a>]]></string>
 	<string name="_cmt_block_comments_title"><![CDATA[Comments ({0})]]></string>
+	<string name="_cmt_view_attached_image"><![CDATA[View attached image]]></string>
 	<string name="_cmt_err_cannot_perform_action"><![CDATA[Cannot perform action. Please report.]]></string>
 	<string name="_Reply_to_this_comment"><![CDATA[Reply]]></string>
 	<string name="_Add Your Comment"><![CDATA[Comment]]></string>

+ 1 - 0
template/bx_img.html

@@ -0,0 +1 @@
+<img <bx_if:class>class="__content__"</bx_if:class> src="__src__" alt="__alt__" title="__alt__" />

+ 3 - 1
template/comment.html

@@ -34,7 +34,9 @@
 				<div class="__style_prefix__-attached bx-def-margin-thd-topbottom bx-clearfix">
 					<bx_repeat:attached>
 						<div class="__style_prefix__-attached-preview bx-def-thumb bx-def-margin-sec-left-auto">
-							<img src="<bx_image_url:spacer.gif />" style="background-image:url(__image__)" />
+							<a href="javascript:void(0)" onclick="__js_object__.showImage(this, __id__); return false;" title="<bx_text:_cmt_view_attached_image />">
+								<img src="<bx_image_url:spacer.gif />" style="background-image:url(__image__)" />
+							</a>
 						</div>
 					</bx_repeat:attached>
 				</div>

+ 1 - 0
template/comment_image.html

@@ -0,0 +1 @@
+<div id="__id__" class="__style_prefix__-attached-image" style="display:none;">__content__</div>

+ 6 - 0
template/css/cmts.css

@@ -166,6 +166,12 @@
 		background-repeat: no-repeat;
 	}
 
+	div.cmt-attached-image img {
+		position: relative;
+		max-width: 600px;
+		max-height: 600px;
+	}
+	
     /*--- Comment Actions ---*/
 	div.cmt-actions {
 		position: relative;

+ 27 - 1
template/scripts/BxBaseCmtsView.php

@@ -217,6 +217,8 @@ class BxBaseCmtsView extends BxDolCmts {
         	foreach($aImages as $aImage)
         		$aTmplImages[] = array(
         			'style_prefix' => $this->_sStylePrefix,
+        			'js_object' => $this->_sJsObjName,
+        			'id' => $aImage['image_id'],
         			'image' => $oTranscoder->getImageUrl($aImage['image_id'])
         		);
 		}
@@ -334,7 +336,31 @@ class BxBaseCmtsView extends BxDolCmts {
 
         return $oTemplate->parseHtmlByName('comment_plused_by.html', array(
         	'style_prefix' => $this->_sStylePrefix,
-        	'id' => $this->_sSystem . '-plused-by' . $iCmtId,
+        	'id' => $this->_sSystem . '-plused-by',
+        	'content' => $sContent
+        ));
+    }
+
+    function getImage($iImgId)
+    {
+    	$oTemplate = BxDolTemplate::getInstance();
+
+    	bx_import('BxDolStorage');
+		$oStorage = BxDolStorage::getObjectInstance($this->_sStorageObject);
+
+    	bx_import('BxTemplStudioFunctions');
+        $sContent = BxTemplStudioFunctions::getInstance()->transBox($oTemplate->parseHtmlByName('bx_img.html', array(
+    		'bx_if:class' => array(
+        		'condition' => false,
+        		'content' => array()
+        	),
+    		'src' => $oStorage->getFileUrlById($iImgId),
+        	'alt' => _t('_cmt_view_attached_image')
+    	)));
+
+        return $oTemplate->parseHtmlByName('comment_image.html', array(
+        	'style_prefix' => $this->_sStylePrefix,
+        	'id' => $this->_sSystem . '-attached-image', 
         	'content' => $sContent
         ));
     }