BxBaseAuditGrid.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 _getCellContent ($mixedValue, $sKey, $aField, $aRow)
  39. {
  40. $mixedValue = '';
  41. if ($aRow['content_id'] > 0 && $aRow['content_info_object'] != ''){
  42. $oContentInfo = BxDolContentInfo::getObjectInstance($aRow['content_info_object']);
  43. if ($oContentInfo){
  44. $sTitle = bx_process_output($oContentInfo->getContentTitle($aRow['content_id']));
  45. if ($sTitle != ''){
  46. $mixedValue = $this->_oTemplate->parseHtmlByName('account_link.html', array(
  47. 'href' => $oContentInfo->getContentLink($aRow['content_id']),
  48. 'title' => $sTitle,
  49. 'content' => $sTitle,
  50. 'class' => 'bx-def-font-grayed'
  51. ));
  52. }
  53. }
  54. }
  55. if ($mixedValue == ''){
  56. $mixedValue = bx_process_output($aRow['content_title']);
  57. }
  58. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  59. }
  60. protected function _getCellContext ($mixedValue, $sKey, $aField, $aRow)
  61. {
  62. if ($aRow['context_profile_id'] > 0){
  63. $oProfile = BxDolProfile::getInstance($aRow['context_profile_id']);
  64. if ($oProfile){
  65. $sProfile = $oProfile->getDisplayName();
  66. $mixedValue = $this->_oTemplate->parseHtmlByName('account_link.html', array(
  67. 'href' => $oProfile->getUrl(),
  68. 'title' => $sProfile,
  69. 'content' => $sProfile,
  70. 'class' => 'bx-def-font-grayed'
  71. ));
  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 _getCellModule ($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 _getCellProfile ($mixedValue, $sKey, $aField, $aRow)
  94. {
  95. if ($aRow['profile_id'] > 0){
  96. $oProfile = BxDolProfile::getInstance($aRow['profile_id']);
  97. if ($oProfile){
  98. $sProfile = $oProfile->getDisplayName();
  99. $mixedValue = $this->_oTemplate->parseHtmlByName('account_link.html', array(
  100. 'href' => $oProfile->getUrl(),
  101. 'title' => $sProfile,
  102. 'content' => $sProfile,
  103. 'class' => 'bx-def-font-grayed'
  104. ));
  105. }
  106. else{
  107. $mixedValue = $aRow['profile_title'];
  108. }
  109. }
  110. else{
  111. $mixedValue = '';
  112. }
  113. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  114. }
  115. function _getFilterControls()
  116. {
  117. parent::_getFilterControls();
  118. return $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values);
  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. }
  140. /** @} */