BxBaseModTextTemplate.php 43 KB

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