1
0

BxBaseModProfileTemplate.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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 BaseProfile Base classes for profile modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /*
  12. * Profile based modules representation.
  13. */
  14. class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
  15. {
  16. protected $_sUnitDefault;
  17. protected $_sUnitSizeDefault;
  18. protected $_sUnitClass;
  19. protected $_sUnitClassWithCover;
  20. protected $_sUnitClassWoInfo;
  21. protected $_sUnitClassWoInfoShowCase;
  22. protected $_sUnitClassShowCase;
  23. /*
  24. * Enable/Disable Letter based thumbnail in "Unit with Cover" only.
  25. */
  26. protected $_bLetterAvatar;
  27. function __construct(&$oConfig, &$oDb)
  28. {
  29. parent::__construct($oConfig, $oDb);
  30. $this->_sUnitDefault = 'unit.html';
  31. $this->_sUnitSizeDefault = 'thumb';
  32. $this->_sUnitClass = 'bx-base-pofile-unit';
  33. $this->_sUnitClassWithCover = 'bx-base-pofile-unit-with-cover';
  34. $this->_sUnitClassWoInfo = 'bx-base-pofile-unit-wo-info';
  35. $this->_sUnitClassWoInfoShowCase = 'bx-base-pofile-unit-wo-info bx-base-unit-showcase bx-base-pofile-unit-wo-info-showcase';
  36. $this->_sUnitClassShowCase = 'bx-base-pofile-unit-with-cover bx-base-unit-showcase bx-base-pofile-unit-showcase';
  37. $this->_bLetterAvatar = true;
  38. }
  39. /**
  40. * Get profile unit
  41. */
  42. function unit ($aData, $isCheckPrivateContent = true, $mixedTemplate = false, $aParams = array())
  43. {
  44. list($sTemplate) = is_array($mixedTemplate) ? $mixedTemplate : array($mixedTemplate);
  45. if(!empty($aParams['template_name']))
  46. $sTemplate = $aParams['template_name'];
  47. if(empty($sTemplate))
  48. $sTemplate = $this->_sUnitDefault;
  49. /**
  50. * Allow use separate template for private profiles.
  51. * These templates will be used if privacy field "Visible to" don't allow to view content.
  52. * To use them you need to create a template with a postfix "_private" and put it in specified module
  53. * Example: "unit_private.html" for "unit.html" or "unit_wo_links_private.html" for "unit_wo_links.html"
  54. */
  55. $oModule = $this->getModule();
  56. if ($oModule->serviceCheckAllowedViewForProfile($aData) !== 0){
  57. $sTemplatePrivate = str_replace('.html', '_private.html' , $sTemplate);
  58. if($this->parseHtmlByName($sTemplatePrivate, array())){
  59. $sTemplate = $sTemplatePrivate;
  60. }
  61. }
  62. $aVars = $this->unitVars($aData, $isCheckPrivateContent, $mixedTemplate, $aParams);
  63. bx_alert($oModule->getName(), 'unit', 0, 0, array(
  64. 'data' => $aData,
  65. 'check_private_content' => $isCheckPrivateContent,
  66. 'template' => $mixedTemplate,
  67. 'params' => $aParams,
  68. 'tmpl_name' => &$sTemplate,
  69. 'tmpl_vars' => &$aVars
  70. ));
  71. return $this->parseHtmlByName($sTemplate, $aVars);
  72. }
  73. function unitVars ($aData, $isCheckPrivateContent = true, $mixedTemplate = false, $aParams = array())
  74. {
  75. $CNF = &$this->_oConfig->CNF;
  76. list($sTemplate, $sTemplateSize, $aTemplateVars) = is_array($mixedTemplate) ? $mixedTemplate : array($mixedTemplate, false, array());
  77. if(!empty($aParams['template_name']))
  78. $sTemplate = $aParams['template_name'];
  79. if(empty($sTemplate))
  80. $sTemplate = $this->_sUnitDefault;
  81. if(!empty($aParams['template_size']))
  82. $sTemplateSize = $aParams['template_size'];
  83. if(empty($sTemplateSize))
  84. $sTemplateSize = $this->_getUnitSize($aData, $sTemplate);
  85. if(!empty($aParams['template_vars']) && is_array($aParams['template_vars']))
  86. $aTemplateVars = $aParams['template_vars'];
  87. if(empty($aTemplateVars) || !is_array($aTemplateVars))
  88. $aTemplateVars = array();
  89. $oModule = $this->getModule();
  90. $iContentId = (int)$aData[$CNF['FIELD_ID']];
  91. $bPublic = $isCheckPrivateContent && !empty($CNF['OBJECT_PRIVACY_VIEW']) ? $this->isProfilePublic($aData) : true;
  92. $bPublicThumb = true;
  93. if($isCheckPrivateContent && $oModule->checkAllowedViewProfileImage($aData) !== CHECK_ACTION_RESULT_ALLOWED)
  94. $bPublicThumb = false;
  95. $bPublicCover = true;
  96. if($isCheckPrivateContent && $oModule->checkAllowedViewCoverImage($aData) !== CHECK_ACTION_RESULT_ALLOWED)
  97. $bPublicCover = false;
  98. $oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->MODULE);
  99. $iProfile = $oProfile->id();
  100. // get profile's url
  101. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId);
  102. // get profile's title
  103. $sTitle = bx_process_output($aData[$CNF['FIELD_NAME']]);
  104. $sText = $sSummary = '';
  105. if(!empty($CNF['FIELD_TEXT']) && !empty($aData[$CNF['FIELD_TEXT']])) {
  106. $sText = $this->getText($aData);
  107. $sSummary = $this->getSummary($aData, $sTitle, $sText, $sUrl);
  108. }
  109. $sThumbUrl = $bPublicThumb ? $this->_getUnitThumbUrl($sTemplateSize, $aData, false) : '';
  110. $bThumbUrl = !empty($sThumbUrl);
  111. $aTmplVarsThumbnail = array(
  112. 'bx_if:show_thumb_image' => array(
  113. 'condition' => $bThumbUrl,
  114. 'content' => array(
  115. 'size' => $sTemplateSize,
  116. 'thumb_url' => $sThumbUrl
  117. )
  118. ),
  119. 'bx_if:show_thumb_letter' => array(
  120. 'condition' => !$bThumbUrl,
  121. 'content' => array(
  122. 'size' => $sTemplateSize,
  123. 'color' => implode(', ', BxDolTemplate::getColorCode($iProfile, 1.0)),
  124. 'letter' => mb_strtoupper(mb_substr($sTitle, 0, 1))
  125. )
  126. ),
  127. 'bx_if:show_online' => array(
  128. 'condition' => $oProfile->isOnline(),
  129. 'content' => array()
  130. ),
  131. 'size' => $sTemplateSize,
  132. 'badges' => $oModule->serviceGetBadges($iContentId, false, true),
  133. 'thumb_url' => $bThumbUrl ? $sThumbUrl : $this->getImageUrl('no-picture-thumb.png'),
  134. );
  135. $sCoverUrl = $bPublicCover ? $this->urlCoverUnit($aData, false) : '';
  136. $bCoverUrl = !empty($sCoverUrl);
  137. if(empty($sCoverUrl) && ($iCoverId = (int)getParam('sys_unit_cover_profile')) != 0)
  138. $sCoverUrl = BxDolTranscoder::getObjectInstance(BX_DOL_TRANSCODER_OBJ_COVER_UNIT_PROFILE)->getFileUrlById($iCoverId);
  139. if(empty($sCoverUrl))
  140. $sCoverUrl = $this->getImageUrl('cover.svg');
  141. $aTmplVarsMeta = array();
  142. if(substr($sTemplate, 0, 8) != 'unit_wo_')
  143. $aTmplVarsMeta = $this->getSnippetMenuVars ($iProfile, $bPublic);
  144. return array_merge(array (
  145. 'class' => $this->_getUnitClass($aData, $sTemplate),
  146. 'id' => $iContentId,
  147. 'public' => $bPublic,
  148. 'bx_if:show_thumbnail' => array(
  149. 'condition' => $bThumbUrl || $this->_bLetterAvatar,
  150. 'content' => $aTmplVarsThumbnail
  151. ),
  152. 'cover_url' => $sCoverUrl,
  153. 'bx_if:show_cover' => array(
  154. 'condition' => $bCoverUrl,
  155. 'content' => array(
  156. 'cover_url' => $sCoverUrl,
  157. )
  158. ),
  159. 'content_url' => $bPublic ? $sUrl : 'javascript:void(0);',
  160. 'content_click' => !$bPublic ? 'javascript:bx_alert(' . bx_js_string('"' . _t('_sys_access_denied_to_private_content') . '"') . ');' : '',
  161. 'title' => $sTitle,
  162. 'title_attr' => bx_html_attribute($sTitle),
  163. 'addon' => !empty($aData['addon']) ? $aData['addon'] : '',
  164. 'module_name' => _t($CNF['T']['txt_sample_single']),
  165. 'ts' => $aData[$CNF['FIELD_ADDED']],
  166. 'bx_if:meta' => array(
  167. 'condition' => !empty($aTmplVarsMeta),
  168. 'content' => $aTmplVarsMeta
  169. ),
  170. 'text' => $sText,
  171. 'summary' => $sSummary,
  172. ), $aTmplVarsThumbnail, $aTemplateVars);
  173. }
  174. function isProfilePublic($aData)
  175. {
  176. $CNF = &$this->_oConfig->CNF;
  177. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  178. if ($oPrivacy && !$oPrivacy->check($aData[$CNF['FIELD_ID']]) && !$oPrivacy->isPartiallyVisible($aData[$CNF['FIELD_ALLOW_VIEW_TO']]))
  179. return false;
  180. return true;
  181. }
  182. function getSnippetMenuVars ($iProfileId, $bPublic = null)
  183. {
  184. if (!($oProfile = BxDolProfile::getInstance($iProfileId)))
  185. return array();
  186. $CNF = &$this->_oConfig->CNF;
  187. if (null === $bPublic) {
  188. $aData = $this->getModule()->serviceGetContentInfoById($oProfile->getContentId());
  189. $bPublic = $this->isProfilePublic($aData);
  190. }
  191. $aTmplVarsMeta = array();
  192. if (!empty($CNF['OBJECT_MENU_SNIPPET_META'])) {
  193. $oMenuMeta = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_SNIPPET_META'], $this);
  194. if($oMenuMeta) {
  195. $oMenuMeta->setContentId($oProfile->getContentId());
  196. $oMenuMeta->setContentPublic($bPublic);
  197. $aTmplVarsMeta = array(
  198. 'meta' => $oMenuMeta->getCode()
  199. );
  200. }
  201. }
  202. return $aTmplVarsMeta;
  203. }
  204. /**
  205. * Get profile cover
  206. */
  207. function setCover ($oPage, $aData, $sTemplateName = 'cover.html')
  208. {
  209. $CNF = &$this->_oConfig->CNF;
  210. $oModule = $this->getModule();
  211. BxDolTemplate::getInstance()->addInjection('injection_main_class', 'text', 'bx-base-profile-view');
  212. $bProfileViewAllowed = CHECK_ACTION_RESULT_ALLOWED === $oModule->checkAllowedView($aData);
  213. if (CHECK_ACTION_RESULT_ALLOWED !== $oModule->checkAllowedViewProfileImage($aData))
  214. $aData[$CNF['FIELD_PICTURE']] = 0;
  215. if (CHECK_ACTION_RESULT_ALLOWED !== $oModule->checkAllowedViewCoverImage($aData))
  216. $aData[$CNF['FIELD_COVER']] = 0;
  217. $oProfile = BxDolProfile::getInstanceByContentAndType($aData[$CNF['FIELD_ID']], $this->MODULE);
  218. $iProfile = $oProfile->id();
  219. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aData[$CNF['FIELD_ID']]);
  220. $sTitle = bx_process_output($oProfile->getDisplayName());
  221. $sUrlAvatar = $this->urlAvatarBig($aData, false);
  222. $bUrlAvatar = !empty($sUrlAvatar);
  223. $sUrlPicture = $this->urlPicture ($aData);
  224. $sUrlPictureChange = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_EDIT_ENTRY'] . '&id=' . $aData[$CNF['FIELD_ID']]);
  225. $sUrlCover = $this->urlCover ($aData, false);
  226. if(!$sUrlCover && $oPage !== false && $oPage->isPageCover()) {
  227. $aCover = $oPage->getPageCoverImage();
  228. if(!empty($aCover))
  229. $sUrlCover = BxDolCover::getCoverImageUrl($aCover);
  230. }
  231. if(!$sUrlCover)
  232. $sUrlCover = $this->getImageUrl('cover.svg');
  233. else
  234. BxDolTemplate::getInstance()->addPageMetaImage($sUrlCover);
  235. $sUrlCoverChange = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_EDIT_COVER'] . '&id=' . $aData[$CNF['FIELD_ID']]);
  236. $sCoverPopup = '';
  237. $sCoverPopupId = $this->MODULE . '-popup-cover';
  238. if($bProfileViewAllowed && $aData[$CNF['FIELD_COVER']]) {
  239. $sCoverPopup = BxTemplFunctions::getInstance()->transBox($sCoverPopupId, $this->parseHtmlByName('image_popup.html', array (
  240. 'image_url' => $sUrlCover,
  241. 'bx_if:owner' => array (
  242. 'condition' => CHECK_ACTION_RESULT_ALLOWED === $oModule->checkAllowedChangeCover($aData),
  243. 'content' => array (
  244. 'change_image_url' => $sUrlCoverChange,
  245. ),
  246. ),
  247. )), true, true);
  248. }
  249. $bShowAvatar = $bUrlAvatar || $this->_bLetterAvatar;
  250. $aShowAvatar = array();
  251. $sPicturePopup = '';
  252. if($bShowAvatar) {
  253. $sPicturePopupId = $this->MODULE . '-popup-picture';
  254. $aShowAvatar = array(
  255. 'bx_if:show_ava_image' => array(
  256. 'condition' => $bUrlAvatar,
  257. 'content' => array(
  258. 'ava_url' => $sUrlAvatar
  259. )
  260. ),
  261. 'bx_if:show_ava_letter' => array(
  262. 'condition' => !$bUrlAvatar,
  263. 'content' => array(
  264. 'color' => implode(', ', BxDolTemplate::getColorCode($iProfile, 1.0)),
  265. 'letter' => mb_substr($sTitle, 0, 1)
  266. )
  267. ),
  268. 'bx_if:show_online' => array(
  269. 'condition' => $oProfile->isOnline(),
  270. 'content' => array()
  271. ),
  272. 'picture_avatar_url' => $bUrlAvatar ? $sUrlAvatar : $this->getImageUrl('no-picture-preview.png'),
  273. 'picture_popup_id' => $sPicturePopupId,
  274. 'picture_url' => $sUrlPicture,
  275. 'picture_href' => !$aData[$CNF['FIELD_PICTURE']] && CHECK_ACTION_RESULT_ALLOWED === $oModule->checkAllowedEdit($aData) ? $sUrlPictureChange : 'javascript:void(0);',
  276. );
  277. if($bProfileViewAllowed && $aData[$CNF['FIELD_PICTURE']]) {
  278. $sPicturePopup = BxTemplFunctions::getInstance()->transBox($sPicturePopupId, $this->parseHtmlByName('image_popup.html', array (
  279. 'image_url' => $sUrlPicture,
  280. 'bx_if:owner' => array (
  281. 'condition' => CHECK_ACTION_RESULT_ALLOWED === $oModule->checkAllowedEdit($aData),
  282. 'content' => array (
  283. 'change_image_url' => $sUrlPictureChange,
  284. ),
  285. ),
  286. )), true, true);
  287. }
  288. }
  289. $sActionsMenu = $oModule->serviceEntityAllActions();
  290. if(!$sActionsMenu && ($oMenu = BxTemplMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'])) !== false)
  291. $sActionsMenu = $oMenu->getCode();
  292. // generate html
  293. $aVars = array (
  294. 'module' => $this->_oConfig->getName(),
  295. 'id' => $aData[$CNF['FIELD_ID']],
  296. 'content_url' => $sUrl,
  297. 'title' => $sTitle,
  298. //'menu' => BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY_COVER'])->getCode(), // TODO: check if menu is used somewhere
  299. 'action_menu' => $sActionsMenu,
  300. 'bx_if:show_avatar' => array(
  301. 'condition' => $bShowAvatar,
  302. 'content' => $aShowAvatar
  303. ),
  304. 'picture_popup' => $sPicturePopup,
  305. 'cover_popup' => $sCoverPopup,
  306. 'cover_popup_id' => $sCoverPopupId,
  307. 'cover_url' => $sUrlCover,
  308. 'cover_href' => !$aData[$CNF['FIELD_COVER']] && CHECK_ACTION_RESULT_ALLOWED === $oModule->checkAllowedChangeCover($aData) ? $sUrlCoverChange : 'javascript:void(0);',
  309. 'badges' => $oModule->serviceGetBadges($aData[$CNF['FIELD_ID']]),
  310. );
  311. BxDolCover::getInstance($this)->set($aVars, $sTemplateName);
  312. }
  313. /**
  314. * Get profile picture thumb url
  315. * @deprecated since 11.0.0 use BxBaseModProfileTemplate::urlAvatar instead.
  316. */
  317. function avatar ($aData, $bSubstituteNoImage = true)
  318. {
  319. return $this->urlAvatar($aData, $bSubstituteNoImage);
  320. }
  321. /**
  322. * Get profile picture thumb url
  323. * @deprecated since 11.0.0 use BxBaseModProfileTemplate::urlThumb instead.
  324. */
  325. function thumb ($aData, $bSubstituteNoImage = true)
  326. {
  327. return $this->urlThumb($aData, $bSubstituteNoImage);
  328. }
  329. /**
  330. * Get profile picture thumb url
  331. * @deprecated since 11.0.0 use BxBaseModProfileTemplate::urlIcon instead.
  332. */
  333. function icon ($aData, $bSubstituteNoImage = true)
  334. {
  335. return $this->urlIcon($aData, $bSubstituteNoImage);
  336. }
  337. /**
  338. * Get profile picture icon url
  339. */
  340. function urlIcon ($aData, $bSubstituteNoImage = true)
  341. {
  342. $CNF = &$this->_oConfig->CNF;
  343. return $this->_image ($CNF['FIELD_PICTURE'], $CNF['OBJECT_IMAGES_TRANSCODER_ICON'], 'no-picture-icon.png', $aData, $bSubstituteNoImage);
  344. }
  345. /**
  346. * Get profile thumb url
  347. */
  348. function urlThumb ($aData, $bSubstituteNoImage = true)
  349. {
  350. $CNF = &$this->_oConfig->CNF;
  351. return $this->_image ($CNF['FIELD_PICTURE'], $CNF['OBJECT_IMAGES_TRANSCODER_THUMB'], 'no-picture-thumb.png', $aData, $bSubstituteNoImage);
  352. }
  353. /**
  354. * Get profile avatar url
  355. */
  356. function urlAvatar ($aData, $bSubstituteNoImage = true)
  357. {
  358. $CNF = &$this->_oConfig->CNF;
  359. return $this->_image ($CNF['FIELD_PICTURE'], $CNF['OBJECT_IMAGES_TRANSCODER_AVATAR'], 'no-picture-preview.png', $aData, $bSubstituteNoImage);
  360. }
  361. /**
  362. * Get profile avatar big url
  363. */
  364. function urlAvatarBig ($aData, $bSubstituteNoImage = true)
  365. {
  366. $CNF = &$this->_oConfig->CNF;
  367. return $this->_image ($CNF['FIELD_PICTURE'], $CNF['OBJECT_IMAGES_TRANSCODER_AVATAR_BIG'], 'no-picture-preview.png', $aData, $bSubstituteNoImage);
  368. }
  369. /**
  370. * Get profile picture url
  371. */
  372. function urlPicture ($aData, $bSubstituteNoImage = true)
  373. {
  374. $CNF = &$this->_oConfig->CNF;
  375. return $this->_image ($CNF['FIELD_PICTURE'], $CNF['OBJECT_IMAGES_TRANSCODER_PICTURE'], 'no-picture-preview.png', $aData, $bSubstituteNoImage);
  376. }
  377. /**
  378. * Get profile cover image url
  379. */
  380. function urlCover ($aData, $bSubstituteNoImage = false)
  381. {
  382. $CNF = &$this->_oConfig->CNF;
  383. $sImageUrl = $this->_image($CNF['FIELD_COVER'], $CNF['OBJECT_IMAGES_TRANSCODER_COVER'], '', $aData, $bSubstituteNoImage);
  384. return $sImageUrl;
  385. }
  386. /**
  387. * Get profile cover image url for browse unit
  388. */
  389. function urlCoverUnit ($aData, $bSubstituteNoImage = true)
  390. {
  391. $CNF = &$this->_oConfig->CNF;
  392. $sImageUrl = $this->_image ($CNF['FIELD_COVER'], $CNF['OBJECT_IMAGES_TRANSCODER_GALLERY'], '', $aData, false);
  393. if($sImageUrl === false) {
  394. $iImageId = (int)getParam('sys_unit_cover_profile');
  395. $oImageTranscoder = BxDolTranscoderImage::getObjectInstance(BX_DOL_TRANSCODER_OBJ_COVER_UNIT_PROFILE);
  396. if($oImageTranscoder && $iImageId != 0)
  397. $sImageUrl = $oImageTranscoder->getFileUrl($iImageId);
  398. }
  399. if($bSubstituteNoImage && !$sImageUrl)
  400. $sImageUrl = $this->getImageUrl('cover.svg');
  401. return $sImageUrl;
  402. }
  403. /**
  404. * Get profile picture icon url
  405. */
  406. function _image ($sField, $sTranscodeObject, $sNoImage, $aData, $bSubstituteNoImage = true)
  407. {
  408. $sImageUrl = false;
  409. if ($aData[$sField]) {
  410. $oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($sTranscodeObject);
  411. if ($oImagesTranscoder)
  412. $sImageUrl = $oImagesTranscoder->getFileUrl($aData[$sField]);
  413. }
  414. return $bSubstituteNoImage && !$sImageUrl ? $this->getImageUrl($sNoImage) : $sImageUrl;
  415. }
  416. protected function _getUnitClass($aData, $sTemplateName = 'unit.html')
  417. {
  418. $sResult = '';
  419. switch($sTemplateName) {
  420. default:
  421. case 'unit.html':
  422. $sResult = $this->_sUnitClass;
  423. break;
  424. case 'unit_with_cover.html':
  425. $sResult = $this->_sUnitClassWithCover;
  426. break;
  427. case 'unit_wo_info.html':
  428. case 'unit_wo_info_links.html':
  429. $sResult = $this->_sUnitClassWoInfo;
  430. break;
  431. case 'unit_with_cover_showcase.html':
  432. $sResult = $this->_sUnitClassShowCase;
  433. break;
  434. case 'unit_wo_info_showcase.html':
  435. $sResult = $this->_sUnitClassWoInfoShowCase;
  436. break;
  437. }
  438. return $sResult;
  439. }
  440. protected function _getUnitSize($aData, $sTemplateName = 'unit.html')
  441. {
  442. $sResult = '';
  443. switch($sTemplateName) {
  444. case 'unit_with_cover.html':
  445. $sResult = 'ava';
  446. break;
  447. default:
  448. $sResult = $this->_sUnitSizeDefault;
  449. break;
  450. }
  451. return $sResult;
  452. }
  453. protected function _getUnitThumbUrl($sSize, $aData, $bSubstituteNoImage = true)
  454. {
  455. $sMethod = 'url' . bx_gen_method_name(str_replace('ava', 'avatar', $sSize), array('_', '-'));
  456. if(method_exists($this, $sMethod))
  457. return $this->$sMethod($aData, $bSubstituteNoImage);
  458. else
  459. return $this->_getUnitThumbUrl($this->_sUnitSizeDefault, $aData, $bSubstituteNoImage);
  460. }
  461. }
  462. /** @} */