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