BxBaseStudioMenuTop.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 BxBaseStudioMenuTop extends BxDolStudioMenuTop implements iBxDolSingleton
  11. {
  12. function __construct()
  13. {
  14. if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
  15. trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
  16. parent::__construct();
  17. }
  18. public static function getInstance()
  19. {
  20. if (!isset($GLOBALS['bxDolClasses']['BxBaseStudioMenuTop']))
  21. $GLOBALS['bxDolClasses']['BxBaseStudioMenuTop'] = new BxTemplStudioMenuTop();
  22. return $GLOBALS['bxDolClasses']['BxBaseStudioMenuTop'];
  23. }
  24. function getCss()
  25. {
  26. return array('menu_top.css');
  27. }
  28. function getJs()
  29. {
  30. return array('menu_top.js');
  31. }
  32. function getJsObject()
  33. {
  34. return 'oBxDolStudioMenuTop';
  35. }
  36. function getCode()
  37. {
  38. $aTmplVars = array();
  39. foreach($this->aItems as $sPosition => $mixedItems) {
  40. if(!$this->aVisible[$sPosition])
  41. continue;
  42. $sContent = "";
  43. if(is_array($mixedItems)) {
  44. $oMenu = new BxTemplStudioMenu(array('template' => 'menu_top_toolbar.html', 'menu_items' => $mixedItems));
  45. $sContent = $oMenu->getCode();
  46. } else if(is_string($mixedItems) && !empty($mixedItems))
  47. $sContent = $mixedItems;
  48. $aTmplVars[] = array(
  49. 'name' => $sPosition,
  50. 'content' => $sContent
  51. );
  52. }
  53. if(empty($aTmplVars))
  54. return '';
  55. $oTemplate = BxDolStudioTemplate::getInstance();
  56. $oTemplate->addJs($this->getJs());
  57. $oTemplate->addCss($this->getCss());
  58. return $oTemplate->parseHtmlByName('menu_top.html', array('bx_repeat:menus' => $aTmplVars));
  59. }
  60. }
  61. /** @} */