| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup UnaView UNA Studio Representation classes
- * @ingroup UnaStudio
- * @{
- */
- class BxBaseStudioMenuTop extends BxDolStudioMenuTop
- {
- function __construct()
- {
- parent::__construct();
- }
- function getCss()
- {
- return array(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'flag-icons/css/|flag-icons.min.css', 'menu_top.css');
- }
- function getJs()
- {
- // the dock's app items are context menu triggers on every Studio page, and the menu's actions (activate, uninstall)
- // run through the module JS object, so its script comes with the menu wherever the page itself does not load it
- return array_merge(BxTemplStudioModules::getInstance()->getJs(), array('menu_top.js', 'context_menu.js'));
- }
- function getJsObject()
- {
- return 'oBxDolStudioMenuTop';
- }
- function getCode()
- {
- $oTemplate = BxDolStudioTemplate::getInstance();
- $aTmplVars = array();
- foreach($this->aItems as $sPosition => $mixedItems) {
- if(!$this->aVisible[$sPosition])
- continue;
- $sContent = "";
- if(is_string($mixedItems) && !empty($mixedItems))
- $sContent = $mixedItems;
- else if(is_array($mixedItems)) {
- $oMenu = new BxTemplStudioMenu($mixedItems);
- $oMenu->addMarkers(array(
- 'js_object' => $this->getJsObject(),
- 'url_root' => BX_DOL_URL_ROOT,
- 'url_studio' => BX_DOL_URL_STUDIO
- ));
- $sContent = $oMenu->getCode();
- if($sPosition == BX_DOL_STUDIO_MT_RIGHT) {
- $sContent = $oTemplate->parseHtmlByContent($sContent, [
- 'bx_if:show_search' => [
- 'condition' => $this->sPageName == 'home' && getParam('sys_std_show_header_right_search') == 'on',
- 'content' => [
- 'bx_if:show_active' => [
- 'condition' => false,
- 'content' => []
- ]
- ]
- ]
- ]);
- }
- }
- $aTmplVars[] = array(
- 'name' => $sPosition,
- 'content' => $sContent
- );
- }
- if(empty($aTmplVars))
- return '';
- $oTemplate->addJs($this->getJs());
- $oTemplate->addCss($this->getCss());
- return $oTemplate->parseHtmlByName('menu_top.html', array(
- 'bx_repeat:menus' => $aTmplVars,
- 'js_code_module' => BxTemplStudioModules::getInstance()->getJsCode(array(), false) // pages with their own instance define it again below
- ));
- }
- }
- /** @} */
|