BxBaseModTextTemplate.php 43 KB

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