BxBaseModGeneralGridAdministration.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 BaseGeneral Base classes for modules
  7. * @ingroup DolphinModules
  8. * @{
  9. */
  10. bx_import('BxDolModule');
  11. bx_import('BxTemplGrid');
  12. class BxBaseModGeneralGridAdministration extends BxTemplGrid
  13. {
  14. protected $MODULE;
  15. protected $_oModule;
  16. protected $_sManageType;
  17. protected $_sParamsDivider;
  18. public function __construct ($aOptions, $oTemplate = false)
  19. {
  20. parent::__construct ($aOptions, $oTemplate);
  21. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  22. $this->_sManageType = 'administration';
  23. $this->_sParamsDivider = '#-#';
  24. }
  25. public function _getFilterSelectOne($sFilterName, $aFilterValues)
  26. {
  27. if(empty($sFilterName) || empty($aFilterValues))
  28. return '';
  29. $sJsObject = $this->_oModule->_oConfig->getJsObject($this->_sManageType);
  30. $sFilterField = '_s' . str_replace(' ', '', ucwords(str_replace('_', ' ', $sFilterName)));
  31. foreach($aFilterValues as $sKey => $sValue)
  32. $aFilterValues[$sKey] = _t($sValue);
  33. $aInputModules = array(
  34. 'type' => 'select',
  35. 'name' => $sFilterName,
  36. 'attrs' => array(
  37. 'id' => 'bx-grid-' . $sFilterName . '-' . $this->_sObject,
  38. 'onChange' => 'javascript:' . $sJsObject . '.onChangeFilter(this)'
  39. ),
  40. 'value' => $this->$sFilterField,
  41. 'values' => array_merge(array('' => _t('_bx_persons_grid_filter_item_title_adm_select_one')), $aFilterValues)
  42. );
  43. bx_import('BxTemplFormView');
  44. $oForm = new BxTemplFormView(array());
  45. return $oForm->genRow($aInputModules);
  46. }
  47. protected function _getSearchInput()
  48. {
  49. $sJsObject = $this->_oModule->_oConfig->getJsObject($this->_sManageType);
  50. $aInputSearch = array(
  51. 'type' => 'text',
  52. 'name' => 'search',
  53. 'attrs' => array(
  54. 'id' => 'bx-grid-search-' . $this->_sObject,
  55. 'onKeyup' => 'javascript:$(this).off(\'keyup\'); ' . $sJsObject . '.onChangeFilter(this)'
  56. )
  57. );
  58. bx_import('BxTemplFormView');
  59. $oForm = new BxTemplFormView(array());
  60. return $oForm->genRow($aInputSearch);
  61. }
  62. }
  63. /** @} */