1
0

BxBaseModTextModule.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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 recently updated entries
  151. * @return HTML string
  152. */
  153. public function serviceBrowseUpdated ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true)
  154. {
  155. return $this->_serviceBrowse ('updated', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  156. }
  157. /**
  158. * Display entries of the author
  159. * @return HTML string
  160. */
  161. public function serviceBrowseAuthor ($iProfileId = 0, $aParams = array())
  162. {
  163. return $this->_serviceBrowseWithParam ('author', 'profile_id', $iProfileId, $aParams);
  164. }
  165. /**
  166. * Display entries posted into particular context
  167. * @return HTML string
  168. */
  169. public function serviceBrowseContext ($iProfileId = 0, $aParams = array())
  170. {
  171. return $this->_serviceBrowseWithParam ('context', 'profile_id', $iProfileId, $aParams);
  172. }
  173. public function _serviceBrowseWithParam ($sParamName, $sParamGet, $sParamVal, $aParams = array())
  174. {
  175. if(!$sParamVal)
  176. $sParamVal = bx_process_input(bx_get($sParamGet), BX_DATA_INT);
  177. if(!$sParamVal)
  178. return '';
  179. $bEmptyMessage = true;
  180. if(isset($aParams['empty_message'])) {
  181. $bEmptyMessage = (bool)$aParams['empty_message'];
  182. unset($aParams['empty_message']);
  183. }
  184. $bAjaxPaginate = true;
  185. if(isset($aParams['ajax_paginate'])) {
  186. $bAjaxPaginate = (bool)$aParams['ajax_paginate'];
  187. unset($aParams['ajax_paginate']);
  188. }
  189. return $this->_serviceBrowse ($sParamName, array_merge(array($sParamName => $sParamVal), $aParams), BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  190. }
  191. /**
  192. * Entry author block
  193. */
  194. public function serviceEntityAuthor ($iContentId = 0)
  195. {
  196. return $this->_serviceTemplateFunc ('entryAuthor', $iContentId);
  197. }
  198. /**
  199. * Entry context block
  200. */
  201. public function serviceEntityContext ($iContentId = 0)
  202. {
  203. return $this->_serviceTemplateFunc ('entryContext', $iContentId);
  204. }
  205. /**
  206. * Entry polls block
  207. */
  208. public function serviceEntityPolls ($iContentId = 0)
  209. {
  210. return $this->_serviceTemplateFunc ('entryPolls', $iContentId);
  211. }
  212. public function serviceEntityBreadcrumb ($iContentId = 0)
  213. {
  214. return $this->_serviceTemplateFunc ('entryBreadcrumb', $iContentId);
  215. }
  216. /**
  217. * Delete all content by profile
  218. * @param $iProfileId profile id
  219. * @return number of deleted items
  220. */
  221. public function serviceDeleteEntitiesByAuthor ($iProfileId)
  222. {
  223. $a = $this->_oDb->getEntriesByAuthor((int)$iProfileId);
  224. if (!$a)
  225. return 0;
  226. $iCount = 0;
  227. foreach ($a as $aContentInfo)
  228. $iCount += ('' == $this->serviceDeleteEntity($aContentInfo[$this->_oConfig->CNF['FIELD_ID']]) ? 1 : 0);
  229. return $iCount;
  230. }
  231. /**
  232. * Entry multicategiries block
  233. */
  234. public function serviceCategoriesMultiList($bDisplayEmptyCats = true)
  235. {
  236. $oCategories = BxDolCategories::getInstance();
  237. $aCats = $oCategories->getData(array('type' => 'by_module_with_num', 'module' => $this->getName()));
  238. $aVars = array('bx_repeat:cats' => array());
  239. foreach ($aCats as $oCat) {
  240. $sValue = $oCat['value'];
  241. $iNum = $oCat['num'];
  242. $aVars['bx_repeat:cats'][] = array(
  243. 'url' => $oCategories->getUrl($this->getName(), $sValue),
  244. 'name' => _t($sValue),
  245. 'value' => $sValue,
  246. 'num' => $iNum,
  247. );
  248. }
  249. if (!$aVars['bx_repeat:cats'])
  250. return '';
  251. return $this->_oTemplate->parseHtmlByName('category_list.html', $aVars);
  252. }
  253. // ====== PERMISSION METHODS
  254. /**
  255. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  256. */
  257. public function checkAllowedSetThumb ($iContentId = 0)
  258. {
  259. // check ACL
  260. $aCheck = checkActionModule($this->_iProfileId, 'set thumb', $this->getName(), false);
  261. if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  262. return $aCheck[CHECK_ACTION_MESSAGE];
  263. return CHECK_ACTION_RESULT_ALLOWED;
  264. }
  265. public function isPollPerformed($iObjectId, $iAuthorId = 0, $iAuthorIp = 0)
  266. {
  267. if(empty($iAuthorId)) {
  268. $iAuthorId = bx_get_logged_profile_id();
  269. $iAuthorIp = ip2long(getVisitorIP());
  270. }
  271. return $this->_oDb->isPollPerformed($iObjectId, $iAuthorId, $iAuthorIp);
  272. }
  273. // ====== COMMON METHODS
  274. public function onPublished($iContentId)
  275. {
  276. parent::onPublished($iContentId);
  277. $CNF = &$this->_oConfig->CNF;
  278. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  279. if(!$aContentInfo)
  280. return;
  281. $aParams = $this->_alertParams($aContentInfo);
  282. bx_alert($this->getName(), 'added', $iContentId, $aContentInfo[$CNF['FIELD_AUTHOR']], $aParams);
  283. }
  284. public function onFailed($iContentId)
  285. {
  286. parent::onFailed($iContentId);
  287. $CNF = &$this->_oConfig->CNF;
  288. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  289. if(!$aContentInfo)
  290. return;
  291. $aParams = array('object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']]);
  292. bx_alert($this->getName(), 'failed', $iContentId, $aContentInfo[$CNF['FIELD_AUTHOR']], $aParams);
  293. }
  294. public function alertAfterAdd($aContentInfo)
  295. {
  296. $CNF = &$this->_oConfig->CNF;
  297. $iId = (int)$aContentInfo[$CNF['FIELD_ID']];
  298. $iAuthorId = (int)$aContentInfo[$CNF['FIELD_AUTHOR']];
  299. $sAction = 'added';
  300. if(isset($CNF['FIELD_STATUS']) && isset($aContentInfo[$CNF['FIELD_STATUS']]) && $aContentInfo[$CNF['FIELD_STATUS']] == 'awaiting')
  301. $sAction = 'deferred';
  302. $aParams = $this->_alertParams($aContentInfo);
  303. bx_alert('system', 'prepare_alert_params', 0, 0, array('unit'=> $this->getName(), 'action' => $sAction, 'object_id' => $iId, 'sender_id' => $iAuthorId, 'extras' => &$aParams));
  304. bx_alert($this->getName(), $sAction, $iId, $iAuthorId, $aParams);
  305. }
  306. public function alertAfterEdit($aContentInfo)
  307. {
  308. $CNF = &$this->_oConfig->CNF;
  309. $iId = (int)$aContentInfo[$CNF['FIELD_ID']];
  310. $aParams = $this->_alertParams($aContentInfo);
  311. bx_alert($this->getName(), 'edited', $iId, false, $aParams);
  312. }
  313. /**
  314. * Get array of params to be passed in Add/Edit Alert.
  315. */
  316. protected function _alertParams($aContentInfo)
  317. {
  318. $CNF = &$this->_oConfig->CNF;
  319. $iId = (int)$aContentInfo[$CNF['FIELD_ID']];
  320. $iAuthorId = (int)$aContentInfo[$CNF['FIELD_AUTHOR']];
  321. $aParams = array(
  322. 'object_author_id' => $iAuthorId
  323. );
  324. if(isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]))
  325. $aParams['privacy_view'] = $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']];
  326. if(!empty($CNF['OBJECT_METATAGS']))
  327. $aParams['timeline_group'] = array(
  328. 'by' => $this->getName() . '_' . $iAuthorId . '_' . $iId,
  329. 'field' => 'owner_id'
  330. );
  331. return $aParams;
  332. }
  333. public function isEntryActive($aContentInfo)
  334. {
  335. $CNF = &$this->_oConfig->CNF;
  336. if($aContentInfo[$CNF['FIELD_AUTHOR']] == bx_get_logged_profile_id() || $this->_isModerator())
  337. return true;
  338. if(isset($CNF['FIELD_STATUS']) && $aContentInfo[$CNF['FIELD_STATUS']] != 'active')
  339. return false;
  340. if(isset($CNF['FIELD_STATUS_ADMIN']) && $aContentInfo[$CNF['FIELD_STATUS_ADMIN']] != 'active')
  341. return false;
  342. return true;
  343. }
  344. public function getPollForm()
  345. {
  346. $CNF = &$this->_oConfig->CNF;
  347. if(empty($CNF['OBJECT_FORM_POLL']))
  348. return array('code' => 1, 'message' => '_sys_txt_error_occured');
  349. $iProfileId = bx_get_logged_profile_id();
  350. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_POLL'], $CNF['OBJECT_FORM_POLL_DISPLAY_ADD'], $this->_oTemplate);
  351. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'submit_poll_form/';
  352. $oForm->initChecker();
  353. if($oForm->isSubmittedAndValid()) {
  354. $iId = $oForm->insert();
  355. if($iId)
  356. return array('code' => 0, 'id' => $iId, 'item' => $this->_oTemplate->getPollItem($iId, $iProfileId, array(
  357. 'manage' => true
  358. )));
  359. else
  360. return array('code' => 2, 'message' => '_sys_txt_error_entry_creation');
  361. }
  362. return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
  363. }
  364. // ====== PROTECTED METHODS
  365. protected function _getImagesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  366. {
  367. $CNF = &$this->_oConfig->CNF;
  368. $aResults = parent::_getImagesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  369. if(!$this->_oConfig->isAttachmentsInTimeline() || empty($CNF['OBJECT_STORAGE_PHOTOS']) || empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS']))
  370. return $aResults;
  371. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  372. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE_PHOTOS']);
  373. $aGhostFiles = $oStorage->getGhosts($this->serviceGetContentOwnerProfileId($iContentId), $iContentId);
  374. if(!$aGhostFiles)
  375. return array();
  376. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS']);
  377. foreach ($aGhostFiles as $k => $a) {
  378. $sPhotoSrc = $oTranscoder->getFileUrl($a['id']);
  379. if(empty($sPhotoSrc))
  380. continue;
  381. $aResults[] = array(
  382. 'src' => $sPhotoSrc,
  383. 'src_medium' => $sPhotoSrc,
  384. 'src_orig' => $oStorage->getFileUrlById($a['id']),
  385. );
  386. }
  387. return $aResults;
  388. }
  389. protected function _getVideosForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  390. {
  391. $CNF = &$this->_oConfig->CNF;
  392. $aResults = parent::_getVideosForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  393. if(!$this->_oConfig->isAttachmentsInTimeline() || empty($CNF['OBJECT_STORAGE_VIDEOS']) || empty($CNF['OBJECT_VIDEOS_TRANSCODERS']))
  394. return $aResults;
  395. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  396. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE_VIDEOS']);
  397. $aGhostFiles = $oStorage->getGhosts($this->serviceGetContentOwnerProfileId($iContentId), $iContentId);
  398. if(!$aGhostFiles)
  399. return array();
  400. $oTcPoster = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['poster']);
  401. $oTcMp4 = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4']);
  402. $oTcMp4Hd = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4_hd']);
  403. if(!$oTcPoster || !$oTcMp4 || !$oTcMp4Hd)
  404. return array();
  405. $aResults = array();
  406. foreach ($aGhostFiles as $k => $a) {
  407. $sVideoUrl = $oStorage->getFileUrlById($a['id']);
  408. $aVideoSize = $oTcMp4Hd->getVideoSize($sVideoUrl);
  409. $sVideoUrlHd = '';
  410. if(!empty($aVideoSize) && is_array($aVideoSize) && (int)$aVideoSize['h'] >= 720)
  411. $sVideoUrlHd = $oTcMp4Hd->getFileUrl($a['id']);
  412. $aResults[$a['id']] = array(
  413. 'id' => $a['id'],
  414. 'src_poster' => $oTcPoster->getFileUrl($a['id']),
  415. 'src_mp4' => $oTcMp4->getFileUrl($a['id']),
  416. 'src_mp4_hd' => $sVideoUrlHd,
  417. );
  418. }
  419. return $aResults;
  420. }
  421. protected function _getFilesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  422. {
  423. $CNF = &$this->_oConfig->CNF;
  424. $aResults = parent::_getFilesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  425. if(!$this->_oConfig->isAttachmentsInTimeline() || empty($CNF['OBJECT_STORAGE_FILES']))
  426. return $aResults;
  427. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  428. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE_FILES']);
  429. $aGhostFiles = $oStorage->getGhosts($this->serviceGetContentOwnerProfileId($iContentId), $iContentId);
  430. if(!$aGhostFiles)
  431. return array();
  432. $oTranscoder = null;
  433. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_FILES']))
  434. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_FILES']);
  435. foreach ($aGhostFiles as $k => $a) {
  436. $bImage = in_array($a['ext'], array('jpg', 'jpeg', 'png', 'gif'));
  437. $sPhotoSrc = '';
  438. if($bImage && $oTranscoder)
  439. $sPhotoSrc = $oTranscoder->getFileUrl($a['id']);
  440. if(empty($sPhotoSrc) && $oStorage)
  441. $sPhotoSrc = $this->_oTemplate->getIconUrl($oStorage->getIconNameByFileName($a['file_name']));
  442. $sUrl = $oStorage->getFileUrlById($a['id']);
  443. $aResults[] = array(
  444. 'src' => $sPhotoSrc,
  445. 'src_medium' => $sPhotoSrc,
  446. 'src_orig' => $bImage ? $sUrl : '',
  447. 'url' => !$bImage ? $sUrl : ''
  448. );
  449. }
  450. return $aResults;
  451. }
  452. protected function _getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams = array())
  453. {
  454. $aResult = parent::_getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams);
  455. if(!$this->_oConfig->isAttachmentsInTimeline())
  456. return $aResult;
  457. $CNF = &$this->_oConfig->CNF;
  458. $bDynamic = isset($aBrowseParams['dynamic_mode']) && (bool)$aBrowseParams['dynamic_mode'] === true;
  459. $aPolls = $this->_oDb->getPolls(array('type' => 'content_id', 'content_id' => (int)$aContentInfo[$CNF['FIELD_ID']]));
  460. if(!empty($aPolls) && is_array($aPolls)) {
  461. $sInclude = $this->_oTemplate->addCss(array('polls.css'), $bDynamic);
  462. $aResult['raw'] = ($bDynamic ? $sInclude : '') . $this->_oTemplate->parseHtmlByName('poll_items_embed.html', array(
  463. 'embed_url' => BX_DOL_URL_ROOT . bx_append_url_params($this->_oConfig->getBaseUri() . 'embed_polls/', array(
  464. 'id' => (int)$aContentInfo[$CNF['FIELD_ID']],
  465. 'param_switch_menu' => 0,
  466. 'param_showcase' => 1
  467. ))
  468. ));
  469. /*
  470. if((!empty($aResult['videos']) && is_array($aResult['videos'])) || (!empty($aResult['videos_attach']) && is_array($aResult['videos_attach'])))
  471. $aResult['_cache'] = false;
  472. */
  473. }
  474. return $aResult;
  475. }
  476. protected function _buildRssParams($sMode, $aArgs)
  477. {
  478. $aParams = array ();
  479. $sMode = bx_process_input($sMode);
  480. switch ($sMode) {
  481. case 'author':
  482. $aParams = array('author' => isset($aArgs[0]) ? (int)$aArgs[0] : '');
  483. break;
  484. }
  485. return $aParams;
  486. }
  487. }
  488. /** @} */