BxBaseStudioLauncher.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 getPageIndex()
  20. {
  21. return $this->isLeftColumn() ? parent::getPageIndex() : 4;
  22. }
  23. public function getPageCss()
  24. {
  25. $aCss = array(
  26. 'launcher.css',
  27. BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'flag-icon-css/css/|flag-icon.min.css',
  28. BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'shepherd/css/|shepherd.css',
  29. );
  30. foreach($this->aIncludes as $sName => $oInclude)
  31. $aCss = array_merge($aCss, $oInclude->getCss());
  32. return array_merge(parent::getPageCss(), $aCss);
  33. }
  34. public function getPageJs()
  35. {
  36. $aJs = array(
  37. 'jquery-ui/jquery-ui.min.js',
  38. 'jquery.ui.touch-punch.min.js',
  39. 'jquery.easing.js',
  40. 'jquery.cookie.min.js',
  41. 'launcher.js',
  42. 'shepherd/js/shepherd.min.js',
  43. );
  44. foreach($this->aIncludes as $sName => $oInclude)
  45. $aJs = array_merge($aJs, $oInclude->getJs());
  46. return $aJs;
  47. }
  48. public function getPageJsClass()
  49. {
  50. return BX_DOL_STUDIO_LAUNCHER_JS_CLASS;
  51. }
  52. public function getPageJsObject()
  53. {
  54. return BX_DOL_STUDIO_LAUNCHER_JS_OBJECT;
  55. }
  56. public function getPageJsCode($aOptions = array(), $bWrap = true)
  57. {
  58. return parent::getPageJsCode(array_merge($aOptions, array(
  59. 'sActionUrl' => $this->sPageUrl
  60. )), $bWrap);
  61. }
  62. public function getPageCode($sPage = '', $bWrap = true)
  63. {
  64. $sResult = parent::getPageCode($sPage, $bWrap);
  65. if($sResult === false)
  66. return false;
  67. $oTemplate = BxDolStudioTemplate::getInstance();
  68. $sIncludes = '';
  69. foreach($this->aIncludes as $sName => $oInclude)
  70. $sIncludes .= $oInclude->getJsCode();
  71. $sResult = $oTemplate->parseHtmlByName('launcher.html', array(
  72. 'js_object' => $this->getPageJsObject(),
  73. 'js_code' => $this->getPageJsCode(),
  74. 'includes' => $sIncludes,
  75. 'items' => $sResult,
  76. ));
  77. if (getParam('site_tour_studio') == 'on')
  78. $sResult .= $oTemplate->parseHtmlByName('launcher_tour.html', array());
  79. $sResult .= BxDolInformer::getInstance($oTemplate)->display();
  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. /** @} */