BxBaseModGroupsTemplate.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. function __construct(&$oConfig, &$oDb)
  18. {
  19. parent::__construct($oConfig, $oDb);
  20. $this->_bLetterAvatar = true;
  21. $this->_iUnitCharsSummary = 50;
  22. $this->_sUnitClassWithCover .= ' bx-base-groups-unit-with-cover';
  23. $this->_sUnitClass = $this->_sUnitClassWithCover;
  24. $this->_sUnitClassWoInfo .= ' bx-base-groups-unit-wo-info';
  25. $this->_sUnitClassWoInfoShowCase .= ' bx-base-groups-unit-wo-info bx-base-groups-unit-wo-info-showcase';
  26. $this->_sUnitClassShowCase .= ' bx-base-groups-unit-with-cover bx-base-groups-unit-showcase';
  27. }
  28. function unitVars ($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html')
  29. {
  30. $aVars = parent::unitVars ($aData, $isCheckPrivateContent, $sTemplateName);
  31. $CNF = &$this->_oConfig->CNF;
  32. $oProfile = BxDolProfile::getInstance($aData[$CNF['FIELD_AUTHOR']]);
  33. if (!$oProfile)
  34. $oProfile = BxDolProfileUndefined::getInstance();
  35. $aVars['title'] = (boolean)$aVars['public'] ? bx_process_output($aData[$CNF['FIELD_NAME']]) : _t($CNF['T']['txt_private_group']);
  36. $aVars['description'] = '';
  37. if(!empty($CNF['FIELD_TEXT']) && !empty($aData[$CNF['FIELD_TEXT']]) && (boolean)$aVars['public'])
  38. $aVars['description'] = strmaxtextlen(strip_tags($aData[$CNF['FIELD_TEXT']]), $this->_iUnitCharsSummary);
  39. $aVars['author'] = $oProfile->getDisplayName();
  40. $aVars['author_url'] = $oProfile->getUrl();
  41. $aVars['author_icon'] = $oProfile->getIcon();
  42. $aVars['author_thumb'] = $oProfile->getThumb();
  43. $aVars['author_avatar'] = $oProfile->getAvatar();
  44. return $aVars;
  45. }
  46. protected function _getUnitSize($aData, $sTemplateName = 'unit.html')
  47. {
  48. $sResult = '';
  49. switch($sTemplateName) {
  50. case 'unit.html':
  51. case 'unit_with_cover.html':
  52. $sResult = 'ava';
  53. break;
  54. default:
  55. $sResult = $this->_sUnitSizeDefault;
  56. break;
  57. }
  58. return $sResult;
  59. }
  60. }
  61. /** @} */