BxBaseMenuAccountNotifications.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * Menu representation.
  11. * @see BxDolMenu
  12. */
  13. class BxBaseMenuAccountNotifications extends BxTemplMenu
  14. {
  15. public function __construct ($aObject, $oTemplate)
  16. {
  17. parent::__construct ($aObject, $oTemplate);
  18. $aMarkers = [
  19. 'studio_url' => BX_DOL_URL_STUDIO,
  20. ];
  21. if(($oProfile = BxDolProfile::getInstance()) !== false && ($sModule = $oProfile->getModule()) != 'system') {
  22. $oModule = BxDolModule::getInstance($sModule);
  23. if($oModule !== null && isset($oModule->_oConfig->CNF['URI_VIEW_ENTRY']))
  24. $aMarkers['own_profile_url'] = 'page.php?i=' . $oModule->_oConfig->CNF['URI_VIEW_ENTRY'];
  25. }
  26. $this->addMarkers($aMarkers);
  27. }
  28. protected function getMenuItemsRaw ()
  29. {
  30. return $this->getMenuItemsRawProfileRelated();
  31. }
  32. /**
  33. * Check if menu items is visible with extended checking for friends notifications
  34. * @param $a menu item array
  35. * @return boolean
  36. */
  37. protected function _isVisible ($a)
  38. {
  39. if(!parent::_isVisible($a))
  40. return false;
  41. switch ($a['name']) {
  42. case 'studio':
  43. if (!isAdmin())
  44. return false;
  45. break;
  46. case 'cart':
  47. $oPayments = BxDolPayments::getInstance();
  48. if(!$oPayments->isActive())
  49. return false;
  50. break;
  51. case 'orders':
  52. $oPayments = BxDolPayments::getInstance();
  53. if(!$oPayments->isActive())
  54. return false;
  55. break;
  56. case 'sounds':
  57. if(!BxDolSounds::getInstance()->isOn('site'))
  58. return false;
  59. break;
  60. }
  61. return true;
  62. }
  63. /**
  64. * Sounds steps through the visitor's own level of interface sounds in this browser (full, quiet, off);
  65. * bx_sound_mark_switches() shows the level on its icon and in its name.
  66. */
  67. protected function _getMenuItem ($a)
  68. {
  69. if($a['name'] == 'sounds')
  70. $a['attrs_add'] = trim((!empty($a['attrs_add']) ? $a['attrs_add'] : '') . ' role="button" data-bx-sounds-switch="1"');
  71. return parent::_getMenuItem($a);
  72. }
  73. protected function _getTmplVarsAddon($mixedAddon, $aMenuItem)
  74. {
  75. $aAddon = parent::_getTmplVarsAddon($mixedAddon, $aMenuItem);
  76. $sAddonF = '';
  77. if(!empty($aAddon['addon']))
  78. $sAddonF = $this->_oTemplate->parseHtmlByTemplateName('menu_item_addon', array(
  79. 'content' => $aAddon['addon']
  80. ));
  81. return array(
  82. 'addon' => $aAddon['addon'],
  83. 'addonf' => $sAddonF
  84. );
  85. }
  86. }
  87. /** @} */