1
0

BxBaseModTextTemplate.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  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 BaseText Base classes for text modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Module representation.
  13. */
  14. class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
  15. {
  16. protected $_sUnitClassShowCase;
  17. function __construct(&$oConfig, &$oDb)
  18. {
  19. parent::__construct($oConfig, $oDb);
  20. $this->_sUnitClassShowCase = 'bx-base-unit-showcase bx-base-text-unit-showcase bx-def-margin-sec-bottom';
  21. }
  22. public function getJsCode($sType, $aParams = array(), $bWrap = true)
  23. {
  24. $aParams = array_merge(array(
  25. 'aHtmlIds' => $this->_oConfig->getHtmlIds()
  26. ), $aParams);
  27. return parent::getJsCode($sType, $aParams, $bWrap);
  28. }
  29. function unit ($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html', $aParams = array())
  30. {
  31. $sResult = $this->checkPrivacy ($aData, $isCheckPrivateContent, $this->getModule(), $sTemplateName);
  32. if($sResult)
  33. return $sResult;
  34. $aParams['template_name'] = $sTemplateName;
  35. return $this->parseHtmlByName($sTemplateName, $this->getUnit($aData, $aParams));
  36. }
  37. function entryAttachments ($aData, $aParams = array())
  38. {
  39. $CNF = &$this->getModule()->_oConfig->CNF;
  40. $aStoragesKeys = array('OBJECT_STORAGE_PHOTOS', 'OBJECT_STORAGE_VIDEOS', 'OBJECT_STORAGE_FILES');
  41. $aStorages = array();
  42. foreach($aStoragesKeys as $sKey)
  43. if(!empty($CNF[$sKey]))
  44. $aStorages[] = $CNF[$sKey];
  45. return $this->entryAttachmentsByStorage($aStorages, $aData, $aParams);
  46. }
  47. function entryAuthor ($aData, $iProfileId = false, $sFuncAuthorDesc = 'getAuthorDesc', $sTemplateName = 'author.html', $sFuncAuthorAddon = 'getAuthorAddon')
  48. {
  49. $CNF = &$this->getModule()->_oConfig->CNF;
  50. if (!$iProfileId)
  51. $iProfileId = $aData[$CNF['FIELD_AUTHOR']];
  52. $oProfile = BxDolProfile::getInstanceMagic($iProfileId);
  53. $sName = $oProfile->getDisplayName();
  54. $sAddon = $sFuncAuthorAddon && is_a($oProfile, 'BxDolProfile') ? $this->$sFuncAuthorAddon($aData, $oProfile) : '';
  55. $aVars = array (
  56. 'author_url' => $oProfile->getUrl(),
  57. 'author_thumb_url' => $oProfile->getThumb(),
  58. 'author_unit' => $oProfile->getUnit(0, array('template' => 'unit_wo_info')),
  59. 'author_title' => $sName,
  60. 'author_title_attr' => bx_html_attribute($sName),
  61. 'author_desc' => $sFuncAuthorDesc ? $this->$sFuncAuthorDesc($aData) : '',
  62. 'bx_if:addon' => array (
  63. 'condition' => (bool)$sAddon,
  64. 'content' => array (
  65. 'content' => $sAddon,
  66. ),
  67. ),
  68. );
  69. return $this->parseHtmlByName($sTemplateName, $aVars);
  70. }
  71. function entryContext ($aData, $iProfileId = false, $sFuncContextDesc = 'getContextDesc', $sTemplateName = 'context.html', $sFuncContextAddon = 'getContextAddon')
  72. {
  73. $CNF = &$this->getModule()->_oConfig->CNF;
  74. $iContextId = $aData[$CNF['FIELD_ALLOW_VIEW_TO']];
  75. if ($iContextId >= 0)
  76. return '';
  77. $iProfileId = - $iContextId;
  78. $oProfile = BxDolProfile::getInstance($iProfileId);
  79. if (!$oProfile)
  80. $oProfile = BxDolProfileUndefined::getInstance();
  81. if (!$oProfile)
  82. return '';
  83. $sName = $oProfile->getDisplayName();
  84. $sAddon = $sFuncContextAddon ? $this->$sFuncContextAddon($aData, $oProfile) : '';
  85. $aVars = array (
  86. 'author_url' => $oProfile->getUrl(),
  87. 'author_thumb_url' => $oProfile->getThumb(),
  88. 'author_unit' => $oProfile->getUnit(0, array('template' => 'unit_wo_info')),
  89. 'author_title' => $sName,
  90. 'author_title_attr' => bx_html_attribute($sName),
  91. 'author_desc' => $sFuncContextDesc ? $this->$sFuncContextDesc($aData) : '',
  92. 'bx_if:addon' => array (
  93. 'condition' => (bool)$sAddon,
  94. 'content' => array (
  95. 'content' => $sAddon,
  96. ),
  97. ),
  98. );
  99. return $this->parseHtmlByName($sTemplateName, $aVars);
  100. }
  101. public function entryPolls($aData)
  102. {
  103. $CNF = &$this->getModule()->_oConfig->CNF;
  104. $aPolls = $this->_oDb->getPolls(array(
  105. 'type' => 'content_id',
  106. 'content_id' => $aData[$CNF['FIELD_ID']],
  107. ));
  108. if(empty($aPolls) || !is_array($aPolls))
  109. return;
  110. $iProfileId = bx_get_logged_profile_id();
  111. $sPolls = '';
  112. foreach($aPolls as $aPoll)
  113. $sPolls .= $this->getPollItem($aPoll, $iProfileId);
  114. if(empty($sPolls))
  115. return '';
  116. $this->addCss(array('polls.css'));
  117. $this->addJs(array('polls.js'));
  118. return $this->parseHtmlByName('poll_items.html', array(
  119. 'polls' => $sPolls
  120. ));
  121. }
  122. public function entryPollAnswers($aPoll, $bDynamic = false)
  123. {
  124. $sContent = $this->_getPollAnswers($aPoll, $bDynamic);
  125. if(empty($sContent))
  126. return '';
  127. return array(
  128. 'content' => $sContent,
  129. 'menu' => $this->_getPollBlockMenu($aPoll, 'answers')
  130. );
  131. }
  132. public function entryPollResults($aPoll, $bDynamic = false)
  133. {
  134. $sContent = $this->_getPollResults($aPoll, $bDynamic);
  135. if(empty($sContent))
  136. return '';
  137. return array(
  138. 'content' => $sContent,
  139. 'menu' => $this->_getPollBlockMenu($aPoll, 'results')
  140. );
  141. }
  142. public function getPollForm()
  143. {
  144. $aForm = $this->getModule()->getPollForm();
  145. return $this->parseHtmlByName('poll_form.html', array(
  146. 'js_object' => $this->_oConfig->getJsObject('poll'),
  147. 'form_id' => $aForm['form_id'],
  148. 'form' => $aForm['form'],
  149. ));
  150. }
  151. public function getPollField($iContentId = 0, $iProfileId = 0)
  152. {
  153. if(empty($iProfileId))
  154. $iProfileId = bx_get_logged_profile_id();
  155. $aPolls = array();
  156. if(!empty($iContentId))
  157. $aPolls = array_merge($aPolls, $this->_oDb->getPolls(array(
  158. 'type' => 'content_id',
  159. 'content_id' => $iContentId,
  160. )));
  161. $aPolls = array_merge($aPolls, $this->_oDb->getPolls(array(
  162. 'type' => 'author_id',
  163. 'author_id' => $iProfileId,
  164. 'unused' => true
  165. )));
  166. $sPolls = '';
  167. foreach($aPolls as $aPoll)
  168. $sPolls .= $this->getPollItem($aPoll, $iProfileId, array(
  169. 'manage' => true
  170. ));
  171. return $this->parseHtmlByName('poll_form_field.html', array(
  172. 'html_id' => $this->_oConfig->getHtmlIds('add_poll_form_field'),
  173. 'polls' => $sPolls
  174. ));
  175. }
  176. public function getPollItem($mixedPoll, $iProfileId = 0, $aParams = array())
  177. {
  178. $CNF = &$this->getModule()->_oConfig->CNF;
  179. $aPoll = is_array($mixedPoll) ? $mixedPoll : $this->_oDb->getPolls(array('type' => 'id', 'id' => (int)$mixedPoll));
  180. if(empty($aPoll) || !is_array($aPoll))
  181. return '';
  182. $sJsObject = $this->_oConfig->getJsObject('poll');
  183. $bDynamic = isset($aParams['dynamic']) && $aParams['dynamic'] === true;
  184. $bManage = isset($aParams['manage']) && $aParams['manage'] === true;
  185. $bSwitchMenu = isset($aParams['switch_menu']) ? (bool)$aParams['switch_menu'] : true;
  186. $bForceDisplayAnswers = isset($aParams['force_display_answers']) && (bool)$aParams['force_display_answers'] === true;
  187. $iPollId = (int)$aPoll[$CNF['FIELD_POLL_ID']];
  188. $sPollView = !$bForceDisplayAnswers && $this->_oDb->isPollPerformed($iPollId, $iProfileId) ? 'results' : 'answers';
  189. $sMethod = '_getPoll' . ucfirst($sPollView);
  190. if(!method_exists($this, $sMethod))
  191. return '';
  192. $mixedMenu = '';
  193. if($bSwitchMenu)
  194. $mixedMenu = $this->_getPollBlockMenu($aPoll, $sPollView, array('template' => 'menu_interactive.html'));
  195. return $this->parseHtmlByName('poll_item.html', array(
  196. 'html_id' => $this->_oConfig->getHtmlIds('poll') . $iPollId,
  197. 'bx_if:show_input_hidden' => array(
  198. 'condition' => $bManage,
  199. 'content' => array(
  200. 'name' => $CNF['FIELD_POLL'],
  201. 'id' => $iPollId
  202. )
  203. ),
  204. 'action_menu' => !empty($mixedMenu) ? $mixedMenu->getCode() : '',
  205. 'bx_if:show_action_delete' => array(
  206. 'condition' => $bManage,
  207. 'content' => array(
  208. 'js_object' => $sJsObject,
  209. 'id' => $iPollId
  210. )
  211. ),
  212. 'text' => bx_process_output($aPoll[$CNF['FIELD_POLL_TEXT']], BX_DATA_HTML),
  213. 'content' => $this->$sMethod($aPoll, $bDynamic)
  214. ));
  215. }
  216. protected function _getPollAnswers($aPoll, $bDynamic = false)
  217. {
  218. $CNF = &$this->getModule()->_oConfig->CNF;
  219. $aAnswers = $this->_oDb->getPollAnswers(array('type' => 'poll_id', 'poll_id' => $aPoll[$CNF['FIELD_POLL_ID']]));
  220. if(empty($aAnswers) || !is_array($aAnswers))
  221. return '';
  222. $aTmplVarsAnswers = array();
  223. foreach($aAnswers as $aAnswer) {
  224. $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_POLL_ANSWERS'], $aAnswer['id']);
  225. $aTmplVarsAnswers[] = array(
  226. 'answer' => $oVotes->getElementBlock(array(
  227. 'dynamic_mode' => $bDynamic
  228. ))
  229. );
  230. }
  231. return $this->parseHtmlByName('poll_item_answers.html', array(
  232. 'html_id' => $this->_oConfig->getHtmlIds('poll_content') . $aPoll[$CNF['FIELD_POLL_ID']],
  233. 'bx_repeat:answers' => $aTmplVarsAnswers
  234. ));
  235. }
  236. protected function _getPollResults($aPoll, $bDynamic = false)
  237. {
  238. $CNF = &$this->getModule()->_oConfig->CNF;
  239. $aAnswers = $this->_oDb->getPollAnswers(array('type' => 'poll_id', 'poll_id' => $aPoll[$CNF['FIELD_POLL_ID']]));
  240. if(empty($aAnswers) || !is_array($aAnswers))
  241. return '';
  242. $iTotal = 0;
  243. foreach($aAnswers as $aAnswer)
  244. $iTotal += $aAnswer['votes'];
  245. $aTmplVarsAnswers = array();
  246. foreach($aAnswers as $aAnswer) {
  247. $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_POLL_ANSWERS'], $aAnswer['id']);
  248. $fPercent = $iTotal > 0 ? 100 * (float)$aAnswer['votes']/$iTotal : 0;
  249. $aTmplVarsAnswers[] = array(
  250. 'title' => bx_process_output($aAnswer['title']),
  251. 'width' => (int)round($fPercent) . '%',
  252. 'votes' => $oVotes->getCounter(array('show_counter_empty' => true, 'show_counter_in_brackets' => false)),
  253. 'percent' => _t($CNF['T']['txt_poll_answer_vote_percent'], $iTotal > 0 ? round($fPercent, 2) : 0),
  254. 'js_code' => $oVotes->getJsScript($bDynamic)
  255. );
  256. }
  257. return $this->parseHtmlByName('poll_item_results.html', array(
  258. 'html_id' => $this->_oConfig->getHtmlIds('poll_content') . $aPoll[$CNF['FIELD_POLL_ID']],
  259. 'bx_repeat:answers' => $aTmplVarsAnswers,
  260. ));
  261. }
  262. protected function _getPollBlockMenu($aPoll, $sSelected = '', $aParams = array())
  263. {
  264. $CNF = &$this->getModule()->_oConfig->CNF;
  265. $sPostfix = '-' . time() . rand(0, PHP_INT_MAX);
  266. $sJsObject = $this->_oConfig->getJsObject('poll');
  267. $iPollId = $aPoll[$CNF['FIELD_POLL_ID']];
  268. $aViews = array(
  269. 'answers' => true,
  270. 'results' => $CNF['PARAM_POLL_HIDDEN_RESULTS'] === false || $this->_oDb->isPollPerformed($iPollId, bx_get_logged_profile_id())
  271. );
  272. $aMenu = array();
  273. foreach($aViews as $sView => $bActive) {
  274. if(!$bActive)
  275. continue;
  276. $sId = $this->_oConfig->getHtmlIds('poll_view_link_' . $sView) . $iPollId;
  277. if(!empty($sSelected) && $sSelected == $sView)
  278. $sSelected = $sId;
  279. $aMenu[] = array('id' => $sId, 'name' => $sId, 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changePollView(this, \'' . $sView . '\', ' . $iPollId . ')', 'target' => '_self', 'title' => _t('_bx_posts_txt_poll_view_' . $sView));
  280. }
  281. if(count($aMenu) <= 1)
  282. return '';
  283. $oMenu = new BxTemplMenuInteractive(array(
  284. 'template' => !empty($aParams['template']) ? $aParams['template'] : 'menu_interactive_vertical.html',
  285. 'menu_id' => $this->_oConfig->getHtmlIds('poll_view_menu') . $sPostfix,
  286. 'menu_items' => $aMenu
  287. ));
  288. if(!empty($sSelected))
  289. $oMenu->setSelected('', $sSelected);
  290. return $oMenu;
  291. }
  292. public function getTmplVarsText($aData)
  293. {
  294. $CNF = &$this->getModule()->_oConfig->CNF;
  295. $aVars = parent::getTmplVarsText($aData);
  296. $sImage = '';
  297. $mixedImage = $this->_getHeaderImage($aData);
  298. if($mixedImage !== false) {
  299. if(!empty($mixedImage['object']))
  300. $o = BxDolStorage::getObjectInstance($mixedImage['object']);
  301. else if(!empty($mixedImage['transcoder']))
  302. $o = BxDolTranscoder::getObjectInstance($mixedImage['transcoder']);
  303. if($o)
  304. $sImage = $o->getFileUrlById($mixedImage['id']);
  305. }
  306. $aVars['content_description_before'] = '';
  307. $aVars['content_description_after'] = '';
  308. $aVars['bx_if:show_image'] = array(
  309. 'condition' => !empty($sImage),
  310. 'content' => array(
  311. 'entry_image' => $sImage
  312. )
  313. );
  314. if(!empty($CNF['OBJECT_REACTIONS'])) {
  315. $oReactions = BxDolVote::getObjectInstance($CNF['OBJECT_REACTIONS'], $aData[$CNF['FIELD_ID']]);
  316. if($oReactions)
  317. $aVars['content_description_after'] .= $oReactions->getCounter(array(
  318. 'show_counter' => true
  319. ));
  320. }
  321. return $aVars;
  322. }
  323. function getAuthorDesc ($aData)
  324. {
  325. if (!($a = $this->getAuthorSnippetMenu($aData)) || !isset($a['meta']))
  326. return '';
  327. return $a['meta'];
  328. }
  329. function getContextDesc ($aData)
  330. {
  331. return '';
  332. }
  333. function getAuthorSnippetMenu ($aData)
  334. {
  335. $CNF = &$this->getModule()->_oConfig->CNF;
  336. if (!($oProfile = BxDolProfile::getInstance($aData[$CNF['FIELD_AUTHOR']])))
  337. return array();
  338. return bx_srv($oProfile->getModule(), 'get_snippet_menu_vars', array($oProfile->id()));
  339. }
  340. function getAuthorAddon ($aData, $oProfile)
  341. {
  342. $CNF = &$this->getModule()->_oConfig->CNF;
  343. $sUrl = 'page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id=' . $oProfile->id();
  344. $sUrl = BxDolPermalinks::getInstance()->permalink($sUrl);
  345. return _t($CNF['T']['txt_all_entries_by'], $sUrl, $oProfile->getDisplayName(), $this->getModule()->_oDb->getEntriesNumByAuthor($oProfile->id()));
  346. }
  347. function getContextAddon ($aData, $oProfile)
  348. {
  349. $CNF = &$this->getModule()->_oConfig->CNF;
  350. $sUrl = 'page.php?i=' . $CNF['URI_ENTRIES_BY_CONTEXT'] . '&profile_id=' . $oProfile->id();
  351. $sUrl = BxDolPermalinks::getInstance()->permalink($sUrl);
  352. return _t($CNF['T']['txt_all_entries_in'], $sUrl, $oProfile->getDisplayName(), $this->getModule()->_oDb->getEntriesNumByContext($oProfile->id()));
  353. }
  354. public function entryBreadcrumb($aContentInfo, $aTmplVarsItems = array())
  355. {
  356. $CNF = &BxDolModule::getInstance($this->MODULE)->_oConfig->CNF;
  357. return $this->parseHtmlByName('breadcrumb.html', array(
  358. 'url_home' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']),
  359. 'icon_home' => $CNF['ICON'],
  360. 'bx_repeat:items' => $aTmplVarsItems
  361. ));
  362. }
  363. protected function checkPrivacy ($aData, $isCheckPrivateContent, $oModule, $sTemplateName = '')
  364. {
  365. if ($isCheckPrivateContent && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $oModule->checkAllowedView($aData))) {
  366. $aVars = array (
  367. 'summary' => $sMsg,
  368. );
  369. return $this->parseHtmlByName($sTemplateName ? str_replace('.html', '_private.html', $sTemplateName) : 'unit_private.html', $aVars);
  370. }
  371. return '';
  372. }
  373. protected function getUnitThumbAndGallery ($aData)
  374. {
  375. $CNF = &BxDolModule::getInstance($this->MODULE)->_oConfig->CNF;
  376. $sPhotoThumb = '';
  377. $sPhotoGallery = '';
  378. if(!empty($CNF['FIELD_THUMB']) && !empty($aData[$CNF['FIELD_THUMB']])) {
  379. $oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW']);
  380. if ($oImagesTranscoder)
  381. $sPhotoThumb = $oImagesTranscoder->getFileUrl($aData[$CNF['FIELD_THUMB']]);
  382. $oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']);
  383. if ($oImagesTranscoder)
  384. $sPhotoGallery = $oImagesTranscoder->getFileUrl($aData[$CNF['FIELD_THUMB']]);
  385. else
  386. $sPhotoGallery = $sPhotoThumb;
  387. }
  388. return array($sPhotoThumb, $sPhotoGallery);
  389. }
  390. protected function getUnit ($aData, $aParams = array())
  391. {
  392. $CNF = &BxDolModule::getInstance($this->MODULE)->_oConfig->CNF;
  393. // get thumb url
  394. list($sPhotoThumb, $sPhotoGallery) = $this->getUnitThumbAndGallery($aData);
  395. // get entry url
  396. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aData[$CNF['FIELD_ID']]);
  397. $oProfile = BxDolProfile::getInstanceMagic($aData[$CNF['FIELD_AUTHOR']]);
  398. $sTitle = $this->getTitle($aData);
  399. $sText = $this->getText($aData);
  400. $sSummary = $this->getSummary($aData, $sTitle, $sText, $sUrl);
  401. $sSummaryPlain = isset($CNF['PARAM_CHARS_SUMMARY_PLAIN']) && $CNF['PARAM_CHARS_SUMMARY_PLAIN'] ? BxTemplFunctions::getInstance()->getStringWithLimitedLength(strip_tags($sSummary), (int)getParam($CNF['PARAM_CHARS_SUMMARY_PLAIN'])) : '';
  402. if(!empty($CNF['OBJECT_METATAGS'])) {
  403. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  404. $sText = $oMetatags->metaParse($aData[$CNF['FIELD_ID']], $sText);
  405. }
  406. $sTitle = bx_process_output($sTitle);
  407. $aTmplVarsMeta = array();
  408. if(!empty($CNF['OBJECT_MENU_SNIPPET_META'])) {
  409. $oMenuMeta = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_SNIPPET_META'], $this);
  410. if($oMenuMeta) {
  411. $oMenuMeta->setContentId($aData[$CNF['FIELD_ID']]);
  412. $aTmplVarsMeta = array(
  413. 'meta' => $oMenuMeta->getCode()
  414. );
  415. }
  416. }
  417. // generate html
  418. return array (
  419. 'class' => $this->_getUnitClass($aData,(isset($aParams['template_name']) ? $aParams['template_name'] : '')),
  420. 'id' => $aData[$CNF['FIELD_ID']],
  421. 'content_url' => $sUrl,
  422. 'title' => $sTitle,
  423. 'title_attr' => bx_html_attribute($sTitle),
  424. 'summary' => $sSummary,
  425. 'text' => $sText,
  426. 'author' => $oProfile->getDisplayName(),
  427. 'author_url' => $oProfile->getUrl(),
  428. 'author_icon' => $oProfile->getIcon(),
  429. 'author_thumb' => $oProfile->getThumb(),
  430. 'author_avatar' => $oProfile->getAvatar(),
  431. 'entry_posting_date' => bx_time_js($aData[$CNF['FIELD_ADDED']], BX_FORMAT_DATE),
  432. 'module_name' => _t($CNF['T']['txt_sample_single']),
  433. 'ts' => $aData[$CNF['FIELD_ADDED']],
  434. 'bx_if:meta' => array(
  435. 'condition' => !empty($aTmplVarsMeta),
  436. 'content' => $aTmplVarsMeta
  437. ),
  438. 'bx_if:thumb' => array (
  439. 'condition' => $sPhotoThumb,
  440. 'content' => array (
  441. 'title' => $sTitle,
  442. 'summary_attr' => bx_html_attribute($sSummaryPlain),
  443. 'content_url' => $sUrl,
  444. 'thumb_url' => $sPhotoThumb ? $sPhotoThumb : '',
  445. 'gallery_url' => $sPhotoGallery ? $sPhotoGallery : '',
  446. 'strecher' => str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ', 40),
  447. ),
  448. ),
  449. 'bx_if:no_thumb' => array (
  450. 'condition' => !$sPhotoThumb,
  451. 'content' => array (
  452. 'content_url' => $sUrl,
  453. 'summary_plain' => $sSummaryPlain,
  454. 'strecher' => mb_strlen($sSummaryPlain) > 240 ? '' : str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ', round((240 - mb_strlen($sSummaryPlain)) / 6)),
  455. ),
  456. ),
  457. );
  458. }
  459. protected function getTitle($aData)
  460. {
  461. $CNF = &$this->getModule()->_oConfig->CNF;
  462. return isset($aData[$CNF['FIELD_TITLE']]) ? $aData[$CNF['FIELD_TITLE']] : '';
  463. }
  464. protected function getText($aData)
  465. {
  466. $CNF = &$this->getModule()->_oConfig->CNF;
  467. return isset($aData[$CNF['FIELD_TEXT']]) ? $aData[$CNF['FIELD_TEXT']] : '';
  468. }
  469. protected function getSummary($aData, $sTitle = '', $sText = '', $sUrl = '')
  470. {
  471. $CNF = &$this->getModule()->_oConfig->CNF;
  472. if(empty($CNF['PARAM_CHARS_SUMMARY']))
  473. return '';
  474. // get summary
  475. $sLinkMore = ' <a title="' . bx_html_attribute(_t('_sys_read_more', $sTitle)) . '" href="' . $sUrl . '"><i class="sys-icon ellipsis-h"></i></a>';
  476. return strmaxtextlen($sText, (int)getParam($CNF['PARAM_CHARS_SUMMARY']), $sLinkMore);
  477. }
  478. protected function getAttachmentsImagesTranscoders ($sStorage = '')
  479. {
  480. $CNF = &$this->getModule()->_oConfig->CNF;
  481. $oTranscoder = null;
  482. $oTranscoderView = null;
  483. switch($sStorage) {
  484. case $CNF['OBJECT_STORAGE_PHOTOS']:
  485. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS']))
  486. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS']);
  487. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS']))
  488. $oTranscoderView = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS']);
  489. break;
  490. case $CNF['OBJECT_STORAGE_FILES']:
  491. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_FILES']))
  492. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_FILES']);
  493. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_FILES']))
  494. $oTranscoderView = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_FILES']);
  495. break;
  496. }
  497. return array($oTranscoder, $oTranscoderView);
  498. }
  499. protected function _getUnitClass($aData, $sTemplateName = 'unit.html')
  500. {
  501. $sResult = '';
  502. switch($sTemplateName) {
  503. case 'unit_showcase.html':
  504. $sResult = $this->_sUnitClassShowCase;
  505. break;
  506. }
  507. return $sResult;
  508. }
  509. protected function _getHeaderImage($aData)
  510. {
  511. return $this->getModule()->getEntryImageData($aData);
  512. }
  513. }
  514. /** @} */