BxBaseStudioLauncher.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.min.js',
  34. 'jquery.ui.touch-punch.min.js',
  35. 'jquery.easing.js',
  36. 'jquery.cookie.min.js',
  37. 'launcher.js',
  38. 'shepherd/js/shepherd.min.js',
  39. );
  40. foreach($this->aIncludes as $sName => $oInclude)
  41. $aJs = array_merge($aJs, $oInclude->getJs());
  42. return $aJs;
  43. }
  44. public function getPageJsClass()
  45. {
  46. return BX_DOL_STUDIO_LAUNCHER_JS_CLASS;
  47. }
  48. public function getPageJsObject()
  49. {
  50. return BX_DOL_STUDIO_LAUNCHER_JS_OBJECT;
  51. }
  52. public function getPageJsCode($aOptions = array(), $bWrap = true)
  53. {
  54. return parent::getPageJsCode(array_merge($aOptions, array(
  55. 'sActionUrl' => $this->sPageUrl
  56. )), $bWrap);
  57. }
  58. public function getPageCode($sPage = '', $bWrap = true)
  59. {
  60. $sResult = parent::getPageCode($sPage, $bWrap);
  61. if($sResult === false)
  62. return false;
  63. $oTemplate = BxDolStudioTemplate::getInstance();
  64. $sIncludes = '';
  65. foreach($this->aIncludes as $sName => $oInclude)
  66. $sIncludes .= $oInclude->getJsCode();
  67. $sResult = $oTemplate->parseHtmlByName('launcher.html', array(
  68. 'js_object' => $this->getPageJsObject(),
  69. 'js_code' => $this->getPageJsCode(),
  70. 'includes' => $sIncludes,
  71. 'items' => $sResult,
  72. ));
  73. if (getParam('site_tour_studio') == 'on')
  74. $sResult .= $oTemplate->parseHtmlByName('launcher_tour.html', array());
  75. $sResult .= BxDolInformer::getInstance($oTemplate)->display();
  76. $oTemplate->addInjection('injection_body_style', 'text', ' bx-std-page-launcher');
  77. return $sResult;
  78. }
  79. public function getPopupBrowser($sType = '')
  80. {
  81. $iAccountId = getLoggedId();
  82. $oUtils = BxDolStudioRolesUtils::getInstance();
  83. $oTemplate = BxDolStudioTemplate::getInstance();
  84. $bType = !empty($sType);
  85. $aTypes = parent::getPageTypes();
  86. $sSelected = $bType ? $sType : reset($aTypes)['Value'];
  87. $aMarkers = array();
  88. $aMenuItems = array();
  89. $aTmplVarsTypes = array();
  90. foreach($aTypes as $sName => $aType) {
  91. if(!$oUtils->isActionAllowed('use ' . $sName, $iAccountId))
  92. continue;
  93. $aTypeData = unserialize($aType['Data']);
  94. //--- Menu
  95. $aMenuItems[] = array(
  96. 'name' => $sName,
  97. 'title' => _t($aType['LKey']),
  98. 'link' => 'javascript:void(0)',
  99. 'onclick' => $this->getPageJsObject() . '.browserChangeType(this, \'' . $sName . '\')',
  100. 'icon' => !empty($aTypeData['icon']) ? $aTypeData['icon'] : '',
  101. 'selected' => $sName == $sSelected
  102. );
  103. //--- Conetent
  104. $aTmplVarsTypes[] = array(
  105. 'type' => $sName,
  106. 'class' => $sName == $sSelected ? 'bx-std-lbw-active' : '',
  107. 'widgets' => $this->getWidgets($this->aPage['name'], $this->oDb->getWidgets(array(
  108. 'type' => 'by_page_id',
  109. 'value' => $this->aPage['id'],
  110. 'wtype' => $sName != BX_DOL_STUDIO_WTYPE_DEFAULT ? $sName : ''
  111. )))
  112. );
  113. }
  114. $oMenu = new BxTemplStudioMenu(array('template' => 'menu_launcher_browser.html', 'menu_items' => $aMenuItems));
  115. if(!empty($aMarkers))
  116. $oMenu->addMarkers($aMarkers);
  117. $sName = 'bx-std-launcher-browser';
  118. $sContent = $oTemplate->parseHtmlByName('launcher_browser.html', array(
  119. 'logo' => BxTemplStudioFunctions::getInstance()->getLogo(),
  120. 'logo_url' => $this->sPageUrl,
  121. 'menu' => $oMenu->getCode(),
  122. 'bx_repeat:types' => $aTmplVarsTypes
  123. ));
  124. return array(
  125. 'html' => BxTemplStudioFunctions::getInstance()->transBox($sName, $sContent),
  126. 'options' => array(
  127. 'closeOnOuterClick' => true,
  128. 'pointer' => array(
  129. 'el' => '.bx-menu-breadcrumb .bx-menu-bc-' . ($bType ? 'type' : 'home'),
  130. 'align' => 'left',
  131. 'offset' => '-16 0'
  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. /** @} */