BxBaseMenuToolbar.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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('account' != $r['name'])
  26. continue;
  27. $oProfile = BxDolProfile::getInstance(bx_get_logged_profile_id());
  28. $sUnit = $oProfile->getUnit(0, array('template' => 'unit_wo_info_links'));
  29. if(!empty($sUnit)) {
  30. $a[$k]['bx_if:icon']['condition'] = false;
  31. $a[$k]['bx_if:unit'] = array (
  32. 'condition' => true,
  33. 'content' => array('unit' => $sUnit),
  34. );
  35. break;
  36. }
  37. $sThumb = $oProfile->getThumb();
  38. if(!empty($sThumb)) {
  39. $a[$k]['bx_if:icon']['condition'] = false;
  40. $a[$k]['bx_if:image'] = array (
  41. 'condition' => true,
  42. 'content' => array('icon_url' => $sThumb),
  43. );
  44. break;
  45. }
  46. }
  47. return $a;
  48. }
  49. protected function _getMenuItem ($a)
  50. {
  51. $a = parent::_getMenuItem ($a);
  52. if($a === false)
  53. return $a;
  54. $a['bx_if:unit'] = array(
  55. 'condition' => false,
  56. 'content' => array()
  57. );
  58. if ('add-content' == $a['name'] || 'search' == $a['name'])
  59. $a['class_add'] .= ' bx-def-media-phone-hide';
  60. return $a;
  61. }
  62. }
  63. /** @} */