BxBaseStudioStorages.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 BxBaseStudioStorages extends BxDolStudioStorages
  11. {
  12. protected $aStorages;
  13. protected $sSubpageUrl;
  14. function __construct($sPage = '')
  15. {
  16. parent::__construct($sPage);
  17. $this->aStorages = [
  18. BX_DOL_STUDIO_STRG_TYPE_FILES => ['icon' => 'mi-stg-files.svg'],
  19. BX_DOL_STUDIO_STRG_TYPE_IMAGES => ['icon' => 'mi-stg-images.svg']
  20. ];
  21. $this->sSubpageUrl = BX_DOL_URL_STUDIO . 'storages.php?page=';
  22. }
  23. function getPageCss()
  24. {
  25. return array_merge(parent::getPageCss(), array());
  26. }
  27. function getPageJs()
  28. {
  29. return array_merge(parent::getPageJs(), array());
  30. }
  31. function getPageJsObject()
  32. {
  33. return '';
  34. }
  35. function getPageMenu($aMenu = [], $aMarkers = [])
  36. {
  37. $aMenu = [];
  38. foreach($this->aStorages as $sName => $aStorage)
  39. $aMenu[] = [
  40. 'name' => $sName,
  41. 'icon' => $aStorage['icon'],
  42. 'icon_bg' => true,
  43. 'link' => $this->sSubpageUrl . $sName,
  44. 'title' => _t('_adm_lmi_cpt_' . $sName),
  45. 'selected' => $sName == $this->sPage
  46. ];
  47. return parent::getPageMenu($aMenu);
  48. }
  49. protected function getFiles()
  50. {
  51. return $this->getGrid(BX_DOL_STUDIO_STRG_TYPE_FILES);
  52. }
  53. protected function getImages()
  54. {
  55. return $this->getGrid(BX_DOL_STUDIO_STRG_TYPE_IMAGES);
  56. }
  57. protected function getGrid($sName)
  58. {
  59. $oGrid = BxDolGrid::getObjectInstance('sys_studio_strg_' . $sName);
  60. if(!$oGrid)
  61. return '';
  62. return BxDolStudioTemplate::getInstance()->parseHtmlByName('storages.html', array(
  63. 'js_object' => $this->getPageJsObject(),
  64. 'content' => $oGrid->getCode()
  65. ));
  66. }
  67. }
  68. /** @} */