1
0

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
  11. {
  12. function __construct()
  13. {
  14. parent::__construct();
  15. }
  16. function getCss()
  17. {
  18. return array('menu_top.css');
  19. }
  20. function getJs()
  21. {
  22. return array('menu_top.js');
  23. }
  24. function getJsObject()
  25. {
  26. return 'oBxDolStudioMenuTop';
  27. }
  28. function getCode()
  29. {
  30. $oTemplate = BxDolStudioTemplate::getInstance();
  31. $aTmplVars = array();
  32. foreach($this->aItems as $sPosition => $mixedItems) {
  33. if(!$this->aVisible[$sPosition])
  34. continue;
  35. $sContent = "";
  36. if(is_string($mixedItems) && !empty($mixedItems))
  37. $sContent = $mixedItems;
  38. else if(is_array($mixedItems)) {
  39. $oMenu = new BxTemplStudioMenu($mixedItems);
  40. $oMenu->addMarkers(array(
  41. 'js_object' => $this->getJsObject(),
  42. 'url_root' => BX_DOL_URL_ROOT,
  43. 'url_studio' => BX_DOL_URL_STUDIO
  44. ));
  45. $sContent = $oMenu->getCode();
  46. if($sPosition == BX_DOL_STUDIO_MT_RIGHT) {
  47. $sContent = $oTemplate->parseHtmlByContent($sContent, [
  48. 'bx_if:show_search' => [
  49. 'condition' => $this->sPageName == 'home' && getParam('sys_std_show_header_right_search') == 'on',
  50. 'content' => []
  51. ]
  52. ]);
  53. }
  54. }
  55. $aTmplVars[] = array(
  56. 'name' => $sPosition,
  57. 'content' => $sContent
  58. );
  59. }
  60. if(empty($aTmplVars))
  61. return '';
  62. $oTemplate->addJs($this->getJs());
  63. $oTemplate->addCss($this->getCss());
  64. return $oTemplate->parseHtmlByName('menu_top.html', array('bx_repeat:menus' => $aTmplVars));
  65. }
  66. }
  67. /** @} */