Răsfoiți Sursa

Ticket #2239 - Point %2

AntonLV 7 ani în urmă
părinte
comite
7352a4be6e

+ 4 - 0
inc/classes/BxDolVoteReactions.php

@@ -12,6 +12,8 @@
  */
 class BxDolVoteReactions extends BxTemplVote
 {
+    protected $_sMenuDoVote; //--- Do vote (reaction)  menu name.
+
     protected $_sDataList; //--- Reactions list name.
     protected $_aDataList; //--- Reactions list with all reactions.
 
@@ -24,6 +26,8 @@ class BxDolVoteReactions extends BxTemplVote
         $this->_oQuery = new BxDolVoteReactionsQuery($this);
         $this->_sType = BX_DOL_VOTE_TYPE_REACTIONS;
 
+        $this->_sMenuDoVote = 'sys_vote_reactions_do';
+
         $this->_sDataList = 'sys_vote_reactions';
         $this->_aDataList = array();
 

+ 2 - 1
install/sql/system.sql

@@ -3675,7 +3675,8 @@ INSERT INTO `sys_objects_menu` (`object`, `title`, `set_name`, `module`, `templa
 ('sys_set_acl_level', '_sys_menu_title_set_acl_level', '', 'system', 6, 0, 1, 'BxTemplMenuSetAclLevel', ''),
 ('sys_social_sharing', '_sys_menu_title_social_sharing', 'sys_social_sharing', 'system', 23, 0, 1, 'BxTemplMenuSocialSharing', ''),
 ('sys_create_post', '_sys_menu_title_create_post', 'sys_add_content_links', 'system', 22, 0, 1, 'BxTemplMenuCreatePost', ''),
-('sys_add_relation', '_sys_menu_title_add_relation', '', 'system', 6, 0, 1, 'BxTemplMenuAddRelation', '');
+('sys_add_relation', '_sys_menu_title_add_relation', '', 'system', 6, 0, 1, 'BxTemplMenuAddRelation', ''),
+('sys_vote_reactions_do', '_sys_menu_title_vote_reactions_do', '', 'system', 3, 0, 1, 'BxTemplVoteReactionsMenuDo', '');
 
 CREATE TABLE IF NOT EXISTS `sys_menu_sets` (
   `set_name` varchar(64) NOT NULL,

+ 21 - 0
modules/boonex/decorous/data/template/system/scripts/BxTemplVoteReactionsMenuDo.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 BxDolMenu
+ */
+class BxTemplVoteReactionsMenuDo extends BxBaseVoteReactionsMenuDo
+{
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

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

@@ -2500,6 +2500,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_menu_title_switch_language_inline"><![CDATA[Language Switch (inline)]]></string>
 	<string name="_sys_menu_title_switch_template"><![CDATA[Switch Template]]></string>
 	<string name="_sys_menu_title_snippet_meta"><![CDATA[Snippet Meta Info]]></string>
+        <string name="_sys_menu_title_vote_reactions_do"><![CDATA[Do Reaction Vote]]></string>
   <string name="_sys_menu_dashboard_manage_tools_addon_counter1_caption_default"><![CDATA[hidden]]></string>
   <string name="_sys_menu_dashboard_manage_tools_addon_counter1_caption_profile_default"><![CDATA[unapproved]]></string>
   <string name="_sys_menu_dashboard_manage_tools_addon_counter2_caption_default"><![CDATA[reported]]></string>

+ 21 - 0
modules/boonex/lucid/data/template/system/scripts/BxTemplVoteReactionsMenuDo.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 BxDolMenu
+ */
+class BxTemplVoteReactionsMenuDo extends BxBaseVoteReactionsMenuDo
+{
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/ocean/data/template/system/scripts/BxTemplVoteReactionsMenuDo.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 BxDolMenu
+ */
+class BxTemplVoteReactionsMenuDo extends BxBaseVoteReactionsMenuDo
+{
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 3 - 0
modules/boonex/protean/data/template/system/_sub_footer.html

@@ -25,6 +25,9 @@
                             <bx_menu:sys_footer />
                         </div>
 
+                        <div class="bx-def-font-align-center">
+                            <bx_menu:sys_switch_language_inline />
+                        </div>
                         <bx_injection:injection_footer_after />
                     </div>
                 </div>

+ 21 - 0
modules/boonex/protean/data/template/system/scripts/BxTemplVoteReactionsMenuDo.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 BxDolMenu
+ */
+class BxTemplVoteReactionsMenuDo extends BxBaseVoteReactionsMenuDo
+{
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

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

@@ -2486,6 +2486,7 @@
 	<string name="_sys_menu_title_switch_language_inline"><![CDATA[Переключатель языка (встроенный)]]></string>
 	<string name="_sys_menu_title_switch_template"><![CDATA[Переключить тему]]></string>
 	<string name="_sys_menu_title_snippet_meta"><![CDATA[Мета информация в карточке]]></string>
+        <string name="_sys_menu_title_vote_reactions_do"><![CDATA[Отреагировать - Меню]]></string>
   <string name="_sys_menu_dashboard_manage_tools_addon_counter1_caption_default"><![CDATA[спрятано]]></string>
   <string name="_sys_menu_dashboard_manage_tools_addon_counter1_caption_profile_default"><![CDATA[неодобрено]]></string>
   <string name="_sys_menu_dashboard_manage_tools_addon_counter2_caption_default"><![CDATA[жалоб]]></string>

+ 3 - 1
template/menu_horizontal.html

@@ -1,5 +1,7 @@
 <ul class="bx-menu-hor bx-menu-object-__object__ bx-clearfix">
     <bx_repeat:menu_items>
-        <li class="bx-def-margin-right-auto __class_add__"><a href="__link__" target="__target__" onclick="__onclick__">__title__</a></li>
+        <li class="bx-def-margin-right-auto __class_add__">
+            <a href="__link__" target="__target__" onclick="__onclick__"><bx_if:icon><i class="sys-icon __icon__"></i></bx_if:icon><bx_if:image><img style="background-image:url(__icon_url__)" src="<bx_icon_url:spacer.gif />" /></bx_if:image><bx_if:title><span>__title__</span></bx_if:title></a>
+        </li>
     </bx_repeat:menu_items>
 </ul>

+ 7 - 18
template/scripts/BxBaseVoteReactions.php

@@ -185,25 +185,14 @@ class BxBaseVoteReactions extends BxDolVoteReactions
         if(empty($iValue))
             $iValue = $this->getValue();
 
-        $sJsObject = $this->getJsObjectName();
-        $aReactions = $this->getReactions(true);
-
-        $aMenu = array();        
-        foreach($aReactions as $sName => $aReaction) {
-            $aMenu[] = array(
-                'id' => $sName, 
-                'name' => $sName, 
-                'class' => '', 
-                'link' => 'javascript:void(0)', 
-                'onclick' => 'javascript:' . $this->getJsClickDo($sName, $iValue), 
-                'target' => '_self', 
-                'title' => _t($aReaction['title']), 
-                'icon' => $aReaction['icon'], 
-                'active' => 1
-            );
-        }
+        $oMenu = BxTemplMenu::getObjectInstance($this->_sMenuDoVote);
+        if(!$oMenu)
+            return '';
 
-        $oMenu = new BxTemplMenu(array('template' => 'menu_buttons_icon_hor.html', 'menu_id'=> $this->_aHtmlIds['do_menu'], 'menu_items' => $aMenu));
+        $oMenu->setParams(array(
+            'object' => &$this,
+            'value' => $iValue,
+        ));
         return $oMenu->getCode();
     }
 

+ 70 - 0
template/scripts/BxBaseVoteReactionsMenuDo.php

@@ -0,0 +1,70 @@
+<?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
+ * @{
+ */
+
+/**
+ * Menu representation.
+ * @see BxDolMenu
+ */
+class BxBaseVoteReactionsMenuDo extends BxTemplMenu
+{
+    protected $_iValue;
+    protected $_oObject;
+
+    public function __construct($aObject, $oTemplate)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+
+    public function setParams($aParams)
+    {
+        if(empty($aParams['object']) || !is_a($aParams['object'], 'BxTemplVoteReactions'))
+            return;
+
+        $this->_oObject = $aParams['object'];
+
+        $this->_iValue = isset($aParams['value']) ? (int)$aParams['value'] : $this->_oObject->getValue();
+    }
+
+    protected function getMenuItemsRaw()
+    {
+        $sJsObject = $this->_oObject->getJsObjectName();
+        $aReactions = $this->_oObject->getReactions(true);
+
+        $aMenuItems = array();        
+        foreach($aReactions as $sName => $aReaction) {
+            $aMenuItems[] = array(
+                'id' => $sName, 
+                'name' => $sName, 
+                'class' => '', 
+                'link' => 'javascript:void(0)', 
+                'onclick' => 'javascript:' . $this->_oObject->getJsClickDo($sName, $this->_iValue), 
+                'target' => '_self', 
+                'title' => _t($aReaction['title']), 
+                'icon' => $aReaction['icon'], 
+                'active' => 1
+            );
+        }
+
+        return $aMenuItems;
+    }
+
+    protected function _getMenuItem ($a)
+    {
+        $aResult = parent::_getMenuItem($a);
+        if(empty($aResult) || !is_array($aResult))
+            return $aResult;
+
+        $aResult['title'] = '';
+        $aResult['bx_if:title']['condition'] = false;
+
+        return $aResult;
+    }
+}
+
+/** @} */