BxBaseStudioGrid.php 2.2 KB

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