BxBaseModTextModule.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  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. * Base module class for text based modules
  13. */
  14. class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolContentInfoService
  15. {
  16. function __construct(&$aModule)
  17. {
  18. parent::__construct($aModule);
  19. }
  20. // ====== ACTIONS METHODS
  21. public function actionEmbedPoll($iPollId = 0)
  22. {
  23. if(empty($iPollId) && bx_get('poll_id') !== false)
  24. $iPollId = (int)bx_get('poll_id');
  25. $aParams = bx_get_with_prefix('param');
  26. array_walk($aParams, function(&$sValue) {
  27. $sValue = bx_process_input($sValue);
  28. });
  29. $this->_oTemplate->embedPollItem($iPollId, $aParams);
  30. }
  31. public function actionEmbedPolls($iId = 0)
  32. {
  33. list($iContentId, $aContentInfo) = $this->_getContent($iId);
  34. if($iContentId === false)
  35. return;
  36. $aParams = bx_get_with_prefix('param');
  37. array_walk($aParams, function(&$sValue) {
  38. $sValue = bx_process_input($sValue);
  39. });
  40. $this->_oTemplate->embedPollItems($aContentInfo, $aParams);
  41. }
  42. public function actionGetPoll()
  43. {
  44. $iPollId = (int)bx_get('poll_id');
  45. $sView = bx_process_input(bx_get('view'));
  46. $sMethod = 'serviceGetBlockPoll' . bx_gen_method_name($sView);
  47. if(!method_exists($this, $sMethod))
  48. return echoJson(array());
  49. $aBlock = $this->$sMethod($iPollId, true);
  50. if(empty($aBlock) || !is_array($aBlock))
  51. return echoJson(array());
  52. return echoJson(array(
  53. 'content' => $aBlock['content']
  54. ));
  55. }
  56. public function actionDeletePoll()
  57. {
  58. $CNF = &$this->_oConfig->CNF;
  59. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  60. if(empty($iId))
  61. return echoJson(array());
  62. $aResult = array();
  63. if($this->_oDb->deletePolls(array($CNF['FIELD_POLL_ID'] => $iId)))
  64. $aResult = array('code' => 0);
  65. else
  66. $aResult = array('code' => 1, 'message' => _t($CNF['txt_err_cannot_perform_action']));
  67. echoJson($aResult);
  68. }
  69. public function actionGetPollForm()
  70. {
  71. echo $this->_oTemplate->getPollForm();
  72. }
  73. public function actionSubmitPollForm()
  74. {
  75. echoJson($this->getPollForm());
  76. }
  77. public function actionFileEmbedVideo($iFileId)
  78. {
  79. $this->_oTemplate->embedVideo($iFileId);
  80. }
  81. // ====== SERVICE METHODS
  82. public function serviceGetBlockPollAnswers($iPollId, $bForceDisplay = false)
  83. {
  84. if(!$iPollId)
  85. return false;
  86. if(!$bForceDisplay && $this->isPollPerformed($iPollId))
  87. return $this->serviceGetBlockPollResults($iPollId);
  88. return $this->_serviceTemplateFunc('entryPollAnswers', $iPollId, 'getPollInfoById');
  89. }
  90. public function serviceGetBlockPollResults($iPollId)
  91. {
  92. return $this->_serviceTemplateFunc('entryPollResults', $iPollId, 'getPollInfoById');
  93. }
  94. public function serviceGetThumb ($iContentId, $sTranscoder = '')
  95. {
  96. $CNF = &$this->_oConfig->CNF;
  97. if(empty($sTranscoder) && !empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']))
  98. $sTranscoder = $CNF['OBJECT_IMAGES_TRANSCODER_GALLERY'];
  99. $mixedResult = $this->_getFieldValueThumb('FIELD_THUMB', $iContentId, $sTranscoder);
  100. return $mixedResult !== false ? $mixedResult : '';
  101. }
  102. public function serviceGetMenuAddonManageTools()
  103. {
  104. bx_import('SearchResult', $this->_aModule);
  105. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  106. $o = new $sClass();
  107. $o->unsetPaginate();
  108. $iNumTotal = $o->getNum();
  109. $o->fillFilters(array(
  110. 'status' => 'hidden'
  111. ));
  112. $iNum1 = $o->getNum();
  113. $iNum2 = 0;
  114. $CNF = &$this->_oConfig->CNF;
  115. if (isset($CNF['OBJECT_REPORTS'])){
  116. $o->fillFilters(array('status' => ''));
  117. $o->fillFiltersByObjects(array('reported' => array('value' => '0', 'field' => 'reports', 'operator' => '>')));
  118. $iNum2 = $o->getNum();
  119. }
  120. return array('counter1_value' => $iNum1, 'counter2_value' => $iNum2, 'counter3_value' => $iNumTotal );
  121. }
  122. public function serviceGetMenuAddonManageToolsProfileStats()
  123. {
  124. bx_import('SearchResult', $this->_aModule);
  125. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  126. $o = new $sClass();
  127. $o->fillFilters(array(
  128. 'author' => bx_get_logged_profile_id()
  129. ));
  130. $o->unsetPaginate();
  131. return $o->getNum();
  132. }
  133. /**
  134. * Display public entries
  135. * @return HTML string
  136. */
  137. public function serviceBrowsePublic ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true)
  138. {
  139. return $this->_serviceBrowse ('public', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  140. }
  141. /**
  142. * Display popular entries
  143. * @return HTML string
  144. */
  145. public function serviceBrowsePopular ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true)
  146. {
  147. return $this->_serviceBrowse ('popular', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  148. }
  149. /**
  150. * Display popular entries
  151. * @return HTML string
  152. */
  153. public function serviceBrowseTop ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true)
  154. {
  155. return $this->_serviceBrowse ('top', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  156. }
  157. /**
  158. * Display recently updated entries
  159. * @return HTML string
  160. */
  161. public function serviceBrowseUpdated ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true)
  162. {
  163. return $this->_serviceBrowse ('updated', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  164. }
  165. /**
  166. * Display entries of the author
  167. * @return HTML string
  168. */
  169. public function serviceBrowseAuthor ($iProfileId = 0, $aParams = array())
  170. {
  171. return $this->_serviceBrowseWithParam ('author', 'profile_id', $iProfileId, $aParams);
  172. }
  173. /**
  174. * Display entries posted into particular context
  175. * @return HTML string
  176. */
  177. public function serviceBrowseContext ($iProfileId = 0, $aParams = array())
  178. {
  179. return $this->_serviceBrowseWithParam ('context', 'profile_id', $iProfileId, $aParams);
  180. }
  181. public function _serviceBrowseWithParam ($sParamName, $sParamGet, $sParamVal, $aParams = array())
  182. {
  183. if(!$sParamVal)
  184. $sParamVal = bx_process_input(bx_get($sParamGet), BX_DATA_INT);
  185. if(!$sParamVal)
  186. return '';
  187. $bEmptyMessage = true;
  188. if(isset($aParams['empty_message'])) {
  189. $bEmptyMessage = (bool)$aParams['empty_message'];
  190. unset($aParams['empty_message']);
  191. }
  192. $bAjaxPaginate = true;
  193. if(isset($aParams['ajax_paginate'])) {
  194. $bAjaxPaginate = (bool)$aParams['ajax_paginate'];
  195. unset($aParams['ajax_paginate']);
  196. }
  197. return $this->_serviceBrowse ($sParamName, array_merge(array($sParamName => $sParamVal), $aParams), BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  198. }
  199. /**
  200. * Entry author block
  201. */
  202. public function serviceEntityAuthor ($iContentId = 0)
  203. {
  204. return $this->_serviceTemplateFunc ('entryAuthor', $iContentId);
  205. }
  206. /**
  207. * Entry context block
  208. */
  209. public function serviceEntityContext ($iContentId = 0)
  210. {
  211. return $this->_serviceTemplateFunc ('entryContext', $iContentId);
  212. }
  213. /**
  214. * Entry polls block
  215. */
  216. public function serviceEntityPolls ($iContentId = 0)
  217. {
  218. return $this->_serviceTemplateFunc ('entryPolls', $iContentId);
  219. }
  220. public function serviceEntityBreadcrumb ($iContentId = 0)
  221. {
  222. return $this->_serviceTemplateFunc ('entryBreadcrumb', $iContentId);
  223. }
  224. /**
  225. * Delete all content by profile
  226. * @param $iProfileId profile id
  227. * @return number of deleted items
  228. */
  229. public function serviceDeleteEntitiesByAuthor ($iProfileId)
  230. {
  231. $a = $this->_oDb->getEntriesByAuthor((int)$iProfileId);
  232. if (!$a)
  233. return 0;
  234. $iCount = 0;
  235. foreach ($a as $aContentInfo)
  236. $iCount += ('' == $this->serviceDeleteEntity($aContentInfo[$this->_oConfig->CNF['FIELD_ID']]) ? 1 : 0);
  237. return $iCount;
  238. }
  239. /**
  240. * Entry multicategiries block
  241. */
  242. public function serviceCategoriesMultiList($bDisplayEmptyCats = true)
  243. {
  244. $oCategories = BxDolCategories::getInstance();
  245. $aCats = $oCategories->getData(array('type' => 'by_module_with_num', 'module' => $this->getName()));
  246. $aVars = array('bx_repeat:cats' => array());
  247. foreach ($aCats as $oCat) {
  248. $sValue = $oCat['value'];
  249. $iNum = $oCat['num'];
  250. $aVars['bx_repeat:cats'][] = array(
  251. 'url' => $oCategories->getUrl($this->getName(), $sValue),
  252. 'name' => _t($sValue),
  253. 'value' => $sValue,
  254. 'num' => $iNum,
  255. );
  256. }
  257. if (!$aVars['bx_repeat:cats'])
  258. return '';
  259. return $this->_oTemplate->parseHtmlByName('category_list.html', $aVars);
  260. }
  261. // ====== PERMISSION METHODS
  262. /**
  263. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  264. */
  265. public function checkAllowedSetThumb ($iContentId = 0)
  266. {
  267. // check ACL
  268. $aCheck = checkActionModule($this->_iProfileId, 'set thumb', $this->getName(), false);
  269. if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  270. return $aCheck[CHECK_ACTION_MESSAGE];
  271. return CHECK_ACTION_RESULT_ALLOWED;
  272. }
  273. public function isPollPerformed($iObjectId, $iAuthorId = 0, $iAuthorIp = 0)
  274. {
  275. if(empty($iAuthorId)) {
  276. $iAuthorId = bx_get_logged_profile_id();
  277. $iAuthorIp = ip2long(getVisitorIP());
  278. }
  279. return $this->_oDb->isPollPerformed($iObjectId, $iAuthorId, $iAuthorIp);
  280. }
  281. // ====== COMMON METHODS
  282. public function onPublished($iContentId)
  283. {
  284. parent::onPublished($iContentId);
  285. $CNF = &$this->_oConfig->CNF;
  286. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  287. if(!$aContentInfo)
  288. return;
  289. $aParams = $this->_alertParams($aContentInfo);
  290. bx_alert($this->getName(), 'added', $iContentId, $aContentInfo[$CNF['FIELD_AUTHOR']], $aParams);
  291. }
  292. public function onFailed($iContentId)
  293. {
  294. parent::onFailed($iContentId);
  295. $CNF = &$this->_oConfig->CNF;
  296. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  297. if(!$aContentInfo)
  298. return;
  299. $aParams = array('object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']]);
  300. bx_alert($this->getName(), 'failed', $iContentId, $aContentInfo[$CNF['FIELD_AUTHOR']], $aParams);
  301. }
  302. public function alertAfterAdd($aContentInfo)
  303. {
  304. $CNF = &$this->_oConfig->CNF;
  305. $iId = (int)$aContentInfo[$CNF['FIELD_ID']];
  306. $iAuthorId = (int)$aContentInfo[$CNF['FIELD_AUTHOR']];
  307. $sAction = 'added';
  308. if(isset($CNF['FIELD_STATUS']) && isset($aContentInfo[$CNF['FIELD_STATUS']]) && $aContentInfo[$CNF['FIELD_STATUS']] == 'awaiting')
  309. $sAction = 'deferred';
  310. $aParams = $this->_alertParams($aContentInfo);
  311. bx_alert('system', 'prepare_alert_params', 0, 0, array('unit'=> $this->getName(), 'action' => $sAction, 'object_id' => $iId, 'sender_id' => $iAuthorId, 'extras' => &$aParams));
  312. bx_alert($this->getName(), $sAction, $iId, $iAuthorId, $aParams);
  313. }
  314. public function alertAfterEdit($aContentInfo)
  315. {
  316. $CNF = &$this->_oConfig->CNF;
  317. $iId = (int)$aContentInfo[$CNF['FIELD_ID']];
  318. $aParams = $this->_alertParams($aContentInfo);
  319. bx_alert($this->getName(), 'edited', $iId, false, $aParams);
  320. }
  321. /**
  322. * Get array of params to be passed in Add/Edit Alert.
  323. */
  324. protected function _alertParams($aContentInfo)
  325. {
  326. $CNF = &$this->_oConfig->CNF;
  327. $iId = (int)$aContentInfo[$CNF['FIELD_ID']];
  328. $iAuthorId = (int)$aContentInfo[$CNF['FIELD_AUTHOR']];
  329. $aParams = array(
  330. 'object_author_id' => $iAuthorId
  331. );
  332. if(isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]))
  333. $aParams['privacy_view'] = $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']];
  334. if(!empty($CNF['OBJECT_METATAGS']))
  335. $aParams['timeline_group'] = array(
  336. 'by' => $this->getName() . '_' . $iAuthorId . '_' . $iId,
  337. 'field' => 'owner_id'
  338. );
  339. return $aParams;
  340. }
  341. public function isEntryActive($aContentInfo)
  342. {
  343. $CNF = &$this->_oConfig->CNF;
  344. if($aContentInfo[$CNF['FIELD_AUTHOR']] == bx_get_logged_profile_id() || $this->_isModerator())
  345. return true;
  346. if(isset($CNF['FIELD_STATUS']) && $aContentInfo[$CNF['FIELD_STATUS']] != 'active')
  347. return false;
  348. if(isset($CNF['FIELD_STATUS_ADMIN']) && $aContentInfo[$CNF['FIELD_STATUS_ADMIN']] != 'active')
  349. return false;
  350. return true;
  351. }
  352. public function getPollForm()
  353. {
  354. $CNF = &$this->_oConfig->CNF;
  355. if(empty($CNF['OBJECT_FORM_POLL']))
  356. return array('code' => 1, 'message' => '_sys_txt_error_occured');
  357. $iProfileId = bx_get_logged_profile_id();
  358. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_POLL'], $CNF['OBJECT_FORM_POLL_DISPLAY_ADD'], $this->_oTemplate);
  359. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'submit_poll_form/';
  360. $oForm->initChecker();
  361. if($oForm->isSubmittedAndValid()) {
  362. $iId = $oForm->insert();
  363. if($iId)
  364. return array('code' => 0, 'id' => $iId, 'item' => $this->_oTemplate->getPollItem($iId, $iProfileId, array(
  365. 'manage' => true
  366. )));
  367. else
  368. return array('code' => 2, 'message' => '_sys_txt_error_entry_creation');
  369. }
  370. return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
  371. }
  372. // ====== PROTECTED METHODS
  373. protected function _getImagesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  374. {
  375. $CNF = &$this->_oConfig->CNF;
  376. $aResults = parent::_getImagesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  377. if(!$this->_oConfig->isAttachmentsInTimeline() || empty($CNF['OBJECT_STORAGE_PHOTOS']) || empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS']))
  378. return $aResults;
  379. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  380. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE_PHOTOS']);
  381. $aGhostFiles = $oStorage->getGhosts($this->serviceGetContentOwnerProfileId($iContentId), $iContentId);
  382. if(!$aGhostFiles)
  383. return array();
  384. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS']);
  385. foreach ($aGhostFiles as $k => $a) {
  386. $sPhotoSrc = $oTranscoder->getFileUrl($a['id']);
  387. if(empty($sPhotoSrc))
  388. continue;
  389. $aResults[] = array(
  390. 'src' => $sPhotoSrc,
  391. 'src_medium' => $sPhotoSrc,
  392. 'src_orig' => $oStorage->getFileUrlById($a['id']),
  393. );
  394. }
  395. return $aResults;
  396. }
  397. protected function _getVideosForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  398. {
  399. $CNF = &$this->_oConfig->CNF;
  400. $aResults = parent::_getVideosForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  401. if(!$this->_oConfig->isAttachmentsInTimeline() || empty($CNF['OBJECT_STORAGE_VIDEOS']) || empty($CNF['OBJECT_VIDEOS_TRANSCODERS']))
  402. return $aResults;
  403. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  404. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE_VIDEOS']);
  405. $aGhostFiles = $oStorage->getGhosts($this->serviceGetContentOwnerProfileId($iContentId), $iContentId);
  406. if(!$aGhostFiles)
  407. return array();
  408. $oTcPoster = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['poster']);
  409. $oTcMp4 = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4']);
  410. $oTcMp4Hd = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4_hd']);
  411. if(!$oTcPoster || !$oTcMp4 || !$oTcMp4Hd)
  412. return array();
  413. $aResults = array();
  414. foreach ($aGhostFiles as $k => $a) {
  415. $sVideoUrl = $oStorage->getFileUrlById($a['id']);
  416. $aVideoSize = $oTcMp4Hd->getVideoSize($sVideoUrl);
  417. $sVideoUrlHd = '';
  418. if(!empty($aVideoSize) && is_array($aVideoSize) && (int)$aVideoSize['h'] >= 720)
  419. $sVideoUrlHd = $oTcMp4Hd->getFileUrl($a['id']);
  420. $aResults[$a['id']] = array(
  421. 'id' => $a['id'],
  422. 'src_poster' => $oTcPoster->getFileUrl($a['id']),
  423. 'src_mp4' => $oTcMp4->getFileUrl($a['id']),
  424. 'src_mp4_hd' => $sVideoUrlHd,
  425. );
  426. }
  427. return $aResults;
  428. }
  429. protected function _getFilesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  430. {
  431. $CNF = &$this->_oConfig->CNF;
  432. $aResults = parent::_getFilesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  433. if(!$this->_oConfig->isAttachmentsInTimeline() || empty($CNF['OBJECT_STORAGE_FILES']))
  434. return $aResults;
  435. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  436. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE_FILES']);
  437. $aGhostFiles = $oStorage->getGhosts($this->serviceGetContentOwnerProfileId($iContentId), $iContentId);
  438. if(!$aGhostFiles)
  439. return array();
  440. $oTranscoder = null;
  441. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_FILES']))
  442. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_FILES']);
  443. foreach ($aGhostFiles as $k => $a) {
  444. $bImage = in_array($a['ext'], array('jpg', 'jpeg', 'png', 'gif'));
  445. $sPhotoSrc = '';
  446. if($bImage && $oTranscoder)
  447. $sPhotoSrc = $oTranscoder->getFileUrl($a['id']);
  448. if(empty($sPhotoSrc) && $oStorage)
  449. $sPhotoSrc = $this->_oTemplate->getIconUrl($oStorage->getIconNameByFileName($a['file_name']));
  450. $sUrl = $oStorage->getFileUrlById($a['id']);
  451. $aResults[] = array(
  452. 'src' => $sPhotoSrc,
  453. 'src_medium' => $sPhotoSrc,
  454. 'src_orig' => $bImage ? $sUrl : '',
  455. 'url' => !$bImage ? $sUrl : ''
  456. );
  457. }
  458. return $aResults;
  459. }
  460. protected function _getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams = array())
  461. {
  462. $aResult = parent::_getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams);
  463. if(!$this->_oConfig->isAttachmentsInTimeline())
  464. return $aResult;
  465. $CNF = &$this->_oConfig->CNF;
  466. $bDynamic = isset($aBrowseParams['dynamic_mode']) && (bool)$aBrowseParams['dynamic_mode'] === true;
  467. $aPolls = $this->_oDb->getPolls(array('type' => 'content_id', 'content_id' => (int)$aContentInfo[$CNF['FIELD_ID']]));
  468. if(!empty($aPolls) && is_array($aPolls)) {
  469. $sInclude = $this->_oTemplate->addCss(array('polls.css'), $bDynamic);
  470. $aResult['raw'] = ($bDynamic ? $sInclude : '') . $this->_oTemplate->parseHtmlByName('poll_items_embed.html', array(
  471. 'embed_url' => BX_DOL_URL_ROOT . bx_append_url_params($this->_oConfig->getBaseUri() . 'embed_polls/', array(
  472. 'id' => (int)$aContentInfo[$CNF['FIELD_ID']],
  473. 'param_switch_menu' => 0,
  474. 'param_showcase' => 1
  475. ))
  476. ));
  477. /*
  478. if((!empty($aResult['videos']) && is_array($aResult['videos'])) || (!empty($aResult['videos_attach']) && is_array($aResult['videos_attach'])))
  479. $aResult['_cache'] = false;
  480. */
  481. }
  482. return $aResult;
  483. }
  484. protected function _buildRssParams($sMode, $aArgs)
  485. {
  486. $aParams = array ();
  487. $sMode = bx_process_input($sMode);
  488. switch ($sMode) {
  489. case 'author':
  490. $aParams = array('author' => isset($aArgs[0]) ? (int)$aArgs[0] : '');
  491. break;
  492. }
  493. return $aParams;
  494. }
  495. }
  496. /** @} */