BxBaseStudioFormsSearchSortableFields.php 4.2 KB

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