BxBaseModTextGridAdministration.php 4.1 KB

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