BxBaseModGeneralMenuView.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. $this->addMarkers(array(
  25. 'module' => $this->_oModule->_oConfig->getName(),
  26. 'module_uri' => $this->_oModule->_oConfig->getUri(),
  27. ));
  28. }
  29. /**
  30. * Check if menu items is visible with extended checking linked to "allow*" method of particular module
  31. * Associated "allow*" method with particular menu item is stored in module config in MENU_ITEM_TO_METHOD array.
  32. * @param $a menu item array
  33. * @return boolean
  34. */
  35. protected function _isVisible ($a)
  36. {
  37. return $this->_oModule->isMenuItemVisible($this->_sObject, $a, $this->_aContentInfo);
  38. }
  39. protected function _getMenuItemsCombined ()
  40. {
  41. // combile values from ACTIONS_VIEW_ENTRY and ACTIONS_VIEW_ENTRY_MORE menus
  42. $CNF = $this->_oModule->_oConfig->CNF;
  43. if (empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']))
  44. return array();
  45. $aItems = $this->_oQuery->getMenuItemsFromSet($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']);
  46. if (empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']))
  47. return $aItems;
  48. $aItemsMore = $this->_oQuery->getMenuItemsFromSet($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']);
  49. // remove "more" item from ACTIONS_VIEW_ENTRY
  50. $aItems = array_filter ($aItems, function ($aItem) {
  51. return $aItem['order'] != BX_MENU_LAST_ITEM_ORDER;
  52. });
  53. // return combined array
  54. return array_merge($aItems, $aItemsMore);
  55. }
  56. }
  57. /** @} */