BxBaseModProfileTemplate.php 21 KB

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