BxBaseMenuToolbar.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 BxBaseMenuToolbar extends BxTemplMenu
  14. {
  15. public function __construct ($aObject, $oTemplate)
  16. {
  17. parent::__construct ($aObject, $oTemplate);
  18. }
  19. public function getMenuItems ()
  20. {
  21. $a = parent::getMenuItems ();
  22. if (!isLogged())
  23. return $a;
  24. foreach ($a as $k => $r) {
  25. if($r['name'] != 'account')
  26. continue;
  27. if($a[$k]['bx_if:image']['condition'])
  28. break;
  29. $oProfile = BxDolProfile::getInstance(bx_get_logged_profile_id());
  30. $sUnit = $oProfile->getUnit(0, array('template' => 'unit_wo_info_links'));
  31. if(!empty($sUnit)) {
  32. $a[$k]['bx_if:icon']['condition'] = false;
  33. $a[$k]['bx_if:unit'] = array (
  34. 'condition' => true,
  35. 'content' => array('unit' => $sUnit),
  36. );
  37. break;
  38. }
  39. $sThumb = $oProfile->getThumb();
  40. if(!empty($sThumb)) {
  41. $a[$k]['bx_if:icon']['condition'] = false;
  42. $a[$k]['bx_if:image'] = array (
  43. 'condition' => true,
  44. 'content' => array('icon_url' => $sThumb),
  45. );
  46. break;
  47. }
  48. }
  49. return $a;
  50. }
  51. protected function _getMenuItem ($a)
  52. {
  53. $a = parent::_getMenuItem ($a);
  54. if($a === false)
  55. return $a;
  56. $a['bx_if:unit'] = array(
  57. 'condition' => false,
  58. 'content' => array()
  59. );
  60. if ('add-content' == $a['name'] || 'search' == $a['name'])
  61. $a['class_add'] .= ' bx-def-media-phone-hide';
  62. return $a;
  63. }
  64. protected function _getTmplVarsAddon($mixedAddon, $aMenuItem)
  65. {
  66. return array(
  67. 'addon' => $mixedAddon,
  68. 'addonf' => $this->_oTemplate->parseHtmlByTemplateName('menu_item_addon', array(
  69. 'content' => $mixedAddon
  70. ))
  71. );
  72. }
  73. }
  74. /** @} */