BxBaseStudioLauncher.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. define('BX_DOL_STUDIO_LAUNCHER_JS_CLASS', 'BxDolStudioLauncher');
  11. define('BX_DOL_STUDIO_LAUNCHER_JS_OBJECT', 'oBxDolStudioLauncher');
  12. class BxBaseStudioLauncher extends BxDolStudioLauncher
  13. {
  14. protected $_sTourTheme = 'default';
  15. public function __construct()
  16. {
  17. parent::__construct();
  18. $this->sPageUrl = BX_DOL_URL_STUDIO . 'launcher.php';
  19. }
  20. public function getPageCss()
  21. {
  22. $aCss = array(
  23. 'launcher.css',
  24. BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'flag-icon-css/css/|flag-icon.min.css',
  25. BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'shepherd/css/|shepherd-theme-' . $this->_sTourTheme . '.css',
  26. );
  27. foreach($this->aIncludes as $sName => $oInclude)
  28. $aCss = array_merge($aCss, $oInclude->getCss());
  29. return array_merge(parent::getPageCss(), $aCss);
  30. }
  31. public function getPageJs()
  32. {
  33. $aJs = array(
  34. 'jquery-ui/jquery.ui.core.min.js',
  35. 'jquery-ui/jquery.ui.widget.min.js',
  36. 'jquery-ui/jquery.ui.mouse.min.js',
  37. 'jquery-ui/jquery.ui.sortable.min.js',
  38. 'jquery.ui.touch-punch.min.js',
  39. 'jquery.easing.js',
  40. 'jquery.cookie.min.js',
  41. 'launcher.js',
  42. 'shepherd/js/tether.min.js',
  43. 'shepherd/js/shepherd.min.js',
  44. );
  45. foreach($this->aIncludes as $sName => $oInclude)
  46. $aJs = array_merge($aJs, $oInclude->getJs());
  47. return $aJs;
  48. }
  49. public function getPageJsClass()
  50. {
  51. return BX_DOL_STUDIO_LAUNCHER_JS_CLASS;
  52. }
  53. public function getPageJsObject()
  54. {
  55. return BX_DOL_STUDIO_LAUNCHER_JS_OBJECT;
  56. }
  57. public function getPageJsCode($aOptions = array(), $bWrap = true)
  58. {
  59. return parent::getPageJsCode(array_merge($aOptions, array(
  60. 'sActionUrl' => $this->sPageUrl
  61. )), $bWrap);
  62. }
  63. public function getPageCode($sPage = '', $bWrap = true)
  64. {
  65. $sResult = parent::getPageCode($sPage, $bWrap);
  66. if($sResult === false)
  67. return false;
  68. $oTemplate = BxDolStudioTemplate::getInstance();
  69. $sIncludes = '';
  70. foreach($this->aIncludes as $sName => $oInclude)
  71. $sIncludes .= $oInclude->getJsCode();
  72. $sResult = $oTemplate->parseHtmlByName('launcher.html', array(
  73. 'js_object' => $this->getPageJsObject(),
  74. 'js_code' => $this->getPageJsCode(),
  75. 'includes' => $sIncludes,
  76. 'items' => $sResult,
  77. ));
  78. if (getParam('site_tour_studio') == 'on')
  79. $sResult .= $oTemplate->parseHtmlByName('launcher_tour.html', array('tour_theme' => $this->_sTourTheme));
  80. $oTemplate->addInjection('injection_body_style', 'text', ' bx-std-page-launcher');
  81. return $sResult;
  82. }
  83. public function getPopupBrowser($sType = '')
  84. {
  85. $iAccountId = getLoggedId();
  86. $oUtils = BxDolStudioRolesUtils::getInstance();
  87. $oTemplate = BxDolStudioTemplate::getInstance();
  88. $bType = !empty($sType);
  89. $aTypes = parent::getPageTypes();
  90. $sSelected = $bType ? $sType : reset($aTypes)['Value'];
  91. $aMarkers = array();
  92. $aMenuItems = array();
  93. $aTmplVarsTypes = array();
  94. foreach($aTypes as $sName => $aType) {
  95. if(!$oUtils->isActionAllowed('use ' . $sName, $iAccountId))
  96. continue;
  97. $aTypeData = unserialize($aType['Data']);
  98. //--- Menu
  99. $aMenuItems[] = array(
  100. 'name' => $sName,
  101. 'title' => _t($aType['LKey']),
  102. 'link' => 'javascript:void(0)',
  103. 'onclick' => $this->getPageJsObject() . '.browserChangeType(this, \'' . $sName . '\')',
  104. 'icon' => !empty($aTypeData['icon']) ? $aTypeData['icon'] : '',
  105. 'selected' => $sName == $sSelected
  106. );
  107. //--- Conetent
  108. $aTmplVarsTypes[] = array(
  109. 'type' => $sName,
  110. 'class' => $sName == $sSelected ? 'bx-std-lbw-active' : '',
  111. 'widgets' => $this->getWidgets($this->aPage['name'], $this->oDb->getWidgets(array(
  112. 'type' => 'by_page_id',
  113. 'value' => $this->aPage['id'],
  114. 'wtype' => $sName != BX_DOL_STUDIO_WTYPE_DEFAULT ? $sName : ''
  115. )))
  116. );
  117. }
  118. $oMenu = new BxTemplStudioMenu(array('template' => 'menu_launcher_browser.html', 'menu_items' => $aMenuItems));
  119. if(!empty($aMarkers))
  120. $oMenu->addMarkers($aMarkers);
  121. $sName = 'bx-std-launcher-browser';
  122. $sContent = $oTemplate->parseHtmlByName('launcher_browser.html', array(
  123. 'logo' => BxTemplStudioFunctions::getInstance()->getLogo(),
  124. 'logo_url' => $this->sPageUrl,
  125. 'menu' => $oMenu->getCode(),
  126. 'bx_repeat:types' => $aTmplVarsTypes
  127. ));
  128. return array(
  129. 'html' => BxTemplStudioFunctions::getInstance()->transBox($sName, $sContent),
  130. 'options' => array(
  131. 'closeOnOuterClick' => true,
  132. 'pointer' => array(
  133. 'el' => '.bx-menu-breadcrumb .bx-menu-bc-' . ($bType ? 'type' : 'home'),
  134. 'align' => 'left',
  135. 'offset' => '-16 0'
  136. )
  137. )
  138. );
  139. }
  140. public function serviceGetCacheUpdater()
  141. {
  142. check_logged();
  143. if(!isAdmin())
  144. return '';
  145. $oTemplate = BxDolStudioTemplate::getInstance();
  146. $sContent = $oTemplate->addJs('launcher.js', true);
  147. $sContent .= $oTemplate->parseHtmlByName('launcher_cache_updater.html', array(
  148. 'js_object' => $this->getPageJsObject()
  149. ));
  150. return $sContent;
  151. }
  152. }
  153. /** @} */