BxBaseModTextGridAdministration.php 4.8 KB

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