BxBaseModTextTemplate.php 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  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 addLocationBase()
  23. {
  24. parent::addLocationBase();
  25. $this->addLocation('mod_text', BX_DIRECTORY_PATH_MODULES . 'base' . DIRECTORY_SEPARATOR . 'text' . DIRECTORY_SEPARATOR, BX_DOL_URL_MODULES . 'base/text/');
  26. }
  27. public function getJsCode($sType, $aParams = array(), $bWrap = true)
  28. {
  29. $CNF = &$this->getModule()->_oConfig->CNF;
  30. $aParams = array_merge(array(
  31. 'aHtmlIds' => $this->_oConfig->getHtmlIds(),
  32. 'sEditorId' => isset($CNF['FIELD_TEXT_ID']) ? $CNF['FIELD_TEXT_ID'] : ''
  33. ), $aParams);
  34. return parent::getJsCode($sType, $aParams, $bWrap);
  35. }
  36. function unit ($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html', $aParams = array())
  37. {
  38. if(!empty($aParams['template_name']))
  39. $sTemplateName = $aParams['template_name'];
  40. else
  41. $aParams['template_name'] = $sTemplateName;
  42. $sResult = $this->checkPrivacy ($aData, $isCheckPrivateContent, $this->getModule(), $sTemplateName);
  43. if($sResult)
  44. return $sResult;
  45. $aTemplateVars = $this->getUnit($aData, $aParams);
  46. bx_alert($this->getModule()->getName(), 'unit', 0, 0, array(
  47. 'data' => $aData,
  48. 'check_private_content' => $isCheckPrivateContent,
  49. 'template' => $sTemplateName,
  50. 'params' => $aParams,
  51. 'tmpl_name' => &$sTemplateName,
  52. 'tmpl_vars' => &$aTemplateVars
  53. ));
  54. return $this->parseHtmlByName($sTemplateName, $aTemplateVars);
  55. }
  56. function entryAttachments ($aData, $aParams = array())
  57. {
  58. $CNF = &$this->getModule()->_oConfig->CNF;
  59. $aStoragesKeys = array('OBJECT_STORAGE_PHOTOS', 'OBJECT_STORAGE_VIDEOS', 'OBJECT_STORAGE_SOUNDS', 'OBJECT_STORAGE_FILES');
  60. $aStorages = array();
  61. foreach($aStoragesKeys as $sKey)
  62. if(!empty($CNF[$sKey]))
  63. $aStorages[] = $CNF[$sKey];
  64. if(!empty($aStorages))
  65. return $this->entryAttachmentsByStorage($aStorages, $aData, array_merge($aParams, array('filter_field' => '')));
  66. return parent::entryAttachments($aData, $aParams);
  67. }
  68. function entryAuthor ($aData, $iProfileId = false, $sFuncAuthorDesc = 'getAuthorDesc', $sTemplateName = 'author.html', $sFuncAuthorAddon = 'getAuthorAddon')
  69. {
  70. $oModule = $this->getModule();
  71. $CNF = &$oModule->_oConfig->CNF;
  72. if (!$iProfileId)
  73. $iProfileId = $aData[$CNF['FIELD_AUTHOR']];
  74. if(bx_is_api())
  75. return [bx_api_get_block('entity_author', [
  76. 'author_data' => BxDolProfile::getData($iProfileId),
  77. 'entry_date' => !empty($CNF['FIELD_ADDED']) && !empty($aData[$CNF['FIELD_ADDED']]) ? $aData[$CNF['FIELD_ADDED']] : '',
  78. 'menu_manage' => $oModule->getEntryAllActions()
  79. ])];
  80. $oProfile = BxDolProfile::getInstanceMagic($iProfileId);
  81. $sName = $oProfile->getDisplayName();
  82. $sAddon = $sFuncAuthorAddon && is_a($oProfile, 'BxDolProfile') ? $this->$sFuncAuthorAddon($aData, $oProfile) : '';
  83. return $this->parseHtmlByName($sTemplateName, [
  84. 'author_url' => $oProfile->getUrl(),
  85. 'author_thumb_url' => $oProfile->getThumb(),
  86. 'author_unit' => $oProfile->getUnit(0, ['template' => 'unit_wo_info']),
  87. 'author_title' => $sName,
  88. 'author_title_attr' => bx_html_attribute($sName),
  89. 'author_desc' => $sFuncAuthorDesc ? $this->$sFuncAuthorDesc($aData, $oProfile) : '',
  90. 'author_profile_desc' => $this->getAuthorProfileDesc($aData, $oProfile),
  91. 'bx_if:addon' => [
  92. 'condition' => (bool)$sAddon,
  93. 'content' => [
  94. 'content' => $sAddon,
  95. ],
  96. ],
  97. ]);
  98. }
  99. public function entryBreadcrumb($aContentInfo, $aTmplVarsItems = array())
  100. {
  101. if(!empty($aTmplVarsItems) && is_array($aTmplVarsItems))
  102. return parent::entryBreadcrumb($aContentInfo, $aTmplVarsItems);
  103. $CNF = &$this->getModule()->_oConfig->CNF;
  104. $aTmplVarsItems = array();
  105. if(!empty($CNF['OBJECT_CATEGORY']) && !empty($CNF['FIELD_CATEGORY'])) {
  106. $oCategory = BxDolCategory::getObjectInstance($CNF['OBJECT_CATEGORY']);
  107. $aTmplVarsItems[] = array(
  108. 'url' => $oCategory->getCategoryUrl($aContentInfo[$CNF['FIELD_CATEGORY']]),
  109. 'title' => $oCategory->getCategoryTitle($aContentInfo[$CNF['FIELD_CATEGORY']])
  110. );
  111. }
  112. $aTmplVarsItems[] = array(
  113. 'url' => BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]),
  114. 'title' => bx_process_output($aContentInfo[$CNF['FIELD_TITLE']])
  115. );
  116. return parent::entryBreadcrumb($aContentInfo, $aTmplVarsItems);
  117. }
  118. public function entryPolls($aData)
  119. {
  120. $CNF = &$this->getModule()->_oConfig->CNF;
  121. $aPolls = $this->_oDb->getPolls(array(
  122. 'type' => 'content_id',
  123. 'content_id' => $aData[$CNF['FIELD_ID']],
  124. ));
  125. if(empty($aPolls) || !is_array($aPolls))
  126. return;
  127. $iProfileId = bx_get_logged_profile_id();
  128. $sPolls = '';
  129. foreach($aPolls as $aPoll)
  130. $sPolls .= $this->getPollItem($aPoll, $iProfileId);
  131. if(empty($sPolls))
  132. return '';
  133. $this->_addCssJs();
  134. return $this->getJsCode('poll') . $this->parseHtmlByName('poll_items.html', array(
  135. 'polls' => $sPolls
  136. ));
  137. }
  138. public function entryPollAnswers($aPoll, $bDynamic = false)
  139. {
  140. $sContent = $this->_getPollAnswers($aPoll, $bDynamic);
  141. if(empty($sContent))
  142. return '';
  143. return array(
  144. 'content' => $sContent,
  145. 'menu' => $this->_getPollBlockMenu($aPoll, 'answers')
  146. );
  147. }
  148. public function entryPollResults($aPoll, $bDynamic = false)
  149. {
  150. $sContent = $this->_getPollResults($aPoll, $bDynamic);
  151. if(empty($sContent))
  152. return '';
  153. return array(
  154. 'content' => $sContent,
  155. 'menu' => $this->_getPollBlockMenu($aPoll, 'results')
  156. );
  157. }
  158. public function getPollForm()
  159. {
  160. $aForm = $this->getModule()->getPollForm();
  161. return $this->parseHtmlByName('poll_form.html', array(
  162. 'js_object' => $this->_oConfig->getJsObject('poll'),
  163. 'form_id' => $aForm['form_id'],
  164. 'form' => $aForm['form'],
  165. ));
  166. }
  167. public function getPollField($iContentId = 0, $iProfileId = 0)
  168. {
  169. if(empty($iProfileId))
  170. $iProfileId = bx_get_logged_profile_id();
  171. $aPolls = array();
  172. if(!empty($iContentId))
  173. $aPolls = array_merge($aPolls, $this->_oDb->getPolls(array(
  174. 'type' => 'content_id',
  175. 'content_id' => $iContentId,
  176. )));
  177. $aPolls = array_merge($aPolls, $this->_oDb->getPolls(array(
  178. 'type' => 'author_id',
  179. 'author_id' => $iProfileId,
  180. 'unused' => true
  181. )));
  182. $sPolls = '';
  183. foreach($aPolls as $aPoll)
  184. $sPolls .= $this->getPollItem($aPoll, $iProfileId, array(
  185. 'manage' => true
  186. ));
  187. return $this->parseHtmlByName('poll_form_field.html', array(
  188. 'html_id' => $this->_oConfig->getHtmlIds('add_poll_form_field'),
  189. 'polls' => $sPolls
  190. ));
  191. }
  192. public function getPollItem($mixedPoll, $iProfileId = 0, $aParams = array())
  193. {
  194. $oModule = $this->getModule();
  195. $CNF = &$oModule->_oConfig->CNF;
  196. $aPoll = is_array($mixedPoll) ? $mixedPoll : $this->_oDb->getPolls(array('type' => 'id', 'id' => (int)$mixedPoll));
  197. if(empty($aPoll) || !is_array($aPoll))
  198. return '';
  199. $sJsObject = $this->_oConfig->getJsObject('poll');
  200. $bDynamic = isset($aParams['dynamic']) && $aParams['dynamic'] === true;
  201. $bManage = isset($aParams['manage']) && $aParams['manage'] === true;
  202. $bSwitchMenu = isset($aParams['switch_menu']) ? (bool)$aParams['switch_menu'] : true;
  203. $bForceDisplayAnswers = isset($aParams['force_display_answers']) && (bool)$aParams['force_display_answers'] === true;
  204. $iPollId = (int)$aPoll[$CNF['FIELD_POLL_ID']];
  205. $sPollView = !$bForceDisplayAnswers && $oModule->isPollPerformed($iPollId, $iProfileId) ? 'results' : 'answers';
  206. $sMethod = '_getPoll' . ucfirst($sPollView);
  207. if(!method_exists($this, $sMethod))
  208. return '';
  209. $mixedMenu = '';
  210. if($bSwitchMenu)
  211. $mixedMenu = $this->_getPollBlockMenu($aPoll, $sPollView, array('template' => 'menu_interactive.html'));
  212. return $this->parseHtmlByName('poll_item.html', array(
  213. 'html_id' => $this->_oConfig->getHtmlIds('poll') . $iPollId,
  214. 'bx_if:show_input_hidden' => array(
  215. 'condition' => $bManage,
  216. 'content' => array(
  217. 'name' => $CNF['FIELD_POLL'],
  218. 'id' => $iPollId
  219. )
  220. ),
  221. 'action_menu' => !empty($mixedMenu) ? $mixedMenu->getCode() : '',
  222. 'bx_if:show_action_embed' => array(
  223. 'condition' => $bManage,
  224. 'content' => array(
  225. 'js_object' => $sJsObject,
  226. 'id' => $iPollId
  227. )
  228. ),
  229. 'bx_if:show_action_delete' => array(
  230. 'condition' => $bManage,
  231. 'content' => array(
  232. 'js_object' => $sJsObject,
  233. 'id' => $iPollId,
  234. 'editor_id' => isset($CNF['FIELD_TEXT_ID']) ? $CNF['FIELD_TEXT_ID'] : ''
  235. )
  236. ),
  237. 'text' => bx_process_output($aPoll[$CNF['FIELD_POLL_TEXT']], BX_DATA_TEXT),
  238. 'content' => $this->$sMethod($aPoll, $bDynamic)
  239. ));
  240. }
  241. public function embedPollItem($mixedPoll, $aParams = array())
  242. {
  243. $CNF = &$this->getModule()->_oConfig->CNF;
  244. $sHeader = '';
  245. $sContent = $this->getPollItem($mixedPoll, 0, $aParams);
  246. if(!empty($sContent)) {
  247. $aPoll = is_array($mixedPoll) ? $mixedPoll : $this->_oDb->getPolls(array('type' => 'id', 'id' => (int)$mixedPoll));
  248. $sHeader = strmaxtextlen($aPoll[$CNF['FIELD_POLL_TEXT']], 32, '...');
  249. $sContent = $this->getJsCode('poll') . $sContent;
  250. }
  251. $this->_addCssJs();
  252. $oTemplate = BxDolTemplate::getInstance();
  253. $oTemplate->addCssStyle($CNF['STYLES_POLLS_EMBED_CLASS'], $CNF['STYLES_POLLS_EMBED_CONTENT']);
  254. $oTemplate->setPageNameIndex(BX_PAGE_EMBED);
  255. $oTemplate->setPageHeader($sHeader);
  256. $oTemplate->setPageContent('page_main_code', $sContent);
  257. $oTemplate->getPageCode();
  258. exit;
  259. }
  260. public function embedPollItems($mixedContentInfo, $aParams = array())
  261. {
  262. $CNF = &$this->getModule()->_oConfig->CNF;
  263. $aContentInfo = is_array($mixedContentInfo) ? $mixedContentInfo : $this->_oDb->getContentInfoById((int)$mixedContentInfo);
  264. if(empty($aContentInfo) || !is_array($aContentInfo))
  265. return;
  266. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  267. $aPolls = $this->_oDb->getPolls(array('type' => 'content_id', 'content_id' => $iContentId));
  268. if(empty($aPolls) || !is_array($aPolls))
  269. return;
  270. $iPolls = 0;
  271. $sContent = '';
  272. foreach($aPolls as $aPoll) {
  273. $sPoll = $this->getPollItem($aPoll, 0, $aParams);
  274. if(empty($sPoll))
  275. continue;
  276. $sContent .= $sPoll;
  277. $iPolls += 1;
  278. }
  279. if(!empty($sContent) && isset($aParams['showcase']) && (bool)$aParams['showcase'] === true) {
  280. $this->addJs(array('flickity/flickity.pkgd.min.js'));
  281. $this->addCss(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'flickity/|flickity.css');
  282. $sContent = $this->parseHtmlByName('poll_items_showcase.html', array(
  283. 'js_object' => $this->_oConfig->getJsObject('poll'),
  284. 'html_id' => $this->_oConfig->getHtmlIds('polls_showcase') . $iContentId,
  285. 'type' => $iPolls == 1 ? 'single' : 'multiple',
  286. 'polls' => $sContent
  287. ));
  288. }
  289. $sHeader = '';
  290. if(!empty($sContent)) {
  291. $sHeader = strmaxtextlen($aContentInfo[$CNF['FIELD_TITLE']], 32, '...');
  292. $sContent = $this->getJsCode('poll') . $sContent;
  293. }
  294. $this->_addCssJs();
  295. $oTemplate = BxDolTemplate::getInstance();
  296. $oTemplate->addCssStyle($CNF['STYLES_POLLS_EMBED_CLASS'], $CNF['STYLES_POLLS_EMBED_CONTENT']);
  297. $oTemplate->setPageNameIndex(BX_PAGE_EMBED);
  298. $oTemplate->setPageHeader($sHeader);
  299. $oTemplate->setPageContent('page_main_code', $sContent);
  300. $oTemplate->getPageCode();
  301. exit;
  302. }
  303. protected function _addCssJs()
  304. {
  305. $this->addJs(array(
  306. 'modules/base/text/js/|polls.js',
  307. 'polls.js'
  308. ));
  309. $this->addCss(array('polls.css'));
  310. }
  311. protected function _getPollAnswers($aPoll, $bDynamic = false)
  312. {
  313. $CNF = &$this->getModule()->_oConfig->CNF;
  314. $aAnswers = $this->_oDb->getPollAnswers(array('type' => 'poll_id', 'poll_id' => $aPoll[$CNF['FIELD_POLL_ID']]));
  315. if(empty($aAnswers) || !is_array($aAnswers))
  316. return '';
  317. $aTmplVarsAnswers = array();
  318. foreach($aAnswers as $aAnswer) {
  319. $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_POLL_ANSWERS'], $aAnswer['id']);
  320. $aTmplVarsAnswers[] = array(
  321. 'answer' => $oVotes->getElementBlock(array(
  322. 'dynamic_mode' => $bDynamic
  323. ))
  324. );
  325. }
  326. return $this->parseHtmlByName('poll_item_answers.html', array(
  327. 'html_id' => $this->_oConfig->getHtmlIds('poll_content') . $aPoll[$CNF['FIELD_POLL_ID']],
  328. 'bx_repeat:answers' => $aTmplVarsAnswers
  329. ));
  330. }
  331. protected function _getPollResults($aPoll, $bDynamic = false)
  332. {
  333. $CNF = &$this->getModule()->_oConfig->CNF;
  334. $aAnswers = $this->_oDb->getPollAnswers(array('type' => 'poll_id', 'poll_id' => $aPoll[$CNF['FIELD_POLL_ID']]));
  335. if(empty($aAnswers) || !is_array($aAnswers))
  336. return '';
  337. $iTotal = 0;
  338. foreach($aAnswers as $aAnswer)
  339. $iTotal += $aAnswer['votes'];
  340. $aTmplVarsAnswers = array();
  341. foreach($aAnswers as $aAnswer) {
  342. $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_POLL_ANSWERS'], $aAnswer['id']);
  343. $aVotesParams = array('show_counter_empty' => true, 'show_counter_in_brackets' => false, 'dynamic_mode' => $bDynamic);
  344. $fPercent = $iTotal > 0 ? 100 * (float)$aAnswer['votes']/$iTotal : 0;
  345. $aTmplVarsAnswers[] = array(
  346. 'title' => bx_process_output($aAnswer['title']),
  347. 'width' => (int)round($fPercent) . '%',
  348. 'votes' => $oVotes->getCounter($aVotesParams),
  349. 'percent' => _t($CNF['T']['txt_poll_answer_vote_percent'], $iTotal > 0 ? round($fPercent, 2) : 0)
  350. );
  351. }
  352. return $this->parseHtmlByName('poll_item_results.html', array(
  353. 'html_id' => $this->_oConfig->getHtmlIds('poll_content') . $aPoll[$CNF['FIELD_POLL_ID']],
  354. 'bx_repeat:answers' => $aTmplVarsAnswers,
  355. ));
  356. }
  357. protected function _getPollBlockMenu($aPoll, $sSelected = '', $aParams = array())
  358. {
  359. $oModule = $this->getModule();
  360. $CNF = &$oModule->_oConfig->CNF;
  361. $sPostfix = '-' . time() . rand(0, PHP_INT_MAX);
  362. $sJsObject = $this->_oConfig->getJsObject('poll');
  363. $iPollId = $aPoll[$CNF['FIELD_POLL_ID']];
  364. $aViews = array(
  365. 'answers' => true,
  366. 'results' => $CNF['PARAM_POLL_HIDDEN_RESULTS'] === false || $oModule->isPollPerformed($iPollId)
  367. );
  368. $aMenu = array();
  369. foreach($aViews as $sView => $bActive) {
  370. if(!$bActive)
  371. continue;
  372. $sId = $this->_oConfig->getHtmlIds('poll_view_link_' . $sView) . $iPollId;
  373. if(!empty($sSelected) && $sSelected == $sView)
  374. $sSelected = $sId;
  375. $aMenu[] = array(
  376. 'id' => $sId,
  377. 'name' => $sId,
  378. 'class' => '',
  379. 'link' => 'javascript:void(0)',
  380. 'onclick' => 'javascript:' . $sJsObject . '.changePollView(this, \'' . $sView . '\', ' . $iPollId . ')',
  381. 'target' => '_self',
  382. 'title_attr' => _t($CNF['T']['txt_poll_menu_view_' . $sView]),
  383. 'title' => $this->parseIcon($CNF['ICON_POLLS_' . strtoupper($sView)])
  384. );
  385. }
  386. if(count($aMenu) <= 1)
  387. return '';
  388. $oMenu = new BxTemplMenuInteractive(array(
  389. 'template' => !empty($aParams['template']) ? $aParams['template'] : 'menu_interactive_vertical.html',
  390. 'menu_id' => $this->_oConfig->getHtmlIds('poll_view_menu') . $sPostfix,
  391. 'menu_items' => $aMenu
  392. ));
  393. if(!empty($sSelected))
  394. $oMenu->setSelected('', $sSelected);
  395. return $oMenu;
  396. }
  397. public function getAttachLinkForm($iContentId = 0)
  398. {
  399. $sStylePrefix = $this->_oConfig->getPrefix('style');
  400. $sJsObject = $this->_oConfig->getJsObject('links');
  401. $aForm = $this->getModule()->getFormAttachLink($iContentId);
  402. return $this->parseHtmlByName('attach_link_form.html', array(
  403. 'style_prefix' => $sStylePrefix,
  404. 'js_object' => $sJsObject,
  405. 'form_id' => $aForm['form_id'],
  406. 'form' => $aForm['form'],
  407. ));
  408. }
  409. public function getAttachLinkField($iUserId, $iContentId = 0)
  410. {
  411. $sStylePrefix = $this->_oConfig->getPrefix('style');
  412. if(!$iContentId)
  413. $aLinks = $this->_oDb->getUnusedLinks($iUserId);
  414. else
  415. $aLinks = $this->_oDb->getLinks($iContentId);
  416. $sLinks = '';
  417. foreach($aLinks as $aLink)
  418. $sLinks .= $this->getAttachLinkItem($iUserId, $aLink);
  419. return $this->parseHtmlByName('attach_link_form_field.html', array(
  420. 'html_id' => $this->_oConfig->getHtmlIds('attach_link_form_field') . $iContentId,
  421. 'style_prefix' => $sStylePrefix,
  422. 'links' => $sLinks
  423. ));
  424. }
  425. public function getAttachLinkItem($iUserId, $mixedLink)
  426. {
  427. $CNF = &$this->getModule()->_oConfig->CNF;
  428. $aLink = is_array($mixedLink) ? $mixedLink : $this->_oDb->getLinksBy(array('type' => 'id', 'id' => (int)$mixedLink, 'profile_id' => $iUserId));
  429. if(empty($aLink) || !is_array($aLink))
  430. return '';
  431. $sLinkIdPrefix = $this->_oConfig->getHtmlIds('attach_link_item');
  432. $sStylePrefix = $this->_oConfig->getPrefix('style');
  433. $sClass = $sStylePrefix . '-al-item';
  434. $sJsObject = $this->_oConfig->getJsObject('links');
  435. $oEmbed = BxDolEmbed::getObjectInstance();
  436. $bEmbed = $oEmbed !== false;
  437. $sThumbnail = '';
  438. $aLinkAttrs = array();
  439. if(!$bEmbed) {
  440. $aLinkAttrs = array(
  441. 'title' => bx_html_attribute($aLink['title'])
  442. );
  443. if(!$this->_oConfig->isEqualUrls(BX_DOL_URL_ROOT, $aLink['url'])) {
  444. $aLinkAttrs['target'] = '_blank';
  445. if($this->_oDb->getParam('sys_add_nofollow') == 'on')
  446. $aLinkAttrs['rel'] = 'nofollow';
  447. }
  448. if((int)$aLink['media_id'] != 0)
  449. $sThumbnail = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS'])->getFileUrl($aLink['media_id']);
  450. }
  451. else
  452. $sClass .= ' embed';
  453. return $this->parseHtmlByName('attach_link_item.html', array(
  454. 'html_id' => $sLinkIdPrefix . $aLink['id'],
  455. 'style_prefix' => $sStylePrefix,
  456. 'class' => $sClass,
  457. 'js_object' => $sJsObject,
  458. 'id' => $aLink['id'],
  459. 'bx_if:show_embed_outer' => array(
  460. 'condition' => $bEmbed,
  461. 'content' => array(
  462. 'style_prefix' => $sStylePrefix,
  463. 'embed' => $bEmbed ? $oEmbed->getLinkHTML($aLink['url'], $aLink['title'], 300) : '',
  464. )
  465. ),
  466. 'bx_if:show_embed_inner' => array(
  467. 'condition' => !$bEmbed,
  468. 'content' => array(
  469. 'style_prefix' => $sStylePrefix,
  470. 'bx_if:show_thumbnail' => array(
  471. 'condition' => !empty($sThumbnail),
  472. 'content' => array(
  473. 'style_prefix' => $sStylePrefix,
  474. 'thumbnail' => $sThumbnail
  475. )
  476. ),
  477. 'url' => $aLink['url'],
  478. 'link' => $this->parseLink($aLink['url'], $aLink['title'], $aLinkAttrs)
  479. )
  480. ),
  481. ));
  482. }
  483. public function getEventLinks($iContentId)
  484. {
  485. $CNF = &$this->getModule()->_oConfig->CNF;
  486. $aLinks = $this->_oDb->getLinks($iContentId);
  487. if(empty($aLinks) || !is_array($aLinks))
  488. return array();
  489. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS']);
  490. $aResult = array();
  491. foreach($aLinks as $aLink)
  492. $aResult[] = array(
  493. 'url' => $aLink['url'],
  494. 'title' => $aLink['title'],
  495. 'text' => $aLink['text'],
  496. 'thumbnail' => (int)$aLink['media_id'] != 0 ? $oTranscoder->getFileUrl($aLink['media_id']) : ''
  497. );
  498. return $aResult;
  499. }
  500. public function getTmplVarsText($aData)
  501. {
  502. $CNF = &$this->getModule()->_oConfig->CNF;
  503. $sStylePrefix = $this->_oConfig->getPrefix('style');
  504. $aVars = parent::getTmplVarsText($aData);
  505. $sImage = '';
  506. $mixedImage = $this->_getHeaderImage($aData);
  507. if($mixedImage !== false) {
  508. if(!empty($mixedImage['object']))
  509. $o = BxDolStorage::getObjectInstance($mixedImage['object']);
  510. else if(!empty($mixedImage['transcoder']))
  511. $o = BxDolTranscoder::getObjectInstance($mixedImage['transcoder']);
  512. if($o)
  513. $sImage = $o->getFileUrlById($mixedImage['id']);
  514. }
  515. if(bx_is_api() ){
  516. if($sImage){
  517. $aVars['image'] = bx_api_get_image($CNF['OBJECT_STORAGE'], $mixedImage['id']);
  518. }
  519. return $aVars;
  520. }
  521. $sAddClassPicture = "";
  522. $sAddCode = "";
  523. $oModule = $this->getModule();
  524. $bIsAllowEditPicture = CHECK_ACTION_RESULT_ALLOWED === $oModule->checkAllowedEdit($aData);
  525. if(isset($CNF['FIELD_THUMB']) && isset($CNF['OBJECT_UPLOADERS']) && isset($CNF['OBJECT_STORAGE']) && isset($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW'])){
  526. bx_alert('system', 'image_editor', 0, 0, array(
  527. 'module' => $oModule->getName(),
  528. 'content_id' => $aData[$CNF['FIELD_ID']],
  529. 'image_type' => 'header_image',
  530. 'image_url' => $sImage,
  531. 'is_allow_edit' => $bIsAllowEditPicture,
  532. 'uploader' => !empty($CNF['OBJECT_UPLOADERS']) && is_array($CNF['OBJECT_UPLOADERS']) ? $CNF['OBJECT_UPLOADERS'][0] : '',
  533. 'storage' => isset($CNF['OBJECT_STORAGE']) ? $CNF['OBJECT_STORAGE'] : '',
  534. 'transcoder' => isset($CNF['OBJECT_IMAGES_TRANSCODER_COVER']) ? $CNF['OBJECT_IMAGES_TRANSCODER_COVER'] : '',
  535. 'field' => isset($CNF['FIELD_THUMB']) ? $CNF['FIELD_THUMB'] : '',
  536. 'is_background' => false,
  537. 'add_class' => &$sAddClassPicture,
  538. 'add_code' => &$sAddCode
  539. ));
  540. }
  541. $sImageTweak = '';
  542. $sUniqIdImage = genRndPwd (8, false);
  543. if ($bIsAllowEditPicture && empty($sAddCode) && isset($CNF['FIELD_THUMB_POSITION'])){
  544. $sImageTweak = $this->_prepareImage($aData, $sUniqIdImage, $CNF['OBJECT_UPLOADERS'], $CNF['OBJECT_STORAGE'], $CNF['FIELD_THUMB'], true);
  545. }
  546. $aVars['content_description_before'] = '';
  547. $aVars['content_description_after'] = '';
  548. $aVars['bx_if:show_image'] = array(
  549. 'condition' => !empty($sImage),
  550. 'content' => array(
  551. 'entry_image' => $sImage,
  552. 'image_settings' => isset($CNF['FIELD_THUMB_POSITION']) ? $this->_getImageSettings($aData[$CNF['FIELD_THUMB_POSITION']]) : '',
  553. 'add_class' => $sAddClassPicture,
  554. 'img_class' => $sAddClassPicture != '' ? 'bx-media-editable-src' : '',
  555. 'additional_code' => $sAddCode,
  556. 'image_tweak' => $sImageTweak,
  557. 'unique_id' => $sUniqIdImage,
  558. )
  559. );
  560. $aTmplVarsLinks = [];
  561. if(isset($CNF['FIELD_LINK'])){
  562. $aLinks = $this->getEventLinks($aData[$CNF['FIELD_ID']]);
  563. $sClass = $sStylePrefix . '-al-item';
  564. $bAddNofollow = $this->_oDb->getParam('sys_add_nofollow') == 'on';
  565. foreach($aLinks as $aLink) {
  566. $sLink = '';
  567. $oEmbed = BxDolEmbed::getObjectInstance();
  568. if ($oEmbed) {
  569. $sLink = $this->parseHtmlByName('link_embed_provider.html', array(
  570. 'style_prefix' => $sStylePrefix,
  571. 'embed' => $oEmbed->getLinkHTML($aLink['url'], $aLink['title']),
  572. ));
  573. }
  574. else {
  575. $aLinkAttrs = array(
  576. 'title' => $aLink['title']
  577. );
  578. if(!$this->_oConfig->isEqualUrls(BX_DOL_URL_ROOT, $aLink['url'])) {
  579. $aLinkAttrs['target'] = '_blank';
  580. if($bAddNofollow)
  581. $aLinkAttrs['rel'] = 'nofollow';
  582. }
  583. $sLinkAttrs = '';
  584. foreach($aLinkAttrs as $sKey => $sValue)
  585. $sLinkAttrs .= ' ' . $sKey . '="' . bx_html_attribute($sValue) . '"';
  586. $sLink = $this->parseHtmlByName('link_embed_common.html', array(
  587. 'bx_if:show_thumbnail' => [
  588. 'condition' => !empty($aLink['thumbnail']),
  589. 'content' => [
  590. 'style_prefix' => $sStylePrefix,
  591. 'thumbnail' => $aLink['thumbnail'],
  592. 'link' => !empty($aLink['url']) ? $aLink['url'] : 'javascript:void(0)',
  593. 'attrs' => $sLinkAttrs
  594. ]
  595. ],
  596. 'link' => !empty($aLink['url']) ? $aLink['url'] : 'javascript:void(0)',
  597. 'attrs' => $sLinkAttrs,
  598. 'content' => $aLink['title'],
  599. 'bx_if:show_text' => [
  600. 'condition' => !empty($aLink['text']),
  601. 'content' => [
  602. 'style_prefix' => $sStylePrefix,
  603. 'text' => $aLink['text']
  604. ]
  605. ]
  606. ));
  607. }
  608. $aTmplVarsLinks[] = [
  609. 'style_prefix' => $sStylePrefix,
  610. 'link' => $sLink
  611. ];
  612. }
  613. }
  614. $aVars['bx_if:show_links'] = [
  615. 'condition' => count($aTmplVarsLinks) > 0,
  616. 'content' => [
  617. 'style_prefix' => $sStylePrefix,
  618. 'bx_repeat:links' => $aTmplVarsLinks
  619. ]
  620. ];
  621. if(!empty($CNF['OBJECT_REACTIONS']) && ($oReactions = BxDolVote::getObjectInstance($CNF['OBJECT_REACTIONS'], $aData[$CNF['FIELD_ID']])) !== false)
  622. $aVars['content_description_after'] .= $oReactions->getCounter([
  623. 'show_counter' => true,
  624. 'show_counter_empty' => false
  625. ]);
  626. $this->addCss(array('cover.css'));
  627. return $aVars;
  628. }
  629. function getAuthorDesc($aData, $oProfile)
  630. {
  631. $CNF = &$this->getModule()->_oConfig->CNF;
  632. $aItem = array(
  633. 'bx_if:text' => array(
  634. 'condition' => false,
  635. 'content' => array(
  636. 'content' => ''
  637. )
  638. ),
  639. 'bx_if:link' => array(
  640. 'condition' => false,
  641. 'content' => array(
  642. 'link' => '',
  643. 'content' => ''
  644. )
  645. )
  646. );
  647. $aTmplVarsItems = array();
  648. if(!empty($CNF['FIELD_ADDED']) && !empty($aData[$CNF['FIELD_ADDED']]))
  649. $aTmplVarsItems[] = array_merge($aItem, array('bx_if:text' => array(
  650. 'condition' => true,
  651. 'content' => array(
  652. 'content' => bx_time_js($aData[$CNF['FIELD_ADDED']], BX_FORMAT_DATE)
  653. )
  654. )));
  655. if(!empty($CNF['URI_AUTHOR_ENTRIES']))
  656. $aTmplVarsItems[] = array_merge($aItem, array('bx_if:link' => array(
  657. 'condition' => true,
  658. 'content' => array(
  659. 'link' => BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id=' . $oProfile->id()),
  660. 'content' => _t($CNF['T']['txt_all_entries_by'], $this->getModule()->_oDb->getEntriesNumByAuthor($oProfile->id()))
  661. )
  662. )));
  663. return $this->parseHtmlByName('author_desc.html', array(
  664. 'bx_repeat:items' => $aTmplVarsItems
  665. ));
  666. }
  667. function getAuthorProfileDesc ($aData, $oProfile)
  668. {
  669. $aSnippetMeta = $this->getProfileSnippetMenu($aData);
  670. if(empty($aSnippetMeta) || !is_array($aSnippetMeta) || !isset($aSnippetMeta['meta']))
  671. return '';
  672. return $aSnippetMeta['meta'];
  673. }
  674. function getProfileSnippetMenu ($aData)
  675. {
  676. $CNF = &$this->getModule()->_oConfig->CNF;
  677. if (!($oProfile = BxDolProfile::getInstance($aData[$CNF['FIELD_AUTHOR']])))
  678. return array();
  679. return bx_srv($oProfile->getModule(), 'get_snippet_menu_vars', array($oProfile->id()));
  680. }
  681. function getAuthorAddon ($aData, $oProfile)
  682. {
  683. return '';
  684. }
  685. protected function checkPrivacy ($aData, $isCheckPrivateContent, $oModule, $sTemplateName = '')
  686. {
  687. if ($isCheckPrivateContent && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $oModule->checkAllowedView($aData))) {
  688. $aVars = array (
  689. 'summary' => $sMsg,
  690. );
  691. return $this->parseHtmlByName($sTemplateName ? str_replace('.html', '_private.html', $sTemplateName) : 'unit_private.html', $aVars);
  692. }
  693. return '';
  694. }
  695. protected function getUnitThumbAndGallery ($aData)
  696. {
  697. $CNF = &BxDolModule::getInstance($this->MODULE)->_oConfig->CNF;
  698. $sPhotoThumb = '';
  699. $sPhotoGallery = '';
  700. if(!empty($CNF['FIELD_THUMB']) && !empty($aData[$CNF['FIELD_THUMB']])) {
  701. $oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW']);
  702. if ($oImagesTranscoder)
  703. $sPhotoThumb = $oImagesTranscoder->getFileUrl($aData[$CNF['FIELD_THUMB']]);
  704. $oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']);
  705. if ($oImagesTranscoder)
  706. $sPhotoGallery = $oImagesTranscoder->getFileUrl($aData[$CNF['FIELD_THUMB']]);
  707. else
  708. $sPhotoGallery = $sPhotoThumb;
  709. }
  710. return array($sPhotoThumb, $sPhotoGallery);
  711. }
  712. protected function getUnit ($aData, $aParams = array())
  713. {
  714. $CNF = &$this->_oConfig->CNF;
  715. $oModule = $this->getModule();
  716. // get thumb url
  717. list($sPhotoThumb, $sPhotoGallery) = $this->getUnitThumbAndGallery($aData);
  718. if ($sPhotoGallery == '' && isset($CNF['PARAM_USE_GALERY_AS_COVER']) && getParam($CNF['PARAM_USE_GALERY_AS_COVER']) == 'on'){
  719. if(!empty($CNF['OBJECT_STORAGE_PHOTOS'])){
  720. $sStorage = $CNF['OBJECT_STORAGE_PHOTOS'];
  721. $oStorage = BxDolStorage::getObjectInstance($sStorage);
  722. list($oTranscoder, $oTranscoderView) = $this->getAttachmentsImagesTranscoders($sStorage);
  723. $aGhostFiles = $oStorage->getGhosts($oModule->serviceGetContentOwnerProfileId($aData[$CNF['FIELD_ID']]), $aData[$CNF['FIELD_ID']]);
  724. if(!empty($aGhostFiles) && is_array($aGhostFiles)) {
  725. $aGhostFile = array_shift($aGhostFiles);
  726. $sPhotoThumb = $oTranscoderView->getFileUrl($aGhostFile['id']);
  727. $sPhotoGallery = $oTranscoder->getFileUrl($aGhostFile['id']);
  728. }
  729. }
  730. }
  731. // get entry url
  732. $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aData[$CNF['FIELD_ID']]));
  733. $oProfile = BxDolProfile::getInstanceMagic($aData[$CNF['FIELD_AUTHOR']]);
  734. $sTitle = $this->getTitle($aData);
  735. $sText = $this->getText($aData);
  736. $sSummary = $this->getSummary($aData, $sTitle, $sText, $sUrl);
  737. $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'])) : '';
  738. if(!empty($CNF['OBJECT_METATAGS'])) {
  739. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  740. $sText = $oMetatags->metaParse($aData[$CNF['FIELD_ID']], $sText);
  741. }
  742. $aTmplVarsMeta = array();
  743. if(!empty($CNF['OBJECT_MENU_SNIPPET_META'])) {
  744. $oMenuMeta = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_SNIPPET_META'], $this);
  745. if($oMenuMeta) {
  746. $oMenuMeta->setContentId($aData[$CNF['FIELD_ID']]);
  747. $aTmplVarsMeta = array(
  748. 'meta' => $oMenuMeta->getCode()
  749. );
  750. }
  751. }
  752. $bBadgesSingle = isset($aParams['badges_single']) ? $aParams['badges_single'] : false;
  753. $bBadgesCompact = isset($aParams['badges_compact']) ? $aParams['badges_compact'] : false;
  754. $sCoverData = isset($aData['thumb_data']) ? $aData['thumb_data'] : '';
  755. $aTmplVars = array (
  756. 'class' => $this->_getUnitClass($aData,(isset($aParams['template_name']) ? $aParams['template_name'] : '')),
  757. 'id' => $aData[$CNF['FIELD_ID']],
  758. 'content_url' => $sUrl,
  759. 'title' => $sTitle,
  760. 'badges' => $oModule->serviceGetBadges($aData[$CNF['FIELD_ID']], $bBadgesSingle, $bBadgesCompact),
  761. 'title_attr' => bx_html_attribute($sTitle),
  762. 'summary' => $sSummary,
  763. 'text' => $sText,
  764. 'author' => $oProfile->getDisplayName(),
  765. 'author_url' => $oProfile->getUrl(),
  766. 'author_icon' => $oProfile->getIcon(),
  767. 'author_thumb' => $oProfile->getThumb(),
  768. 'author_avatar' => $oProfile->getAvatar(),
  769. 'entry_posting_date' => bx_time_js($aData[$CNF['FIELD_ADDED']], BX_FORMAT_DATE),
  770. 'module_name' => _t($CNF['T']['txt_sample_single']),
  771. 'ts' => $aData[$CNF['FIELD_ADDED']],
  772. 'bx_if:meta' => array(
  773. 'condition' => !empty($aTmplVarsMeta),
  774. 'content' => $aTmplVarsMeta
  775. ),
  776. 'bx_if:thumb' => array (
  777. 'condition' => $sPhotoThumb,
  778. 'content' => array (
  779. 'title' => $sTitle,
  780. 'summary_attr' => bx_html_attribute($sSummaryPlain),
  781. 'content_url' => $sUrl,
  782. 'thumb_url' => $sPhotoThumb ? $sPhotoThumb : '',
  783. 'gallery_url' => $sPhotoGallery ? $sPhotoGallery : '',
  784. 'image_settings' => $this->_getImageSettings($sCoverData),
  785. 'strecher' => str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ', 40),
  786. ),
  787. ),
  788. 'bx_if:no_thumb' => array (
  789. 'condition' => !$sPhotoThumb,
  790. 'content' => array (
  791. 'module_icon' => $CNF['ICON'],
  792. 'content_url' => $sUrl,
  793. 'summary_plain' => $sSummaryPlain,
  794. 'strecher' => mb_strlen($sSummaryPlain) > 240 ? '' : str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ', round((240 - mb_strlen($sSummaryPlain)) / 6)),
  795. ),
  796. ),
  797. );
  798. if(isset($aParams['template_vars']) && is_array($aParams['template_vars']))
  799. $aTmplVars = array_merge($aTmplVars, $aParams['template_vars']);
  800. // generate html
  801. return $aTmplVars;
  802. }
  803. protected function getAttachmentsImagesTranscoders ($sStorage = '')
  804. {
  805. $CNF = &$this->getModule()->_oConfig->CNF;
  806. $oTranscoder = null;
  807. $oTranscoderView = null;
  808. if(isset($CNF['OBJECT_STORAGE_PHOTOS']) && $CNF['OBJECT_STORAGE_PHOTOS'] == $sStorage) {
  809. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS']))
  810. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS']);
  811. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_VIEW_PHOTOS']))
  812. $oTranscoderView = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_VIEW_PHOTOS']);
  813. else if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS']))
  814. $oTranscoderView = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS']);
  815. }
  816. else if(isset($CNF['OBJECT_STORAGE_FILES']) && $CNF['OBJECT_STORAGE_FILES'] == $sStorage) {
  817. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_FILES']))
  818. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_FILES']);
  819. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_FILES']))
  820. $oTranscoderView = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_FILES']);
  821. }
  822. else
  823. list($oTranscoder, $oTranscoderView) = parent::getAttachmentsImagesTranscoders($sStorage);
  824. return array($oTranscoder, $oTranscoderView);
  825. }
  826. protected function _getUnitName($aData, $sTemplateName = 'unit.html')
  827. {
  828. return trim(str_replace('.html', '', $sTemplateName));
  829. }
  830. protected function _getUnitClass($aData, $sTemplateName = 'unit.html')
  831. {
  832. $sResult = '';
  833. switch($sTemplateName) {
  834. case 'unit_showcase.html':
  835. $sResult = $this->_sUnitClassShowCase;
  836. break;
  837. }
  838. return $sResult;
  839. }
  840. protected function _getHeaderImage($aData)
  841. {
  842. return $this->getModule()->getEntryImageData($aData);
  843. }
  844. function mediaExif ($aMediaInfo, $iProfileId = false, $sFuncAuthorDesc = '', $sTemplateName = 'media-exif.html')
  845. {
  846. if (empty($aMediaInfo['exif']))
  847. return '';
  848. $a = unserialize($aMediaInfo['exif']);
  849. $s = '';
  850. if (!empty($a['Make'])) {
  851. $oModule = BxDolModule::getInstance($this->MODULE);
  852. $CNF = &$oModule->_oConfig->CNF;
  853. $sCamera = BxDolMetatags::keywordsCameraModel($a);
  854. if (!empty($CNF['OBJECT_METATAGS_MEDIA_CAMERA'])) {
  855. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS_MEDIA_CAMERA']);
  856. if ($oMetatags->keywordsIsEnabled()) {
  857. $sCamera = $oMetatags->keywordsParseOne($aMediaInfo['id'], $sCamera);
  858. }
  859. }
  860. if (!empty($sCamera))
  861. $s .= $this->parseHtmlByName('media-exif-value.html', array(
  862. 'key' => _t($CNF['T']['txt_media_exif_camera']),
  863. 'val' => $sCamera,
  864. ));
  865. }
  866. if (!empty($a['FocalLength']))
  867. $s .= $this->parseHtmlByName('media-exif-value.html', array(
  868. 'key' => _t($CNF['T']['txt_media_exif_focal_length']),
  869. 'val' => _t($CNF['T']['txt_media_exif_focal_length_value'], $a['FocalLength']),
  870. ));
  871. if (!empty($a['COMPUTED']['ApertureFNumber']))
  872. $s .= $this->parseHtmlByName('media-exif-value.html', array(
  873. 'key' => _t($CNF['T']['txt_media_exif_aperture']),
  874. 'val' => $a['COMPUTED']['ApertureFNumber'],
  875. ));
  876. if (!empty($a['ExposureTime']))
  877. $s .= $this->parseHtmlByName('media-exif-value.html', array(
  878. 'key' => _t($CNF['T']['txt_media_exif_shutter_speed']),
  879. 'val' => _t($CNF['T']['txt_media_exif_shutter_speed_value'], $a['ExposureTime']),
  880. ));
  881. if (!empty($a['ISOSpeedRatings']))
  882. $s .= $this->parseHtmlByName('media-exif-value.html', array(
  883. 'key' => _t($CNF['T']['txt_media_exif_iso']),
  884. 'val' => $a['ISOSpeedRatings'],
  885. ));
  886. if (empty($s))
  887. return '';
  888. return $this->parseHtmlByName($sTemplateName, array('content' => $s));
  889. }
  890. }
  891. /** @} */