BxBaseStudioLauncher.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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()
  64. {
  65. $sResult = parent::getPageCode();
  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()
  84. {
  85. $iAccountId = getLoggedId();
  86. $oUtils = BxDolStudioRolesUtils::getInstance();
  87. $oTemplate = BxDolStudioTemplate::getInstance();
  88. $aTypes = parent::getPageTypes();
  89. $sSelected = reset($aTypes)['Value'];
  90. $aMarkers = array();
  91. $aMenuItems = array();
  92. $aTmplVarsTypes = array();
  93. foreach($aTypes as $sType => $aType) {
  94. if(!$oUtils->isActionAllowed('use ' . $sType, $iAccountId))
  95. continue;
  96. $aTypeData = unserialize($aType['Data']);
  97. //--- Menu
  98. $aMenuItems[] = array(
  99. 'name' => $sType,
  100. 'title' => _t($aType['LKey']),
  101. 'link' => 'javascript:void(0)',
  102. 'onclick' => $this->getPageJsObject() . '.browserChangeType(this, \'' . $sType . '\')',
  103. 'icon' => !empty($aTypeData['icon']) ? $aTypeData['icon'] : '',
  104. 'selected' => $sType == $sSelected
  105. );
  106. //--- Conetent
  107. $aTmplVarsTypes[] = array(
  108. 'type' => $sType,
  109. 'class' => $sType == $sSelected ? 'bx-std-lbw-active' : '',
  110. 'widgets' => $this->getWidgets($this->aPage['name'], $this->oDb->getWidgets(array(
  111. 'type' => 'by_page_id',
  112. 'value' => $this->aPage['id'],
  113. 'wtype' => $sType != BX_DOL_STUDIO_WTYPE_DEFAULT ? $sType : ''
  114. )))
  115. );
  116. }
  117. $oMenu = new BxTemplStudioMenu(array('template' => 'menu_launcher_browser.html', 'menu_items' => $aMenuItems));
  118. if(!empty($aMarkers))
  119. $oMenu->addMarkers($aMarkers);
  120. $sName = 'bx-std-launcher-browser';
  121. $sContent = $oTemplate->parseHtmlByName('launcher_browser.html', array(
  122. 'logo' => BxTemplStudioFunctions::getInstance()->getLogo(),
  123. 'menu' => $oMenu->getCode(),
  124. 'bx_repeat:types' => $aTmplVarsTypes
  125. ));
  126. return array(
  127. 'html' => BxTemplStudioFunctions::getInstance()->transBox($sName, $sContent),
  128. 'options' => array(
  129. 'closeOnOuterClick' => true,
  130. 'pointer' => array(
  131. 'el' => '.bx-menu-breadcrumb .bx-menu-bc-home',
  132. )
  133. )
  134. );
  135. }
  136. public function serviceGetCacheUpdater()
  137. {
  138. check_logged();
  139. if(!isAdmin())
  140. return '';
  141. $oTemplate = BxDolStudioTemplate::getInstance();
  142. $sContent = $oTemplate->addJs('launcher.js', true);
  143. $sContent .= $oTemplate->parseHtmlByName('launcher_cache_updater.html', array(
  144. 'js_object' => $this->getPageJsObject()
  145. ));
  146. return $sContent;
  147. }
  148. }
  149. /** @} */