BxDevStudioPage.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 Developer Developer
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxDevStudioPage extends BxTemplStudioModule
  12. {
  13. protected $oModule;
  14. protected $sUrl;
  15. function __construct($sModule, $mixedPageName, $sPage = "")
  16. {
  17. parent::__construct($sModule, $mixedPageName, $sPage);
  18. $this->aPageCodeNoWrap = array('polyglot', 'forms', 'navigation', 'pages');
  19. $this->oModule = BxDolModule::getInstance($this->sModule);
  20. $this->sUrl = BX_DOL_URL_STUDIO . 'module.php?name=%s&page=%s';
  21. }
  22. function getPageMenu($aMenu = [], $aMarkers = [])
  23. {
  24. $oTemplate = BxDolStudioTemplate::getInstance();
  25. $sActions = $this->getPageCaptionActions();
  26. $oTemplate->addInjection('injection_header', 'text', BxTemplStudioFunctions::getInstance()->transBox('bx-std-pmenu-popup-actions', $sActions, true));
  27. $this->aMenuItems = [];
  28. foreach($this->oModule->aTools as $aTool)
  29. $this->aMenuItems[] = [
  30. 'name' => $aTool['name'],
  31. 'icon' => $aTool['icon'],
  32. 'link' => sprintf($this->sUrl, $this->sModule, $aTool['name']),
  33. 'title' => $aTool['title'],
  34. 'selected' => $aTool['name'] == $this->sPage
  35. ];
  36. $oMenu = new BxTemplStudioMenu(['template' => 'menu_main_dev.html', 'menu_items' => $this->aMenuItems], $this->oModule->_oTemplate);
  37. return $this->oModule->_oTemplate->parseHtmlByName('page_menu.html', [
  38. 'actions_onclick' => BX_DOL_STUDIO_PAGE_JS_OBJECT . ".togglePopup('actions', this)",
  39. 'actions_icon' => $oTemplate->getIconUrl('mi-cog.svg'),
  40. 'menu' => $oMenu->getCode()
  41. ]);
  42. }
  43. protected function getSettings()
  44. {
  45. $oOptions = new BxTemplStudioOptions('system', 'hidden');
  46. $oOptions->enableManage(true);
  47. if(($mixedResult = $oOptions->checkAction()) !== false) {
  48. echoJson($mixedResult);
  49. exit;
  50. }
  51. $this->aPageCss = array_merge($this->aPageCss, $oOptions->getCss());
  52. $this->aPageJs = array_merge($this->aPageJs, $oOptions->getJs());
  53. return $this->oModule->_oTemplate->displayPageSettings($this->sPage, $oOptions);
  54. }
  55. protected function getForms()
  56. {
  57. $sPage = bx_get('form_page');
  58. $sPage = $sPage !== false ? bx_process_input($sPage) : '';
  59. bx_import('Forms', $this->aModule);
  60. $oContent = new BxDevForms(array(
  61. 'page' => $sPage,
  62. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_FORMS),
  63. ));
  64. if(($mixedResult = $oContent->checkAction()) !== false) {
  65. echoJson($mixedResult);
  66. exit;
  67. }
  68. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  69. }
  70. protected function getNavigation()
  71. {
  72. $sPage = bx_get('nav_page');
  73. $sPage = $sPage !== false ? bx_process_input($sPage) : '';
  74. bx_import('Navigation', $this->aModule);
  75. $oContent = new BxDevNavigation(array(
  76. 'page' => $sPage,
  77. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_NAVIGATION),
  78. ));
  79. if(($mixedResult = $oContent->checkAction()) !== false) {
  80. echoJson($mixedResult);
  81. exit;
  82. }
  83. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  84. }
  85. protected function getPages()
  86. {
  87. $sType = bx_get('bp_type');
  88. $sType = $sType !== false ? bx_process_input($sType) : '';
  89. $sPage = bx_get('bp_page');
  90. $sPage = $sPage !== false ? bx_process_input($sPage) : '';
  91. bx_import('BuilderPage', $this->aModule);
  92. $oContent = new BxDevBuilderPage(array(
  93. 'type' => $sType,
  94. 'page' => $sPage,
  95. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_PAGES),
  96. ));
  97. if(($mixedResult = $oContent->checkAction()) !== false) {
  98. echoJson($mixedResult);
  99. exit;
  100. }
  101. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  102. }
  103. protected function getPolyglot()
  104. {
  105. $sType = bx_get('pgt_type');
  106. $sType = $sType !== false ? bx_process_input($sType) : '';
  107. $sPage = bx_get('pgt_page');
  108. $sPage = $sPage !== false ? bx_process_input($sPage) : 'manager';
  109. bx_import('Polyglot', $this->aModule);
  110. $oContent = new BxDevPolyglot(array(
  111. 'page' => $sPage,
  112. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_POLYGLOT),
  113. ));
  114. if(($mixedResult = $oContent->checkAction()) !== false) {
  115. echoJson($mixedResult);
  116. exit;
  117. }
  118. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  119. }
  120. protected function getPermissions()
  121. {
  122. $sPage = bx_get('prm_page');
  123. $sPage = $sPage !== false ? bx_process_input($sPage) : '';
  124. bx_import('Permissions', $this->aModule);
  125. $oContent = new BxDevPermissions(array(
  126. 'page' => $sPage,
  127. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_PERMISSIONS),
  128. ));
  129. if(($mixedResult = $oContent->checkAction()) !== false) {
  130. echoJson($mixedResult);
  131. exit;
  132. }
  133. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  134. }
  135. }
  136. /** @} */