1
0

BxBaseStudioFormsSearchFormFields.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 UnaView UNA Studio Representation classes
  7. * @ingroup UnaStudio
  8. * @{
  9. */
  10. class BxBaseStudioFormsSearchFormFields extends BxDolStudioFormsSearchFields
  11. {
  12. protected $sUrlPage;
  13. public function __construct($aOptions, $oTemplate = false)
  14. {
  15. parent::__construct($aOptions, $oTemplate);
  16. $this->sUrlPage = BX_DOL_URL_STUDIO . 'builder_forms.php?page=';
  17. }
  18. function getJsObject()
  19. {
  20. return 'oBxDolStudioFormsSearchFields';
  21. }
  22. function getFormsSelector($sModule = '')
  23. {
  24. $oForm = new BxTemplStudioFormView(array());
  25. $aInputForms = array(
  26. 'type' => 'select',
  27. 'name' => 'form',
  28. 'attrs' => array(
  29. 'id' => 'bx-grid-form-' . $this->_sObject,
  30. 'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeForm()'
  31. ),
  32. 'value' => $this->sForm,
  33. 'values' => array(
  34. '' => _t('_adm_form_txt_search_forms_fields_select_object'),
  35. )
  36. );
  37. if(!empty($sModule)) {
  38. $aForms = array();
  39. $this->oDb->getSearchForms(array('type' => 'by_module', 'module' => $sModule), $aForms, false);
  40. foreach($aForms as $aForm)
  41. $aInputForms['values'][] = array(
  42. 'key' => $aForm['object'],
  43. 'value' => _t($aForm['title'])
  44. );
  45. }
  46. else
  47. $aInputForms['attrs']['disabled'] = 'disabled';
  48. return $oForm->genRow($aInputForms);
  49. }
  50. public function getCode($isDisplayHeader = true)
  51. {
  52. return $this->_oTemplate->parseHtmlByName('forms_search_fields.html', array(
  53. 'content' => parent::getCode($isDisplayHeader),
  54. 'js_object' => $this->getJsObject(),
  55. 'page_url' => $this->sUrlPage,
  56. 'grid_object' => $this->_sObject,
  57. 'params_divider' => $this->sParamsDivider
  58. ));
  59. }
  60. protected function _addJsCss()
  61. {
  62. parent::_addJsCss();
  63. $this->_oTemplate->addCss(['menu.css']);
  64. $this->_oTemplate->addJs(['jquery.form.min.js']);
  65. $oForm = new BxTemplStudioFormView([]);
  66. $oForm->addCssJs();
  67. }
  68. protected function _getCellSwitcher ($mixedValue, $sKey, $aField, $aRow)
  69. {
  70. if(!$this->_isEditable($aRow))
  71. return parent::_getCellDefault('', $sKey, $aField, $aRow);
  72. return parent::_getCellSwitcher($mixedValue, $sKey, $aField, $aRow);
  73. }
  74. protected function _getActionReset ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  75. {
  76. if(!$this->_isResetable($aRow))
  77. return '';
  78. if($this->sForm == '')
  79. $isDisabled = true;
  80. return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
  81. }
  82. protected function _getFilterControls ()
  83. {
  84. parent::_getFilterControls();
  85. $sContent = $this->getModulesSelectOne('getSearchForms') . $this->getFormsSelector($this->sModule);
  86. $oForm = new BxTemplStudioFormView(array());
  87. $aInputSearch = array(
  88. 'type' => 'text',
  89. 'name' => 'keyword',
  90. 'attrs' => array(
  91. 'id' => 'bx-grid-search-' . $this->_sObject,
  92. ),
  93. 'tr_attrs' => array(
  94. 'style' => empty($this->sModule) || empty($this->sForm) ? 'display:none;' : ''
  95. )
  96. );
  97. $sContent .= $oForm->genRow($aInputSearch);
  98. return $sContent;
  99. }
  100. protected function _isEditable(&$aRow)
  101. {
  102. return true;
  103. }
  104. protected function _isResetable(&$aRow)
  105. {
  106. return true;
  107. }
  108. }
  109. /** @} */