BxBaseAuditGrid.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. $sLink = BxDolRequest::serviceExists($aRow['content_module'], 'get_link') ? BxDolService::call($aRow['content_module'], 'get_link', array($aRow['content_id'])) : '';
  43. $sTitle = BxDolRequest::serviceExists($aRow['content_module'], 'get_title') ? BxDolService::call($aRow['content_module'], 'get_title', array($aRow['content_id'])) : $aRow['content_title'];
  44. if ($sLink){
  45. $mixedValue = BxDolTemplate::getInstance()->parseLink($sLink, $sTitle);
  46. }
  47. else{
  48. $mixedValue = $sTitle;
  49. }
  50. }
  51. $sLinkExtras = '';
  52. $aExtras = unserialize($aRow['extras']);
  53. if (isset($aExtras['display_info'])){
  54. $sLinkExtras = $this->_oTemplate->parseLink('javascript:void(0)',' <i class="sys-icon info-circle"></i>' , array(
  55. 'title' => '',
  56. 'bx_grid_action_single' => 'show_stat',
  57. 'bx_grid_action_data' => $aRow['extras']
  58. ));
  59. }
  60. return parent::_getCellDefault($mixedValue . $sLinkExtras, $sKey, $aField, $aRow);
  61. }
  62. protected function _getCellContextProfileId ($mixedValue, $sKey, $aField, $aRow)
  63. {
  64. if ($aRow['context_profile_id'] > 0){
  65. $oProfile = BxDolProfile::getInstance($aRow['context_profile_id']);
  66. if ($oProfile){
  67. $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName());
  68. }
  69. else{
  70. $mixedValue = $aRow['context_profile_title'];
  71. }
  72. }
  73. else{
  74. $mixedValue = '';
  75. }
  76. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  77. }
  78. protected function _getCellContentModule ($mixedValue, $sKey, $aField, $aRow)
  79. {
  80. $oModule = bxDolModule::getInstance($aRow['content_module']);
  81. if($oModule && $oModule instanceof iBxDolContentInfoService){
  82. $mixedValue = $oModule->_aModule['title'];
  83. }
  84. else{
  85. $mixedValue = $aRow['content_module'];
  86. }
  87. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  88. }
  89. protected function _getCellProfileId ($mixedValue, $sKey, $aField, $aRow)
  90. {
  91. if ($aRow['profile_id'] > 0){
  92. $oProfile = BxDolProfile::getInstance($aRow['profile_id']);
  93. if ($oProfile){
  94. $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName());
  95. }
  96. else{
  97. $mixedValue = $aRow['profile_title'];
  98. }
  99. }
  100. else{
  101. $mixedValue = '';
  102. }
  103. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  104. }
  105. protected function _getCellAuthorId ($mixedValue, $sKey, $aField, $aRow)
  106. {
  107. if ($aRow['profile_id'] > 0){
  108. $oProfile = BxDolProfile::getInstance($aRow['profile_id']);
  109. if ($oProfile){
  110. $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName());
  111. }
  112. else{
  113. $mixedValue = $aRow['profile_title'];
  114. }
  115. }
  116. else{
  117. $mixedValue = '';
  118. }
  119. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  120. }
  121. function _getFilterControls()
  122. {
  123. parent::_getFilterControls();
  124. return $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values) .
  125. $this->_getFilterSelectOne($this->_sFilterProfileName, $this->_sFilterProfileValue, $this->_aFilterProfileValues) .
  126. $this->_getFilterSelectOne($this->_sFilterActionName, $this->_sFilterActionValue, $this->_aFilterActionValues) .
  127. $this->_getFilterDatePicker($this->_sFilterFromDateName, $this->_sFilterFromDateValue) .
  128. $this->_getFilterLabel('-') .
  129. $this->_getFilterDatePicker($this->_sFilterToDateName, $this->_sFilterToDateValue) .
  130. $this->_getFilterButton();
  131. }
  132. protected function _getFilterSelectOne($sFilterName, $sFilterValue, $aFilterValues)
  133. {
  134. if(empty($sFilterName) || empty($aFilterValues))
  135. return '';
  136. foreach($aFilterValues as $sKey => $sValue)
  137. $aFilterValues[$sKey] = _t($sValue);
  138. $aInputModules = array(
  139. 'type' => 'select',
  140. 'name' => $sFilterName,
  141. 'attrs' => array(
  142. 'id' => 'bx-grid-' . $sFilterName . '-' . $this->_sObject,
  143. // 'onChange' => 'javascript:' . $this->sJsObject . '.onChangeFilter(this)'
  144. ),
  145. 'value' => $sFilterValue,
  146. 'values' => $aFilterValues
  147. );
  148. $oForm = new BxTemplFormView(array());
  149. return $oForm->genRow($aInputModules);
  150. }
  151. protected function _getFilterLabel($sFilterValue)
  152. {
  153. $aInputModules = array(
  154. 'type' => 'value',
  155. 'value' => $sFilterValue,
  156. 'tr_attrs' => array('class' => 'bx-grid-controls-filter-label'),
  157. );
  158. $oForm = new BxTemplFormView(array());
  159. return $oForm->genRow($aInputModules, true);
  160. }
  161. protected function _getFilterDatePicker($sFilterName, $sFilterValue)
  162. {
  163. if(empty($sFilterName))
  164. return '';
  165. $aInputModules = array(
  166. 'type' => 'datepicker',
  167. 'name' => $sFilterName,
  168. 'attrs' => array(
  169. 'id' => 'bx-grid-' . $sFilterName . '-' . $this->_sObject,
  170. ),
  171. 'tr_attrs' => array('class' => 'bx-grid-controls-filter-datepicker'),
  172. 'value' => $sFilterValue,
  173. );
  174. $oForm = new BxTemplFormView(array());
  175. return $oForm->genRow($aInputModules, true);
  176. }
  177. protected function _getFilterButton()
  178. {
  179. $aInputModules = array(
  180. 'type' => 'button',
  181. 'name' => 'button',
  182. 'attrs' => array(
  183. 'id' => 'bx-grid-button-' . $this->_sObject,
  184. 'onClick' => 'javascript:' . $this->sJsObject . '.onChangeFilter(this)',
  185. ),
  186. 'tr_attrs' => array('class' => 'bx-grid-controls-filter-button'),
  187. 'value' => _t('_Search'),
  188. );
  189. $oForm = new BxTemplFormView(array());
  190. return $oForm->genRow($aInputModules, true);
  191. }
  192. public function performActionShowStat()
  193. {
  194. $aTmp2 = bx_get('ids');
  195. $sData = $aTmp2[0];
  196. $aData = unserialize($sData);
  197. $sContentInfo = '';
  198. if (isset($aData['display_info'])){
  199. foreach($aData['display_info'] as $sKey => $sValue)
  200. $sContentInfo .= $sKey . ': ' . $sValue;
  201. }
  202. $sContent = BxTemplStudioFunctions::getInstance()->popupBox('sys-audit-content-info', _t('_sys_audit_content_info_popup_title'), $sContentInfo);
  203. echoJson(array('popup' => $sContent));
  204. }
  205. }
  206. /** @} */