BxBaseMenuToolbar.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. }
  65. /** @} */