1
0

BxBaseAuditGrid.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. class BxBaseAuditGrid extends BxDolAuditGrid
  10. {
  11. protected $sJsObject = 'oBxDolAuditManageTools';
  12. public function __construct($aInfo, $oTemplate = false)
  13. {
  14. parent::__construct($aInfo, $oTemplate);
  15. }
  16. public function getCode($isDisplayHeader = true)
  17. {
  18. return $this->getJsCode() . parent::getCode($isDisplayHeader);
  19. }
  20. public function getJsCode()
  21. {
  22. $aParams = array(
  23. 'sObjName' => $this->sJsObject,
  24. 'aHtmlIds' => array(),
  25. 'oRequestParams' => array(),
  26. 'sObjNameGrid' => 'sys_audit_administration'
  27. );
  28. return BxDolTemplate::getInstance()->_wrapInTagJsCode("var " . $this->sJsObject . " = new BxDolAuditManageTools(" . json_encode($aParams) . ");");
  29. }
  30. protected function _getCellAdded($mixedValue, $sKey, $aField, $aRow)
  31. {
  32. return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
  33. }
  34. protected function _getCellAction ($mixedValue, $sKey, $aField, $aRow)
  35. {
  36. return parent::_getCellDefault(_t($aRow['action_lang_key'], $aRow['action_lang_key_params']), $sKey, $aField, $aRow);
  37. }
  38. protected function _getCellContentId ($mixedValue, $sKey, $aField, $aRow)
  39. {
  40. $mixedValue = '';
  41. if ($aRow['content_id'] > 0){
  42. $iAuthorProfileId = BxDolRequest::serviceExists($aRow['content_module'], 'get_author') ? BxDolService::call($aRow['content_module'], 'get_author', array($aRow['content_id'])) : '';
  43. $oProfile = BxDolProfile::getInstance($iAuthorProfileId);
  44. if ($oProfile){
  45. $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName());
  46. }
  47. }
  48. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  49. }
  50. protected function _getCellContextProfileId ($mixedValue, $sKey, $aField, $aRow)
  51. {
  52. if ($aRow['context_profile_id'] > 0){
  53. $oProfile = BxDolProfile::getInstance($aRow['context_profile_id']);
  54. if ($oProfile){
  55. $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName());
  56. }
  57. else{
  58. $mixedValue = $aRow['context_profile_title'];
  59. }
  60. }
  61. else{
  62. $mixedValue = '';
  63. }
  64. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  65. }
  66. protected function _getCellContentModule ($mixedValue, $sKey, $aField, $aRow)
  67. {
  68. $oModule = bxDolModule::getInstance($aRow['content_module']);
  69. if($oModule && $oModule instanceof iBxDolContentInfoService){
  70. $mixedValue = $oModule->_aModule['title'];
  71. }
  72. else{
  73. $mixedValue = $aRow['content_module'];
  74. }
  75. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  76. }
  77. protected function _getCellProfileId ($mixedValue, $sKey, $aField, $aRow)
  78. {
  79. if ($aRow['profile_id'] > 0){
  80. $oProfile = BxDolProfile::getInstance($aRow['profile_id']);
  81. if ($oProfile){
  82. $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName());
  83. }
  84. else{
  85. $mixedValue = $aRow['profile_title'];
  86. }
  87. }
  88. else{
  89. $mixedValue = '';
  90. }
  91. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  92. }
  93. protected function _getCellAuthorId ($mixedValue, $sKey, $aField, $aRow)
  94. {
  95. if ($aRow['profile_id'] > 0){
  96. $oProfile = BxDolProfile::getInstance($aRow['profile_id']);
  97. if ($oProfile){
  98. $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName());
  99. }
  100. else{
  101. $mixedValue = $aRow['profile_title'];
  102. }
  103. }
  104. else{
  105. $mixedValue = '';
  106. }
  107. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  108. }
  109. function _getFilterControls()
  110. {
  111. parent::_getFilterControls();
  112. return $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values) .
  113. $this->_getFilterSelectOne($this->_sFilterProfileName, $this->_sFilterProfileValue, $this->_aFilterProfileValues) .
  114. $this->_getFilterSelectOne($this->_sFilterActionName, $this->_sFilterActionValue, $this->_aFilterActionValues) .
  115. $this->_getFilterDatePicker($this->_sFilterFromDateName, $this->_sFilterFromDateValue) .
  116. $this->_getFilterLabel('-') .
  117. $this->_getFilterDatePicker($this->_sFilterToDateName, $this->_sFilterToDateValue) .
  118. $this->_getFilterButton();
  119. }
  120. protected function _getFilterSelectOne($sFilterName, $sFilterValue, $aFilterValues)
  121. {
  122. if(empty($sFilterName) || empty($aFilterValues))
  123. return '';
  124. foreach($aFilterValues as $sKey => $sValue)
  125. $aFilterValues[$sKey] = _t($sValue);
  126. $aInputModules = array(
  127. 'type' => 'select',
  128. 'name' => $sFilterName,
  129. 'attrs' => array(
  130. 'id' => 'bx-grid-' . $sFilterName . '-' . $this->_sObject,
  131. // 'onChange' => 'javascript:' . $this->sJsObject . '.onChangeFilter(this)'
  132. ),
  133. 'value' => $sFilterValue,
  134. 'values' => $aFilterValues
  135. );
  136. $oForm = new BxTemplFormView(array());
  137. return $oForm->genRow($aInputModules);
  138. }
  139. protected function _getFilterLabel($sFilterValue)
  140. {
  141. $aInputModules = array(
  142. 'type' => 'value',
  143. 'value' => $sFilterValue,
  144. 'tr_attrs' => array('class' => 'bx-grid-controls-filter-label'),
  145. );
  146. $oForm = new BxTemplFormView(array());
  147. return $oForm->genRow($aInputModules, true);
  148. }
  149. protected function _getFilterDatePicker($sFilterName, $sFilterValue)
  150. {
  151. if(empty($sFilterName))
  152. return '';
  153. $aInputModules = array(
  154. 'type' => 'datepicker',
  155. 'name' => $sFilterName,
  156. 'attrs' => array(
  157. 'id' => 'bx-grid-' . $sFilterName . '-' . $this->_sObject,
  158. ),
  159. 'tr_attrs' => array('class' => 'bx-grid-controls-filter-datepicker'),
  160. 'value' => $sFilterValue,
  161. );
  162. $oForm = new BxTemplFormView(array());
  163. return $oForm->genRow($aInputModules, true);
  164. }
  165. protected function _getFilterButton()
  166. {
  167. $aInputModules = array(
  168. 'type' => 'button',
  169. 'name' => 'button',
  170. 'attrs' => array(
  171. 'id' => 'bx-grid-button-' . $this->_sObject,
  172. 'onClick' => 'javascript:' . $this->sJsObject . '.onChangeFilter(this)',
  173. ),
  174. 'tr_attrs' => array('class' => 'bx-grid-controls-filter-button'),
  175. 'value' => _t('_Search'),
  176. );
  177. $oForm = new BxTemplFormView(array());
  178. return $oForm->genRow($aInputModules, true);
  179. }
  180. }
  181. /** @} */