BxBaseAuditGrid.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. list($aCssCalendar, $aJsCalendar) = BxBaseFormView::getCssJsCalendar();
  19. $this->_oTemplate->addCss(array_merge($aCssCalendar, ['manage_tools.css']));
  20. $this->_oTemplate->addJs(array_merge($aJsCalendar, ['BxDolAuditManageTools.js', 'BxDolGrid.js']));
  21. $this->_oTemplate->addJsTranslation(['_sys_grid_search']);
  22. return $this->getJsCode() . parent::getCode($isDisplayHeader);
  23. }
  24. public function getJsCode()
  25. {
  26. $aParams = array(
  27. 'sObjName' => $this->sJsObject,
  28. 'aHtmlIds' => array(),
  29. 'oRequestParams' => array(),
  30. 'sObjNameGrid' => 'sys_audit_administration'
  31. );
  32. return BxDolTemplate::getInstance()->_wrapInTagJsCode("var " . $this->sJsObject . " = new BxDolAuditManageTools(" . json_encode($aParams) . ");");
  33. }
  34. protected function _getCellAdded($mixedValue, $sKey, $aField, $aRow)
  35. {
  36. return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
  37. }
  38. protected function _getCellAction ($mixedValue, $sKey, $aField, $aRow)
  39. {
  40. return parent::_getCellDefault(_t($aRow['action_lang_key'], $aRow['action_lang_key_params']), $sKey, $aField, $aRow);
  41. }
  42. protected function _getCellContentId ($mixedValue, $sKey, $aField, $aRow)
  43. {
  44. $mixedValue = '';
  45. if ($aRow['content_id'] > 0){
  46. $sLink = BxDolRequest::serviceExists($aRow['content_module'], 'get_link') ? BxDolService::call($aRow['content_module'], 'get_link', array($aRow['content_id'])) : '';
  47. $sTitle = BxDolRequest::serviceExists($aRow['content_module'], 'get_title') ? BxDolService::call($aRow['content_module'], 'get_title', array($aRow['content_id'])) : $aRow['content_title'];
  48. if ($sLink){
  49. $mixedValue = BxDolTemplate::getInstance()->parseLink($sLink, $sTitle);
  50. }
  51. else{
  52. $mixedValue = $sTitle;
  53. }
  54. }
  55. $sLinkExtras = '';
  56. $aExtras = unserialize($aRow['extras']);
  57. if (isset($aExtras['display_info'])){
  58. $sLinkExtras = $this->_oTemplate->parseLink('javascript:void(0)',' <i class="sys-icon info-circle"></i>' , array(
  59. 'title' => '',
  60. 'bx_grid_action_single' => 'show_stat',
  61. 'bx_grid_action_data' => $aRow['extras']
  62. ));
  63. }
  64. return parent::_getCellDefault($mixedValue . $sLinkExtras, $sKey, $aField, $aRow);
  65. }
  66. protected function _getCellContextProfileId ($mixedValue, $sKey, $aField, $aRow)
  67. {
  68. if ($aRow['context_profile_id'] > 0){
  69. $oProfile = BxDolProfile::getInstance($aRow['context_profile_id']);
  70. if ($oProfile){
  71. $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName());
  72. }
  73. else{
  74. $mixedValue = $aRow['context_profile_title'];
  75. }
  76. }
  77. else{
  78. $mixedValue = '';
  79. }
  80. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  81. }
  82. protected function _getCellContentModule ($mixedValue, $sKey, $aField, $aRow)
  83. {
  84. $oModule = bxDolModule::getInstance($aRow['content_module']);
  85. if($oModule && $oModule instanceof iBxDolContentInfoService){
  86. $mixedValue = $oModule->_aModule['title'];
  87. }
  88. else{
  89. $mixedValue = $aRow['content_module'];
  90. }
  91. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  92. }
  93. protected function _getCellProfileId ($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. protected function _getCellAuthorId ($mixedValue, $sKey, $aField, $aRow)
  110. {
  111. if ($aRow['profile_id'] > 0){
  112. $oProfile = BxDolProfile::getInstance($aRow['profile_id']);
  113. if ($oProfile){
  114. $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName());
  115. }
  116. else{
  117. $mixedValue = $aRow['profile_title'];
  118. }
  119. }
  120. else{
  121. $mixedValue = '';
  122. }
  123. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  124. }
  125. function _getFilterControls()
  126. {
  127. parent::_getFilterControls();
  128. return $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values) .
  129. $this->_getFilterSelectOne($this->_sFilterProfileName, $this->_sFilterProfileValue, $this->_aFilterProfileValues) .
  130. $this->_getFilterSelectOne($this->_sFilterActionName, $this->_sFilterActionValue, $this->_aFilterActionValues) .
  131. $this->_getFilterDatePicker($this->_sFilterFromDateName, $this->_sFilterFromDateValue) .
  132. $this->_getFilterLabel('-') .
  133. $this->_getFilterDatePicker($this->_sFilterToDateName, $this->_sFilterToDateValue) .
  134. $this->_getFilterButton();
  135. }
  136. protected function _getFilterSelectOne($sFilterName, $sFilterValue, $aFilterValues)
  137. {
  138. if(empty($sFilterName) || empty($aFilterValues))
  139. return '';
  140. foreach($aFilterValues as $sKey => $sValue)
  141. $aFilterValues[$sKey] = _t($sValue);
  142. $aInputModules = array(
  143. 'type' => 'select',
  144. 'name' => $sFilterName,
  145. 'attrs' => array(
  146. 'id' => 'bx-grid-' . $sFilterName . '-' . $this->_sObject,
  147. // 'onChange' => 'javascript:' . $this->sJsObject . '.onChangeFilter(this)'
  148. ),
  149. 'value' => $sFilterValue,
  150. 'values' => $aFilterValues
  151. );
  152. $oForm = new BxTemplFormView(array());
  153. return $oForm->genRow($aInputModules);
  154. }
  155. protected function _getFilterLabel($sFilterValue)
  156. {
  157. $aInputModules = array(
  158. 'type' => 'value',
  159. 'value' => $sFilterValue,
  160. 'tr_attrs' => array('class' => 'bx-grid-controls-filter-label'),
  161. );
  162. $oForm = new BxTemplFormView(array());
  163. return $oForm->genRow($aInputModules, true);
  164. }
  165. protected function _getFilterDatePicker($sFilterName, $sFilterValue)
  166. {
  167. if(empty($sFilterName))
  168. return '';
  169. $aInputModules = array(
  170. 'type' => 'datepicker',
  171. 'name' => $sFilterName,
  172. 'attrs' => array(
  173. 'id' => 'bx-grid-' . $sFilterName . '-' . $this->_sObject,
  174. ),
  175. 'tr_attrs' => array('class' => 'bx-grid-controls-filter-datepicker'),
  176. 'value' => $sFilterValue,
  177. );
  178. $oForm = new BxTemplFormView(array());
  179. return $oForm->genRow($aInputModules, true);
  180. }
  181. protected function _getFilterButton()
  182. {
  183. $aInputModules = array(
  184. 'type' => 'button',
  185. 'name' => 'button',
  186. 'attrs' => array(
  187. 'id' => 'bx-grid-button-' . $this->_sObject,
  188. 'onClick' => 'javascript:' . $this->sJsObject . '.onChangeFilter(this)',
  189. ),
  190. 'tr_attrs' => array('class' => 'bx-grid-controls-filter-button'),
  191. 'value' => _t('_Search'),
  192. );
  193. $oForm = new BxTemplFormView(array());
  194. return $oForm->genRow($aInputModules, true);
  195. }
  196. public function performActionShowStat()
  197. {
  198. $aTmp2 = bx_get('ids');
  199. $sData = $aTmp2[0];
  200. $aData = unserialize($sData);
  201. $sContentInfo = '';
  202. if (isset($aData['display_info'])){
  203. foreach($aData['display_info'] as $sKey => $sValue)
  204. $sContentInfo .= $sKey . ': ' . $sValue;
  205. }
  206. $sContent = BxTemplStudioFunctions::getInstance()->popupBox('sys-audit-content-info', _t('_sys_audit_content_info_popup_title'), $sContentInfo);
  207. echoJson(array('popup' => $sContent));
  208. }
  209. }
  210. /** @} */