BxBaseModGeneralGridAdministration.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. protected function _getActionSettings($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  26. {
  27. $sJsObject = $this->_oModule->_oConfig->getJsObject('manage_tools');
  28. $sMenuName = $this->_oModule->_oConfig->CNF['OBJECT_MENU_MANAGE_TOOLS'];
  29. bx_import('BxDolMenu');
  30. $sMenu = BxDolMenu::getObjectInstance($sMenuName)->getCode();
  31. if(empty($sMenu))
  32. return '';
  33. $a['attr'] = array_merge($a['attr'], array(
  34. "bx-popup-id" => $sMenuName . "-" . $aRow['id'],
  35. "onclick" => "$(this).off('click'); " . $sJsObject . ".onClickSettings('" . $sMenuName . "', this);"
  36. ));
  37. return $this->_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  38. }
  39. protected function _getFilterSelectOne($sFilterName, $aFilterValues)
  40. {
  41. if(empty($sFilterName) || empty($aFilterValues))
  42. return '';
  43. $sJsObject = $this->_oModule->_oConfig->getJsObject('manage_tools');
  44. $sPrefixLang = $this->_oModule->_oConfig->getPrefix('lang');
  45. $sFilterField = '_s' . str_replace(' ', '', ucwords(str_replace('_', ' ', $sFilterName)));
  46. foreach($aFilterValues as $sKey => $sValue)
  47. $aFilterValues[$sKey] = _t($sValue);
  48. $aInputModules = array(
  49. 'type' => 'select',
  50. 'name' => $sFilterName,
  51. 'attrs' => array(
  52. 'id' => 'bx-grid-' . $sFilterName . '-' . $this->_sObject,
  53. 'onChange' => 'javascript:' . $sJsObject . '.onChangeFilter(this)'
  54. ),
  55. 'value' => $this->$sFilterField,
  56. 'values' => array_merge(array('' => _t($sPrefixLang . '_grid_filter_item_title_adm_select_one')), $aFilterValues)
  57. );
  58. bx_import('BxTemplFormView');
  59. $oForm = new BxTemplFormView(array());
  60. return $oForm->genRow($aInputModules);
  61. }
  62. protected function _getSearchInput()
  63. {
  64. $sJsObject = $this->_oModule->_oConfig->getJsObject('manage_tools');
  65. $aInputSearch = array(
  66. 'type' => 'text',
  67. 'name' => 'search',
  68. 'attrs' => array(
  69. 'id' => 'bx-grid-search-' . $this->_sObject,
  70. 'onKeyup' => 'javascript:$(this).off(\'keyup\'); ' . $sJsObject . '.onChangeFilter(this)'
  71. )
  72. );
  73. bx_import('BxTemplFormView');
  74. $oForm = new BxTemplFormView(array());
  75. return $oForm->genRow($aInputSearch);
  76. }
  77. }
  78. /** @} */