BxBaseModTextTemplate.php 40 KB

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