BxBaseModTextTemplate.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  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. $sStylePrefix = $this->_oConfig->getPrefix('style');
  498. $aVars = parent::getTmplVarsText($aData);
  499. $sImage = '';
  500. $mixedImage = $this->_getHeaderImage($aData);
  501. if($mixedImage !== false) {
  502. if(!empty($mixedImage['object']))
  503. $o = BxDolStorage::getObjectInstance($mixedImage['object']);
  504. else if(!empty($mixedImage['transcoder']))
  505. $o = BxDolTranscoder::getObjectInstance($mixedImage['transcoder']);
  506. if($o)
  507. $sImage = $o->getFileUrlById($mixedImage['id']);
  508. }
  509. $sAddClassPicture = "";
  510. $sAddCode = "";
  511. $oModule = $this->getModule();
  512. $bIsAllowEditPicture = CHECK_ACTION_RESULT_ALLOWED === $oModule->checkAllowedEdit($aData);
  513. if(isset($CNF['FIELD_THUMB']) && isset($CNF['OBJECT_UPLOADERS']) && isset($CNF['OBJECT_STORAGE']) && isset($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW'])){
  514. bx_alert('system', 'image_editor', 0, 0, array(
  515. 'module' => $oModule->getName(),
  516. 'content_id' => $aData[$CNF['FIELD_ID']],
  517. 'image_type' => 'header_image',
  518. 'image_url' => $sImage,
  519. 'is_allow_edit' => $bIsAllowEditPicture,
  520. 'uploader' => !empty($CNF['OBJECT_UPLOADERS']) && is_array($CNF['OBJECT_UPLOADERS']) ? $CNF['OBJECT_UPLOADERS'][0] : '',
  521. 'storage' => isset($CNF['OBJECT_STORAGE']) ? $CNF['OBJECT_STORAGE'] : '',
  522. 'transcoder' => isset($CNF['OBJECT_IMAGES_TRANSCODER_COVER']) ? $CNF['OBJECT_IMAGES_TRANSCODER_COVER'] : '',
  523. 'field' => isset($CNF['FIELD_THUMB']) ? $CNF['FIELD_THUMB'] : '',
  524. 'is_background' => false,
  525. 'add_class' => &$sAddClassPicture,
  526. 'add_code' => &$sAddCode
  527. ));
  528. }
  529. $sImageTweak = '';
  530. $sUniqIdImage = genRndPwd (8, false);
  531. if ($bIsAllowEditPicture && empty($sAddCode)){
  532. $sImageTweak = $this->_prepareImage($aData, $sUniqIdImage, $CNF['OBJECT_UPLOADERS'], $CNF['OBJECT_STORAGE'], $CNF['FIELD_THUMB'], true);
  533. }
  534. $aVars['content_description_before'] = '';
  535. $aVars['content_description_after'] = '';
  536. $aVars['bx_if:show_image'] = array(
  537. 'condition' => !empty($sImage),
  538. 'content' => array(
  539. 'entry_image' => $sImage,
  540. 'image_settings' => isset($CNF['FIELD_THUMB_POSITION']) ? $this->_getImageSettings($aData[$CNF['FIELD_THUMB_POSITION']]) : '',
  541. 'add_class' => $sAddClassPicture,
  542. 'img_class' => $sAddClassPicture != '' ? 'bx-media-editable-src' : '',
  543. 'additional_code' => $sAddCode,
  544. 'image_tweak' => $sImageTweak,
  545. 'unique_id' => $sUniqIdImage,
  546. )
  547. );
  548. $aTmplVarsLinks = [];
  549. if(isset($CNF['FIELD_LINK'])){
  550. $aLinks = $this->getEventLinks($aData[$CNF['FIELD_ID']]);
  551. $sClass = $sStylePrefix . '-al-item';
  552. $bAddNofollow = $this->_oDb->getParam('sys_add_nofollow') == 'on';
  553. foreach($aLinks as $aLink) {
  554. $sLink = '';
  555. $oEmbed = BxDolEmbed::getObjectInstance();
  556. if ($oEmbed) {
  557. $sLink = $this->parseHtmlByName('link_embed_provider.html', array(
  558. 'style_prefix' => $sStylePrefix,
  559. 'embed' => $oEmbed->getLinkHTML($aLink['url'], $aLink['title']),
  560. ));
  561. }
  562. else {
  563. $aLinkAttrs = array(
  564. 'title' => $aLink['title']
  565. );
  566. if(!$this->_oConfig->isEqualUrls(BX_DOL_URL_ROOT, $aLink['url'])) {
  567. $aLinkAttrs['target'] = '_blank';
  568. if($bAddNofollow)
  569. $aLinkAttrs['rel'] = 'nofollow';
  570. }
  571. $sLinkAttrs = '';
  572. foreach($aLinkAttrs as $sKey => $sValue)
  573. $sLinkAttrs .= ' ' . $sKey . '="' . bx_html_attribute($sValue) . '"';
  574. $sLink = $this->parseHtmlByName('link_embed_common.html', array(
  575. 'bx_if:show_thumbnail' => [
  576. 'condition' => !empty($aLink['thumbnail']),
  577. 'content' => [
  578. 'style_prefix' => $sStylePrefix,
  579. 'thumbnail' => $aLink['thumbnail'],
  580. 'link' => !empty($aLink['url']) ? $aLink['url'] : 'javascript:void(0)',
  581. 'attrs' => $sLinkAttrs
  582. ]
  583. ],
  584. 'link' => !empty($aLink['url']) ? $aLink['url'] : 'javascript:void(0)',
  585. 'attrs' => $sLinkAttrs,
  586. 'content' => $aLink['title'],
  587. 'bx_if:show_text' => [
  588. 'condition' => !empty($aLink['text']),
  589. 'content' => [
  590. 'style_prefix' => $sStylePrefix,
  591. 'text' => $aLink['text']
  592. ]
  593. ]
  594. ));
  595. }
  596. $aTmplVarsLinks[] = [
  597. 'style_prefix' => $sStylePrefix,
  598. 'link' => $sLink
  599. ];
  600. }
  601. }
  602. $aVars['bx_if:show_links'] = [
  603. 'condition' => count($aTmplVarsLinks) > 0,
  604. 'content' => [
  605. 'style_prefix' => $sStylePrefix,
  606. 'bx_repeat:links' => $aTmplVarsLinks
  607. ]
  608. ];
  609. if(!empty($CNF['OBJECT_REACTIONS']) && ($oReactions = BxDolVote::getObjectInstance($CNF['OBJECT_REACTIONS'], $aData[$CNF['FIELD_ID']])) !== false)
  610. $aVars['content_description_after'] .= $oReactions->getCounter([
  611. 'show_counter' => true,
  612. 'show_counter_empty' => false
  613. ]);
  614. return $aVars;
  615. }
  616. function getAuthorDesc($aData, $oProfile)
  617. {
  618. $CNF = &$this->getModule()->_oConfig->CNF;
  619. $aItem = array(
  620. 'bx_if:text' => array(
  621. 'condition' => false,
  622. 'content' => array(
  623. 'content' => ''
  624. )
  625. ),
  626. 'bx_if:link' => array(
  627. 'condition' => false,
  628. 'content' => array(
  629. 'link' => '',
  630. 'content' => ''
  631. )
  632. )
  633. );
  634. $aTmplVarsItems = array();
  635. if(!empty($CNF['FIELD_ADDED']) && !empty($aData[$CNF['FIELD_ADDED']]))
  636. $aTmplVarsItems[] = array_merge($aItem, array('bx_if:text' => array(
  637. 'condition' => true,
  638. 'content' => array(
  639. 'content' => bx_time_js($aData[$CNF['FIELD_ADDED']], BX_FORMAT_DATE)
  640. )
  641. )));
  642. if(!empty($CNF['URI_AUTHOR_ENTRIES']))
  643. $aTmplVarsItems[] = array_merge($aItem, array('bx_if:link' => array(
  644. 'condition' => true,
  645. 'content' => array(
  646. 'link' => BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id=' . $oProfile->id()),
  647. 'content' => _t($CNF['T']['txt_all_entries_by'], $this->getModule()->_oDb->getEntriesNumByAuthor($oProfile->id()))
  648. )
  649. )));
  650. return $this->parseHtmlByName('author_desc.html', array(
  651. 'bx_repeat:items' => $aTmplVarsItems
  652. ));
  653. }
  654. function getAuthorProfileDesc ($aData, $oProfile)
  655. {
  656. $aSnippetMeta = $this->getProfileSnippetMenu($aData);
  657. if(empty($aSnippetMeta) || !is_array($aSnippetMeta) || !isset($aSnippetMeta['meta']))
  658. return '';
  659. return $aSnippetMeta['meta'];
  660. }
  661. function getProfileSnippetMenu ($aData)
  662. {
  663. $CNF = &$this->getModule()->_oConfig->CNF;
  664. if (!($oProfile = BxDolProfile::getInstance($aData[$CNF['FIELD_AUTHOR']])))
  665. return array();
  666. return bx_srv($oProfile->getModule(), 'get_snippet_menu_vars', array($oProfile->id()));
  667. }
  668. function getAuthorAddon ($aData, $oProfile)
  669. {
  670. return '';
  671. }
  672. protected function checkPrivacy ($aData, $isCheckPrivateContent, $oModule, $sTemplateName = '')
  673. {
  674. if ($isCheckPrivateContent && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $oModule->checkAllowedView($aData))) {
  675. $aVars = array (
  676. 'summary' => $sMsg,
  677. );
  678. return $this->parseHtmlByName($sTemplateName ? str_replace('.html', '_private.html', $sTemplateName) : 'unit_private.html', $aVars);
  679. }
  680. return '';
  681. }
  682. protected function getUnitThumbAndGallery ($aData)
  683. {
  684. $CNF = &BxDolModule::getInstance($this->MODULE)->_oConfig->CNF;
  685. $sPhotoThumb = '';
  686. $sPhotoGallery = '';
  687. if(!empty($CNF['FIELD_THUMB']) && !empty($aData[$CNF['FIELD_THUMB']])) {
  688. $oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW']);
  689. if ($oImagesTranscoder)
  690. $sPhotoThumb = $oImagesTranscoder->getFileUrl($aData[$CNF['FIELD_THUMB']]);
  691. $oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']);
  692. if ($oImagesTranscoder)
  693. $sPhotoGallery = $oImagesTranscoder->getFileUrl($aData[$CNF['FIELD_THUMB']]);
  694. else
  695. $sPhotoGallery = $sPhotoThumb;
  696. }
  697. return array($sPhotoThumb, $sPhotoGallery);
  698. }
  699. protected function getUnit ($aData, $aParams = array())
  700. {
  701. $CNF = &$this->_oConfig->CNF;
  702. $oModule = $this->getModule();
  703. // get thumb url
  704. list($sPhotoThumb, $sPhotoGallery) = $this->getUnitThumbAndGallery($aData);
  705. if ($sPhotoGallery == '' && isset($CNF['PARAM_USE_GALERY_AS_COVER']) && getParam($CNF['PARAM_USE_GALERY_AS_COVER']) == 'on'){
  706. if(!empty($CNF['OBJECT_STORAGE_PHOTOS'])){
  707. $sStorage = $CNF['OBJECT_STORAGE_PHOTOS'];
  708. $oStorage = BxDolStorage::getObjectInstance($sStorage);
  709. list($oTranscoder, $oTranscoderView) = $this->getAttachmentsImagesTranscoders($sStorage);
  710. $aGhostFiles = $oStorage->getGhosts($oModule->serviceGetContentOwnerProfileId($aData[$CNF['FIELD_ID']]), $aData[$CNF['FIELD_ID']]);
  711. if(!empty($aGhostFiles) && is_array($aGhostFiles)) {
  712. $aGhostFile = array_shift($aGhostFiles);
  713. $sPhotoThumb = $oTranscoderView->getFileUrl($aGhostFile['id']);
  714. $sPhotoGallery = $oTranscoder->getFileUrl($aGhostFile['id']);
  715. }
  716. }
  717. }
  718. // get entry url
  719. $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aData[$CNF['FIELD_ID']]));
  720. $oProfile = BxDolProfile::getInstanceMagic($aData[$CNF['FIELD_AUTHOR']]);
  721. $sTitle = $this->getTitle($aData);
  722. $sText = $this->getText($aData);
  723. $sSummary = $this->getSummary($aData, $sTitle, $sText, $sUrl);
  724. $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'])) : '';
  725. if(!empty($CNF['OBJECT_METATAGS'])) {
  726. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  727. $sText = $oMetatags->metaParse($aData[$CNF['FIELD_ID']], $sText);
  728. }
  729. $aTmplVarsMeta = array();
  730. if(!empty($CNF['OBJECT_MENU_SNIPPET_META'])) {
  731. $oMenuMeta = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_SNIPPET_META'], $this);
  732. if($oMenuMeta) {
  733. $oMenuMeta->setContentId($aData[$CNF['FIELD_ID']]);
  734. $aTmplVarsMeta = array(
  735. 'meta' => $oMenuMeta->getCode()
  736. );
  737. }
  738. }
  739. $bBadgesSingle = isset($aParams['badges_single']) ? $aParams['badges_single'] : false;
  740. $bBadgesCompact = isset($aParams['badges_compact']) ? $aParams['badges_compact'] : false;
  741. $sCoverData = isset($aData['thumb_data']) ? $aData['thumb_data'] : '';
  742. $aTmplVars = array (
  743. 'class' => $this->_getUnitClass($aData,(isset($aParams['template_name']) ? $aParams['template_name'] : '')),
  744. 'id' => $aData[$CNF['FIELD_ID']],
  745. 'content_url' => $sUrl,
  746. 'title' => $sTitle,
  747. 'badges' => $oModule->serviceGetBadges($aData[$CNF['FIELD_ID']], $bBadgesSingle, $bBadgesCompact),
  748. 'title_attr' => bx_html_attribute($sTitle),
  749. 'summary' => $sSummary,
  750. 'text' => $sText,
  751. 'author' => $oProfile->getDisplayName(),
  752. 'author_url' => $oProfile->getUrl(),
  753. 'author_icon' => $oProfile->getIcon(),
  754. 'author_thumb' => $oProfile->getThumb(),
  755. 'author_avatar' => $oProfile->getAvatar(),
  756. 'entry_posting_date' => bx_time_js($aData[$CNF['FIELD_ADDED']], BX_FORMAT_DATE),
  757. 'module_name' => _t($CNF['T']['txt_sample_single']),
  758. 'ts' => $aData[$CNF['FIELD_ADDED']],
  759. 'bx_if:meta' => array(
  760. 'condition' => !empty($aTmplVarsMeta),
  761. 'content' => $aTmplVarsMeta
  762. ),
  763. 'bx_if:thumb' => array (
  764. 'condition' => $sPhotoThumb,
  765. 'content' => array (
  766. 'title' => $sTitle,
  767. 'summary_attr' => bx_html_attribute($sSummaryPlain),
  768. 'content_url' => $sUrl,
  769. 'thumb_url' => $sPhotoThumb ? $sPhotoThumb : '',
  770. 'gallery_url' => $sPhotoGallery ? $sPhotoGallery : '',
  771. 'image_settings' => $this->_getImageSettings($sCoverData),
  772. 'strecher' => str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ', 40),
  773. ),
  774. ),
  775. 'bx_if:no_thumb' => array (
  776. 'condition' => !$sPhotoThumb,
  777. 'content' => array (
  778. 'module_icon' => $CNF['ICON'],
  779. 'content_url' => $sUrl,
  780. 'summary_plain' => $sSummaryPlain,
  781. 'strecher' => mb_strlen($sSummaryPlain) > 240 ? '' : str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ', round((240 - mb_strlen($sSummaryPlain)) / 6)),
  782. ),
  783. ),
  784. );
  785. if(isset($aParams['template_vars']) && is_array($aParams['template_vars']))
  786. $aTmplVars = array_merge($aTmplVars, $aParams['template_vars']);
  787. // generate html
  788. return $aTmplVars;
  789. }
  790. protected function getAttachmentsImagesTranscoders ($sStorage = '')
  791. {
  792. $CNF = &$this->getModule()->_oConfig->CNF;
  793. $oTranscoder = null;
  794. $oTranscoderView = null;
  795. if(isset($CNF['OBJECT_STORAGE_PHOTOS']) && $CNF['OBJECT_STORAGE_PHOTOS'] == $sStorage) {
  796. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS']))
  797. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS']);
  798. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_VIEW_PHOTOS']))
  799. $oTranscoderView = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_VIEW_PHOTOS']);
  800. else if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS']))
  801. $oTranscoderView = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS']);
  802. }
  803. else if(isset($CNF['OBJECT_STORAGE_FILES']) && $CNF['OBJECT_STORAGE_FILES'] == $sStorage) {
  804. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_FILES']))
  805. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_FILES']);
  806. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_FILES']))
  807. $oTranscoderView = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_FILES']);
  808. }
  809. else
  810. list($oTranscoder, $oTranscoderView) = parent::getAttachmentsImagesTranscoders($sStorage);
  811. return array($oTranscoder, $oTranscoderView);
  812. }
  813. protected function _getUnitName($aData, $sTemplateName = 'unit.html')
  814. {
  815. return trim(str_replace('.html', '', $sTemplateName));
  816. }
  817. protected function _getUnitClass($aData, $sTemplateName = 'unit.html')
  818. {
  819. $sResult = '';
  820. switch($sTemplateName) {
  821. case 'unit_showcase.html':
  822. $sResult = $this->_sUnitClassShowCase;
  823. break;
  824. }
  825. return $sResult;
  826. }
  827. protected function _getHeaderImage($aData)
  828. {
  829. return $this->getModule()->getEntryImageData($aData);
  830. }
  831. function mediaExif ($aMediaInfo, $iProfileId = false, $sFuncAuthorDesc = '', $sTemplateName = 'media-exif.html')
  832. {
  833. if (empty($aMediaInfo['exif']))
  834. return '';
  835. $a = unserialize($aMediaInfo['exif']);
  836. $s = '';
  837. if (!empty($a['Make'])) {
  838. $oModule = BxDolModule::getInstance($this->MODULE);
  839. $CNF = &$oModule->_oConfig->CNF;
  840. $sCamera = BxDolMetatags::keywordsCameraModel($a);
  841. if (!empty($CNF['OBJECT_METATAGS_MEDIA_CAMERA'])) {
  842. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS_MEDIA_CAMERA']);
  843. if ($oMetatags->keywordsIsEnabled()) {
  844. $sCamera = $oMetatags->keywordsParseOne($aMediaInfo['id'], $sCamera);
  845. }
  846. }
  847. if (!empty($sCamera))
  848. $s .= $this->parseHtmlByName('media-exif-value.html', array(
  849. 'key' => _t($CNF['T']['txt_media_exif_camera']),
  850. 'val' => $sCamera,
  851. ));
  852. }
  853. if (!empty($a['FocalLength']))
  854. $s .= $this->parseHtmlByName('media-exif-value.html', array(
  855. 'key' => _t($CNF['T']['txt_media_exif_focal_length']),
  856. 'val' => _t($CNF['T']['txt_media_exif_focal_length_value'], $a['FocalLength']),
  857. ));
  858. if (!empty($a['COMPUTED']['ApertureFNumber']))
  859. $s .= $this->parseHtmlByName('media-exif-value.html', array(
  860. 'key' => _t($CNF['T']['txt_media_exif_aperture']),
  861. 'val' => $a['COMPUTED']['ApertureFNumber'],
  862. ));
  863. if (!empty($a['ExposureTime']))
  864. $s .= $this->parseHtmlByName('media-exif-value.html', array(
  865. 'key' => _t($CNF['T']['txt_media_exif_shutter_speed']),
  866. 'val' => _t($CNF['T']['txt_media_exif_shutter_speed_value'], $a['ExposureTime']),
  867. ));
  868. if (!empty($a['ISOSpeedRatings']))
  869. $s .= $this->parseHtmlByName('media-exif-value.html', array(
  870. 'key' => _t($CNF['T']['txt_media_exif_iso']),
  871. 'val' => $a['ISOSpeedRatings'],
  872. ));
  873. if (empty($s))
  874. return '';
  875. return $this->parseHtmlByName($sTemplateName, array('content' => $s));
  876. }
  877. }
  878. /** @} */