BxBaseStudioLauncher.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. 'hammer.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. 'sTxtMatches' => _t('_adm_txt_launcher_search_matches'),
  62. 'sTxtMatchesOne' => _t('_adm_txt_launcher_search_matches_one'),
  63. 'sTxtMoved' => _t('_adm_txt_widget_moved'),
  64. )), $bWrap);
  65. }
  66. public function getPageCode($sPage = '', $bWrap = true)
  67. {
  68. $sResult = parent::getPageCode($sPage, $bWrap);
  69. if($sResult === false)
  70. return false;
  71. $oTemplate = BxDolStudioTemplate::getInstance();
  72. $sIncludes = '';
  73. foreach($this->aIncludes as $sName => $oInclude)
  74. $sIncludes .= $oInclude->getJsCode();
  75. $sResult = $oTemplate->parseHtmlByName('launcher.html', array(
  76. 'js_object' => $this->getPageJsObject(),
  77. 'js_code' => $this->getPageJsCode(),
  78. 'includes' => $sIncludes,
  79. 'items' => $sResult,
  80. 'empty' => _t('_adm_txt_launcher_search_empty'),
  81. 'edit_title' => _t('_sys_menu_item_title_sa_edit'),
  82. 'edit_done' => _t('_sys_done'),
  83. ));
  84. if (getParam('site_tour_studio') == 'on')
  85. $sResult .= $oTemplate->parseHtmlByName('launcher_tour.html', array());
  86. $sResult .= BxDolInformer::getInstance($oTemplate)->display();
  87. $oTemplate->addInjection('injection_body_style', 'text', ' bx-std-page-launcher');
  88. return $sResult;
  89. }
  90. public function getPopupBrowser($sType = '')
  91. {
  92. $iAccountId = getLoggedId();
  93. $oUtils = BxDolStudioRolesUtils::getInstance();
  94. $oTemplate = BxDolStudioTemplate::getInstance();
  95. $bType = !empty($sType);
  96. $aTypes = parent::getPageTypes();
  97. $sSelected = $bType ? $sType : reset($aTypes)['Value'];
  98. $aMarkers = array();
  99. $aMenuItems = array();
  100. $aTmplVarsTypes = array();
  101. foreach($aTypes as $sName => $aType) {
  102. if(!$oUtils->isActionAllowed('use ' . $sName, $iAccountId))
  103. continue;
  104. $aTypeData = unserialize($aType['Data']);
  105. //--- Menu
  106. $aMenuItems[] = array(
  107. 'name' => $sName,
  108. 'title' => _t($aType['LKey']),
  109. 'link' => 'javascript:void(0)',
  110. 'onclick' => $this->getPageJsObject() . '.browserChangeType(this, \'' . $sName . '\')',
  111. 'icon' => !empty($aTypeData['icon']) ? $aTypeData['icon'] : '',
  112. 'selected' => $sName == $sSelected
  113. );
  114. //--- Conetent
  115. $aTmplVarsTypes[] = array(
  116. 'type' => $sName,
  117. 'class' => $sName == $sSelected ? 'bx-std-lbw-active' : '',
  118. 'widgets' => $this->getWidgets($this->aPage['name'], $this->oDb->getWidgets(array(
  119. 'type' => 'by_page_id',
  120. 'value' => $this->aPage['id'],
  121. 'wtype' => $sName != BX_DOL_STUDIO_WTYPE_DEFAULT ? $sName : ''
  122. )))
  123. );
  124. }
  125. $oMenu = new BxTemplStudioMenu(array('template' => 'menu_launcher_browser.html', 'menu_items' => $aMenuItems));
  126. if(!empty($aMarkers))
  127. $oMenu->addMarkers($aMarkers);
  128. $sName = 'bx-std-launcher-browser';
  129. $sContent = $oTemplate->parseHtmlByName('launcher_browser.html', array(
  130. 'logo' => BxTemplStudioFunctions::getInstance()->getLogo(),
  131. 'logo_url' => $this->sPageUrl,
  132. 'menu' => $oMenu->getCode(),
  133. 'bx_repeat:types' => $aTmplVarsTypes
  134. ));
  135. return array(
  136. 'html' => BxTemplStudioFunctions::getInstance()->transBox($sName, $sContent),
  137. 'options' => array(
  138. 'closeOnOuterClick' => true,
  139. 'pointer' => array(
  140. 'el' => '.bx-menu-breadcrumb .bx-menu-bc-' . ($bType ? 'type' : 'home'),
  141. 'align' => 'left',
  142. 'offset' => '-16 0'
  143. )
  144. )
  145. );
  146. }
  147. public function serviceGetCacheUpdater()
  148. {
  149. check_logged();
  150. if(!isAdmin())
  151. return '';
  152. $oTemplate = BxDolStudioTemplate::getInstance();
  153. $sContent = $oTemplate->addJs('launcher.js', true);
  154. $sContent .= $oTemplate->parseHtmlByName('launcher_cache_updater.html', array(
  155. 'js_object' => $this->getPageJsObject()
  156. ));
  157. return $sContent;
  158. }
  159. }
  160. /** @} */