1
0

BxDevStudioPage.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. $this->aMenuItems = [];
  26. foreach($this->oModule->aTools as $aTool)
  27. $this->aMenuItems[] = [
  28. 'name' => $aTool['name'],
  29. 'icon' => $aTool['icon'],
  30. 'link' => sprintf($this->sUrl, $this->sModule, $aTool['name']),
  31. 'title' => $aTool['title'],
  32. 'selected' => $aTool['name'] == $this->sPage
  33. ];
  34. $oMenu = new BxTemplStudioMenu(['template' => 'menu_main_dev.html', 'menu_items' => $this->aMenuItems], $this->oModule->_oTemplate);
  35. $sActions = $this->bPageMenuTitle ? $this->getPageCaptionActions() : '';
  36. return $this->oModule->_oTemplate->parseHtmlByName('page_menu.html', [
  37. 'bx_if:show_title' => [
  38. 'condition' => (bool)$sActions,
  39. 'content' => [
  40. 'actions_onclick' => $sActions,
  41. 'actions_icon' => $oTemplate->getIconUrl('mi-cog.svg'),
  42. ]
  43. ],
  44. 'menu' => $oMenu->getCode()
  45. ]);
  46. }
  47. protected function getSettings()
  48. {
  49. $oOptions = new BxTemplStudioOptions('system', 'hidden');
  50. $oOptions->enableManage(true);
  51. if(($mixedResult = $oOptions->checkAction()) !== false) {
  52. echoJson($mixedResult);
  53. exit;
  54. }
  55. $this->aPageCss = array_merge($this->aPageCss, $oOptions->getCss());
  56. $this->aPageJs = array_merge($this->aPageJs, $oOptions->getJs());
  57. return $this->oModule->_oTemplate->displayPageSettings($this->sPage, $oOptions);
  58. }
  59. protected function getForms()
  60. {
  61. $sPage = bx_get('form_page');
  62. $sPage = $sPage !== false ? bx_process_input($sPage) : '';
  63. bx_import('Forms', $this->aModule);
  64. $oContent = new BxDevForms(array(
  65. 'page' => $sPage,
  66. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_FORMS),
  67. ));
  68. if(($mixedResult = $oContent->checkAction()) !== false) {
  69. echoJson($mixedResult);
  70. exit;
  71. }
  72. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  73. }
  74. protected function getNavigation()
  75. {
  76. $sPage = bx_get('nav_page');
  77. $sPage = $sPage !== false ? bx_process_input($sPage) : '';
  78. bx_import('Navigation', $this->aModule);
  79. $oContent = new BxDevNavigation(array(
  80. 'page' => $sPage,
  81. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_NAVIGATION),
  82. ));
  83. if(($mixedResult = $oContent->checkAction()) !== false) {
  84. echoJson($mixedResult);
  85. exit;
  86. }
  87. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  88. }
  89. protected function getPages()
  90. {
  91. $sType = bx_get('bp_type');
  92. $sType = $sType !== false ? bx_process_input($sType) : '';
  93. $sPage = bx_get('bp_page');
  94. $sPage = $sPage !== false ? bx_process_input($sPage) : '';
  95. bx_import('BuilderPage', $this->aModule);
  96. $oContent = new BxDevBuilderPage(array(
  97. 'type' => $sType,
  98. 'page' => $sPage,
  99. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_PAGES),
  100. ));
  101. if(($mixedResult = $oContent->checkAction()) !== false) {
  102. echoJson($mixedResult);
  103. exit;
  104. }
  105. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  106. }
  107. protected function getPolyglot()
  108. {
  109. $sType = bx_get('pgt_type');
  110. $sType = $sType !== false ? bx_process_input($sType) : '';
  111. $sPage = bx_get('pgt_page');
  112. $sPage = $sPage !== false ? bx_process_input($sPage) : 'manager';
  113. bx_import('Polyglot', $this->aModule);
  114. $oContent = new BxDevPolyglot(array(
  115. 'page' => $sPage,
  116. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_POLYGLOT),
  117. ));
  118. if(($mixedResult = $oContent->checkAction()) !== false) {
  119. echoJson($mixedResult);
  120. exit;
  121. }
  122. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  123. }
  124. protected function getPermissions()
  125. {
  126. $sPage = bx_get('prm_page');
  127. $sPage = $sPage !== false ? bx_process_input($sPage) : '';
  128. bx_import('Permissions', $this->aModule);
  129. $oContent = new BxDevPermissions(array(
  130. 'page' => $sPage,
  131. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_PERMISSIONS),
  132. ));
  133. if(($mixedResult = $oContent->checkAction()) !== false) {
  134. echoJson($mixedResult);
  135. exit;
  136. }
  137. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  138. }
  139. }
  140. /** @} */