AntonLV 6 ani în urmă
părinte
comite
1a94d256cb

+ 17 - 4
inc/classes/BxDolVoteReactions.php

@@ -34,7 +34,7 @@ class BxDolVoteReactions extends BxTemplVote
         $this->_sDataList = 'sys_vote_reactions';
         $this->_aDataList = array();
 
-        $this->_sDefault = '';
+        $this->_sDefault = 'default';
     }
 
     public function init($iId)
@@ -52,13 +52,14 @@ class BxDolVoteReactions extends BxTemplVote
                 'title' => $aReaction['LKey'],
                 'title_aux' => $aReaction['LKey2'],
                 'icon' => isset($aData['icon']) ? $aData['icon'] : '',
+                'color' => isset($aData['color']) ? $aData['color'] : '',
                 'weight' => isset($aData['weight']) ? $aData['weight'] : 1,
             );
         }
 
         if(!empty($this->_aDataList)) {
-            $aNames = array_keys($this->_aDataList);
-            $this->_sDefault = array_shift($aNames);
+            $this->_aDataList[$this->_sDefault] = reset($this->_aDataList);
+            $this->_aDataList[$this->_sDefault]['color'] = '';
         }
     }
     /**
@@ -69,6 +70,11 @@ class BxDolVoteReactions extends BxTemplVote
         return (int)$this->_aSystem['min_value'];
     }
 
+    public function getDefault()
+    {
+        return $this->_sDefault;
+    }
+
     public function getReaction($sName)
     {
         if(empty($this->_aDataList))
@@ -86,6 +92,13 @@ class BxDolVoteReactions extends BxTemplVote
     {
         return $this->_oQuery->getTrackBy($aParams);
     }
+    
+    public function getIcon($sReaction, $bWithColor = true)
+    {
+        $aReaction = isset($this->_aDataList[$sReaction]) ? $this->_aDataList[$sReaction] : $this->_aDataList[$this->_sDefault];
+
+    	return $aReaction['icon'] . ($bWithColor && !empty($aReaction['color']) ? ' ' . $aReaction['color'] : '');
+    }
 
     /**
      * Actions functions
@@ -200,7 +213,7 @@ class BxDolVoteReactions extends BxTemplVote
     {
         $sReaction = $bVoted ? $aTrack['reaction'] : $this->_sDefault;
 
-    	return $this->_aDataList[$sReaction]['icon'];
+    	return $this->getIcon($sReaction);
     }
 
     protected function _getTitleDoWithTrack($bVoted, $aTrack = array())

+ 6 - 6
install/sql/system.sql

@@ -3661,12 +3661,12 @@ INSERT INTO `sys_form_pre_values`(`Key`, `Value`, `Order`, `LKey`, `LKey2`) VALU
 ('sys_report_types', 'other', 5, '_sys_pre_lists_report_types_other', '');
 
 INSERT INTO `sys_form_pre_values`(`Key`, `Value`, `Order`, `LKey`, `LKey2`, `Data`) VALUES
-('sys_vote_reactions', 'like', 1, '_sys_pre_lists_vote_reactions_like', '', 'a:2:{s:4:"icon";s:9:"thumbs-up";s:6:"weight";s:1:"1";}'),
-('sys_vote_reactions', 'love', 2, '_sys_pre_lists_vote_reactions_love', '', 'a:2:{s:4:"icon";s:26:"heart sys-colored col-red1";s:6:"weight";s:1:"1";}'),
-('sys_vote_reactions', 'joy', 3, '_sys_pre_lists_vote_reactions_joy', '', 'a:2:{s:4:"icon";s:32:"grin-squint sys-colored col-red3";s:6:"weight";s:1:"1";}'),
-('sys_vote_reactions', 'surprise', 4, '_sys_pre_lists_vote_reactions_surprise', '', 'a:2:{s:4:"icon";s:29:"surprise sys-colored col-red3";s:6:"weight";s:1:"1";}'),
-('sys_vote_reactions', 'sadness', 5, '_sys_pre_lists_vote_reactions_sadness', '', 'a:2:{s:4:"icon";s:29:"sad-tear sys-colored col-red3";s:6:"weight";s:1:"1";}'),
-('sys_vote_reactions', 'anger', 6, '_sys_pre_lists_vote_reactions_anger', '', 'a:2:{s:4:"icon";s:26:"angry sys-colored col-red3";s:6:"weight";s:1:"1";}');
+('sys_vote_reactions', 'like', 1, '_sys_pre_lists_vote_reactions_like', '', 'a:3:{s:4:"icon";s:9:"thumbs-up";s:5:"color";s:20:"sys-colored col-gray";s:6:"weight";s:1:"1";}'),
+('sys_vote_reactions', 'love', 2, '_sys_pre_lists_vote_reactions_love', '', 'a:3:{s:4:"icon";s:5:"heart";s:5:"color";s:20:"sys-colored col-red1";s:6:"weight";s:1:"1";}'),
+('sys_vote_reactions', 'joy', 3, '_sys_pre_lists_vote_reactions_joy', '', 'a:3:{s:4:"icon";s:11:"grin-squint";s:5:"color";s:20:"sys-colored col-red3";s:6:"weight";s:1:"1";}'),
+('sys_vote_reactions', 'surprise', 4, '_sys_pre_lists_vote_reactions_surprise', '', 'a:3:{s:4:"icon";s:8:"surprise";s:5:"color";s:20:"sys-colored col-red3";s:6:"weight";s:1:"1";}'),
+('sys_vote_reactions', 'sadness', 5, '_sys_pre_lists_vote_reactions_sadness', '', 'a:3:{s:4:"icon";s:8:"sad-tear";s:5:"color";s:20:"sys-colored col-red3";s:6:"weight";s:1:"1";}'),
+('sys_vote_reactions', 'anger', 6, '_sys_pre_lists_vote_reactions_anger', '', 'a:3:{s:4:"icon";s:5:"angry";s:5:"color";s:20:"sys-colored col-red3";s:6:"weight";s:1:"1";}');
 
 INSERT INTO `sys_form_pre_values`(`Key`, `Value`, `Order`, `LKey`, `LKey2`, `Data`) VALUES
 ('sys_relations', '1', 1, '_sys_pre_lists_relations_husband', '', 'a:1:{i:0;s:1:"2";}'),

+ 3 - 3
template/scripts/BxBaseVoteReactions.php

@@ -329,7 +329,7 @@ class BxBaseVoteReactions extends BxDolVoteReactions
                 'condition' => !isset($aParams['show_counter_label_icon']) || (bool)$aParams['show_counter_label_icon'] === true,
                 'content' => array(
                     'style_prefix' => $this->_sStylePrefix,
-                    'name' => $this->_aDataList[$sReaction]['icon']
+                    'name' => $this->getIcon($sReaction)
                 )
             ),
             'bx_if:show_text' => array(
@@ -367,7 +367,7 @@ class BxBaseVoteReactions extends BxDolVoteReactions
                     'condition' => $bSummary,
                     'content' => array(
                         'style_prefix' => $this->_sStylePrefix,
-                        'icon' => $bSummary ? $this->_aDataList[$mValue['reaction']]['icon'] : ''
+                        'icon' => $bSummary ? $this->getIcon($mValue['reaction']) : ''
                     )
                 )
             );
@@ -396,7 +396,7 @@ class BxBaseVoteReactions extends BxDolVoteReactions
             $bSummary = $sReaction == 'summary';
 
             $sName = $this->_sStylePrefix . '-' . $sReaction;
-            $sTitle = !$bSummary ? $this->_oTemplate->parseIcon($this->_aDataList[$sReaction]['icon']) : $sTxtSummary;
+            $sTitle = !$bSummary ? $this->_oTemplate->parseIcon($this->getIcon($sReaction)) : $sTxtSummary;
             $sTitleAttr = !$bSummary ? _t('_vote_do_by_x_reaction', _t($this->_aDataList[$sReaction]['title'])) : $sTxtSummary;
 
             $aMenuItems[] = array('id' => $sName, 'name' => $sName, 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeVotedBy(this, \'' . $sReaction . '\')', 'target' => '_self', 'title' => $sTitle, 'title_attr' => $sTitleAttr, 'active' => 1);

+ 5 - 1
template/scripts/BxBaseVoteReactionsMenuDo.php

@@ -35,9 +35,13 @@ class BxBaseVoteReactionsMenuDo extends BxTemplMenu
     {
         $sJsObject = $this->_oObject->getJsObjectName();
         $aReactions = $this->_oObject->getReactions(true);
+        $sDefault = $this->_oObject->getDefault();
 
         $aMenuItems = array();        
         foreach($aReactions as $sName => $aReaction) {
+            if($sName == $sDefault)
+                continue;
+
             $aMenuItems[] = array(
                 'id' => $sName, 
                 'name' => $sName, 
@@ -46,7 +50,7 @@ class BxBaseVoteReactionsMenuDo extends BxTemplMenu
                 'onclick' => 'javascript:' . $this->_oObject->getJsClickDo($sName, $this->_iValue), 
                 'target' => '_self', 
                 'title' => _t($aReaction['title']), 
-                'icon' => $aReaction['icon'], 
+                'icon' => $this->_oObject->getIcon($sName), 
                 'active' => 1
             );
         }