1
0

BxBaseModGeneralMenuView.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup BaseGeneral Base classes for modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * View entry menu
  13. */
  14. class BxBaseModGeneralMenuView extends BxTemplMenu
  15. {
  16. protected $MODULE;
  17. protected $_oModule;
  18. protected $_iContentId;
  19. protected $_aContentInfo;
  20. public function __construct($aObject, $oTemplate = false)
  21. {
  22. parent::__construct($aObject, $oTemplate);
  23. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  24. }
  25. /**
  26. * Check if menu items is visible with extended checking linked to "allow*" method of particular module
  27. * Associated "allow*" method with particular menu item is stored in module config in MENU_ITEM_TO_METHOD array.
  28. * @param $a menu item array
  29. * @return boolean
  30. */
  31. protected function _isVisible ($a)
  32. {
  33. return $this->_oModule->isMenuItemVisible($this->_sObject, $a, $this->_aContentInfo);
  34. }
  35. protected function _getMenuItemsCombined ()
  36. {
  37. // combile values from ACTIONS_VIEW_ENTRY and ACTIONS_VIEW_ENTRY_MORE menus
  38. $CNF = $this->_oModule->_oConfig->CNF;
  39. if (empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']))
  40. return array();
  41. $aItems = $this->_oQuery->getMenuItemsFromSet($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']);
  42. if (empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']))
  43. return $aItems;
  44. $aItemsMore = $this->_oQuery->getMenuItemsFromSet($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']);
  45. // remove "more" item from ACTIONS_VIEW_ENTRY
  46. $aItems = array_filter ($aItems, function ($aItem) {
  47. return $aItem['order'] != BX_MENU_LAST_ITEM_ORDER;
  48. });
  49. // return combined array
  50. return array_merge($aItems, $aItemsMore);
  51. }
  52. }
  53. /** @} */