BxBaseModTextTemplate.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  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');
  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. 'bx_if:show_autosizing' => array(
  120. 'condition' => true,
  121. 'content' => array()
  122. ),
  123. 'polls' => $sPolls
  124. ));
  125. }
  126. public function entryPollAnswers($aPoll, $bDynamic = false)
  127. {
  128. $sContent = $this->_getPollAnswers($aPoll, $bDynamic);
  129. if(empty($sContent))
  130. return '';
  131. return array(
  132. 'content' => $sContent,
  133. 'menu' => $this->_getPollBlockMenu($aPoll, 'answers')
  134. );
  135. }
  136. public function entryPollResults($aPoll, $bDynamic = false)
  137. {
  138. $sContent = $this->_getPollResults($aPoll, $bDynamic);
  139. if(empty($sContent))
  140. return '';
  141. return array(
  142. 'content' => $sContent,
  143. 'menu' => $this->_getPollBlockMenu($aPoll, 'results')
  144. );
  145. }
  146. public function getPollForm()
  147. {
  148. $aForm = $this->getModule()->getPollForm();
  149. return $this->parseHtmlByName('poll_form.html', array(
  150. 'js_object' => $this->_oConfig->getJsObject('poll'),
  151. 'form_id' => $aForm['form_id'],
  152. 'form' => $aForm['form'],
  153. ));
  154. }
  155. public function getPollField($iContentId = 0, $iProfileId = 0)
  156. {
  157. if(empty($iProfileId))
  158. $iProfileId = bx_get_logged_profile_id();
  159. $aPolls = array();
  160. if(!empty($iContentId))
  161. $aPolls = array_merge($aPolls, $this->_oDb->getPolls(array(
  162. 'type' => 'content_id',
  163. 'content_id' => $iContentId,
  164. )));
  165. $aPolls = array_merge($aPolls, $this->_oDb->getPolls(array(
  166. 'type' => 'author_id',
  167. 'author_id' => $iProfileId,
  168. 'unused' => true
  169. )));
  170. $sPolls = '';
  171. foreach($aPolls as $aPoll)
  172. $sPolls .= $this->getPollItem($aPoll, $iProfileId, array(
  173. 'manage' => true
  174. ));
  175. return $this->parseHtmlByName('poll_form_field.html', array(
  176. 'html_id' => $this->_oConfig->getHtmlIds('add_poll_form_field'),
  177. 'polls' => $sPolls
  178. ));
  179. }
  180. public function getPollItem($mixedPoll, $iProfileId = 0, $aParams = array())
  181. {
  182. $CNF = &$this->getModule()->_oConfig->CNF;
  183. $aPoll = is_array($mixedPoll) ? $mixedPoll : $this->_oDb->getPolls(array('type' => 'id', 'id' => (int)$mixedPoll));
  184. if(empty($aPoll) || !is_array($aPoll))
  185. return '';
  186. $sJsObject = $this->_oConfig->getJsObject('poll');
  187. $bDynamic = isset($aParams['dynamic']) && $aParams['dynamic'] === true;
  188. $bManage = isset($aParams['manage']) && $aParams['manage'] === true;
  189. $bSwitchMenu = isset($aParams['switch_menu']) ? (bool)$aParams['switch_menu'] : true;
  190. $bForceDisplayAnswers = isset($aParams['force_display_answers']) && (bool)$aParams['force_display_answers'] === true;
  191. $iPollId = (int)$aPoll[$CNF['FIELD_POLL_ID']];
  192. $sPollView = !$bForceDisplayAnswers && $this->_oDb->isPollPerformed($iPollId, $iProfileId) ? 'results' : 'answers';
  193. $sMethod = '_getPoll' . ucfirst($sPollView);
  194. if(!method_exists($this, $sMethod))
  195. return '';
  196. $mixedMenu = '';
  197. if($bSwitchMenu)
  198. $mixedMenu = $this->_getPollBlockMenu($aPoll, $sPollView, array('template' => 'menu_interactive.html'));
  199. return $this->parseHtmlByName('poll_item.html', array(
  200. 'html_id' => $this->_oConfig->getHtmlIds('poll') . $iPollId,
  201. 'bx_if:show_input_hidden' => array(
  202. 'condition' => $bManage,
  203. 'content' => array(
  204. 'name' => $CNF['FIELD_POLL'],
  205. 'id' => $iPollId
  206. )
  207. ),
  208. 'action_menu' => !empty($mixedMenu) ? $mixedMenu->getCode() : '',
  209. 'bx_if:show_action_delete' => array(
  210. 'condition' => $bManage,
  211. 'content' => array(
  212. 'js_object' => $sJsObject,
  213. 'id' => $iPollId
  214. )
  215. ),
  216. 'text' => bx_process_output($aPoll[$CNF['FIELD_POLL_TEXT']], BX_DATA_HTML),
  217. 'content' => $this->$sMethod($aPoll, $bDynamic)
  218. ));
  219. }
  220. protected function _getPollAnswers($aPoll, $bDynamic = false)
  221. {
  222. $CNF = &$this->getModule()->_oConfig->CNF;
  223. $aAnswers = $this->_oDb->getPollAnswers(array('type' => 'poll_id', 'poll_id' => $aPoll[$CNF['FIELD_POLL_ID']]));
  224. if(empty($aAnswers) || !is_array($aAnswers))
  225. return '';
  226. $aTmplVarsAnswers = array();
  227. foreach($aAnswers as $aAnswer) {
  228. $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_POLL_ANSWERS'], $aAnswer['id']);
  229. $aTmplVarsAnswers[] = array(
  230. 'answer' => $oVotes->getElementBlock(array(
  231. 'dynamic_mode' => $bDynamic
  232. ))
  233. );
  234. }
  235. return $this->parseHtmlByName('poll_item_answers.html', array(
  236. 'html_id' => $this->_oConfig->getHtmlIds('poll_content') . $aPoll[$CNF['FIELD_POLL_ID']],
  237. 'bx_repeat:answers' => $aTmplVarsAnswers
  238. ));
  239. }
  240. protected function _getPollResults($aPoll, $bDynamic = false)
  241. {
  242. $CNF = &$this->getModule()->_oConfig->CNF;
  243. $aAnswers = $this->_oDb->getPollAnswers(array('type' => 'poll_id', 'poll_id' => $aPoll[$CNF['FIELD_POLL_ID']]));
  244. if(empty($aAnswers) || !is_array($aAnswers))
  245. return '';
  246. $iTotal = 0;
  247. foreach($aAnswers as $aAnswer)
  248. $iTotal += $aAnswer['votes'];
  249. $aTmplVarsAnswers = array();
  250. foreach($aAnswers as $aAnswer) {
  251. $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_POLL_ANSWERS'], $aAnswer['id']);
  252. $fPercent = $iTotal > 0 ? 100 * (float)$aAnswer['votes']/$iTotal : 0;
  253. $aTmplVarsAnswers[] = array(
  254. 'title' => bx_process_output($aAnswer['title']),
  255. 'width' => (int)round($fPercent) . '%',
  256. 'votes' => $oVotes->getCounter(array('show_counter_empty' => true, 'show_counter_in_brackets' => false)),
  257. 'percent' => _t($CNF['T']['txt_poll_answer_vote_percent'], $iTotal > 0 ? round($fPercent, 2) : 0),
  258. 'js_code' => $oVotes->getJsScript($bDynamic)
  259. );
  260. }
  261. return $this->parseHtmlByName('poll_item_results.html', array(
  262. 'html_id' => $this->_oConfig->getHtmlIds('poll_content') . $aPoll[$CNF['FIELD_POLL_ID']],
  263. 'bx_repeat:answers' => $aTmplVarsAnswers,
  264. ));
  265. }
  266. protected function _getPollBlockMenu($aPoll, $sSelected = '', $aParams = array())
  267. {
  268. $CNF = &$this->getModule()->_oConfig->CNF;
  269. $sPostfix = '-' . time() . rand(0, PHP_INT_MAX);
  270. $sJsObject = $this->_oConfig->getJsObject('poll');
  271. $iPollId = $aPoll[$CNF['FIELD_POLL_ID']];
  272. $aViews = array(
  273. 'answers' => true,
  274. 'results' => $CNF['PARAM_POLL_HIDDEN_RESULTS'] === false || $this->_oDb->isPollPerformed($iPollId, bx_get_logged_profile_id())
  275. );
  276. $aMenu = array();
  277. foreach($aViews as $sView => $bActive) {
  278. if(!$bActive)
  279. continue;
  280. $sId = $this->_oConfig->getHtmlIds('poll_view_link_' . $sView) . $iPollId . $sPostfix;
  281. if(!empty($sSelected) && $sSelected == $sView)
  282. $sSelected = $sId;
  283. $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));
  284. }
  285. if(count($aMenu) <= 1)
  286. return '';
  287. $oMenu = new BxTemplMenuInteractive(array(
  288. 'template' => !empty($aParams['template']) ? $aParams['template'] : 'menu_interactive_vertical.html',
  289. 'menu_id' => $this->_oConfig->getHtmlIds('poll_view_menu') . $sPostfix,
  290. 'menu_items' => $aMenu
  291. ));
  292. if(!empty($sSelected))
  293. $oMenu->setSelected('', $sSelected);
  294. return $oMenu;
  295. }
  296. public function getTmplVarsText($aData)
  297. {
  298. $aVars = parent::getTmplVarsText($aData);
  299. $sImage = '';
  300. $mixedImage = $this->_getHeaderImage($aData);
  301. if($mixedImage !== false) {
  302. if(!empty($mixedImage['object']))
  303. $o = BxDolStorage::getObjectInstance($mixedImage['object']);
  304. else if(!empty($mixedImage['transcoder']))
  305. $o = BxDolTranscoder::getObjectInstance($mixedImage['transcoder']);
  306. if($o)
  307. $sImage = $o->getFileUrlById($mixedImage['id']);
  308. }
  309. $aVars['bx_if:show_image'] = array(
  310. 'condition' => !empty($sImage),
  311. 'content' => array(
  312. 'entry_image' => $sImage
  313. )
  314. );
  315. return $aVars;
  316. }
  317. function getAuthorDesc ($aData)
  318. {
  319. if (!($a = $this->getAuthorSnippetMenu($aData)) || !isset($a['meta']))
  320. return '';
  321. return $a['meta'];
  322. }
  323. function getContextDesc ($aData)
  324. {
  325. return '';
  326. }
  327. function getAuthorSnippetMenu ($aData)
  328. {
  329. $CNF = &$this->getModule()->_oConfig->CNF;
  330. if (!($oProfile = BxDolProfile::getInstance($aData[$CNF['FIELD_AUTHOR']])))
  331. return array();
  332. return bx_srv($oProfile->getModule(), 'get_snippet_menu_vars', array($oProfile->id()));
  333. }
  334. function getAuthorAddon ($aData, $oProfile)
  335. {
  336. $CNF = &$this->getModule()->_oConfig->CNF;
  337. $sUrl = 'page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id=' . $oProfile->id();
  338. $sUrl = BxDolPermalinks::getInstance()->permalink($sUrl);
  339. return _t($CNF['T']['txt_all_entries_by'], $sUrl, $oProfile->getDisplayName(), $this->getModule()->_oDb->getEntriesNumByAuthor($oProfile->id()));
  340. }
  341. function getContextAddon ($aData, $oProfile)
  342. {
  343. $CNF = &$this->getModule()->_oConfig->CNF;
  344. $sUrl = 'page.php?i=' . $CNF['URI_ENTRIES_BY_CONTEXT'] . '&profile_id=' . $oProfile->id();
  345. $sUrl = BxDolPermalinks::getInstance()->permalink($sUrl);
  346. return _t($CNF['T']['txt_all_entries_in'], $sUrl, $oProfile->getDisplayName(), $this->getModule()->_oDb->getEntriesNumByContext($oProfile->id()));
  347. }
  348. public function entryBreadcrumb($aContentInfo, $aTmplVarsItems = array())
  349. {
  350. $CNF = &BxDolModule::getInstance($this->MODULE)->_oConfig->CNF;
  351. return $this->parseHtmlByName('breadcrumb.html', array(
  352. 'url_home' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']),
  353. 'icon_home' => $CNF['ICON'],
  354. 'bx_repeat:items' => $aTmplVarsItems
  355. ));
  356. }
  357. protected function checkPrivacy ($aData, $isCheckPrivateContent, $oModule, $sTemplateName = '')
  358. {
  359. if ($isCheckPrivateContent && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $oModule->checkAllowedView($aData))) {
  360. $aVars = array (
  361. 'summary' => $sMsg,
  362. );
  363. return $this->parseHtmlByName($sTemplateName ? str_replace('.html', '_private.html', $sTemplateName) : 'unit_private.html', $aVars);
  364. }
  365. return '';
  366. }
  367. protected function getUnitThumbAndGallery ($aData)
  368. {
  369. $CNF = &BxDolModule::getInstance($this->MODULE)->_oConfig->CNF;
  370. $sPhotoThumb = '';
  371. $sPhotoGallery = '';
  372. if(!empty($CNF['FIELD_THUMB']) && !empty($aData[$CNF['FIELD_THUMB']])) {
  373. $oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW']);
  374. if ($oImagesTranscoder)
  375. $sPhotoThumb = $oImagesTranscoder->getFileUrl($aData[$CNF['FIELD_THUMB']]);
  376. $oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']);
  377. if ($oImagesTranscoder)
  378. $sPhotoGallery = $oImagesTranscoder->getFileUrl($aData[$CNF['FIELD_THUMB']]);
  379. else
  380. $sPhotoGallery = $sPhotoThumb;
  381. }
  382. return array($sPhotoThumb, $sPhotoGallery);
  383. }
  384. protected function getUnit ($aData, $aParams = array())
  385. {
  386. $CNF = &BxDolModule::getInstance($this->MODULE)->_oConfig->CNF;
  387. // get thumb url
  388. list($sPhotoThumb, $sPhotoGallery) = $this->getUnitThumbAndGallery($aData);
  389. // get entry url
  390. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aData[$CNF['FIELD_ID']]);
  391. $oProfile = BxDolProfile::getInstanceMagic($aData[$CNF['FIELD_AUTHOR']]);
  392. $sTitle = $this->getTitle($aData);
  393. $sText = $this->getText($aData);
  394. $sSummary = $this->getSummary($aData, $sTitle, $sText, $sUrl);
  395. $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'])) : '';
  396. if(!empty($CNF['OBJECT_METATAGS'])) {
  397. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  398. $sText = $oMetatags->metaParse($aData[$CNF['FIELD_ID']], $sText);
  399. }
  400. $sTitle = bx_process_output($sTitle);
  401. $aTmplVarsMeta = array();
  402. if(!empty($CNF['OBJECT_MENU_SNIPPET_META'])) {
  403. $oMenuMeta = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_SNIPPET_META'], $this);
  404. if($oMenuMeta) {
  405. $oMenuMeta->setContentId($aData[$CNF['FIELD_ID']]);
  406. $aTmplVarsMeta = array(
  407. 'meta' => $oMenuMeta->getCode()
  408. );
  409. }
  410. }
  411. // generate html
  412. return array (
  413. 'class' => $this->_getUnitClass($aData,(isset($aParams['template_name']) ? $aParams['template_name'] : '')),
  414. 'id' => $aData[$CNF['FIELD_ID']],
  415. 'content_url' => $sUrl,
  416. 'title' => $sTitle,
  417. 'title_attr' => bx_html_attribute($sTitle),
  418. 'summary' => $sSummary,
  419. 'text' => $sText,
  420. 'author' => $oProfile->getDisplayName(),
  421. 'author_url' => $oProfile->getUrl(),
  422. 'author_icon' => $oProfile->getIcon(),
  423. 'author_thumb' => $oProfile->getThumb(),
  424. 'author_avatar' => $oProfile->getAvatar(),
  425. 'entry_posting_date' => bx_time_js($aData[$CNF['FIELD_ADDED']], BX_FORMAT_DATE),
  426. 'module_name' => _t($CNF['T']['txt_sample_single']),
  427. 'ts' => $aData[$CNF['FIELD_ADDED']],
  428. 'bx_if:meta' => array(
  429. 'condition' => !empty($aTmplVarsMeta),
  430. 'content' => $aTmplVarsMeta
  431. ),
  432. 'bx_if:thumb' => array (
  433. 'condition' => $sPhotoThumb,
  434. 'content' => array (
  435. 'title' => $sTitle,
  436. 'summary_attr' => bx_html_attribute($sSummaryPlain),
  437. 'content_url' => $sUrl,
  438. 'thumb_url' => $sPhotoThumb ? $sPhotoThumb : '',
  439. 'gallery_url' => $sPhotoGallery ? $sPhotoGallery : '',
  440. 'strecher' => str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ', 40),
  441. ),
  442. ),
  443. 'bx_if:no_thumb' => array (
  444. 'condition' => !$sPhotoThumb,
  445. 'content' => array (
  446. 'content_url' => $sUrl,
  447. 'summary_plain' => $sSummaryPlain,
  448. 'strecher' => mb_strlen($sSummaryPlain) > 240 ? '' : str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ', round((240 - mb_strlen($sSummaryPlain)) / 6)),
  449. ),
  450. ),
  451. );
  452. }
  453. protected function getTitle($aData)
  454. {
  455. $CNF = &$this->getModule()->_oConfig->CNF;
  456. return isset($aData[$CNF['FIELD_TITLE']]) ? $aData[$CNF['FIELD_TITLE']] : '';
  457. }
  458. protected function getText($aData)
  459. {
  460. $CNF = &$this->getModule()->_oConfig->CNF;
  461. return isset($aData[$CNF['FIELD_TEXT']]) ? $aData[$CNF['FIELD_TEXT']] : '';
  462. }
  463. protected function getSummary($aData, $sTitle = '', $sText = '', $sUrl = '')
  464. {
  465. $CNF = &$this->getModule()->_oConfig->CNF;
  466. if(empty($CNF['PARAM_CHARS_SUMMARY']))
  467. return '';
  468. // get summary
  469. $sLinkMore = ' <a title="' . bx_html_attribute(_t('_sys_read_more', $sTitle)) . '" href="' . $sUrl . '"><i class="sys-icon ellipsis-h"></i></a>';
  470. return strmaxtextlen($sText, (int)getParam($CNF['PARAM_CHARS_SUMMARY']), $sLinkMore);
  471. }
  472. protected function getAttachmentsImagesTranscoders ()
  473. {
  474. $CNF = &$this->getModule()->_oConfig->CNF;
  475. $oTranscoder = null;
  476. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS']))
  477. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS']);
  478. $oTranscoderView = null;
  479. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_PICTURE_PHOTOS']))
  480. $oTranscoderView = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PICTURE_PHOTOS']);
  481. return array($oTranscoder, $oTranscoderView);
  482. }
  483. protected function _getUnitClass($aData, $sTemplateName = 'unit.html')
  484. {
  485. $sResult = '';
  486. switch($sTemplateName) {
  487. case 'unit_showcase.html':
  488. $sResult = $this->_sUnitClassShowCase;
  489. break;
  490. }
  491. return $sResult;
  492. }
  493. protected function _getHeaderImage($aData)
  494. {
  495. return $this->getModule()->getEntryImageData($aData);
  496. }
  497. }
  498. /** @} */