1
0

BxBaseStudioWidgets.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 BxBaseStudioWidgets extends BxDolStudioWidgets
  11. {
  12. public function __construct($mixedPageName)
  13. {
  14. parent::__construct($mixedPageName);
  15. }
  16. public function getPageMenu($aMenu = array(), $aMarkers = array())
  17. {
  18. $aTypes = parent::getPageTypes();
  19. $iAccountId = getLoggedId();
  20. $oUtils = BxDolStudioRolesUtils::getInstance();
  21. $aMenuItems = array();
  22. foreach($aTypes as $sName => $aType) {
  23. if(!$oUtils->isActionAllowed('use ' . $sName, $iAccountId))
  24. continue;
  25. $aTypeData = unserialize($aType['Data']);
  26. $aMenuItems[] = array(
  27. 'name' => $sName,
  28. 'title' => _t($aType['LKey']),
  29. 'link' => bx_append_url_params($this->sPageUrl, array(
  30. 'type' => $sName
  31. )),
  32. 'icon' => !empty($aTypeData['icon']) ? $aTypeData['icon'] : '',
  33. 'selected' => $sName == $this->_sType
  34. );
  35. }
  36. return parent::getPageMenu($aMenuItems);
  37. }
  38. public function getPageCode($sPage = '', $bWrap = true)
  39. {
  40. $sResult = parent::getPageCode($sPage, $bWrap);
  41. if($sResult === false)
  42. return false;
  43. $aWidgetsParams = array(
  44. 'featured' => $this->isFeatured(),
  45. 'notices' => $this->aWidgetsNotices
  46. );
  47. if(!$this->bPageMultiple)
  48. return $this->wrapWidgets($this->aPage['name'], $this->getWidgets($this->aPage['name'], $this->aWidgets, $aWidgetsParams));
  49. $sContent = "";
  50. foreach($this->aWidgets as $sPage => $aWidgets)
  51. $sContent .= $this->wrapWidgets($sPage, $this->getWidgets($sPage, $aWidgets, $aWidgetsParams), $sPage != $this->sPageSelected);
  52. return $sContent;
  53. }
  54. public function getPageCaption()
  55. {
  56. if(empty($this->aPage) || !is_array($this->aPage))
  57. return '';
  58. $sResult = parent::getPageCaption();
  59. //--- Menu Right ---//
  60. $aItemsRight = array(
  61. 'template' => 'menu_top_toolbar.html',
  62. 'menu_items' => array(
  63. 'tour' => array(
  64. 'name' => 'tour',
  65. 'icon' => 'tmi-help.svg',
  66. 'link' => 'javascript:void(0);',
  67. 'onclick' => 'glTour.start()',
  68. 'title' => '_adm_tmi_cpt_tour'
  69. ),
  70. 'assistant' => array(
  71. 'name' => 'assistant',
  72. 'icon' => 'tmi-assistant.svg',
  73. 'link' => 'javascript:void(0);',
  74. 'onclick' => BX_DOL_STUDIO_PAGE_JS_OBJECT . ".togglePopup('assistant', this)",
  75. 'title' => '_adm_tmi_cpt_assistant'
  76. ),
  77. 'site' => array(
  78. 'name' => 'site',
  79. 'icon' => 'tmi-site.svg',
  80. 'link' => '{url_root}',
  81. 'title' => '_adm_tmi_cpt_site'
  82. ),
  83. 'scheme' => array(
  84. 'name' => 'scheme',
  85. 'icon' => 'tmi-scheme-auto.svg',
  86. 'link' => 'javascript:void(0);',
  87. 'onclick' => 'bx_menu_popup_inline(\'#bx-std-pcap-menu-popup-scheme\', this);',
  88. 'title' => '_adm_tmi_cpt_scheme'
  89. ),
  90. 'account' => array(
  91. 'name' => 'account',
  92. 'icon' => 'tmi-account.svg',
  93. 'link' => 'javascript:void(0);',
  94. 'onclick' => 'bx_menu_popup_inline(\'#bx-std-pcap-menu-popup-account\', this);',
  95. 'title' => '_adm_tmi_cpt_account'
  96. )
  97. )
  98. );
  99. if($this->_sType != BX_DOL_STUDIO_WTYPE_DEFAULT || getParam('site_tour_studio') != 'on')
  100. unset($aItemsRight['menu_items']['tour']);
  101. if(!$this->_bShowHeaderRightAssistant)
  102. unset($aItemsRight['menu_items']['assistant']);
  103. if(!$this->_bShowHeaderRightSite)
  104. unset($aItemsRight['menu_items']['site']);
  105. $oTopMenu = BxTemplStudioMenuTop::getInstance();
  106. $oTopMenu->setPageName($this->aPage['name']);
  107. $oTopMenu->setContent(BX_DOL_STUDIO_MT_LEFT, $this->getPageBreadcrumb());
  108. $oTopMenu->setContent(BX_DOL_STUDIO_MT_RIGHT, $aItemsRight);
  109. return $sResult;
  110. }
  111. protected function wrapWidgets($sName, $sContent, $bHidden = false)
  112. {
  113. return BxDolStudioTemplate::getInstance()->parseHtmlByName('widgets_page.html', array(
  114. 'page' => $sName,
  115. 'bx_if:page_hidden' => array(
  116. 'condition' => $bHidden,
  117. 'content' => array()
  118. ),
  119. 'content' => $sContent
  120. ));
  121. }
  122. protected function getWidgets($sPage, $aWidgets, $aParams = array())
  123. {
  124. $oFunction = BxTemplStudioFunctions::getInstance();
  125. $aTmplVars = array();
  126. foreach($aWidgets as $aWidget) {
  127. $sWidget = $oFunction->getWidget($aWidget, $aParams);
  128. if(empty($sWidget))
  129. continue;
  130. $aTmplVars[] = array(
  131. 'widget' => $sWidget,
  132. );
  133. }
  134. return BxDolStudioTemplate::getInstance()->parseHtmlByName('widgets.html', array(
  135. 'bx_repeat:widgets' => $aTmplVars
  136. ));
  137. }
  138. }
  139. /** @} */