BxDevStudioPage.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. $oOptions->enableManage(true);
  40. if(($mixedResult = $oOptions->checkAction()) !== false) {
  41. echoJson($mixedResult);
  42. exit;
  43. }
  44. $this->aPageCss = array_merge($this->aPageCss, $oOptions->getCss());
  45. $this->aPageJs = array_merge($this->aPageJs, $oOptions->getJs());
  46. return $this->oModule->_oTemplate->displayPageSettings($this->sPage, $oOptions);
  47. }
  48. protected function getForms()
  49. {
  50. $sPage = bx_get('form_page');
  51. $sPage = $sPage !== false ? bx_process_input($sPage) : '';
  52. bx_import('Forms', $this->aModule);
  53. $oContent = new BxDevForms(array(
  54. 'page' => $sPage,
  55. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_FORMS),
  56. ));
  57. if(($mixedResult = $oContent->checkAction()) !== false) {
  58. echoJson($mixedResult);
  59. exit;
  60. }
  61. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  62. }
  63. protected function getNavigation()
  64. {
  65. $sPage = bx_get('nav_page');
  66. $sPage = $sPage !== false ? bx_process_input($sPage) : '';
  67. bx_import('Navigation', $this->aModule);
  68. $oContent = new BxDevNavigation(array(
  69. 'page' => $sPage,
  70. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_NAVIGATION),
  71. ));
  72. if(($mixedResult = $oContent->checkAction()) !== false) {
  73. echoJson($mixedResult);
  74. exit;
  75. }
  76. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  77. }
  78. protected function getPages()
  79. {
  80. $sType = bx_get('bp_type');
  81. $sType = $sType !== false ? bx_process_input($sType) : '';
  82. $sPage = bx_get('bp_page');
  83. $sPage = $sPage !== false ? bx_process_input($sPage) : '';
  84. bx_import('BuilderPage', $this->aModule);
  85. $oContent = new BxDevBuilderPage(array(
  86. 'type' => $sType,
  87. 'page' => $sPage,
  88. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_PAGES),
  89. ));
  90. if(($mixedResult = $oContent->checkAction()) !== false) {
  91. echoJson($mixedResult);
  92. exit;
  93. }
  94. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  95. }
  96. protected function getPolyglot()
  97. {
  98. $sType = bx_get('pgt_type');
  99. $sType = $sType !== false ? bx_process_input($sType) : '';
  100. $sPage = bx_get('pgt_page');
  101. $sPage = $sPage !== false ? bx_process_input($sPage) : 'manager';
  102. bx_import('Polyglot', $this->aModule);
  103. $oContent = new BxDevPolyglot(array(
  104. 'page' => $sPage,
  105. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_POLYGLOT),
  106. ));
  107. if(($mixedResult = $oContent->checkAction()) !== false) {
  108. echoJson($mixedResult);
  109. exit;
  110. }
  111. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  112. }
  113. protected function getPermissions()
  114. {
  115. $sPage = bx_get('prm_page');
  116. $sPage = $sPage !== false ? bx_process_input($sPage) : '';
  117. bx_import('Permissions', $this->aModule);
  118. $oContent = new BxDevPermissions(array(
  119. 'page' => $sPage,
  120. 'url' => sprintf($this->sUrl, $this->sModule, BX_DEV_TOOLS_PERMISSIONS),
  121. ));
  122. if(($mixedResult = $oContent->checkAction()) !== false) {
  123. echoJson($mixedResult);
  124. exit;
  125. }
  126. return $this->oModule->_oTemplate->displayPageContent($this->sPage, $oContent);
  127. }
  128. }
  129. /** @} */