BxBaseStudioStorages.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 = array(
  18. BX_DOL_STUDIO_STRG_TYPE_FILES => array('icon' => 'far file'),
  19. BX_DOL_STUDIO_STRG_TYPE_IMAGES => array('icon' => 'far file-image')
  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 = array(), $aMarkers = array())
  36. {
  37. $aMenu = array();
  38. foreach($this->aStorages as $sName => $aStorage)
  39. $aMenu[] = array(
  40. 'name' => $sName,
  41. 'icon' => $aStorage['icon'],
  42. 'link' => $this->sSubpageUrl . $sName,
  43. 'title' => _t('_adm_lmi_cpt_' . $sName),
  44. 'selected' => $sName == $this->sPage
  45. );
  46. return parent::getPageMenu($aMenu);
  47. }
  48. function getPageCode($sPage = '', $bWrap = true)
  49. {
  50. $sResult = parent::getPageCode($sPage, $bWrap);
  51. if($sResult === false)
  52. return false;
  53. $sMethod = 'get' . ucfirst($this->sPage);
  54. if(!method_exists($this, $sMethod))
  55. return '';
  56. return $sResult . $this->$sMethod();
  57. }
  58. protected function getFiles()
  59. {
  60. return $this->getGrid(BX_DOL_STUDIO_STRG_TYPE_FILES);
  61. }
  62. protected function getImages()
  63. {
  64. return $this->getGrid(BX_DOL_STUDIO_STRG_TYPE_IMAGES);
  65. }
  66. protected function getGrid($sName)
  67. {
  68. $oGrid = BxDolGrid::getObjectInstance('sys_studio_strg_' . $sName);
  69. if(!$oGrid)
  70. return '';
  71. return BxDolStudioTemplate::getInstance()->parseHtmlByName('storages.html', array(
  72. 'js_object' => $this->getPageJsObject(),
  73. 'content' => $this->getBlockCode(array(
  74. 'items' => $oGrid->getCode()
  75. ))
  76. ));
  77. }
  78. }
  79. /** @} */