BxBaseStudioMenu.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 UnaView UNA Studio Representation classes
  7. * @ingroup UnaStudio
  8. * @{
  9. */
  10. class BxBaseStudioMenu extends BxDolStudioMenu
  11. {
  12. protected $_bInlineIcons;
  13. public function __construct ($aObject, $oTemplate)
  14. {
  15. parent::__construct ($aObject, $oTemplate);
  16. $this->_bInlineIcons = in_array($this->_aObject['template'], array(
  17. 'menu_side.html',
  18. 'menu_top_toolbar.html',
  19. 'menu_launcher_browser.html',
  20. 'page_breadcrumb.html'
  21. ));
  22. }
  23. protected function _getMenuItem ($aItem)
  24. {
  25. $aItem = parent::_getMenuItem($aItem);
  26. if($aItem === false)
  27. return $aItem;
  28. $aItem['class'] = isset($aItem['class']) ? $aItem['class'] : '';
  29. if($this->_bInlineIcons && $aItem['bx_if:image']['condition'] && strpos($aItem['bx_if:image']['content']['icon_url'], '.svg') !== false)
  30. $aItem = array_merge($aItem, array(
  31. 'bx_if:image' => array (
  32. 'condition' => false,
  33. 'content' => array(),
  34. ),
  35. 'bx_if:image_inline' => array (
  36. 'condition' => true,
  37. 'content' => array(
  38. 'image' => bx_file_get_contents($aItem['bx_if:image']['content']['icon_url'])
  39. ),
  40. ),
  41. ));
  42. return $aItem;
  43. }
  44. /**
  45. * Check if menu items is selected.
  46. * @param $a menu item array
  47. * @return boolean
  48. */
  49. protected function _isSelected ($a)
  50. {
  51. return isset($a['selected']) && $a['selected'] === true;
  52. }
  53. }
  54. /** @} */