BxDevStudioPage.php 5.0 KB

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