BxBaseModGroupsTemplate.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 BaseGroups Base classes for groups modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /*
  12. * Groups module representation.
  13. */
  14. class BxBaseModGroupsTemplate extends BxBaseModProfileTemplate
  15. {
  16. protected $_iUnitCharsSummary;
  17. protected $_sUnitClassWoCover;
  18. function __construct(&$oConfig, &$oDb)
  19. {
  20. parent::__construct($oConfig, $oDb);
  21. $this->_bLetterAvatar = false;
  22. $this->_iUnitCharsSummary = 50;
  23. $this->_sUnitClassWoCover = $this->_sUnitClass; //--- Save default 'Unit' class (from BxBaseModProfileTemplate) as 'Unit W\O Cover' class here.
  24. $this->_sUnitClassWithCover .= ' bx-base-groups-unit-with-cover';
  25. $this->_sUnitClass = $this->_sUnitClassWithCover;
  26. $this->_sUnitClassWoInfo .= ' bx-base-groups-unit-wo-info';
  27. $this->_sUnitClassWoInfoShowCase .= ' bx-base-groups-unit-wo-info bx-base-groups-unit-wo-info-showcase';
  28. $this->_sUnitClassShowCase .= ' bx-base-groups-unit-with-cover bx-base-groups-unit-showcase';
  29. }
  30. function unitVars ($aData, $isCheckPrivateContent = true, $mixedTemplate = false, $aParams = array())
  31. {
  32. $aVars = parent::unitVars ($aData, $isCheckPrivateContent, $mixedTemplate, $aParams);
  33. $CNF = &$this->_oConfig->CNF;
  34. $oProfile = BxDolProfile::getInstance($aData[$CNF['FIELD_AUTHOR']]);
  35. if (!$oProfile)
  36. $oProfile = BxDolProfileUndefined::getInstance();
  37. $aVars['title'] = (boolean)$aVars['public'] ? bx_process_output($aData[$CNF['FIELD_NAME']]) : _t($CNF['T']['txt_private_group']);
  38. $aVars['description'] = '';
  39. if(!empty($CNF['FIELD_TEXT']) && !empty($aData[$CNF['FIELD_TEXT']]) && (boolean)$aVars['public'])
  40. $aVars['description'] = strmaxtextlen(strip_tags($aData[$CNF['FIELD_TEXT']]), $this->_iUnitCharsSummary);
  41. $aVars['author'] = $oProfile->getDisplayName();
  42. $aVars['author_url'] = $oProfile->getUrl();
  43. $aVars['author_icon'] = $oProfile->getIcon();
  44. $aVars['author_thumb'] = $oProfile->getThumb();
  45. $aVars['author_avatar'] = $oProfile->getAvatar();
  46. return $aVars;
  47. }
  48. public function getPopupSetRole($aRoles, $iProfileId, $iProfileRole)
  49. {
  50. $sJsObject = $this->_oConfig->getJsObject('main');
  51. $sHtmlIdPrefix = str_replace('_', '-', $this->_oConfig->getName()) . '-role';
  52. $aTmplVarsRoles = array();
  53. foreach($aRoles as $iRole => $sRole)
  54. $aTmplVarsRoles[] = array(
  55. 'id' => $sHtmlIdPrefix . '-' . $iRole,
  56. 'value' => $iRole,
  57. 'onclick' => $sJsObject . '.onClickSetRoleMulti(this, ' . $iProfileId . ', ' . $iRole . ')',
  58. 'title' => $sRole,
  59. 'bx_if:show_checked' => array(
  60. 'condition' => $iRole != 0 && $iProfileRole & (1 << ($iRole - 1)),
  61. 'content' => array()
  62. )
  63. );
  64. return $this->parseHtmlByName('set_role_popup.html', array(
  65. 'bx_repeat:roles' => $aTmplVarsRoles
  66. ));
  67. }
  68. protected function _getUnitClass($aData, $sTemplateName = 'unit.html')
  69. {
  70. $sResult = '';
  71. switch($sTemplateName) {
  72. case 'unit_wo_cover.html':
  73. $sResult = $this->_sUnitClassWoCover;
  74. break;
  75. default:
  76. $sResult = parent::_getUnitClass($aData, $sTemplateName);
  77. }
  78. return $sResult;
  79. }
  80. protected function _getUnitSize($aData, $sTemplateName = 'unit.html')
  81. {
  82. $sResult = '';
  83. switch($sTemplateName) {
  84. case 'unit.html':
  85. case 'unit_with_cover.html':
  86. $sResult = 'ava';
  87. break;
  88. default:
  89. $sResult = $this->_sUnitSizeDefault;
  90. break;
  91. }
  92. return $sResult;
  93. }
  94. }
  95. /** @} */