BxBaseStudioMenuTop.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'flag-icons/css/|flag-icons.min.css', '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. 'bx_if:show_active' => [
  52. 'condition' => false,
  53. 'content' => []
  54. ]
  55. ]
  56. ]
  57. ]);
  58. }
  59. }
  60. $aTmplVars[] = array(
  61. 'name' => $sPosition,
  62. 'content' => $sContent
  63. );
  64. }
  65. if(empty($aTmplVars))
  66. return '';
  67. $oTemplate->addJs($this->getJs());
  68. $oTemplate->addCss($this->getCss());
  69. return $oTemplate->parseHtmlByName('menu_top.html', array('bx_repeat:menus' => $aTmplVars));
  70. }
  71. }
  72. /** @} */