Selaa lähdekoodia

Ticket #2213 - Core changes.

AntonLV 7 vuotta sitten
vanhempi
sitoutus
ce46c9b1bc

+ 6 - 0
inc/classes/BxDolCmts.php

@@ -9,6 +9,9 @@
 
 bx_import('BxDolAcl');
 
+define('BX_DOL_CMT_TYPE_COMMENT', 'comment');
+define('BX_DOL_CMT_TYPE_REVIEW', 'review');
+
 define('BX_CMT_OLD_VOTES', 365*86400); ///< comment votes older than this number of seconds will be deleted automatically
 
 define('BX_CMT_ACTION_POST', 'post');
@@ -143,6 +146,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
     protected $_sTableImages = 'sys_cmts_images';
     protected $_sTableImages2Entries = 'sys_cmts_images2entries';
 
+    protected $_sType;
     protected $_oQuery = null;
     protected $_oTemplate = null;
 
@@ -196,6 +200,8 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
     {
         parent::__construct();
 
+        $this->_sType = BX_DOL_CMT_TYPE_COMMENT;
+
         $this->_aSystems = $this->getSystems();
         if(!isset($this->_aSystems[$sSystem]))
             return;

+ 8 - 33
inc/classes/BxDolCmtsQuery.php

@@ -159,16 +159,8 @@ class BxDolCmtsQuery extends BxDolDb
        	$sLimit = $iCount != -1 ? $this->prepareAsString(" LIMIT ?, ?", (int)$iStart, (int)$iCount) : '';
 
         $sQuery = "SELECT
-                `{$this->_sTable}`.`cmt_id`,
-                `{$this->_sTableIds}`.`id` AS `cmt_unique_id`,
-                `{$this->_sTable}`.`cmt_parent_id`,
-                `{$this->_sTable}`.`cmt_vparent_id`,
-                `{$this->_sTable}`.`cmt_object_id`,
-                `{$this->_sTable}`.`cmt_author_id`,
-                `{$this->_sTable}`.`cmt_level`,
-                `{$this->_sTable}`.`cmt_text`,
-                `{$this->_sTable}`.`cmt_replies`,
-                `{$this->_sTable}`.`cmt_time`
+                `{$this->_sTable}`.*,
+                `{$this->_sTableIds}`.`id` AS `cmt_unique_id`
                 $sFields
             FROM `{$this->_sTable}`
             LEFT JOIN `{$this->_sTableIds}` ON (`{$this->_sTable}`.`cmt_id` = `{$this->_sTableIds}`.`cmt_id` AND `{$this->_sTableIds}`.`system_id` = :system_id)
@@ -177,26 +169,17 @@ class BxDolCmtsQuery extends BxDolDb
         return $this->getAll($sQuery, $aBindings);
     }
 
-	function getCommentsBy($aParams = array())
+    function getCommentsBy($aParams = array())
     {
     	$aMethod = array('name' => 'getAll', 'params' => array(0 => 'query', 1 => array()));
         $sSelectClause = $sJoinClause = $sWhereClause = $sOrderClause = $sLimitClause = "";
 
-        $sSelectClause = "
-        	`{$this->_sTable}`.`cmt_id`,
-            `{$this->_sTable}`.`cmt_parent_id`,
-            `{$this->_sTable}`.`cmt_vparent_id`,
-            `{$this->_sTable}`.`cmt_object_id`,
-            `{$this->_sTable}`.`cmt_author_id`,
-            `{$this->_sTable}`.`cmt_level`,
-            `{$this->_sTable}`.`cmt_text`,
-            `{$this->_sTable}`.`cmt_replies`,
-            `{$this->_sTable}`.`cmt_time`";
+        $sSelectClause = "`{$this->_sTable}`.*";
 
         if(isset($aParams['object_id'])) {
-        	$aMethod['params'][1]['cmt_object_id'] = (int)$aParams['object_id'];
+            $aMethod['params'][1]['cmt_object_id'] = (int)$aParams['object_id'];
 
-        	$sWhereClause .= " AND `{$this->_sTable}`.`cmt_object_id` = :cmt_object_id";
+            $sWhereClause .= " AND `{$this->_sTable}`.`cmt_object_id` = :cmt_object_id";
         }
 
         switch($aParams['type']) {
@@ -310,16 +293,8 @@ class BxDolCmtsQuery extends BxDolDb
         }
 
         $sQuery = $this->prepare("SELECT
-                `{$this->_sTable}`.`cmt_id`,
-                `{$this->_sTableIds}`.`id` AS `cmt_unique_id`,
-                `{$this->_sTable}`.`cmt_parent_id`,
-                `{$this->_sTable}`.`cmt_vparent_id`,
-                `{$this->_sTable}`.`cmt_object_id`,
-                `{$this->_sTable}`.`cmt_author_id`,
-                `{$this->_sTable}`.`cmt_level`,
-                `{$this->_sTable}`.`cmt_text`,
-                `{$this->_sTable}`.`cmt_replies`,
-                `{$this->_sTable}`.`cmt_time`
+                `{$this->_sTable}`.*,
+                `{$this->_sTableIds}`.`id` AS `cmt_unique_id`
                 $sFields
             FROM `{$this->_sTable}`
             LEFT JOIN `{$this->_sTableIds}` ON (`{$this->_sTable}`.`cmt_id` = `{$this->_sTableIds}`.`cmt_id` AND `{$this->_sTableIds}`.`system_id` = ?)

+ 83 - 0
inc/classes/BxDolCmtsReviews.php

@@ -0,0 +1,83 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+
+
+/**
+ * Reviews for any content
+ */
+class BxDolCmtsReviews extends BxTemplCmts
+{
+    protected $_iMoodMinValue;
+    protected $_iMoodMaxValue;
+    protected $_sMoodLegendId;
+
+    protected $_sRatingLegendId;
+
+    public function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+
+        $this->_sType = BX_DOL_CMT_TYPE_REVIEW;
+        $this->_oQuery = new BxDolCmtsReviewsQuery($this);
+
+        $this->_sFormObject = 'sys_review';
+        $this->_sFormDisplayPost = 'sys_review_post';
+        $this->_sFormDisplayEdit = 'sys_review_edit';
+
+        $this->_aT = array(
+            'block_comments_title' => '_cmt_rvw_block_reviews_title',
+            'block_rating_title' => '_cmt_rvw_block_rating_title',
+            'txt_sample_single' => '_cmt_rvw_txt_sample_review_single',
+            'txt_sample_vote_single' => '_cmt_rvw_txt_sample_vote_single',
+            'txt_sample_reaction_single' => '_cmt_rvw_txt_sample_reaction_single',
+            'txt_sample_score_up_single' => '_cmt_rvw_txt_sample_score_up_single',
+            'txt_sample_score_down_single' => '_cmt_rvw_txt_sample_score_down_single'
+        );
+
+        $this->_iMoodMinValue = 1;
+        $this->_iMoodMaxValue = 5;
+        $this->_sMoodLegendId = "cmt-legend-%s-%d-%d";
+
+        $this->_sRatingLegendId = "cmt-legend-%s-%d";
+    }
+
+    public function getMoodMinValue()
+    {
+        return $this->_iMoodMinValue;
+    }
+
+    public function getMoodMaxValue()
+    {
+        return $this->_iMoodMaxValue;
+    }
+
+    public function getMoodLegendId($iItemId)
+    {
+        return sprintf($this->_sMoodLegendId, str_replace('_', '-', $this->getSystemName()), $this->getId(), $iItemId);
+    }
+
+    public function getRatingLegendId()
+    {
+        return sprintf($this->_sRatingLegendId, str_replace('_', '-', $this->getSystemName()), $this->getId());
+    }
+
+    protected function _triggerComment()
+    {
+        $mixedResult = parent::_triggerComment();
+        if($mixedResult === false)
+            return $mixedResult;
+
+        $iId = $this->getId();
+        $fAvg = $this->_oQuery->getReviewsAvg($iId);
+        return $this->_oQuery->updateTriggerTableAvg($iId, $fAvg);
+    }
+}
+
+/** @} */

+ 63 - 0
inc/classes/BxDolCmtsReviewsQuery.php

@@ -0,0 +1,63 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+/**
+ * @see BxDolCmtsReviews
+ */
+class BxDolCmtsReviewsQuery extends BxDolCmtsQuery
+{
+    public function __construct(&$oMain)
+    {
+        parent::__construct($oMain);
+    }
+
+    function getReviewsAvg ($iId, $iCmtVParentId = -1, $iAuthorId = 0, $sFilter = '')
+    {
+    	$aBindings = array(
+            'cmt_object_id' => $iId
+    	);
+        $sWhereClause = " AND `{$this->_sTable}`.`cmt_object_id` = :cmt_object_id";
+
+        if((int)$iCmtVParentId >= 0) {
+            $aBindings['cmt_vparent_id'] = $iCmtVParentId;
+
+            $sWhereClause .= " AND `{$this->_sTable}`.`cmt_vparent_id` = :cmt_vparent_id";
+        }
+
+        $sJoinClause = '';
+        switch($sFilter) {
+            case BX_CMT_FILTER_FRIENDS:
+            case BX_CMT_FILTER_SUBSCRIPTIONS:
+                $oConnection = BxDolConnection::getObjectInstance($this->_oMain->getConnectionObject($sFilter));
+
+                $aQueryParts = $oConnection->getConnectedContentAsSQLParts($this->_sTable, 'cmt_author_id', $iAuthorId);
+                $sJoinClause .= ' ' . $aQueryParts['join'];
+                break;
+
+            case BX_CMT_FILTER_OTHERS:
+                $aBindings['cmt_author_id'] = $iAuthorId;
+
+                $sWhereClause .= " AND `{$this->_sTable}`.`cmt_author_id` <> :cmt_author_id";
+                break;
+        }
+
+        return (float)$this->getOne("SELECT SUM(`cmt_mood`)/COUNT(*) FROM `{$this->_sTable}` $sJoinClause WHERE 1 " . $sWhereClause, $aBindings);
+    }
+
+    function updateTriggerTableAvg($iId, $fAvg)
+    {
+        $sField = $this->_sTriggerFieldComments . '_avg';
+        return $this->query("UPDATE `{$this->_sTriggerTable}` SET `{$sField}` = :avg WHERE `{$this->_sTriggerFieldId}` = :id LIMIT 1", array(
+            'avg' => $fAvg,
+            'id' => $iId
+        ));
+    }
+}
+
+/** @} */

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

@@ -21,6 +21,7 @@ function BxDolCmts (options) {
     this._sBrowseType = undefined == options.sBrowseType ? 'tail' : options.sBrowseType;
     this._sBrowseFilter = undefined == options.sBrowseFilter ? 'all' : options.sBrowseFilter;
 
+    this._sSP = options.sStylePrefix === undefined ? 'cmt' : options.sStylePrefix;
     this._sAnimationEffect = 'fade';
     this._iAnimationSpeed = 'slow';
 

+ 82 - 0
inc/js/classes/BxDolCmtsReviews.js

@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+function BxDolCmtsReviews (oOptions) {
+    BxDolCmts.call(this, oOptions);
+
+    this._sClassRating = this._sSP + '-rating';
+    this._sClassRatingLegend = this._sSP + '-rating-legend';
+    this._sClassRatingElement = this._sSP + '-rating-element';
+    this._sAttributeRating = this._sSP + '-rating-data';
+}
+
+BxDolCmtsReviews.prototype = Object.create(BxDolCmts.prototype);
+BxDolCmtsReviews.prototype.constructor = BxDolCmtsReviews;
+
+BxDolCmtsReviews.prototype.cmtInit = function ()
+{
+    var $this = this;
+
+    $('.' + this._sClassRating).each(function() {
+        $this.cmtInitRating($(this));
+    });
+
+    BxDolCmts.prototype.cmtInit.call(this);
+};
+
+BxDolCmtsReviews.prototype.cmtInitRating = function(oElement)
+{
+    var fValue = oElement.attr(this._sAttributeRating);
+    var iStarWidth = this._getStarWidth(oElement);
+
+    this._getSlider(oElement).width(Math.round(fValue * iStarWidth));
+};
+
+BxDolCmtsReviews.prototype.vote = function(oLink, iValue)
+{
+    this._iSaveWidth = Math.round(iValue * this._getStarWidth(oLink));
+
+    $(oLink).parents('.' + this._sClassRatingElement + ':first').attr(this._sAttributeRating, iValue).find(':input:hidden').val(iValue);
+};
+
+BxDolCmtsReviews.prototype.over = function (oLink)
+{
+    var oSlider = this._getSlider(oLink);
+    var iIndex = this._getButtons(oLink).index(oLink);
+
+    this._iSaveWidth = parseInt(oSlider.width());
+    oSlider.width((iIndex + 1) * this._getStarWidth(oLink));
+};
+
+BxDolCmtsReviews.prototype.out = function (oLink)
+{
+    this._getSlider(oLink).width(this._iSaveWidth);
+};
+
+BxDolCmtsReviews.prototype._getButtons = function(oElement)
+{
+    if($(oElement).hasClass(this._sClassRatingElement))
+        return $(oElement).find('.' + this._sSP + '-mood-button');
+    else
+        return $(oElement).parents('.' + this._sClassRatingElement + ':first').find('.' + this._sSP + '-mood-button');
+};
+
+BxDolCmtsReviews.prototype._getSlider = function(oElement, sParent) {
+    var sSlider = (sParent != undefined && sParent.length > 0 ? sParent + ' ' : '') + '.' + this._sSP + '-mood-slider';
+    if($(oElement).hasClass(this._sClassRating))
+        return $(oElement).find(sSlider);
+    else
+        return $(oElement).parents('.' + this._sClassRating + ':first').find(sSlider);
+};
+
+BxDolCmtsReviews.prototype._getStarWidth = function(oElement)
+{
+    return this._getSlider(oElement).find('.sys-icon').width();
+};
+
+/** @} */

+ 35 - 0
install/sql/system.sql

@@ -2915,6 +2915,7 @@ INSERT INTO `sys_objects_form` (`object`, `module`, `title`, `action`, `form_att
 ('sys_confirm_phone', 'system', '_sys_form_confirm_phone', '', '', 'a:2:{i:0;s:9:"do_submit";i:1;s:10:"do_sendsms";}', '', '', '', '', 'a:1:{s:14:"checker_helper";s:31:"BxFormConfirmPhoneCheckerHelper";}', 0, 1, 'BxTemplFormConfirmPhone', ''),
 ('sys_unsubscribe', 'system', '_sys_form_unsubscribe', '', '', 'do_submit', 'sys_accounts', 'id', '', '', '', 0, 1, 'BxTemplFormAccount', ''),
 ('sys_comment', 'system', '_sys_form_comment', 'cmts.php', 'a:3:{s:2:"id";s:17:"cmt-%s-form-%s-%d";s:4:"name";s:17:"cmt-%s-form-%s-%d";s:5:"class";s:14:"cmt-post-reply";}', 'cmt_submit', '', 'cmt_id', '', '', '', 0, 1, 'BxTemplCmtsForm', ''),
+('sys_review', 'system', '_sys_form_review', 'cmts.php', 'a:3:{s:2:"id";s:17:"cmt-%s-form-%s-%d";s:4:"name";s:17:"cmt-%s-form-%s-%d";s:5:"class";s:14:"cmt-post-reply";}', 'cmt_submit', '', 'cmt_id', '', '', '', 0, 1, 'BxTemplCmtsReviewsForm', ''),
 ('sys_report', 'system', '_sys_form_report', 'report.php', 'a:3:{s:2:"id";s:0:"";s:4:"name";s:0:"";s:5:"class";s:17:"bx-report-do-form";}', 'submit', '', 'id', '', '', '', 0, 1, '', '');
 
 CREATE TABLE IF NOT EXISTS `sys_form_displays` (
@@ -2945,6 +2946,8 @@ INSERT INTO `sys_form_displays` (`display_name`, `module`, `object`, `title`, `v
 ('sys_unsubscribe_news', 'system', 'sys_unsubscribe', '_sys_form_display_unsubscribe_news', 0),
 ('sys_comment_post', 'system', 'sys_comment', '_sys_form_display_comment_post', 0),
 ('sys_comment_edit', 'system', 'sys_comment', '_sys_form_display_comment_edit', 0),
+('sys_review_post', 'system', 'sys_review', '_sys_form_review_display_post', 0),
+('sys_review_edit', 'system', 'sys_review', '_sys_form_review_display_edit', 0),
 ('sys_report_post', 'system', 'sys_report', '_sys_form_display_report_post', 0);
 
 
@@ -3034,6 +3037,17 @@ INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `c
 ('sys_comment', 'system', 'cmt_image', 'a:1:{i:0;s:15:"sys_cmts_simple";}', 'a:1:{s:15:"sys_cmts_simple";s:26:"_sys_uploader_simple_title";}', 0, 'files', '_sys_form_comment_input_caption_system_cmt_image', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('sys_comment', 'system', 'cmt_submit', '_sys_form_comment_input_submit', '', 0, 'submit', '_sys_form_comment_input_caption_system_cmt_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
 
+('sys_review', 'system', 'sys', '', '', 0, 'hidden', '_sys_form_review_input_caption_system_sys', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
+('sys_review', 'system', 'id', '', '', 0, 'hidden', '_sys_form_review_input_caption_system_id', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
+('sys_review', 'system', 'action', '', '', 0, 'hidden', '_sys_form_review_input_caption_system_action', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
+('sys_review', 'system', 'cmt_id', '', '', 0, 'hidden', '_sys_form_review_input_caption_system_cmt_id', '', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 0, 0),
+('sys_review', 'system', 'cmt_parent_id', '', '', 0, 'hidden', '_sys_form_review_input_caption_system_cmt_parent_id', '', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 0, 0),
+('sys_review', 'system', 'cmt_text', '', '', 0, 'textarea', '_sys_form_review_input_caption_system_cmt_text', '', '', 0, 0, 3, 'a:1:{s:12:"autocomplete";s:3:"off";}', '', '', 'Length', 'a:2:{s:3:"min";i:1;s:3:"max";i:5000;}', '_Please enter n1-n2 characters', 'XssHtml', '', 1, 0),
+('sys_review', 'system', 'cmt_mood', '', '', 0, 'custom', '_sys_form_review_input_caption_system_cmt_mood', '', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
+('sys_review', 'system', 'cmt_anonymous', '', '', 0, 'switcher', '_sys_form_input_sys_anonymous', '_sys_form_input_anonymous', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+('sys_review', 'system', 'cmt_image', 'a:1:{i:0;s:15:"sys_cmts_simple";}', 'a:1:{s:15:"sys_cmts_simple";s:26:"_sys_uploader_simple_title";}', 0, 'files', '_sys_form_review_input_caption_system_cmt_image', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+('sys_review', 'system', 'cmt_submit', '_sys_form_review_input_submit', '', 0, 'submit', '_sys_form_review_input_caption_system_cmt_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
+
 ('sys_report', 'system', 'sys', '', '', 0, 'hidden', '_sys_form_report_input_caption_system_sys', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
 ('sys_report', 'system', 'object_id', '', '', 0, 'hidden', '_sys_form_report_input_caption_system_object_id', '', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 0, 0),
 ('sys_report', 'system', 'action', '', '', 0, 'hidden', '_sys_form_report_input_caption_system_action', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
@@ -3140,6 +3154,26 @@ INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_fo
 ('sys_comment_edit', 'cmt_image', 2147483647, 0, 7),
 ('sys_comment_edit', 'cmt_submit', 2147483647, 1, 8),
 
+('sys_review_post', 'sys', 2147483647, 1, 1),
+('sys_review_post', 'id', 2147483647, 1, 2),
+('sys_review_post', 'action', 2147483647, 1, 3),
+('sys_review_post', 'cmt_id', 2147483647, 0, 4),
+('sys_review_post', 'cmt_parent_id', 2147483647, 1, 5),
+('sys_review_post', 'cmt_text', 2147483647, 1, 6),
+('sys_review_post', 'cmt_mood', 2147483647, 1, 7),
+('sys_review_post', 'cmt_image', 2147483647, 1, 8),
+('sys_review_post', 'cmt_submit', 2147483647, 1, 9),
+
+('sys_review_edit', 'sys', 2147483647, 1, 1),
+('sys_review_edit', 'id', 2147483647, 1, 2),
+('sys_review_edit', 'action', 2147483647, 1, 3),
+('sys_review_edit', 'cmt_id', 2147483647, 1, 4),
+('sys_review_edit', 'cmt_parent_id', 2147483647, 1, 5),
+('sys_review_edit', 'cmt_text', 2147483647, 1, 6),
+('sys_review_edit', 'cmt_mood', 2147483647, 1, 7),
+('sys_review_edit', 'cmt_image', 2147483647, 0, 8),
+('sys_review_edit', 'cmt_submit', 2147483647, 1, 9),
+
 ('sys_report_post', 'sys', 2147483647, 1, 1),
 ('sys_report_post', 'object_id', 2147483647, 1, 2),
 ('sys_report_post', 'action', 2147483647, 1, 3),
@@ -4654,6 +4688,7 @@ INSERT INTO `sys_preloader`(`module`, `type`, `content`, `active`, `order`) VALU
 ('system', 'js_system', 'BxDolVoteLikes.js', 1, 37),
 ('system', 'js_system', 'BxDolVoteReactions.js', 1, 38),
 ('system', 'js_system', 'BxDolVoteStars.js', 1, 39),
+('system', 'js_system', 'BxDolCmtsReviews.js', 1, 40),
 
 ('system', 'js_translation', '_Are_you_sure', 1, 1),
 ('system', 'js_translation', '_error occured', 1, 2),

+ 21 - 0
modules/boonex/decorous/data/template/system/scripts/BxTemplCmtsReviews.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolCmtsReviews
+ */
+class BxTemplCmtsReviews extends BxBaseCmtsReviews
+{
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/decorous/data/template/system/scripts/BxTemplCmtsReviewsForm.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxBaseCmtsForm
+ */
+class BxTemplCmtsReviewsForm extends BxBaseCmtsReviewsForm
+{
+    public function __construct($aInfo, $oTemplate = false)
+    {
+        parent::__construct($aInfo, $oTemplate);
+    }
+}
+
+/** @} */

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

@@ -1601,7 +1601,14 @@
         <string name="_cmt_txt_counter"><![CDATA[{0}]]></string>
 	<string name="_cmt_txt_counter_empty"><![CDATA[Comment]]></string>
         <string name="_cmt_txt_min_form_placeholder"><![CDATA[{0}, leave your comment here.]]></string>
-	<string name="_copyright"><![CDATA[&copy; {0} Company]]></string>
+        <string name="_cmt_rvw_block_rating_title"><![CDATA[Rating]]></string>
+        <string name="_cmt_rvw_block_reviews_title"><![CDATA[Reviews ({0})]]></string>
+        <string name="_cmt_rvw_txt_sample_comment_single"><![CDATA[review]]></string>
+        <string name="_cmt_rvw_txt_sample_reaction_single"><![CDATA['{0}' reaction to review]]></string>
+        <string name="_cmt_rvw_txt_sample_score_up_single"><![CDATA[score up vote to review]]></string>
+        <string name="_cmt_rvw_txt_sample_score_down_single"><![CDATA[score down vote to review]]></string>
+        <string name="_cmt_rvw_txt_sample_vote_single"><![CDATA[vote to review]]></string>
+        <string name="_copyright"><![CDATA[&copy; {0} Company]]></string>
 	<string name="_delete"><![CDATA[delete]]></string>
 	<string name="_error occured"><![CDATA[Error occurred]]></string>
 	<string name="_from"><![CDATA[from]]></string>
@@ -2099,6 +2106,22 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_form_report_input_caption_system_text"><![CDATA[Report Text]]></string>
 	<string name="_sys_form_report_input_caption_system_type"><![CDATA[Report Type]]></string>
 	<string name="_sys_form_report_input_caption_system_sys"><![CDATA[Object Type]]></string>
+        <string name="_sys_form_review"><![CDATA[Review]]></string>
+        <string name="_sys_form_review_display_edit"><![CDATA[Review Edit Form]]></string>
+	<string name="_sys_form_review_display_post"><![CDATA[Review Post Form]]></string>
+	<string name="_sys_form_review_input_caption_cmt_author_id"><![CDATA[Author]]></string>
+	<string name="_sys_form_review_input_caption_cmt_text"><![CDATA[Text]]></string>
+	<string name="_sys_form_review_input_caption_system_action"><![CDATA[Action]]></string>
+        <string name="_sys_form_review_input_caption_system_cmt_author_id"><![CDATA[Author]]></string>
+	<string name="_sys_form_review_input_caption_system_cmt_id"><![CDATA[ID]]></string>
+	<string name="_sys_form_review_input_caption_system_cmt_image"><![CDATA[Image]]></string>
+	<string name="_sys_form_review_input_caption_system_cmt_parent_id"><![CDATA[Parent ID]]></string>
+	<string name="_sys_form_review_input_caption_system_cmt_submit"><![CDATA[Post]]></string>
+	<string name="_sys_form_review_input_caption_system_cmt_text"><![CDATA[Text]]></string>
+        <string name="_sys_form_review_input_caption_system_cmt_mood"><![CDATA[Rating]]></string>
+	<string name="_sys_form_review_input_caption_system_id"><![CDATA[Object ID]]></string>
+	<string name="_sys_form_review_input_caption_system_sys"><![CDATA[Object Type]]></string>
+	<string name="_sys_form_review_input_submit"><![CDATA[Post]]></string>
 	<string name="_sys_form_unsubscribe"><![CDATA[Unsubscribe]]></string>
 	<string name="_sys_form_unsubscribe_input_caption_system_code"><![CDATA[Security Code]]></string>
 	<string name="_sys_form_unsubscribe_input_caption_system_do_submit"><![CDATA[Submit]]></string>

+ 21 - 0
modules/boonex/lucid/data/template/system/scripts/BxTemplCmtsReviews.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolCmtsReviews
+ */
+class BxTemplCmtsReviews extends BxBaseCmtsReviews
+{
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/lucid/data/template/system/scripts/BxTemplCmtsReviewsForm.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxBaseCmtsForm
+ */
+class BxTemplCmtsReviewsForm extends BxBaseCmtsReviewsForm
+{
+    public function __construct($aInfo, $oTemplate = false)
+    {
+        parent::__construct($aInfo, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/ocean/data/template/system/scripts/BxTemplCmtsReviews.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolCmtsReviews
+ */
+class BxTemplCmtsReviews extends BxBaseCmtsReviews
+{
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/ocean/data/template/system/scripts/BxTemplCmtsReviewsForm.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxBaseCmtsForm
+ */
+class BxTemplCmtsReviewsForm extends BxBaseCmtsReviewsForm
+{
+    public function __construct($aInfo, $oTemplate = false)
+    {
+        parent::__construct($aInfo, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/protean/data/template/system/scripts/BxTemplCmtsReviews.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolCmtsReviews
+ */
+class BxTemplCmtsReviews extends BxBaseCmtsReviews
+{
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/protean/data/template/system/scripts/BxTemplCmtsReviewsForm.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxBaseCmtsForm
+ */
+class BxTemplCmtsReviewsForm extends BxBaseCmtsReviewsForm
+{
+    public function __construct($aInfo, $oTemplate = false)
+    {
+        parent::__construct($aInfo, $oTemplate);
+    }
+}
+
+/** @} */

+ 23 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -1601,6 +1601,13 @@
         <string name="_cmt_txt_counter"><![CDATA[{0}]]></string>
 	<string name="_cmt_txt_counter_empty"><![CDATA[Комментировать]]></string>
         <string name="_cmt_txt_min_form_placeholder"><![CDATA[{0}, здесь Вы можете оставить комментарий.]]></string>
+        <string name="_cmt_rvw_block_rating_title"><![CDATA[Оценка]]></string>
+        <string name="_cmt_rvw_block_reviews_title"><![CDATA[Обзоры ({0})]]></string>
+        <string name="_cmt_rvw_txt_sample_comment_single"><![CDATA[обзор]]></string>
+        <string name="_cmt_rvw_txt_sample_reaction_single"><![CDATA[реакция '{0}' к обзору]]></string>
+        <string name="_cmt_rvw_txt_sample_score_up_single"><![CDATA[голос за обзор]]></string>
+        <string name="_cmt_rvw_txt_sample_score_down_single"><![CDATA[голос против обзора]]></string>
+        <string name="_cmt_rvw_txt_sample_vote_single"><![CDATA[голос за обзор]]></string>
 	<string name="_copyright"><![CDATA[&copy; {0} Компания]]></string>
 	<string name="_delete"><![CDATA[удалить]]></string>
 	<string name="_error occured"><![CDATA[Произошла ошибка]]></string>
@@ -2100,6 +2107,22 @@
 	<string name="_sys_form_report_input_caption_system_text"><![CDATA[Текст жалобы]]></string>
 	<string name="_sys_form_report_input_caption_system_type"><![CDATA[Тип жалобы]]></string>
 	<string name="_sys_form_report_input_caption_system_sys"><![CDATA[Тип объекта]]></string>
+        <string name="_sys_form_review"><![CDATA[Обзор]]></string>
+        <string name="_sys_form_review_display_edit"><![CDATA[Редактировать обзор]]></string>
+	<string name="_sys_form_review_display_post"><![CDATA[Разместить обзор]]></string>
+	<string name="_sys_form_review_input_caption_cmt_author_id"><![CDATA[Автор]]></string>
+	<string name="_sys_form_review_input_caption_cmt_text"><![CDATA[Текст]]></string>
+	<string name="_sys_form_review_input_caption_system_action"><![CDATA[Действие]]></string>
+        <string name="_sys_form_review_input_caption_system_cmt_author_id"><![CDATA[Автор]]></string>
+	<string name="_sys_form_review_input_caption_system_cmt_id"><![CDATA[ID]]></string>
+	<string name="_sys_form_review_input_caption_system_cmt_image"><![CDATA[Изображение]]></string>
+	<string name="_sys_form_review_input_caption_system_cmt_parent_id"><![CDATA[Родительский ID]]></string>
+	<string name="_sys_form_review_input_caption_system_cmt_submit"><![CDATA[Сообщение]]></string>
+	<string name="_sys_form_review_input_caption_system_cmt_text"><![CDATA[Текст]]></string>
+        <string name="_sys_form_review_input_caption_system_cmt_mood"><![CDATA[Оценка]]></string>
+	<string name="_sys_form_review_input_caption_system_id"><![CDATA[ID объекта]]></string>
+	<string name="_sys_form_review_input_caption_system_sys"><![CDATA[Тип объекта]]></string>
+	<string name="_sys_form_review_input_submit"><![CDATA[Сообщение]]></string>
 	<string name="_sys_form_unsubscribe"><![CDATA[Отписаться]]></string>
 	<string name="_sys_form_unsubscribe_input_caption_system_code"><![CDATA[Код безопасности]]></string>
 	<string name="_sys_form_unsubscribe_input_caption_system_do_submit"><![CDATA[Выполнить]]></string>

+ 58 - 0
template/css/cmts.css

@@ -363,4 +363,62 @@ div.cmt div.cmt-counter-holder {
 
 .cmt-link .cmt-counter-holder.bx-btn-border {
 	border-width: 0px;
+}
+
+
+/*----------------------*/
+/*--- Reviews Styles ---*/
+/*----------------------*/
+
+/*--- Mood Element Styles ---*/
+div.cmt-mood {
+    position: relative;
+    display: inline-block;
+}
+div.cmt-mood-underlay {}
+div.cmt-mood-slider {
+    position: absolute;
+    z-index: 1;
+    top: 0px;
+    left: 0px;
+    white-space: nowrap;
+    overflow: hidden;
+}
+div.cmt-mood a.cmt-mood-button,
+div.cmt-mood i.cmt-mood-star {
+    position: relative;
+    display: inline-block;
+    vertical-align: top;
+    height: 16px;
+    width: 16px;
+    margin: 0;
+    padding: 0;
+    text-align: center;
+}
+div.cmt-mood-underlay i.cmt-mood-star {
+    color: rgba(255, 204, 102, 1);
+}
+div.cmt-mood-slider i.cmt-mood-star,
+div.cmt-mood-buttons a:hover i.cmt-mood-star {
+    color: rgba(255, 100, 0, 1);
+}
+
+div.cmt-mood-buttons {
+    position: absolute;
+    z-index: 2;
+    top: 0px;
+    left: 0px;
+}
+div.cmt-mood-buttons a:hover {
+	text-decoration: none;
+}
+div.cmt-mood-buttons i.cmt-mood-star {
+    color: transparent;
+}
+
+/*--- Rating Block Styles ---*/
+.cmts-box-rating div.cmt-mood i.cmt-mood-star {
+    height: 24px;
+    width: 24px;
+    font-size: 20px;
 }

+ 29 - 0
template/review.html

@@ -0,0 +1,29 @@
+<li id="cmt__id__" class="__style_prefix____class__ bx-def-padding-top bx-def-margin-bottom">
+    <a id="__anchor__" class="__style_prefix__-anchor"></a>
+    <div class="__style_prefix__-cnt__class_cnt__">
+        <div class="__style_prefix__-blink-plate"></div>
+        <div class="__style_prefix__-avatar bx-def-thumb-size">__author_unit__</div>
+        <div class="__style_prefix__-info bx-def-thumb-size-min-height bx-def-thumb-size-left-indent">
+            <div class="__style_prefix__-head bx-clearfix">
+                <bx_if:show_reply_to>
+                    <span class="__style_prefix__-reply-to">
+                        <a href="__par_cmt_link__" title="__par_cmt_title__"><i class="sys-icon reply"></i></a>
+                    </span>
+                </bx_if:show_reply_to>
+                <bx_if:meta><span class="__style_prefix__-meta">__meta__</span></bx_if:meta>
+            </div>
+            <div class="__style_prefix__-cont bx-def-margin-sec-topbottom">
+                <div class="__style_prefix__-cont-cnt">
+                    <div class="__style_prefix__-body">__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>
+                    <div class="__style_prefix__-mood">__mood__</div>
+                    <bx_if:show_attached>
+                        <div class="__style_prefix__-attached bx-def-margin-thd-leftright-neg bx-clearfix">__attached__</div>
+                    </bx_if:show_attached>
+                    <div class="__style_prefix__-reactions">__reactions__</div>
+                </div>
+            </div>
+            __actions__
+        </div>
+    </div>
+    <ul class="cmts cmts-margin">__replies__</ul>
+</li>

+ 19 - 0
template/review_mood_form_field.html

@@ -0,0 +1,19 @@
+<div class="__style_prefix__-rating __style_prefix__-rating-element" __style_prefix__-rating-data="__value__">
+    <div class="__style_prefix__-mood">
+        <div class="__style_prefix__-mood-underlay">
+            <bx_repeat:stars><i class="__style_prefix__-mood-star sys-icon far star"></i></bx_repeat:stars>
+        </div>
+        <div class="__style_prefix__-mood-slider">
+            <bx_repeat:slider><i class="__style_prefix__-mood-star sys-icon star"></i></bx_repeat:slider>
+        </div>
+        <div class="__style_prefix__-mood-buttons">
+            <bx_repeat:buttons><a class="__style_prefix__-mood-button" href="javascript:void(0);" onmouseover="__js_object__.over(this);" onmouseout="__js_object__.out(this);" onclick="__js_object__.vote(this, __value__)"><i class="__style_prefix__-mood-star sys-icon star"></i></a></bx_repeat:buttons>
+        </div>
+    </div>
+    <input class="__style_prefix__-mood-value" type="hidden" name="__name__" value="__value__" />
+</div>
+<bx_if:show_init>
+    <script type="text/javascript" language="javascript">
+        __js_object__.cmtInitRating($('#__form_id__ .__style_prefix__-rating-element'));
+    </script>
+</bx_if:show_init>

+ 15 - 0
template/review_mood_legend.html

@@ -0,0 +1,15 @@
+<div class="__style_prefix__-rating __style_prefix__-rating-legend" id="__html_id__" __style_prefix__-rating-data="__value__">
+    <div class="__style_prefix__-mood">
+        <div class="__style_prefix__-mood-underlay">
+            <bx_repeat:stars><i class="__style_prefix__-mood-star sys-icon far star"></i></bx_repeat:stars>
+        </div>
+        <div class="__style_prefix__-mood-slider">
+            <bx_repeat:slider><i class="__style_prefix__-mood-star sys-icon star"></i></bx_repeat:slider>
+        </div>
+    </div>
+</div>
+<bx_if:show_init>
+    <script type="text/javascript" language="javascript">
+        __js_object__.cmtInitRating($('#__html_id__'));
+    </script>
+</bx_if:show_init>

+ 4 - 0
template/reviews_rating_block.html

@@ -0,0 +1,4 @@
+<div class="__style_prefix__s-box-rating" id="cmts-box-rating-__system__-__id__">
+    __content__
+</div>
+__script__

+ 9 - 2
template/scripts/BxBaseCmts.php

@@ -17,6 +17,9 @@ class BxBaseCmts extends BxDolCmts
     protected static $_sTmplContentDoCommentLabel;
     protected static $_sTmplContentCounter;
 
+    protected $_sTmplNameItem;
+
+    protected $_sJsObjClass;
     protected $_sJsObjName;
     protected $_sStylePrefix;
 
@@ -30,6 +33,9 @@ class BxBaseCmts extends BxDolCmts
         if (empty($sSystem))
             return;
 
+        $this->_sTmplNameItem = 'comment.html';
+                
+        $this->_sJsObjClass = 'BxDolCmts';
         $this->_sJsObjName = 'oCmts' . bx_gen_method_name($sSystem, array('_' , '-')) . $iId;
         $this->_sStylePrefix = isset($this->_aSystem['root_style_prefix']) ? $this->_aSystem['root_style_prefix'] : 'cmt';
 
@@ -99,10 +105,11 @@ class BxBaseCmts extends BxDolCmts
             'sBrowseType' => $this->_sBrowseType,
             'sDisplayType' => $this->_sDisplayType,
             'iMinPostForm' => $bMinPostForm ? 1 : 0,
+            'sStylePrefix' => $this->_sStylePrefix,
         );
 
         $this->addCssJs();
-        return $this->_oTemplate->_wrapInTagJsCode("if(window['" . $this->_sJsObjName . "'] == undefined) var " . $this->_sJsObjName . " = new BxDolCmts(" . json_encode($aParams) . "); " . $this->_sJsObjName . ".cmtInit();");
+        return $this->_oTemplate->_wrapInTagJsCode("if(window['" . $this->_sJsObjName . "'] == undefined) var " . $this->_sJsObjName . " = new " . $this->_sJsObjClass . "(" . json_encode($aParams) . "); " . $this->_sJsObjName . ".cmtInit();");
     }
 
     /**
@@ -281,7 +288,7 @@ class BxBaseCmts extends BxDolCmts
                 'show_counter' => true
             ));
 
-        return $this->_oTemplate->parseHtmlByName('comment.html', array_merge(array(
+        return $this->_oTemplate->parseHtmlByName($this->_sTmplNameItem, array_merge(array(
             'system' => $this->_sSystem,
             'style_prefix' => $this->_sStylePrefix,
             'js_object' => $this->_sJsObjName,

+ 111 - 0
template/scripts/BxBaseCmtsReviews.php

@@ -0,0 +1,111 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaBaseView UNA Base Representation Classes
+ * @{
+ */
+
+/**
+ * @see BxDolCmtsReviews
+ */
+class BxBaseCmtsReviews extends BxDolCmtsReviews
+{
+    function __construct( $sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+
+        $this->_sTmplNameItem = 'review.html';
+        $this->_sJsObjClass = 'BxDolCmtsReviews';
+    }
+
+    public function getStylePrefix()
+    {
+        return $this->_sStylePrefix;
+    }
+    
+    public function getComment($mixedCmt, $aBp = array(), $aDp = array())
+    {
+        $sResult = parent::getComment($mixedCmt, $aBp, $aDp);
+        if(empty($sResult))
+            return $sResult;
+
+        return $this->_oTemplate->parseHtmlByContent($sResult, array(
+            'mood' => $this->_getMood($mixedCmt, $aDp)
+        ));
+    }
+    
+    function getRatingBlock($aDp = array())
+    {
+        $mixedResult = $this->isViewAllowed();
+        if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
+            return $mixedResult;
+
+        $aBp = array();
+        $this->_getParams($aBp, $aDp);
+
+        $iId = $this->getId();
+
+        $sCaption = _t($this->_aT['block_rating_title']);
+        $sContent = $this->_oTemplate->parseHtmlByName('reviews_rating_block.html', array(
+            'style_prefix' => $this->_sStylePrefix,
+            'system' => $this->_sSystem,
+            'id' => $iId,
+            'content' => $this->_oTemplate->parseHtmlByName('review_mood_legend.html', array_merge(array(
+                'style_prefix' => $this->_sStylePrefix,
+                'html_id' => $this->getRatingLegendId(),
+                'value' => $this->_oQuery->getReviewsAvg($iId),
+                'bx_if:show_init' => array(
+                    'condition' => false,
+                    'content' => array()
+                )
+            ), $this->_getTmplVarsStars())),
+            'script' => $this->getJsScript($aBp, $aDp)
+        ));
+
+        return $aDp['in_designbox'] ? DesignBoxContent($sCaption, $sContent) : array(
+            'title' => $sCaption,
+            'content' => $sContent
+        );
+    }
+
+    protected function _getMood(&$aCmt, $aDp = array())
+    {
+        $sHtmlId = $this->getMoodLegendId($aCmt['cmt_id']);
+        return $this->_oTemplate->parseHtmlByName('review_mood_legend.html', array_merge(array(
+            'style_prefix' => $this->_sStylePrefix,
+            'html_id' => $sHtmlId,
+            'value' => (int)$aCmt['cmt_mood'],
+            'bx_if:show_init' => array(
+                'condition' => isset($aDp['dynamic_mode']) && (bool)$aDp['dynamic_mode'],
+                'content' => array(
+                    'style_prefix' => $this->_sStylePrefix,
+                    'js_object' => $this->_sJsObjName,
+                    'html_id' => $sHtmlId,
+                )
+            )
+        ), $this->_getTmplVarsStars()));
+    }
+
+    protected function _getTmplVarsStars() {
+        $aTmplVarsStars = $aTmplVarsSlider = array();
+        for($i = $this->_iMoodMinValue; $i <= $this->_iMoodMaxValue; $i++) {
+            $aTmplVarsStars[] = array(
+                'style_prefix' => $this->_sStylePrefix,
+                'value' => $i
+            );
+
+            $aTmplVarsSlider[] = array(
+                'style_prefix' => $this->_sStylePrefix
+            );
+        }
+
+        return array(
+            'bx_repeat:stars' => $aTmplVarsStars,
+            'bx_repeat:slider' => $aTmplVarsSlider
+        );
+    }
+}
+
+/** @} */

+ 81 - 0
template/scripts/BxBaseCmtsReviewsForm.php

@@ -0,0 +1,81 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaBaseView UNA Base Representation Classes
+ * @{
+ */
+
+class BxBaseCmtsReviewsForm extends BxTemplCmtsForm
+{
+    protected $_sSystem; ///< current review system name
+    protected $_iId; ///< obect id to be reviewed
+
+    public function __construct($aInfo, $oTemplate)
+    {
+        parent::__construct($aInfo, $oTemplate);
+
+        $this->_sSystem = '';
+        $this->_iId = 0;
+    }
+
+    protected function genCustomInputCmtMood ($aInput)
+    {
+        $oSystem = $this->_getSystemObject();
+
+        $sStylePrefix = $oSystem->getStylePrefix();
+        $sJsObject = $oSystem->getJsObjectName();
+
+        $iMoodMinValue = $oSystem->getMoodMinValue();
+        $iMoodMaxValue = $oSystem->getMoodMaxValue();
+
+        $aTmplVarsStars = $aTmplVarsSlider = $aTmplVarsButtons = array();
+        for($i = $iMoodMinValue; $i <= $iMoodMaxValue; $i++) {
+            $aTmplVarsStars[] = array(
+                'style_prefix' => $sStylePrefix,
+                'value' => $i
+            );
+
+            $aTmplVarsSlider[] = array(
+                'style_prefix' => $sStylePrefix
+            );
+
+            $aTmplVarsButtons[] = array(
+                'style_prefix' => $sStylePrefix,
+                'js_object' => $sJsObject,
+                'value' => $i
+            );
+        }
+
+        return $this->oTemplate->parseHtmlByName('review_mood_form_field.html', array(
+            'style_prefix' => $sStylePrefix,
+            'name' => $aInput['name'],
+            'value' => !empty($aInput['value']) ? $aInput['value'] : 0,
+            'bx_repeat:stars' => $aTmplVarsStars,
+            'bx_repeat:slider' => $aTmplVarsSlider,
+            'bx_repeat:buttons' => $aTmplVarsButtons,
+            'bx_if:show_init' => array(
+                'condition' => $this->_bDynamicMode,
+                'content' => array(
+                    'style_prefix' => $sStylePrefix,
+                    'js_object' => $sJsObject,
+                    'form_id' => $this->getId(),
+                )
+            )
+        ));
+    }
+
+    protected function _getSystemObject()
+    {
+        if(empty($this->_sSystem))
+            $this->_sSystem = $this->aInputs['sys']['value'];
+
+        if(empty($this->_iId))
+            $this->_iId = (int)$this->aInputs['id']['value'];
+
+        return BxDolCmts::getObjectInstance($this->_sSystem, $this->_iId);
+    }
+}
+
+/** @} */