1
0

BxBaseStudioAPI.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. class BxBaseStudioAPI extends BxDolStudioAPI
  11. {
  12. protected $sSubpageUrl;
  13. protected $aMenuItems;
  14. protected $aGridObjects;
  15. public function __construct($sPage = '')
  16. {
  17. parent::__construct($sPage);
  18. $this->aPageCss = array_merge($this->aPageCss, ['forms.css', 'paginate.css']);
  19. $this->sSubpageUrl = BX_DOL_URL_STUDIO . 'api.php?page=';
  20. $this->aMenuItems = array(
  21. BX_DOL_STUDIO_API_TYPE_SETTINGS => array('icon' => 'mi-cog.svg'),
  22. BX_DOL_STUDIO_API_TYPE_CONFIG => array('icon' => 'mi-api-config.svg'),
  23. BX_DOL_STUDIO_API_TYPE_ORIGINS => array('icon' => 'mi-api-origins.svg'),
  24. BX_DOL_STUDIO_API_TYPE_KEYS => array('icon' => 'mi-api-keys.svg'),
  25. );
  26. $this->aGridObjects = [
  27. 'keys' => 'sys_studio_api_keys',
  28. 'origins' => 'sys_studio_api_origins',
  29. 'configs' => 'sys_studio_api_configs',
  30. ];
  31. }
  32. public function getPageMenu($aMenu = array(), $aMarkers = array())
  33. {
  34. $sJsObject = $this->getPageJsObject();
  35. $aMenu = array();
  36. foreach($this->aMenuItems as $sMenuItem => $aItem)
  37. $aMenu[] = array(
  38. 'name' => $sMenuItem,
  39. 'icon' => $aItem['icon'],
  40. 'icon_bg' => true,
  41. 'link' => $this->sSubpageUrl . $sMenuItem,
  42. 'title' => _t('_adm_lmi_cpt_' . $sMenuItem),
  43. 'selected' => $sMenuItem == $this->sPage
  44. );
  45. return parent::getPageMenu($aMenu);
  46. }
  47. protected function getSettings()
  48. {
  49. $oOptions = new BxTemplStudioOptions(BX_DOL_STUDIO_STG_TYPE_DEFAULT, [
  50. 'api_general',
  51. 'api_layout'
  52. ]);
  53. $this->aPageCss = array_merge($this->aPageCss, $oOptions->getCss());
  54. $this->aPageJs = array_merge($this->aPageJs, $oOptions->getJs());
  55. return $oOptions->getCode();
  56. }
  57. protected function getApiConfig()
  58. {
  59. $oOptions = new BxTemplStudioOptionsApi(BX_DOL_STUDIO_STG_TYPE_DEFAULT, [
  60. 'api_config'
  61. ]);
  62. $this->aPageCss = array_merge($this->aPageCss, $oOptions->getCss());
  63. $this->aPageJs = array_merge($this->aPageJs, $oOptions->getJs());
  64. return [[
  65. 'caption' => '_adm_api_page_block_title_config_system',
  66. 'content' => $oOptions->getCode() . $this->getPageJsCode()
  67. ], [
  68. 'caption' => '_adm_api_page_block_title_config_modules',
  69. 'content' => $this->getGrid($this->aGridObjects['configs'])
  70. ]];
  71. }
  72. protected function getKeys()
  73. {
  74. return $this->getGrid($this->aGridObjects['keys']);
  75. }
  76. protected function getOrigins()
  77. {
  78. return $this->getGrid($this->aGridObjects['origins']);
  79. }
  80. protected function getGrid($sObjectName)
  81. {
  82. $oGrid = BxDolGrid::getObjectInstance($sObjectName);
  83. if(!$oGrid)
  84. return '';
  85. return $oGrid->getCode();
  86. }
  87. }
  88. /** @} */