BxBaseStudioMenu.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. ));
  21. }
  22. protected function _getMenuItem ($aItem)
  23. {
  24. $aItem = parent::_getMenuItem($aItem);
  25. if($aItem === false)
  26. return $aItem;
  27. $aItem['class'] = isset($aItem['class']) ? $aItem['class'] : '';
  28. if($this->_bInlineIcons && $aItem['bx_if:image']['condition'] && strpos($aItem['bx_if:image']['content']['icon_url'], '.svg') !== false)
  29. $aItem = array_merge($aItem, array(
  30. 'bx_if:image' => array (
  31. 'condition' => false,
  32. 'content' => array(),
  33. ),
  34. 'bx_if:image_inline' => array (
  35. 'condition' => true,
  36. 'content' => array(
  37. 'image' => bx_file_get_contents($aItem['bx_if:image']['content']['icon_url'])
  38. ),
  39. ),
  40. ));
  41. return $aItem;
  42. }
  43. /**
  44. * Check if menu items is selected.
  45. * @param $a menu item array
  46. * @return boolean
  47. */
  48. protected function _isSelected ($a)
  49. {
  50. return isset($a['selected']) && $a['selected'] === true;
  51. }
  52. }
  53. /** @} */