Просмотр исходного кода

#1 - Different classes for Manage and Actions menus

AntonLV 11 лет назад
Родитель
Сommit
a0e23a491f

+ 2 - 2
install/sql/system.sql

@@ -2657,8 +2657,8 @@ INSERT INTO `sys_objects_menu` (`object`, `title`, `set_name`, `module`, `templa
 ('sys_account_settings_submenu', '_sys_menu_title_account_settings', 'sys_account_settings', 'system', 8, 0, 1, '', ''),
 ('sys_account_settings_more', '_sys_menu_title_account_settings_more', 'sys_account_settings_more', 'system', 4, 0, 1, '', ''),
 ('sys_profiles_create', '_sys_menu_title_profiles_create', 'sys_profiles_create', 'system', 4, 0, 1, '', ''),
-('sys_cmts_item_manage', '_sys_menu_title_cmts_item_manage', 'sys_cmts_item_manage', 'system', 6, 0, 1, 'BxTemplCmtsMenu', ''),
-('sys_cmts_item_actions', '_sys_menu_title_cmts_item_actions', 'sys_cmts_item_actions', 'system', 15, 0, 1, 'BxTemplCmtsMenu', ''),
+('sys_cmts_item_manage', '_sys_menu_title_cmts_item_manage', 'sys_cmts_item_manage', 'system', 6, 0, 1, 'BxTemplCmtsMenuManage', ''),
+('sys_cmts_item_actions', '_sys_menu_title_cmts_item_actions', 'sys_cmts_item_actions', 'system', 15, 0, 1, 'BxTemplCmtsMenuActions', ''),
 ('sys_account_popup', '_sys_menu_title_account_popup', '', 'system', 12, 0, 1, 'BxTemplMenuAccountPopup', ''),
 ('sys_account_notifications', '_sys_menu_title_account_notifications', 'sys_account_notifications', 'system', 13, 0, 1, 'BxTemplMenuAccountNotifications', ''),
 ('sys_profile_stats', '_sys_menu_title_profile_stats', 'sys_profile_stats', 'system', 6, 0, 1, 'BxTemplMenuProfileStats', ''),

+ 23 - 0
modules/boonex/lagoon/data/template/system/scripts/BxTemplCmtsMenuActions.php

@@ -0,0 +1,23 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TridentCore Trident Core
+ * @{
+ */
+
+bx_import('BxBaseCmtsMenuActions');
+
+/**
+ * @see BxDolMenu
+ */
+class BxTemplCmtsMenuActions extends BxBaseCmtsMenuActions
+{
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 2 - 2
modules/boonex/lagoon/data/template/system/scripts/BxTemplCmtsMenu.php → modules/boonex/lagoon/data/template/system/scripts/BxTemplCmtsMenuManage.php

@@ -7,12 +7,12 @@
  * @{
  */
 
-bx_import('BxBaseCmtsMenu');
+bx_import('BxBaseCmtsMenuManage');
 
 /**
  * @see BxDolMenu
  */
-class BxTemplCmtsMenu extends BxBaseCmtsMenu
+class BxTemplCmtsMenuManage extends BxBaseCmtsMenuManage
 {
     public function __construct ($aObject, $oTemplate = false)
     {

+ 23 - 0
modules/boonex/ocean/data/template/system/scripts/BxTemplCmtsMenuActions.php

@@ -0,0 +1,23 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TridentCore Trident Core
+ * @{
+ */
+
+bx_import('BxBaseCmtsMenuActions');
+
+/**
+ * @see BxDolMenu
+ */
+class BxTemplCmtsMenuActions extends BxBaseCmtsMenuActions
+{
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 2 - 2
modules/boonex/ocean/data/template/system/scripts/BxTemplCmtsMenu.php → modules/boonex/ocean/data/template/system/scripts/BxTemplCmtsMenuManage.php

@@ -7,12 +7,12 @@
  * @{
  */
 
-bx_import('BxBaseCmtsMenu');
+bx_import('BxBaseCmtsMenuManage');
 
 /**
  * @see BxDolMenu
  */
-class BxTemplCmtsMenu extends BxBaseCmtsMenu
+class BxTemplCmtsMenuManage extends BxBaseCmtsMenuManage
 {
     public function __construct ($aObject, $oTemplate = false)
     {

+ 1 - 13
template/scripts/BxBaseCmtsMenu.php → template/scripts/BxBaseCmtsMenuActions.php

@@ -13,7 +13,7 @@ bx_import('BxTemplMenuCustom');
  * Menu representation.
  * @see BxDolMenu
  */
-class BxBaseCmtsMenu extends BxTemplMenuCustom
+class BxBaseCmtsMenuActions extends BxTemplMenuCustom
 {
     protected $_oCmts;
     protected $_aCmt;
@@ -63,18 +63,6 @@ class BxBaseCmtsMenu extends BxTemplMenuCustom
         $sCheckFuncName = '';
         $aCheckFuncParams = array();
         switch ($a['name']) {
-            case 'item-edit':
-                $sCheckFuncName = 'isEditAllowed';
-                if(!empty($this->_aCmt))
-                    $aCheckFuncParams = array($this->_aCmt);
-                break;
-
-            case 'item-delete':
-                $sCheckFuncName = 'isRemoveAllowed';
-                if(!empty($this->_aCmt))
-                    $aCheckFuncParams = array($this->_aCmt);
-                break;
-
             case 'item-vote':
                 $sCheckFuncName = 'isVoteAllowed';
                 if(!empty($this->_aCmt))

+ 73 - 0
template/scripts/BxBaseCmtsMenuManage.php

@@ -0,0 +1,73 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TridentCore Trident Core
+ * @{
+ */
+
+bx_import('BxTemplMenu');
+
+/**
+ * Menu representation.
+ * @see BxDolMenu
+ */
+class BxBaseCmtsMenuManage extends BxTemplMenu
+{
+    protected $_oCmts;
+    protected $_aCmt;
+
+    public function __construct ($aObject, $oTemplate)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+
+    public function setCmtsData($oCmts, $iCmtId)
+    {
+        if(empty($oCmts) || empty($iCmtId))
+            return;
+
+        $this->_oCmts = $oCmts;
+        $this->_aCmt = $oCmts->getCommentRow($iCmtId);
+
+        $this->addMarkers(array(
+            'js_object' => $oCmts->getJsObjectName(),
+            'content_id' => $iCmtId,
+        ));
+    }
+
+    /**
+     * Check if menu items is visible.
+     * @param $a menu item array
+     * @return boolean
+     */
+    protected function _isVisible ($a)
+    {
+        if(!parent::_isVisible($a))
+            return false;
+
+        $sCheckFuncName = '';
+        $aCheckFuncParams = array();
+        switch ($a['name']) {
+            case 'item-edit':
+                $sCheckFuncName = 'isEditAllowed';
+                if(!empty($this->_aCmt))
+                    $aCheckFuncParams = array($this->_aCmt);
+                break;
+
+            case 'item-delete':
+                $sCheckFuncName = 'isRemoveAllowed';
+                if(!empty($this->_aCmt))
+                    $aCheckFuncParams = array($this->_aCmt);
+                break;
+        }
+
+        if(!$sCheckFuncName || !method_exists($this->_oCmts, $sCheckFuncName))
+            return true;
+
+        return call_user_func_array(array($this->_oCmts, $sCheckFuncName), $aCheckFuncParams);
+    }
+}
+
+/** @} */