BxBaseStudioMenuTop.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_string($mixedItems) && !empty($mixedItems))
  44. $sContent = $mixedItems;
  45. else if(is_array($mixedItems)) {
  46. $oMenu = new BxTemplStudioMenu($mixedItems);
  47. $oMenu->addMarkers(array(
  48. 'url_studio' => BX_DOL_URL_STUDIO
  49. ));
  50. $sContent = $oMenu->getCode();
  51. }
  52. $aTmplVars[] = array(
  53. 'name' => $sPosition,
  54. 'content' => $sContent
  55. );
  56. }
  57. if(empty($aTmplVars))
  58. return '';
  59. $oTemplate = BxDolStudioTemplate::getInstance();
  60. $oTemplate->addJs($this->getJs());
  61. $oTemplate->addCss($this->getCss());
  62. return $oTemplate->parseHtmlByName('menu_top.html', array('bx_repeat:menus' => $aTmplVars));
  63. }
  64. }
  65. /** @} */