BxBaseStudioGrid.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  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 DolphinView Dolphin Studio Representation classes
  7. * @ingroup DolphinStudio
  8. * @{
  9. */
  10. defined('BX_DOL') or die('hack attempt');
  11. bx_import('BxDolStudioGrid');
  12. class BxBaseStudioGrid extends BxDolStudioGrid {
  13. function __construct($aOptions, $oTemplate = false) {
  14. parent::__construct($aOptions, $oTemplate);
  15. }
  16. function getJsObject() {
  17. return '';
  18. }
  19. public function getModulesSelectOne($sGetItemsMethod, $bShowCustom = true, $bShowSystem = true)
  20. {
  21. if(empty($sGetItemsMethod))
  22. return '';
  23. bx_import('BxTemplStudioFormView');
  24. $oForm = new BxTemplStudioFormView(array());
  25. $aInputModules = array(
  26. 'type' => 'select',
  27. 'name' => 'module',
  28. 'attrs' => array(
  29. 'id' => 'bx-grid-module-' . $this->_sObject,
  30. 'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeModule()'
  31. ),
  32. 'value' => $this->sModule,
  33. 'values' => $this->getModules($bShowCustom, $bShowSystem)
  34. );
  35. $aCounter = array();
  36. $this->oDb->$sGetItemsMethod(array('type' => 'counter_by_modules'), $aCounter, false);
  37. foreach($aInputModules['values'] as $sKey => $sValue)
  38. $aInputModules['values'][$sKey] = $aInputModules['values'][$sKey] . " (" . (isset($aCounter[$sKey]) ? $aCounter[$sKey] : "0") . ")";
  39. $aInputModules['values'] = array_merge(array('' => _t('_adm_txt_select_module')), $aInputModules['values']);
  40. return $oForm->genRow($aInputModules);
  41. }
  42. protected function _getItem($sDbMethod = '')
  43. {
  44. $aIds = bx_get('ids');
  45. if(!$aIds || !is_array($aIds)) {
  46. $iId = (int)bx_get('id');
  47. if(!$iId)
  48. return false;
  49. $aIds = array($iId);
  50. }
  51. $iId = $aIds[0];
  52. $aItem = array();
  53. $this->oDb->$sDbMethod(array('type' => 'by_id', 'value' => $iId), $aItem, false);
  54. if(!is_array($aItem) || empty($aItem))
  55. return false;
  56. return $aItem;
  57. }
  58. }
  59. /** @} */