BxBaseModGeneralGrid.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 BaseGeneral Base classes for modules
  7. * @ingroup UnaModules
  8. * @{
  9. */
  10. class BxBaseModGeneralGrid extends BxTemplGrid
  11. {
  12. protected $MODULE;
  13. protected $_sModule;
  14. protected $_oModule;
  15. protected $_sParamsDivider;
  16. protected $_sJsObject;
  17. public function __construct ($aOptions, $oTemplate = false)
  18. {
  19. $this->MODULE = $this->MODULE ?: $this->_sModule;
  20. $this->_sModule = $this->_sModule ?: $this->MODULE;
  21. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  22. parent::__construct ($aOptions, $oTemplate ?: $this->_oModule->_oTemplate);
  23. $this->_sParamsDivider = '#-#';
  24. }
  25. protected function _getFilterSelectOne($sFilterName, $sFilterValue, $aFilterValues, $mixedAddSelectOne = true, $bAsArray = false)
  26. {
  27. $CNF = &$this->_oModule->_oConfig->CNF;
  28. if($mixedAddSelectOne === true && ($sKey = $CNF['T']['filter_item_select_one_' . $sFilterName] ?? ''))
  29. $mixedAddSelectOne = $sKey;
  30. return parent::_getFilterSelectOne($sFilterName, $sFilterValue, $aFilterValues, $mixedAddSelectOne, $bAsArray);
  31. }
  32. protected function _initFilter($iNumber, $aValues = [])
  33. {
  34. $sFfName = '_sFilter' . $iNumber . 'Name';
  35. $sFfValue = '_sFilter' . $iNumber . 'Value';
  36. if(!property_exists($this, $sFfName) || !property_exists($this, $sFfValue))
  37. return;
  38. $this->$sFfName = 'filter' . $iNumber;
  39. if(($sFfValues = '_aFilter' . $iNumber . 'Values') && property_exists($this, $sFfValues))
  40. $this->$sFfValues = $aValues ?: [];
  41. if(($sValue = bx_get($this->$sFfName)) !== false) {
  42. $this->$sFfValue = bx_process_input($sValue);
  43. $this->_aQueryAppend[$this->$sFfName] = $this->$sFfValue;
  44. }
  45. }
  46. protected function _parseFilterValue(&$sFilter)
  47. {
  48. $iFilterParts = substr_count($sFilter, $this->_sParamsDivider);
  49. if(!$iFilterParts)
  50. return;
  51. $aFilterParts = explode($this->_sParamsDivider, $sFilter);
  52. for($i = 1; $i <= $iFilterParts; $i++)
  53. if(($sField = '_sFilter' . $i . 'Value') && property_exists($this, $sField))
  54. $this->$sField = $aFilterParts[$i - 1];
  55. $sFilter = $aFilterParts[$iFilterParts];
  56. }
  57. }
  58. /** @} */