BxBaseModTextGridAdministration.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup BaseText Base classes for text modules
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxBaseModGeneralGridAdministration');
  12. class BxBaseModTextGridAdministration extends BxBaseModGeneralGridAdministration
  13. {
  14. protected $_sFilter1Name;
  15. protected $_sFilter1Value;
  16. protected $_aFilter1Values;
  17. public function __construct ($aOptions, $oTemplate = false)
  18. {
  19. parent::__construct ($aOptions, $oTemplate);
  20. $CNF = &$this->_oModule->_oConfig->CNF;
  21. $this->_sFilter1Name = 'filter1';
  22. $this->_aFilter1Values = array(
  23. 'active' => $CNF['T']['filter_item_active'],
  24. 'hidden' => $CNF['T']['filter_item_hidden'],
  25. );
  26. $sFilter1 = bx_get($this->_sFilter1Name);
  27. if(!empty($sFilter1)) {
  28. $this->_sFilter1Value = bx_process_input($sFilter1);
  29. $this->_aQueryAppend['filter1'] = $this->_sFilter1Value;
  30. }
  31. }
  32. protected function _switcherChecked2State($isChecked)
  33. {
  34. return $isChecked ? 'active' : 'hidden';
  35. }
  36. protected function _switcherState2Checked($mixedState)
  37. {
  38. return 'active' == $mixedState ? true : false;
  39. }
  40. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  41. {
  42. if(strpos($sFilter, $this->_sParamsDivider) !== false)
  43. list($this->_sFilter1Value, $sFilter) = explode($this->_sParamsDivider, $sFilter);
  44. if(!empty($this->_sFilter1Value))
  45. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepare(" AND `status`=?", $this->_sFilter1Value);
  46. return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  47. }
  48. //--- Layout methods ---//
  49. protected function _getFilterControls()
  50. {
  51. parent::_getFilterControls();
  52. return $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values) . $this->_getSearchInput();
  53. }
  54. protected function _getCellTitle($mixedValue, $sKey, $aField, $aRow)
  55. {
  56. $CNF = &$this->_oModule->_oConfig->CNF;
  57. bx_import('BxDolPermalinks');
  58. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aRow[$CNF['FIELD_ID']]);
  59. $mixedValue = $this->_oTemplate->parseHtmlByName('title_link.html', array(
  60. 'href' => $sUrl,
  61. 'title' => $mixedValue,
  62. 'content' => $mixedValue
  63. ));
  64. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  65. }
  66. protected function _getCellAdded($mixedValue, $sKey, $aField, $aRow)
  67. {
  68. return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
  69. }
  70. protected function _getCellAuthor($mixedValue, $sKey, $aField, $aRow)
  71. {
  72. bx_import('BxDolProfile');
  73. $oProfile = $this->_getProfileObject($aRow['author']);
  74. $sProfile = $oProfile->getDisplayName();
  75. bx_import('BxDolAcl');
  76. $oAcl = BxDolAcl::getInstance();
  77. $sAccountEmail = '';
  78. $sManageAccountUrl = '';
  79. if($oProfile && $oProfile instanceof BxDolProfile && $oAcl->isMemberLevelInSet(128)) {
  80. $sAccountEmail = $oProfile->getAccountObject()->getEmail();
  81. $sManageAccountUrl = $this->_getManageAccountUrl($sAccountEmail);
  82. }
  83. $mixedValue = $this->_oTemplate->parseHtmlByName('author_link.html', array(
  84. 'href' => $oProfile->getUrl(),
  85. 'title' => $sProfile,
  86. 'content' => $sProfile,
  87. 'bx_if:show_account' => array(
  88. 'condition' => !empty($sManageAccountUrl),
  89. 'content' => array(
  90. 'href' => $sManageAccountUrl,
  91. 'title' => _t($this->_oModule->_oConfig->CNF['T']['grid_txt_account_manager']),
  92. 'content' => $sAccountEmail
  93. )
  94. )
  95. ));
  96. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  97. }
  98. protected function _getActionEdit($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  99. {
  100. if($this->_sManageType == BX_DOL_MANAGE_TOOLS_ADMINISTRATION && $this->_oModule->checkAllowedEditAnyEntry() !== CHECK_ACTION_RESULT_ALLOWED)
  101. return '';
  102. $CNF = &$this->_oModule->_oConfig->CNF;
  103. bx_import('BxDolPermalinks');
  104. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_EDIT_ENTRY'] . '&id=' . $aRow[$CNF['FIELD_ID']]);
  105. $a['attr'] = array_merge($a['attr'], array(
  106. "onclick" => "window.open('" . $sUrl . "','_self');"
  107. ));
  108. return $this->_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  109. }
  110. protected function _getProfileObject($iId)
  111. {
  112. bx_import('BxDolProfile');
  113. $oProfile = BxDolProfile::getInstance($iId);
  114. if (!$oProfile) {
  115. bx_import('BxDolProfileUndefined');
  116. $oProfile = BxDolProfileUndefined::getInstance();
  117. }
  118. return $oProfile;
  119. }
  120. }
  121. /** @} */