BxBaseStudioStorages.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup TridentView Trident Studio Representation classes
  7. * @ingroup TridentStudio
  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' => 'file-o'),
  19. BX_DOL_STUDIO_STRG_TYPE_IMAGES => array('icon' => 'file-image-o')
  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($bHidden = false)
  49. {
  50. $sMethod = 'get' . ucfirst($this->sPage);
  51. if(!method_exists($this, $sMethod))
  52. return '';
  53. return $this->$sMethod();
  54. }
  55. protected function getFiles()
  56. {
  57. return $this->getGrid(BX_DOL_STUDIO_STRG_TYPE_FILES);
  58. }
  59. protected function getImages()
  60. {
  61. return $this->getGrid(BX_DOL_STUDIO_STRG_TYPE_IMAGES);
  62. }
  63. protected function getGrid($sName)
  64. {
  65. $oGrid = BxDolGrid::getObjectInstance('sys_studio_strg_' . $sName);
  66. if(!$oGrid)
  67. return '';
  68. return BxDolStudioTemplate::getInstance()->parseHtmlByName('storages.html', array(
  69. 'js_object' => $this->getPageJsObject(),
  70. 'content' => $this->getBlockCode(array(
  71. 'items' => $oGrid->getCode()
  72. ))
  73. ));
  74. }
  75. }
  76. /** @} */