BxBaseStudioMenu.php 1.9 KB

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