BxAlbumsModule.php 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014
  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 Albums Albums
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolAcl');
  12. /**
  13. * Albums module
  14. */
  15. class BxAlbumsModule extends BxBaseModTextModule
  16. {
  17. protected $_aContexts = array('popular', 'public', 'author');
  18. function __construct(&$aModule)
  19. {
  20. parent::__construct($aModule);
  21. }
  22. public function serviceGetSafeServices()
  23. {
  24. $a = parent::serviceGetSafeServices();
  25. return array_merge($a, array (
  26. 'EntityAddFiles' => '',
  27. 'MediaComments' => '',
  28. 'BrowseRecentMedia' => '',
  29. 'BrowseFeaturedMedia' => '',
  30. 'BrowsePopularMedia' => '',
  31. 'BrowseTopMedia' => '',
  32. 'BrowseFavoriteMedia' => '',
  33. ));
  34. }
  35. /**
  36. * Entry actions and social sharing block
  37. */
  38. public function serviceEntityAllActions ($mixedContent = false, $aParams = array())
  39. {
  40. if(!empty($mixedContent)) {
  41. if(!is_array($mixedContent))
  42. $mixedContent = array((int)$mixedContent, array());
  43. }
  44. else {
  45. $mixedContent = $this->_getContent();
  46. if($mixedContent === false)
  47. return false;
  48. }
  49. list($iContentId, $aContentInfo) = $mixedContent;
  50. $aMedias = $this->_oDb->getMediaListByContentId($iContentId);
  51. if(!empty($aMedias) && is_array($aMedias)) {
  52. $aMedia = array_shift($aMedias);
  53. if(!empty($aMedia['file_id']))
  54. $aParams = array_merge(array(
  55. 'entry_thumb' => $aMedia['file_id']
  56. ), $aParams);
  57. }
  58. return parent::serviceEntityAllActions(array($iContentId, $aContentInfo), $aParams);
  59. }
  60. /**
  61. * @page service Service Calls
  62. * @section bx_albums Albums
  63. * @subsection bx_albums-forms Forms
  64. * @subsubsection bx_albums-entity_add_files entity_add_files
  65. *
  66. * @code bx_srv('bx_albums', 'entity_add_files', [...]); @endcode
  67. *
  68. * Display form for adding media to the album.
  69. * @param $iContentId album content id where media will be added, if it's not provided then it's determined from 'id' GET variable
  70. * @return HTML string with form, all necessary CSS and JS files are automatically added to the HEAD section of the site HTML. On error false or empty string is returned.
  71. *
  72. * @see BxAlbumsModule::serviceEntityAddFiles
  73. */
  74. /**
  75. * @ref bx_albums-entity_add_files "entity_add_files"
  76. */
  77. public function serviceEntityAddFiles ($iContentId = 0)
  78. {
  79. return $this->_serviceEntityForm ('editDataForm', $iContentId, 'bx_albums_entry_add_images');
  80. }
  81. /**
  82. * Delete file and album association, also file views, votes, comments, meta data are also deleted
  83. * @param $iFileId file ID
  84. * @return true on success of false on error
  85. */
  86. public function serviceDeleteFileAssociations($iFileId)
  87. {
  88. $CNF = &$this->_oConfig->CNF;
  89. if (!($aMediaInfo = $this->_oDb->getMediaInfoSimpleByFileId($iFileId))) // file is already deleted
  90. return true;
  91. if (!$this->_oDb->deassociateFileWithContent(0, $iFileId))
  92. return false;
  93. $aContentInfo = $this->_oDb->getContentInfoById($aMediaInfo['content_id']);
  94. $iSender = isLogged() ? bx_get_logged_profile_id() : $aMediaInfo['author'];
  95. $iAuthor = isset($aContentInfo[$CNF['FIELD_AUTHOR']]) ? $aContentInfo[$CNF['FIELD_AUTHOR']] : $aMediaInfo['author'];
  96. bx_alert($this->getName(), 'media_deleted', $aMediaInfo['content_id'], $iSender, array(
  97. 'object_author_id' => $iAuthor,
  98. 'subobject_id' => $aMediaInfo['id'],
  99. 'media_id' => $aMediaInfo['id'],
  100. 'media_info' => $aMediaInfo,
  101. ));
  102. bx_alert($this->getName() . '_media', 'deleted', $aMediaInfo['id'], $iSender, array(
  103. 'object_id' => $aMediaInfo['content_id'],
  104. 'object_author_id' => $iAuthor,
  105. 'media_info' => $aMediaInfo,
  106. ));
  107. if (!empty($CNF['OBJECT_VIEWS_MEDIA'])) {
  108. $o = BxDolView::getObjectInstance($CNF['OBJECT_VIEWS_MEDIA'], $aMediaInfo['id']);
  109. if ($o) $o->onObjectDelete();
  110. }
  111. if (!empty($CNF['OBJECT_VOTES_MEDIA'])) {
  112. $o = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_MEDIA'], $aMediaInfo['id']);
  113. if ($o) $o->onObjectDelete();
  114. }
  115. if (!empty($CNF['OBJECT_SCORES_MEDIA'])) {
  116. $o = BxDolScore::getObjectInstance($CNF['OBJECT_SCORES_MEDIA'], $aMediaInfo['id']);
  117. if ($o) $o->onObjectDelete();
  118. }
  119. if (!empty($CNF['OBJECT_COMMENTS_MEDIA'])) {
  120. $o = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS_MEDIA'], $aMediaInfo['id']);
  121. if ($o) $o->onObjectDelete();
  122. }
  123. if (!empty($CNF['OBJECT_METATAGS_MEDIA'])) {
  124. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS_MEDIA']);
  125. $oMetatags->onDeleteContent($aMediaInfo['id']);
  126. }
  127. if (!empty($CNF['OBJECT_METATAGS_MEDIA_CAMERA'])) {
  128. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS_MEDIA_CAMERA']);
  129. $oMetatags->onDeleteContent($aMediaInfo['id']);
  130. }
  131. BxDolPage::deleteSeoLink ($this->getName(), 'bx_albums_media', $aMediaInfo['id']);
  132. return true;
  133. }
  134. /**
  135. * @page service Service Calls
  136. * @section bx_albums Albums
  137. * @subsection bx_albums-page_blocks Page Blocks
  138. * @subsubsection bx_albums-media_comments media_comments
  139. *
  140. * @code bx_srv('bx_albums', 'media_comments', [...]); @endcode
  141. *
  142. * Display media comments block.
  143. * @param $iMediaId media ID, if it's omitted then it's taken from 'id' GET variable.
  144. * @return HTML string with comments. On error false or empty string is returned.
  145. *
  146. * @see BxAlbumsModule::serviceMediaComments
  147. */
  148. /**
  149. * @ref bx_albums-media_comments "media_comments"
  150. */
  151. public function serviceMediaComments ($iMediaId = 0)
  152. {
  153. return $this->_entityComments($this->_oConfig->CNF['OBJECT_COMMENTS_MEDIA'], $iMediaId);
  154. }
  155. /**
  156. * Display media author block.
  157. * @param $iMediaId media ID, if it's omitted then it's taken from 'id' GET variable.
  158. * @return HTML string with block content. On error false or empty string is returned.
  159. */
  160. public function serviceMediaAuthor ($iMediaId = 0)
  161. {
  162. return $this->_serviceTemplateFunc ('mediaAuthor', $iMediaId, 'getMediaInfoById');
  163. }
  164. /**
  165. * Entry actions and social sharing block
  166. */
  167. public function serviceMediaAllActions ($mixedContent = false, $aParams = array())
  168. {
  169. $iMediaId = 0;
  170. $aMediaInfo = array();
  171. $bContent = !empty($mixedContent);
  172. if($bContent && is_array($mixedContent))
  173. list($iMediaId, $aMediaInfo) = $mixedContent;
  174. else {
  175. if($bContent)
  176. $iMediaId = (int)$mixedContent;
  177. else
  178. $iMediaId = bx_process_input(bx_get('id'), BX_DATA_INT);
  179. if(!$iMediaId)
  180. return false;
  181. $aMediaInfo = $this->_oDb->getMediaInfoById($iMediaId);
  182. }
  183. if(!$iMediaId || !$aMediaInfo)
  184. return false;
  185. $CNF = &$this->_oConfig->CNF;
  186. return parent::serviceEntityAllActions (array($iMediaId, $aMediaInfo), array_merge(array(
  187. 'object_menu' => $CNF['OBJECT_MENU_ACTIONS_VIEW_MEDIA_ALL'],
  188. 'object_transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_BIG'],
  189. 'entry_url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_MEDIA'] . '&id=' . $iMediaId),
  190. 'entry_title' => $aMediaInfo['title'],
  191. 'entry_thumb' => $aMediaInfo['file_id']
  192. ), $aParams));
  193. }
  194. /**
  195. * Entry actions block
  196. */
  197. public function serviceMediaActions ($iContentId = 0)
  198. {
  199. $iContentId = $this->_getContent($iContentId, false);
  200. if($iContentId === false)
  201. return false;
  202. $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_VIEW_MEDIA']);
  203. return $oMenu ? $oMenu->getCode() : false;
  204. }
  205. /**
  206. * Display media social sharing buttons block.
  207. * @param $iMediaId media ID, if it's omitted then it's taken from 'id' GET variable.
  208. * @return HTML string with block content. On error false or empty string is returned.
  209. */
  210. public function serviceMediaSocialSharing ($iMediaId = 0)
  211. {
  212. if(!$iMediaId)
  213. $iMediaId = bx_process_input(bx_get('id'), BX_DATA_INT);
  214. if(!$iMediaId)
  215. return false;
  216. $aMediaInfo = $this->_oDb->getMediaInfoById($iMediaId);
  217. if(!$aMediaInfo)
  218. return false;
  219. $CNF = &$this->_oConfig->CNF;
  220. return $this->serviceEntitySocialSharing(array($iMediaId, $aMediaInfo), array(
  221. 'uri' => $CNF['URI_VIEW_MEDIA'],
  222. 'title' => $aMediaInfo['title'],
  223. 'id_thumb' => $aMediaInfo['file_id'],
  224. 'object_transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_BIG']
  225. ));
  226. }
  227. /**
  228. * Display media preview block.
  229. * @param $iMediaId media ID, if it's omitted then it's taken from 'id' GET variable.
  230. * @param $mixedContext current context to navigate to next and previous file, possible values: popular, public, author. If omitted then value from 'context' GTE variable is taken. Default context is 'album' - when nothin is specified.
  231. * @param $aParams array of additional params.
  232. * @return HTML string with block content. On error false or empty string is returned.
  233. */
  234. public function serviceMediaView ($iMediaId = 0, $mixedContext = false, $aParams = array())
  235. {
  236. if(!$iMediaId)
  237. $iMediaId = bx_process_input(bx_get('id'), BX_DATA_INT);
  238. if(!$iMediaId)
  239. return false;
  240. if(!$mixedContext) {
  241. $mixedContext = bx_process_input(bx_get('context'));
  242. if(!in_array($mixedContext, $this->_aContexts)) // when no context specified, it is assumed that it is an album context
  243. $mixedContext = bx_process_input($mixedContext, BX_DATA_INT); // numeric context is reserved for future use
  244. }
  245. $aParams['context'] = $mixedContext;
  246. $iAutoplay = 0;
  247. if(!isset($aParams['autoplay']) && ($iAutoplay = bx_get('autoplay')) !== false)
  248. $aParams['autoplay'] = (int)$iAutoplay;
  249. return $this->_oTemplate->entryMediaView ($iMediaId, $aParams);
  250. }
  251. public function checkAllowedSetThumb ($iContentId = 0)
  252. {
  253. return CHECK_ACTION_RESULT_NOT_ALLOWED;
  254. }
  255. /**
  256. * @page service Service Calls
  257. * @section bx_albums Albums
  258. * @subsection bx_albums-browse Browse
  259. * @subsubsection bx_albums-browse_recent_media browse_recent_media
  260. *
  261. * @code bx_srv('bx_albums', 'browse_recent_media', [...]); @endcode
  262. *
  263. * Display block for browsing recently uploaded media files.
  264. * @param $sUnitView unit view mode: gallery
  265. * @param $bDisplayEmptyMsg display 'empty' message when nothing to browse, or return empty string.
  266. * @param $bAjaxPaginate use AJAX or regular paginate.
  267. * @return HTML string with block content. On error false or empty string is returned.
  268. *
  269. * @see BxAlbumsModule::serviceBrowseRecentMedia
  270. */
  271. /**
  272. * @ref bx_albums-browse_recent_media "browse_recent_media"
  273. */
  274. public function serviceBrowseRecentMedia ($sUnitView = false, $bDisplayEmptyMsg = true, $bAjaxPaginate = true)
  275. {
  276. return $this->_serviceBrowse ('recent', array('unit_view' => $sUnitView), BX_DB_PADDING_DEF, $bDisplayEmptyMsg, $bAjaxPaginate, 'SearchResultMedia');
  277. }
  278. /**
  279. * @page service Service Calls
  280. * @section bx_albums Albums
  281. * @subsection bx_albums-browse Browse
  282. * @subsubsection bx_albums-browse_featured_media browse_featured_media
  283. *
  284. * @code bx_srv('bx_albums', 'browse_featured_media', [...]); @endcode
  285. *
  286. * Display featured media.
  287. * @param $sUnitView unit view mode: gallery
  288. * @param $bDisplayEmptyMsg display 'empty' message when nothing to browse, or return empty string.
  289. * @param $bAjaxPaginate use AJAX or regular paginate.
  290. * @return HTML string with block content. On error false or empty string is returned.
  291. *
  292. * @see BxAlbumsModule::serviceBrowseFeaturedMedia
  293. */
  294. /**
  295. * @ref bx_albums-browse_featured_media "browse_featured_media"
  296. */
  297. public function serviceBrowseFeaturedMedia ($sUnitView = false, $bDisplayEmptyMsg = false, $bAjaxPaginate = true)
  298. {
  299. return $this->_serviceBrowse ('featured', array('unit_view' => $sUnitView), BX_DB_PADDING_DEF, $bDisplayEmptyMsg, $bAjaxPaginate, 'SearchResultMedia');
  300. }
  301. /**
  302. * @page service Service Calls
  303. * @section bx_albums Albums
  304. * @subsection bx_albums-browse Browse
  305. * @subsubsection bx_albums-browse_popular_media browse_popular_media
  306. *
  307. * @code bx_srv('bx_albums', 'browse_popular_media', [...]); @endcode
  308. *
  309. * Display popular media.
  310. * @param $sUnitView unit view mode: gallery
  311. * @param $bDisplayEmptyMsg display 'empty' message when nothing to browse, or return empty string.
  312. * @param $bAjaxPaginate use AJAX or regular paginate.
  313. * @return HTML string with block content. On error false or empty string is returned.
  314. *
  315. * @see BxAlbumsModule::serviceBrowsePopularMedia
  316. */
  317. /**
  318. * @ref bx_albums-browse_popular_media "browse_popular_media"
  319. */
  320. public function serviceBrowsePopularMedia ($sUnitView = false, $bDisplayEmptyMsg = true, $bAjaxPaginate = true)
  321. {
  322. return $this->_serviceBrowse ('popular', array('unit_view' => $sUnitView), BX_DB_PADDING_DEF, $bDisplayEmptyMsg, $bAjaxPaginate, 'SearchResultMedia');
  323. }
  324. /**
  325. * @page service Service Calls
  326. * @section bx_albums Albums
  327. * @subsection bx_albums-browse Browse
  328. * @subsubsection bx_albums-browse_top_media browse_top_media
  329. *
  330. * @code bx_srv('bx_albums', 'browse_top_media', [...]); @endcode
  331. *
  332. * Display top media.
  333. * @param $sUnitView unit view mode: gallery
  334. * @param $bDisplayEmptyMsg display 'empty' message when nothing to browse, or return empty string.
  335. * @param $bAjaxPaginate use AJAX or regular paginate.
  336. * @return HTML string with block content. On error false or empty string is returned.
  337. *
  338. * @see BxAlbumsModule::serviceBrowseTopMedia
  339. */
  340. /**
  341. * @ref bx_albums-browse_top_media "browse_top_media"
  342. */
  343. public function serviceBrowseTopMedia ($sUnitView = false, $bDisplayEmptyMsg = true, $bAjaxPaginate = true)
  344. {
  345. return $this->_serviceBrowse ('top', array('unit_view' => $sUnitView), BX_DB_PADDING_DEF, $bDisplayEmptyMsg, $bAjaxPaginate, 'SearchResultMedia');
  346. }
  347. /**
  348. * @page service Service Calls
  349. * @section bx_albums Albums
  350. * @subsection bx_albums-browse Browse
  351. * @subsubsection bx_albums-browse_favorite_media browse_favorite_media
  352. *
  353. * @code bx_srv('bx_albums', 'browse_favorite_media', [...]); @endcode
  354. *
  355. * Display favorite media for particular profile.
  356. * @param $iProfileId profile ID, if omitted then 'profile_id' GET variable is used
  357. * @param $aParams additional params for browsing such as 'unit_view'
  358. *
  359. * @see BxAlbumsModule::serviceBrowseFavoriteMedia
  360. */
  361. /**
  362. * @ref bx_albums-browse_favorite_media "browse_favorite_media"
  363. */
  364. public function serviceBrowseFavoriteMedia ($iProfileId = 0, $aParams = array())
  365. {
  366. $oProfile = null;
  367. if((int)$iProfileId)
  368. $oProfile = BxDolProfile::getInstance($iProfileId);
  369. if(!$oProfile && bx_get('profile_id') !== false)
  370. $oProfile = BxDolProfile:: getInstance(bx_process_input(bx_get('profile_id'), BX_DATA_INT));
  371. if(!$oProfile)
  372. $oProfile = BxDolProfile::getInstance();
  373. if(!$oProfile)
  374. return '';
  375. $bEmptyMessage = false;
  376. if(isset($aParams['empty_message'])) {
  377. $bEmptyMessage = (bool)$aParams['empty_message'];
  378. unset($aParams['empty_message']);
  379. }
  380. return $this->_serviceBrowse ('favorite', array_merge(array('user' => $oProfile->id()), $aParams), BX_DB_PADDING_DEF, $bEmptyMessage, true, 'SearchResultMedia');
  381. }
  382. public function serviceGetTimelineData()
  383. {
  384. $sModule = $this->_aModule['name'];
  385. $aResult = parent::serviceGetTimelineData();
  386. $aResult['handlers'] = array_merge($aResult['handlers'], array(
  387. array('group' => $sModule . '_object_media', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'medias_added', 'module_name' => $sModule, 'module_method' => 'get_timeline_media', 'module_class' => 'Module', 'groupable' => 0, 'group_by' => ''),
  388. ));
  389. $aResult['alerts'] = array_merge($aResult['alerts'], array(
  390. array('unit' => $sModule, 'action' => 'medias_added')
  391. ));
  392. return $aResult;
  393. }
  394. public function serviceGetTimelineMedia($aEvent, $aBrowseParams = array())
  395. {
  396. if(empty($aEvent['content']))
  397. return false;
  398. $aEvent['content'] = unserialize($aEvent['content']);
  399. if(empty($aEvent['content']['medias_added']) || !is_array($aEvent['content']['medias_added']))
  400. return false;
  401. $iContentId = (int)$aEvent['object_id'];
  402. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  403. if(empty($aContentInfo) || !is_array($aContentInfo))
  404. return false;
  405. $CNF = &$this->_oConfig->CNF;
  406. //--- Views
  407. $oViews = isset($CNF['OBJECT_VIEWS']) ? BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $iContentId) : null;
  408. $aViews = array();
  409. if ($oViews && $oViews->isEnabled())
  410. $aViews = array(
  411. 'system' => $CNF['OBJECT_VIEWS'],
  412. 'object_id' => $iContentId,
  413. 'count' => $aContentInfo['views']
  414. );
  415. //--- Votes
  416. $oVotes = isset($CNF['OBJECT_VOTES']) ? BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $iContentId) : null;
  417. $aVotes = array();
  418. if ($oVotes && $oVotes->isEnabled())
  419. $aVotes = array(
  420. 'system' => $CNF['OBJECT_VOTES'],
  421. 'object_id' => $iContentId,
  422. 'count' => $aContentInfo['votes']
  423. );
  424. //--- Scores
  425. $oScores = isset($CNF['OBJECT_SCORES']) ? BxDolScore::getObjectInstance($CNF['OBJECT_SCORES'], $iContentId) : null;
  426. $aScores = array();
  427. if ($oScores && $oScores->isEnabled())
  428. $aScores = array(
  429. 'system' => $CNF['OBJECT_SCORES'],
  430. 'object_id' => $iContentId,
  431. 'score' => $aContentInfo['score']
  432. );
  433. //--- Reports
  434. $oReports = isset($CNF['OBJECT_REPORTS']) ? BxDolReport::getObjectInstance($CNF['OBJECT_REPORTS'], $aEvent['object_id']) : null;
  435. $aReports = array();
  436. if ($oReports && $oReports->isEnabled())
  437. $aReports = array(
  438. 'system' => $CNF['OBJECT_REPORTS'],
  439. 'object_id' => $iContentId,
  440. 'count' => $aContentInfo['reports']
  441. );
  442. //--- Comments
  443. $oCmts = isset($CNF['OBJECT_COMMENTS']) ? BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContentId) : null;
  444. $aComments = array();
  445. if($oCmts && $oCmts->isEnabled())
  446. $aComments = array(
  447. 'system' => $CNF['OBJECT_COMMENTS'],
  448. 'object_id' => $iContentId,
  449. 'count' => $aContentInfo['comments']
  450. );
  451. //--- Title & Description
  452. $sTitle = isset($CNF['FIELD_TITLE']) && isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : (isset($CNF['FIELD_TEXT']) && isset($aContentInfo[$CNF['FIELD_TEXT']]) ? strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...') : '');
  453. return array(
  454. '_cache' => true,
  455. 'owner_id' => $aEvent['owner_id'],
  456. 'object_owner_id' => $aContentInfo['author'],
  457. 'icon' => !empty($CNF['ICON']) ? $CNF['ICON'] : '',
  458. 'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
  459. 'sample_wo_article' => $CNF['T']['txt_sample_single'],
  460. 'sample_action' => $CNF['T']['txt_sample_action_changed'],
  461. 'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId),
  462. 'content' => $this->_getContentForTimelineMedia($aEvent, $aContentInfo, $aBrowseParams), //a string to display or array to parse default template before displaying.
  463. 'date' => $aContentInfo[$CNF['FIELD_ADDED']],
  464. 'views' => $aViews,
  465. 'votes' => $aVotes,
  466. 'scores' => $aScores,
  467. 'reports' => $aReports,
  468. 'comments' => $aComments,
  469. 'title' => $sTitle, //may be empty.
  470. 'description' => '' //may be empty.
  471. );
  472. }
  473. public function serviceGetNotificationsData()
  474. {
  475. $sModule = $this->_aModule['name'];
  476. $sEventPrivacy = $sModule . '_allow_view_event_to';
  477. if(BxDolPrivacy::getObjectInstance($sEventPrivacy) === false)
  478. $sEventPrivacy = '';
  479. $aResult = parent::serviceGetNotificationsData();
  480. $aResult['handlers'] = array_merge($aResult['handlers'], array(
  481. array('group' => $sModule . '_object_media', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'medias_added', 'module_name' => $sModule, 'module_method' => 'get_notifications_media', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  482. array('group' => $sModule . '_object_media', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'media_deleted'),
  483. array('group' => $sModule . '_comment_media', 'type' => 'insert', 'alert_unit' => $sModule . '_media', 'alert_action' => 'commentPost', 'module_name' => $sModule, 'module_method' => 'get_notifications_comment_media', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  484. array('group' => $sModule . '_comment_media', 'type' => 'delete', 'alert_unit' => $sModule . '_media', 'alert_action' => 'commentRemoved'),
  485. array('group' => $sModule . '_vote_media', 'type' => 'insert', 'alert_unit' => $sModule . '_media', 'alert_action' => 'doVote', 'module_name' => $sModule, 'module_method' => 'get_notifications_vote_media', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  486. array('group' => $sModule . '_vote_media', 'type' => 'delete', 'alert_unit' => $sModule . '_media', 'alert_action' => 'undoVote'),
  487. array('group' => $sModule . '_score_up_media', 'type' => 'insert', 'alert_unit' => $sModule . '_media', 'alert_action' => 'doVoteUp', 'module_name' => $sModule, 'module_method' => 'get_notifications_score_up_media', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  488. array('group' => $sModule . '_score_down_media', 'type' => 'insert', 'alert_unit' => $sModule . '_media', 'alert_action' => 'doVoteDown', 'module_name' => $sModule, 'module_method' => 'get_notifications_score_down_media', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  489. ));
  490. $aResult['settings'] = array_merge($aResult['settings'], array(
  491. array('group' => 'content', 'unit' => $sModule, 'action' => 'medias_added', 'types' => array('follow_member', 'follow_context')),
  492. array('group' => 'comment', 'unit' => $sModule . '_media', 'action' => 'commentPost', 'types' => array('personal', 'follow_member', 'follow_context')),
  493. array('group' => 'vote', 'unit' => $sModule . '_media', 'action' => 'doVote', 'types' => array('personal', 'follow_member', 'follow_context')),
  494. array('group' => 'score_up', 'unit' => $sModule . '_media', 'action' => 'doVoteUp', 'types' => array('personal', 'follow_member', 'follow_context')),
  495. array('group' => 'score_down', 'unit' => $sModule . '_media', 'action' => 'doVoteDown', 'types' => array('personal', 'follow_member', 'follow_context'))
  496. ));
  497. $aResult['alerts'] = array_merge($aResult['alerts'], array(
  498. array('unit' => $sModule, 'action' => 'medias_added'),
  499. array('unit' => $sModule, 'action' => 'media_deleted'),
  500. array('unit' => $sModule . '_media', 'action' => 'commentPost'),
  501. array('unit' => $sModule . '_media', 'action' => 'commentRemoved'),
  502. array('unit' => $sModule . '_media', 'action' => 'doVote'),
  503. array('unit' => $sModule . '_media', 'action' => 'undoVote'),
  504. array('unit' => $sModule . '_media', 'action' => 'doVoteUp'),
  505. array('unit' => $sModule . '_media', 'action' => 'doVoteDown'),
  506. ));
  507. return $aResult;
  508. }
  509. public function serviceGetNotificationsMedia($aEvent)
  510. {
  511. $CNF = &$this->_oConfig->CNF;
  512. $iContentId = (int)$aEvent['object_id'];
  513. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  514. if(empty($aContentInfo) || !is_array($aContentInfo))
  515. return array();
  516. $iMediaId = (int)$aEvent['subobject_id'];
  517. $aMediaInfo = $this->_oDb->getMediaInfoById($iMediaId);
  518. if(empty($aMediaInfo) || !is_array($aMediaInfo))
  519. return array();
  520. $oPermalinks = BxDolPermalinks::getInstance();
  521. $sEntryUrl = BX_DOL_URL_ROOT . $oPermalinks->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId);
  522. $sSubentryUrl = BX_DOL_URL_ROOT . $oPermalinks->permalink('page.php?i=' . $CNF['URI_VIEW_MEDIA'] . '&id=' . $iMediaId);
  523. $sEntryCaption = isset($aMediaInfo['title']) ? $aMediaInfo['title'] : _t('_bx_albums_media');
  524. return array(
  525. 'entry_sample' => $CNF['T']['txt_sample_single'],
  526. 'entry_url' => $sEntryUrl,
  527. 'entry_caption' => $sEntryCaption,
  528. 'entry_author' => $aMediaInfo['author'],
  529. 'subentry_sample' => $CNF['T']['txt_media_single'],
  530. 'subentry_url' => $sSubentryUrl,
  531. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  532. );
  533. }
  534. public function serviceGetNotificationsCommentMedia($aEvent)
  535. {
  536. $CNF = &$this->_oConfig->CNF;
  537. $iMediaId = (int)$aEvent['object_id'];
  538. $aMediaInfo = $this->_oDb->getMediaInfoById($iMediaId);
  539. if(empty($aMediaInfo) || !is_array($aMediaInfo))
  540. return array();
  541. $oComment = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS_MEDIA'], $iMediaId);
  542. if(!$oComment || !$oComment->isEnabled())
  543. return array();
  544. $sEntryUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_MEDIA'] . '&id=' . $aMediaInfo['id']);
  545. $sEntryCaption = isset($aMediaInfo['title']) ? $aMediaInfo['title'] : _t('_bx_albums_media');
  546. return array(
  547. 'entry_sample' => $CNF['T']['txt_media_single'],
  548. 'entry_url' => $sEntryUrl,
  549. 'entry_caption' => $sEntryCaption,
  550. 'entry_author' => $aMediaInfo['author'],
  551. 'subentry_sample' => $CNF['T']['txt_media_comment_single'],
  552. 'subentry_url' => $oComment->getViewUrl((int)$aEvent['subobject_id']),
  553. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  554. );
  555. }
  556. public function serviceGetNotificationsVoteMedia($aEvent)
  557. {
  558. $CNF = &$this->_oConfig->CNF;
  559. $iMediaId = (int)$aEvent['object_id'];
  560. $aMediaInfo = $this->_oDb->getMediaInfoById($iMediaId);
  561. if(empty($aMediaInfo) || !is_array($aMediaInfo))
  562. return array();
  563. $oVote = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_MEDIA'], $iMediaId);
  564. if(!$oVote || !$oVote->isEnabled())
  565. return array();
  566. $sEntryUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_MEDIA'] . '&id=' . $aMediaInfo['id']);
  567. $sEntryCaption = isset($aMediaInfo['title']) ? $aMediaInfo['title'] : _t('_bx_albums_media');
  568. return array(
  569. 'entry_sample' => $CNF['T']['txt_media_single'],
  570. 'entry_url' => $sEntryUrl,
  571. 'entry_caption' => $sEntryCaption,
  572. 'entry_author' => $aMediaInfo['author'],
  573. 'subentry_sample' => $CNF['T']['txt_media_vote_single'],
  574. 'subentry_url' => '',
  575. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  576. );
  577. }
  578. public function serviceGetNotificationsScoreUpMedia($aEvent)
  579. {
  580. return $this->_serviceGetNotificationsScoreMedia('up', $aEvent);
  581. }
  582. public function serviceGetNotificationsScoreDownMedia($aEvent)
  583. {
  584. return $this->_serviceGetNotificationsScoreMedia('down', $aEvent);
  585. }
  586. protected function _serviceGetNotificationsScoreMedia($sType, $aEvent)
  587. {
  588. $CNF = &$this->_oConfig->CNF;
  589. $iMediaId = (int)$aEvent['object_id'];
  590. $aMediaInfo = $this->_oDb->getMediaInfoById($iMediaId);
  591. if(empty($aMediaInfo) || !is_array($aMediaInfo))
  592. return array();
  593. $oVote = BxDolScore::getObjectInstance($CNF['OBJECT_SCORES_MEDIA'], $iMediaId);
  594. if(!$oVote || !$oVote->isEnabled())
  595. return array();
  596. $sEntryUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_MEDIA'] . '&id=' . $aMediaInfo['id']);
  597. $sEntryCaption = isset($aMediaInfo['title']) ? $aMediaInfo['title'] : _t('_bx_albums_media');
  598. return array(
  599. 'entry_sample' => $CNF['T']['txt_media_single'],
  600. 'entry_url' => $sEntryUrl,
  601. 'entry_caption' => $sEntryCaption,
  602. 'entry_author' => $aMediaInfo['author'],
  603. 'subentry_sample' => $CNF['T']['txt_media_score_' . $sType . '_single'],
  604. 'subentry_url' => '',
  605. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  606. );
  607. }
  608. public function actionEditMedia($iMediaId)
  609. {
  610. $CNF = &$this->_oConfig->CNF;
  611. $iMediaId = (int)$iMediaId;
  612. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_MEDIA'], $CNF['OBJECT_FORM_MEDIA_DISPLAY_EDIT']);
  613. $oForm->initForm('edit', $iMediaId);
  614. $oForm->initChecker();
  615. if($oForm->isSubmittedAndValid()) {
  616. if($oForm->update($iMediaId) !== false)
  617. $aRes = array('reload' => 1);
  618. else
  619. $aRes = array('msg' => _t('_bx_albums_txt_err_cannot_perform_action'));
  620. return echoJson($aRes);
  621. }
  622. $sContent = BxTemplStudioFunctions::getInstance()->transBox('bx-albums-edit-media-popup', $this->_oTemplate->parseHtmlByName('media-edit.html', array(
  623. 'form_id' => $oForm->aFormAttrs['id'],
  624. 'form' => $oForm->getCode(true)
  625. )));
  626. echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))));
  627. }
  628. public function actionDeleteMedia($iMediaId)
  629. {
  630. $CNF = &$this->_oConfig->CNF;
  631. $aMediaInfo = $this->_oDb->getMediaInfoById($iMediaId);
  632. $oUploader = BxDolUploader::getObjectInstance($CNF['OBJECT_UPLOADERS'][0], $CNF['OBJECT_STORAGE'], '');
  633. $oUploader->deleteGhost($aMediaInfo['file_id'], bx_get_logged_profile_id());
  634. echoJson(['redirect' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aMediaInfo['content_id'])]);
  635. }
  636. public function actionMoveMedia($iMediaId)
  637. {
  638. $CNF = &$this->_oConfig->CNF;
  639. $iMediaId = (int)$iMediaId;
  640. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_MEDIA'], $CNF['OBJECT_FORM_MEDIA_DISPLAY_MOVE']);
  641. $oForm->initForm('move', $iMediaId);
  642. $oForm->initChecker();
  643. if($oForm->isSubmittedAndValid()) {
  644. if($oForm->update($iMediaId) !== false)
  645. $aRes = array('reload' => 1);
  646. else
  647. $aRes = array('msg' => _t('_bx_albums_txt_err_cannot_perform_action'));
  648. return echoJson($aRes);
  649. }
  650. $sContent = BxTemplStudioFunctions::getInstance()->transBox('bx-albums-move-media-popup', $this->_oTemplate->parseHtmlByName('media-edit.html', array(
  651. 'form_id' => $oForm->aFormAttrs['id'],
  652. 'form' => $oForm->getCode(true)
  653. )));
  654. echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))));
  655. }
  656. public function actionGetSiblingMedia($iMediaId, $mixedContext)
  657. {
  658. $aSiblings = false;
  659. $sErrorMsg = false;
  660. if (!($aMediaInfo = $this->_oDb->getMediaInfoById((int)$iMediaId)))
  661. $sErrorMsg = _t('_sys_txt_error_occured');
  662. if (empty($sErrorMsg) && !($aContentInfo = $this->_oDb->getContentInfoById($aMediaInfo['content_id'])))
  663. $sErrorMsg = _t('_sys_txt_error_occured');
  664. if (empty($sErrorMsg) && (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedView($aContentInfo))))
  665. $sErrorMsg = $sMsg;
  666. if (empty($sErrorMsg)) {
  667. $aSiblings = array (
  668. 'next' => $this->_oTemplate->getNextPrevMedia($aMediaInfo, true, $mixedContext),
  669. 'prev' => $this->_oTemplate->getNextPrevMedia($aMediaInfo, false, $mixedContext),
  670. );
  671. }
  672. $a = $sErrorMsg ? array('error' => $sErrorMsg) : array('next' => $aSiblings['next'], 'prev' => $aSiblings['prev']);
  673. $s = json_encode($a);
  674. header('Content-type: text/html; charset=utf-8');
  675. echo $s;
  676. }
  677. public function actionRssMedia ()
  678. {
  679. $aArgs = func_get_args();
  680. $this->_rss($aArgs, 'SearchResultMedia');
  681. }
  682. public function getMediaDuration($aMediaInfo)
  683. {
  684. $CNF = &$this->_oConfig->CNF;
  685. if(empty($aMediaInfo) || !is_array($aMediaInfo))
  686. return 0;
  687. $sField = 'duration';
  688. if(!empty($aMediaInfo[$sField]))
  689. return (int)$aMediaInfo[$sField];
  690. $iMedia = $aMediaInfo['id'];
  691. $sMedia = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4'])->getFileUrl($iMedia);
  692. if(empty($sMedia))
  693. return 0;
  694. $iDuration = (int)BxDolTranscoderVideo::getDuration($sMedia);
  695. if(!empty($iDuration))
  696. $this->_oDb->updateMedia(array($sField => $iDuration), array('id' => $iMedia));
  697. return $iDuration;
  698. }
  699. protected function _buildRssParams($sMode, $aArgs)
  700. {
  701. if ($aParams = parent::_buildRssParams($sMode, $aArgs))
  702. return $aParams;
  703. $sMode = bx_process_input($sMode);
  704. switch ($sMode) {
  705. case 'album':
  706. $aParams = array('album_id' => isset($aArgs[0]) ? (int)$aArgs[0] : '');
  707. break;
  708. }
  709. return $aParams;
  710. }
  711. protected function _getImagesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  712. {
  713. $CNF = &$this->_oConfig->CNF;
  714. if(empty($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW']) || empty($CNF['OBJECT_TRANSCODER_COVER']))
  715. return array();
  716. $aMediaList = $this->_oDb->getMediaListByContentId($aContentInfo[$CNF['FIELD_ID']]);
  717. if(empty($aMediaList) || !is_array($aMediaList))
  718. return array();
  719. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
  720. $oTcPoster = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['poster']);
  721. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW']);
  722. $oTranscoderCover = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_TRANSCODER_COVER']);
  723. if(!$oTranscoder || !$oTranscoderCover)
  724. return array();
  725. $aOutput = array();
  726. foreach ($aMediaList as $aMedia) {
  727. $aFileInfo = $oStorage->getFile($aMedia['file_id']);
  728. $bVideo = $oTcPoster && strncmp('video/', $aFileInfo['mime_type'], 6) === 0 && $oTcPoster->isMimeTypeSupported($aFileInfo['mime_type']);
  729. if($bVideo)
  730. continue;
  731. $aOutput[$aMedia['id']] = array (
  732. 'id' => $aMedia['id'],
  733. 'url' => $this->_oTemplate->getViewMediaUrl($CNF, $aMedia['id']),
  734. 'src' => $oTranscoder->getFileUrl($aMedia['file_id']),
  735. 'src_orig' => $oTranscoderCover->getFileUrl($aMedia['file_id'])
  736. );
  737. }
  738. if(empty($aOutput))
  739. return array();
  740. $iSlice = 4;
  741. $iTotal = count($aOutput);
  742. return array(
  743. 'total' => $iTotal,
  744. 'items' => $iTotal > $iSlice ? array_slice($aOutput, 0, $iSlice) : $aOutput
  745. );
  746. }
  747. protected function _getVideosForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  748. {
  749. $CNF = &$this->_oConfig->CNF;
  750. if(empty($CNF['OBJECT_VIDEOS_TRANSCODERS']))
  751. return array();
  752. $aMediaList = $this->_oDb->getMediaListByContentId($aContentInfo[$CNF['FIELD_ID']]);
  753. if(empty($aMediaList) || !is_array($aMediaList))
  754. return array();
  755. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
  756. $oTcPoster = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['poster']);
  757. $oTcMp4 = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4']);
  758. $oTcMp4Hd = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4_hd']);
  759. if(!$oTcPoster || !$oTcMp4 || !$oTcMp4Hd)
  760. return array();
  761. $aOutput = array();
  762. foreach($aMediaList as $k => $aMedia) {
  763. $aFileInfo = $oStorage->getFile($aMedia['file_id']);
  764. $bVideo = $oTcPoster && strncmp('video/', $aFileInfo['mime_type'], 6) === 0 && $oTcPoster->isMimeTypeSupported($aFileInfo['mime_type']);
  765. if(!$bVideo)
  766. continue;
  767. $sVideoUrl = $oStorage->getFileUrlById($aMedia['file_id']);
  768. $aVideoFile = $oStorage->getFile($aMedia['file_id']);
  769. $sVideoUrlHd = '';
  770. if (!empty($aVideoFile['dimensions']) && $oTcMp4Hd->isProcessHD($aVideoFile['dimensions']))
  771. $sVideoUrlHd = $oTcMp4Hd->getFileUrl($aMedia['file_id']);
  772. $aOutput[$aMedia['id']] = array(
  773. 'id' => $aMedia['id'],
  774. 'src_poster' => $oTcPoster->getFileUrl($aMedia['file_id']),
  775. 'src_mp4' => $oTcMp4->getFileUrl($aMedia['file_id']),
  776. 'src_mp4_hd' => $sVideoUrlHd,
  777. 'duration' => $aFileInfo['duration'],
  778. );
  779. }
  780. if(empty($aOutput))
  781. return array();
  782. $iSlice = 4;
  783. $iTotal = count($aOutput);
  784. return array(
  785. 'total' => $iTotal,
  786. 'items' => $iTotal > $iSlice ? array_slice($aOutput, 0, $iSlice) : $aOutput
  787. );
  788. }
  789. protected function _getContentForTimelineMedia($aEvent, $aContentInfo, $aBrowseParams = array())
  790. {
  791. $CNF = &$this->_oConfig->CNF;
  792. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  793. $sTitle = isset($CNF['FIELD_TITLE']) && isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : (isset($CNF['FIELD_TEXT']) && isset($aContentInfo[$CNF['FIELD_TEXT']]) ? strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...') : '');
  794. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
  795. $oTcPoster = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['poster']);
  796. $oTcMp4 = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4']);
  797. $oTcMp4Hd = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4_hd']);
  798. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW']);
  799. $oTranscoderCover = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_TRANSCODER_COVER']);
  800. //--- Image(s) and Video(s)
  801. $aImages = $aVideos = array();
  802. foreach($aEvent['content']['medias_added'] as $iMediaId) {
  803. $aMediaInfo = $this->_oDb->getMediaInfoById($iMediaId);
  804. if(empty($aMediaInfo) || !is_array($aMediaInfo))
  805. continue;
  806. $aFileInfo = $oStorage->getFile($aMediaInfo['file_id']);
  807. $bVideo = $oTcPoster && strncmp('video/', $aFileInfo['mime_type'], 6) === 0 && $oTcPoster->isMimeTypeSupported($aFileInfo['mime_type']);
  808. if($bVideo)
  809. $aVideos[$iMediaId] = array(
  810. 'id' => $aMediaInfo['id'],
  811. 'src_poster' => $oTcPoster->getFileUrl($aMediaInfo['file_id']),
  812. 'src_mp4' => $oTcMp4->getFileUrl($aMediaInfo['file_id']),
  813. 'src_mp4_hd' => $oTcMp4Hd->getFileUrl($aMediaInfo['file_id']),
  814. 'duration' => $aFileInfo['duration'],
  815. );
  816. else
  817. $aImages[$iMediaId] = array(
  818. 'id' => $aMediaInfo['id'],
  819. 'url' => $this->_oTemplate->getViewMediaUrl($CNF, $aMediaInfo['id']),
  820. 'src' => $oTranscoder->getFileUrl($aMediaInfo['file_id']),
  821. 'src_orig' => $oTranscoderCover->getFileUrl($aMediaInfo['file_id'])
  822. );
  823. }
  824. return array(
  825. 'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
  826. 'sample_wo_article' => $CNF['T']['txt_sample_single'],
  827. 'sample_action' => isset($CNF['T']['txt_sample_action_changed']),
  828. 'url' => $sUrl,
  829. 'title' => $sTitle,
  830. 'text' => '',
  831. 'images_attach' => $aImages,
  832. 'videos_attach' => $aVideos
  833. );
  834. }
  835. protected function _getImagesForTimelineMedia($aEvent, $aMediaInfo, $sUrl, $aBrowseParams = array())
  836. {
  837. $CNF = &$this->_oConfig->CNF;
  838. $aImages = array();
  839. return $aImages;
  840. }
  841. }
  842. /** @} */