BxBaseStudioAuditGrid.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 BxBaseStudioAuditGrid extends BxDolStudioAuditGrid
  11. {
  12. function __construct($aOptions, $oTemplate = false)
  13. {
  14. parent::__construct($aOptions, $oTemplate);
  15. }
  16. protected function _addJsCss()
  17. {
  18. parent::_addJsCss();
  19. $this->_oTemplate->addJs(array('jquery.form.min.js', 'forms_audit.js'));
  20. $oForm = new BxTemplStudioFormView(array());
  21. $oForm->addCssJs();
  22. }
  23. protected function _getCellAdded($mixedValue, $sKey, $aField, $aRow)
  24. {
  25. return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
  26. }
  27. protected function _getCellAction ($mixedValue, $sKey, $aField, $aRow)
  28. {
  29. return parent::_getCellDefault(_t($aRow['action_lang_key'], $aRow['action_lang_key_params']), $sKey, $aField, $aRow);
  30. }
  31. protected function _getCellContent ($mixedValue, $sKey, $aField, $aRow)
  32. {
  33. $mixedValue = '';
  34. if ($aRow['content_id'] > 0 && $aRow['content_info_object'] != ''){
  35. $oContentInfo = BxDolContentInfo::getObjectInstance($aRow['content_info_object']);
  36. if ($oContentInfo){
  37. $sTitle = bx_process_output($oContentInfo->getContentTitle($aRow['content_id']));
  38. if ($sTitle != ''){
  39. $mixedValue = $this->_oTemplate->parseHtmlByName('account_link.html', array(
  40. 'href' => $oContentInfo->getContentLink($aRow['content_id']),
  41. 'title' => $sTitle,
  42. 'content' => $sTitle,
  43. 'class' => 'bx-def-font-grayed'
  44. ));
  45. }
  46. }
  47. }
  48. if ($mixedValue == ''){
  49. $mixedValue = bx_process_output($aRow['content_title']);
  50. }
  51. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  52. }
  53. protected function _getCellContext ($mixedValue, $sKey, $aField, $aRow)
  54. {
  55. if ($aRow['context_profile_id'] > 0){
  56. $oProfile = BxDolProfile::getInstance($aRow['context_profile_id']);
  57. if ($oProfile){
  58. $sProfile = $oProfile->getDisplayName();
  59. $mixedValue = $this->_oTemplate->parseHtmlByName('account_link.html', array(
  60. 'href' => $oProfile->getUrl(),
  61. 'title' => $sProfile,
  62. 'content' => $sProfile,
  63. 'class' => 'bx-def-font-grayed'
  64. ));
  65. }
  66. else{
  67. $mixedValue = $aRow['context_profile_title'];
  68. }
  69. }
  70. else{
  71. $mixedValue = '';
  72. }
  73. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  74. }
  75. protected function _getCellModule ($mixedValue, $sKey, $aField, $aRow)
  76. {
  77. $oModule = bxDolModule::getInstance($aRow['content_module']);
  78. if($oModule && $oModule instanceof iBxDolContentInfoService){
  79. $mixedValue = $oModule->_aModule['title'];
  80. }
  81. else{
  82. $mixedValue = $aRow['content_module'];
  83. }
  84. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  85. }
  86. protected function _getCellProfile ($mixedValue, $sKey, $aField, $aRow)
  87. {
  88. if ($aRow['profile_id'] > 0){
  89. $oProfile = BxDolProfile::getInstance($aRow['profile_id']);
  90. if ($oProfile){
  91. $sProfile = $oProfile->getDisplayName();
  92. $mixedValue = $this->_oTemplate->parseHtmlByName('account_link.html', array(
  93. 'href' => $oProfile->getUrl(),
  94. 'title' => $sProfile,
  95. 'content' => $sProfile,
  96. 'class' => 'bx-def-font-grayed'
  97. ));
  98. }
  99. else{
  100. $mixedValue = $aRow['profile_title'];
  101. }
  102. }
  103. else{
  104. $mixedValue = '';
  105. }
  106. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  107. }
  108. protected function _getFilterControls ()
  109. {
  110. parent::_getFilterControls();
  111. $aInputModules = $this->getModulesSelectOneArray('getAudit', false, false);
  112. $aInputModules['values'] = array_merge(array('' => _t('_adm_txt_select_module')), $aInputModules['values']);
  113. $oForm = new BxTemplStudioFormView(array());
  114. $sContent = $oForm->genRow($aInputModules);
  115. $oForm = new BxTemplStudioFormView(array());
  116. $aInputSearch = array(
  117. 'type' => 'text',
  118. 'name' => 'keyword',
  119. 'attrs' => array(
  120. 'id' => 'bx-grid-search-' . $this->_sObject,
  121. ),
  122. 'tr_attrs' => array(
  123. 'style' => 'display:none;'
  124. )
  125. );
  126. $sContent .= $oForm->genRow($aInputSearch);
  127. return $sContent;
  128. }
  129. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  130. {
  131. $sFilterContent = bx_get('content_id');
  132. if(!empty($sFilter2)) {
  133. $sFilterContent = bx_process_input($sFilterContent);
  134. $this->_aOptions['source'] .= " AND `content_id` = " . $sFilterContent . 'AND `content_module` = ' . $this->sModule;
  135. }
  136. $sFilterContext = bx_get('context_id');
  137. if(!empty($sFilterContext)) {
  138. $sFilterContext = bx_process_input($sFilterContext);
  139. $this->_aOptions['source'] .= " AND `context_profile_id` = " . $sFilterContext;
  140. }
  141. $sPrifile = bx_get('profile_id');
  142. if(!empty($sPrifile)) {
  143. $sPrifile = bx_process_input($sPrifile);
  144. $this->_aOptions['source'] .= " AND `profile_id` = " . $sPrifile;
  145. }
  146. return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  147. }
  148. function getJsObject()
  149. {
  150. return 'oBxDolStudioFormsAudit';
  151. }
  152. function getCode($isDisplayHeader = true)
  153. {
  154. return $this->_oTemplate->parseHtmlByName('forms_audit.html', array(
  155. 'content' => parent::getCode($isDisplayHeader),
  156. 'js_object' => $this->getJsObject(),
  157. 'grid_object' => $this->_sObject,
  158. 'params_divider' => $this->sParamsDivider
  159. ));
  160. }
  161. }
  162. /** @} */