BxTimelineConfig.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  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 Timeline Timeline
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolPrivacy');
  12. class BxTimelineConfig extends BxBaseModNotificationsConfig
  13. {
  14. protected $_aTypeToFormDisplay;
  15. protected $_bAllowEdit;
  16. protected $_bAllowDelete;
  17. protected $_bShowAll;
  18. protected $_bCountAllViews;
  19. protected $_bCacheItem;
  20. protected $_sCacheItemEngine;
  21. protected $_iCacheItemLifetime;
  22. protected $_bCacheList;
  23. protected $_aCacheListExceptions;
  24. protected $_bInfScroll;
  25. protected $_iInfScrollAutoPreloads;
  26. protected $_iRssLength;
  27. protected $_iLiveUpdateLength;
  28. protected $_iCharsDisplayMinTitle;
  29. protected $_iCharsDisplayMaxTitle;
  30. protected $_bDynamicCards;
  31. protected $_sVideosAutoplay;
  32. protected $_iPreloadComments;
  33. protected $_iPreloadCommentsMax;
  34. protected $_bJumpTo;
  35. protected $_sAttachmentsLayout;
  36. protected $_bHot;
  37. protected $_iHotInterval;
  38. protected $_bEditorToolbar;
  39. protected $_bUnhideRestored;
  40. protected $_sStorageObject;
  41. protected $_sTranscoderObjectPreview;
  42. protected $_sTranscoderObjectView;
  43. protected $_aPhotoUploaders;
  44. protected $_aVideoUploaders;
  45. protected $_sMenuItemManage;
  46. protected $_sMenuItemActions;
  47. protected $_aRepostDefaults;
  48. protected $_iTimelineVisibilityThreshold;
  49. protected $_aPregPatterns;
  50. /**
  51. * Constructor
  52. */
  53. public function __construct($aModule)
  54. {
  55. parent::__construct($aModule);
  56. $this->CNF = array (
  57. 'ICON' => 'far clock col-green1',
  58. // database tables
  59. 'TABLE_ENTRIES' => $aModule['db_prefix'] . 'events',
  60. // database fields
  61. 'FIELD_ID' => 'id',
  62. 'FIELD_OWNER_ID' => 'owner_id',
  63. 'FIELD_SYSTEM' => 'system',
  64. 'FIELD_OBJECT_ID' => 'object_id', //Note. For 'Direct Timeline Posts' ('system' db field == 0) this field contains post's author profile ID.
  65. 'FIELD_OBJECT_PRIVACY_VIEW' => 'object_privacy_view',
  66. 'FIELD_ADDED' => 'date',
  67. 'FIELD_PUBLISHED' => 'published',
  68. 'FIELD_TITLE' => 'title',
  69. 'FIELD_TEXT' => 'description',
  70. 'FIELD_STATUS' => 'status',
  71. 'FIELD_STICKED' => 'sticked',
  72. 'FIELD_DATE' => 'date',
  73. 'FIELD_ANONYMOUS' => 'anonymous',
  74. 'FIELD_CONTROLS' => 'controls',
  75. 'FIELD_LOCATION' => 'location',
  76. 'FIELD_LOCATION_PREFIX' => 'location',
  77. 'FIELDS_DELAYED_PROCESSING' => 'video', // can be array of fields or comma separated string of field names
  78. // page URIs
  79. 'URI_VIEW_LIST' => 'timeline-view',
  80. 'URI_VIEW_ENTRY' => 'item',
  81. 'URL_HOME' => 'page.php?i=timeline-view-home',
  82. // objects
  83. 'OBJECT_STORAGE' => $this->_sName . '_photos',
  84. 'OBJECT_STORAGE_VIDEOS' => $this->_sName . '_videos',
  85. 'OBJECT_IMAGES_TRANSCODER_PREVIEW' => $this->_sName . '_photos_preview',
  86. 'OBJECT_VIDEOS_TRANSCODERS' => array(
  87. 'poster' => 'bx_timeline_videos_poster',
  88. 'mp4' => 'bx_timeline_videos_mp4',
  89. 'mp4_hd' => 'bx_timeline_videos_mp4_hd'
  90. ),
  91. 'OBJECT_GRID_ADMINISTRATION' => $this->_sName . '_administration',
  92. 'OBJECT_MENU_ENTRY_ATTACHMENTS' => $this->_sName . '_menu_post_attachments',
  93. 'OBJECT_METATAGS' => $this->_sName,
  94. 'OBJECT_COMMENTS' => $this->_sName,
  95. 'OBJECT_VIEWS' => $this->_sName,
  96. 'OBJECT_VOTES' => $this->_sName,
  97. 'OBJECT_REACTIONS' => $this->_sName . '_reactions',
  98. 'OBJECT_SCORES' => $this->_sName,
  99. 'OBJECT_REPORTS' => $this->_sName,
  100. 'OBJECT_PRIVACY_VIEW' => $this->_sName . '_privacy_view',
  101. // some language keys
  102. 'T' => array (
  103. 'txt_status_deleted' => '_bx_timeline_txt_status_deleted',
  104. 'txt_sample_single' => '_bx_timeline_txt_sample',
  105. 'txt_sample_single_ext' => '_bx_timeline_txt_sample_ext',
  106. 'txt_sample_comment_single' => '_bx_timeline_txt_sample_comment_single',
  107. 'txt_sample_vote_single' => '_bx_timeline_txt_sample_vote_single',
  108. 'txt_sample_reaction_single' => '_bx_timeline_txt_sample_reaction_single',
  109. 'txt_sample_score_up_single' => '_bx_timeline_txt_sample_score_up_single',
  110. 'txt_sample_score_down_single' => '_bx_timeline_txt_sample_score_down_single',
  111. 'txt_sample_with_link' => '_bx_timeline_txt_sample_with_link',
  112. 'txt_sample_with_image' => '_bx_timeline_txt_sample_with_image',
  113. 'txt_sample_with_video' => '_bx_timeline_txt_sample_with_video',
  114. 'txt_sample_with_media' => '_bx_timeline_txt_sample_with_media',
  115. 'grid_action_err_delete' => '_bx_timeline_grid_action_err_delete',
  116. 'grid_txt_account_manager' => '_bx_timeline_grid_txt_account_manager',
  117. 'form_input_title_object_privacy_view' => '_bx_timeline_form_post_input_object_privacy_view',
  118. 'option_vap_off' => '_bx_timeline_option_videos_autoplay_off',
  119. 'option_vap_on_mute' => '_bx_timeline_option_videos_autoplay_on_mute',
  120. 'option_vap_on' => '_bx_timeline_option_videos_autoplay_on',
  121. 'option_al_gallery' => '_bx_timeline_option_attachments_layout_gallery',
  122. 'option_al_showcase' => '_bx_timeline_option_attachments_layout_showcase'
  123. ),
  124. );
  125. $this->_aTypeToFormDisplay = array(
  126. BX_BASE_MOD_NTFS_TYPE_OWNER => 'form_display_post_add_profile',
  127. BX_BASE_MOD_NTFS_TYPE_PUBLIC => 'form_display_post_add_public',
  128. BX_TIMELINE_TYPE_CHANNELS => 'form_display_post_add',
  129. BX_TIMELINE_TYPE_FEED => 'form_display_post_add',
  130. BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS => 'form_display_post_add'
  131. );
  132. $this->_aPrefixes = array(
  133. 'style' => 'bx-tl',
  134. 'language' => '_bx_timeline',
  135. 'option' => 'bx_timeline_',
  136. 'common_post' => 'timeline_common_',
  137. 'cache_item' => 'bx_timeline_item_'
  138. );
  139. $this->_aObjects = array_merge($this->_aObjects, array(
  140. 'comment' => $this->CNF['OBJECT_COMMENTS'],
  141. 'view' => $this->CNF['OBJECT_VIEWS'],
  142. 'vote' => $this->CNF['OBJECT_VOTES'],
  143. 'reaction' => $this->CNF['OBJECT_REACTIONS'],
  144. 'score' => $this->CNF['OBJECT_SCORES'],
  145. 'report' => $this->CNF['OBJECT_REPORTS'],
  146. 'privacy_view' => $this->CNF['OBJECT_PRIVACY_VIEW'],
  147. 'metatags' => $this->_sName,
  148. 'storage_photos' => $this->CNF['OBJECT_STORAGE'],
  149. 'storage_videos' => $this->CNF['OBJECT_STORAGE_VIDEOS'],
  150. 'transcoder_photos_preview' => $this->CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW'],
  151. 'transcoder_photos_view' => $this->_sName . '_photos_view',
  152. 'transcoder_photos_medium' => $this->_sName . '_photos_medium',
  153. 'transcoder_photos_big' => $this->_sName . '_photos_big',
  154. 'transcoder_videos_poster' => $this->CNF['OBJECT_VIDEOS_TRANSCODERS']['poster'],
  155. 'transcoder_videos_mp4' => $this->CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4'],
  156. 'transcoder_videos_mp4_hd' => $this->CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4_hd'],
  157. 'page_item_brief' => $this->_sName . '_item_brief',
  158. 'menu_view' => $this->_sName . '_menu_view',
  159. 'menu_item_manage' => $this->_sName . '_menu_item_manage',
  160. 'menu_item_actions' => $this->_sName . '_menu_item_actions',
  161. 'menu_item_actions_all' => $this->_sName . '_menu_item_actions_all',
  162. 'menu_item_counters' => $this->_sName . '_menu_item_counters',
  163. 'menu_item_meta' => $this->_sName . '_menu_item_meta',
  164. 'menu_post_attachments' => $this->CNF['OBJECT_MENU_ENTRY_ATTACHMENTS'],
  165. 'form_post' => $this->_sName . '_post',
  166. 'form_attach_link' => $this->_sName . '_attach_link',
  167. 'form_display_post_add' => $this->_sName . '_post_add',
  168. 'form_display_post_add_public' => $this->_sName . '_post_add_public',
  169. 'form_display_post_add_profile' => $this->_sName . '_post_add_profile',
  170. 'form_display_post_edit' => $this->_sName . '_post_edit',
  171. 'form_display_post_view' => $this->_sName . '_post_view',
  172. 'form_display_attach_link_add' => $this->_sName . '_attach_link_add'
  173. ));
  174. $this->_aHandlerDescriptor = array('module_name' => '', 'module_method' => '', 'module_class' => '', 'groupable' => '', 'group_by' => '');
  175. $this->_sHandlersMethod = 'get_timeline_data';
  176. $this->_aPhotoUploaders = array($this->_sName . '_simple_photo');
  177. $this->_aVideoUploaders = array($this->_sName . '_simple_video');
  178. $this->_bJsMode = false;
  179. $this->_aJsClasses = array(
  180. 'main' => 'BxTimelineMain',
  181. 'view' => 'BxTimelineView',
  182. 'post' => 'BxTimelinePost',
  183. 'repost' => 'BxTimelineRepost',
  184. 'manage_tools' => 'BxTimelineManageTools'
  185. );
  186. $this->_aJsObjects = array(
  187. 'view' => 'oTimelineView',
  188. 'post' => 'oTimelinePost',
  189. 'repost' => 'oTimelineRepost',
  190. 'manage_tools' => 'oBxTimelineManageTools'
  191. );
  192. $this->_aGridObjects = array(
  193. 'administration' => $this->CNF['OBJECT_GRID_ADMINISTRATION']
  194. );
  195. $sHp = str_replace('_', '-', $this->_sName);
  196. $sHpT = BX_TIMELINE_VIEW_TIMELINE;
  197. $sHpO = BX_TIMELINE_VIEW_OUTLINE;
  198. $this->_aHtmlIds = array(
  199. 'view' => array(
  200. 'edit_form' => $sHp . '-edit-',
  201. 'menu_popup' => $sHp . '-menu-popup-',
  202. 'video_iframe' => $sHp . '-video-iframe-',
  203. 'video' => $sHp . '-video-',
  204. 'live_update_popup' => $sHp . '-live-update-popup-',
  205. ),
  206. 'post' => array(
  207. 'attach_link_popup' => $sHp . '-attach-link-popup',
  208. 'attach_link_form_field' => $sHp . '-attach-link-form_field',
  209. 'attach_link_item' => $sHp . '-attach-link-item-',
  210. 'textarea' => $sHp . '-textarea-',
  211. 'main_' . $sHpT => $sHp . '-' . $sHpT,
  212. 'main_' . $sHpO => $sHp . '-' . $sHpO,
  213. ),
  214. 'repost' => array(
  215. 'main' => $sHp . '-repost-',
  216. 'counter' => $sHp . '-repost-counter-',
  217. 'by_popup' => $sHp . '-repost-by-',
  218. )
  219. );
  220. $this->_aRepostDefaults = array(
  221. 'show_do_repost_as_button' => false,
  222. 'show_do_repost_as_button_small' => false,
  223. 'show_do_repost_image' => false,
  224. 'show_do_repost_icon' => true,
  225. 'show_do_repost_text' => false,
  226. 'show_counter' => true,
  227. //--- Images
  228. 'image_do_repost' => '',
  229. //--- Icons
  230. 'icon_do_repost' => 'sync-alt',
  231. //--- Texts
  232. 'text_do_repost' => '_bx_timeline_txt_do_repost',
  233. //--- Templates
  234. 'template_do_repost_label' => '',
  235. 'template_do_repost_label_name' => 'repost_do_repost_label.html',
  236. );
  237. $this->_iTimelineVisibilityThreshold = 0;
  238. $this->_aPregPatterns = array(
  239. "meta_title" => "/<title>(.*)<\/title>/",
  240. "meta_description" => "/<meta[\s]+[^>]*?name[\s]?=[\s\"\']+description[\s\"\']+content[\s]?=[\s\"\']+(.*?)[\"\']+.*?>/",
  241. "url" => "/(([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_!]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?/"
  242. );
  243. }
  244. public function init(&$oDb)
  245. {
  246. parent::init($oDb);
  247. $sOptionPrefix = $this->getPrefix('option');
  248. $this->_bAllowEdit = getParam($sOptionPrefix . 'enable_edit') == 'on';
  249. $this->_bAllowDelete = getParam($sOptionPrefix . 'enable_delete') == 'on';
  250. $this->_bShowAll = getParam($sOptionPrefix . 'enable_show_all') == 'on';
  251. $this->_bCountAllViews = getParam($sOptionPrefix . 'enable_count_all_views') == 'on';
  252. $this->_bCacheItem = getParam($sOptionPrefix . 'enable_cache_item') == 'on';
  253. $this->_sCacheItemEngine = getParam($sOptionPrefix . 'cache_item_engine');
  254. $this->_iCacheItemLifetime = (int)getParam($sOptionPrefix . 'cache_item_lifetime');
  255. $this->_bCacheList = getParam($sOptionPrefix . 'enable_cache_list') == 'on';
  256. $this->_aCacheListExceptions = array(BX_TIMELINE_TYPE_HOT);
  257. $this->_aPerPage = array(
  258. 'default' => (int)getParam($sOptionPrefix . 'events_per_page'),
  259. 'profile' => (int)getParam($sOptionPrefix . 'events_per_page_profile'),
  260. 'account' => (int)getParam($sOptionPrefix . 'events_per_page_account'),
  261. 'home' => (int)getParam($sOptionPrefix . 'events_per_page_home'),
  262. 'preload' => (int)getParam($sOptionPrefix . 'events_per_preload')
  263. );
  264. $this->_bInfScroll = getParam($sOptionPrefix . 'enable_infinite_scroll') == 'on';
  265. $this->_iInfScrollAutoPreloads = (int)getParam($sOptionPrefix . 'auto_preloads');
  266. $this->_iRssLength = (int)getParam($sOptionPrefix . 'rss_length');
  267. $this->_iLiveUpdateLength = 10;
  268. $this->_iCharsDisplayMinTitle = 32;
  269. $this->_iCharsDisplayMaxTitle = 64;
  270. $this->_bDynamicCards = getParam($sOptionPrefix . 'enable_dynamic_cards') == 'on';
  271. $this->_sVideosAutoplay = getParam($sOptionPrefix . 'videos_autoplay');
  272. $this->_iPreloadCommentsMax = 7;
  273. $this->_iPreloadComments = (int)getParam($sOptionPrefix . 'preload_comments');
  274. if($this->_iPreloadComments > $this->_iPreloadCommentsMax)
  275. $this->_iPreloadComments = $this->_iPreloadCommentsMax;
  276. $this->_bJumpTo = getParam($sOptionPrefix . 'enable_jump_to_switcher') == 'on';
  277. $this->_sAttachmentsLayout = getParam($sOptionPrefix . 'attachments_layout');
  278. $this->_bHot = getParam($sOptionPrefix . 'enable_hot') == 'on';
  279. $this->_iHotInterval = (int)getParam($sOptionPrefix . 'hot_interval');
  280. $this->_bEditorToolbar = getParam($sOptionPrefix . 'enable_editor_toolbar') == 'on';
  281. $this->_bUnhideRestored = false;
  282. }
  283. /**
  284. * Generate name from parameters.
  285. *
  286. * @param type $aParams - parameters whose values will be used during generation.
  287. * @param type $aRules - generation rules.
  288. * @return string
  289. */
  290. protected function getNameView($aParams, $aRules = array())
  291. {
  292. $bWithView = !isset($aRules['with_view']) || $aRules['with_view'] === true;
  293. $bWithType = !isset($aRules['with_type']) || $aRules['with_type'] === true;
  294. $bWithOwner = isset($aRules['with_owner']) && $aRules['with_owner'] === true;
  295. $sGlue = !empty($aRules['glue']) ? $aRules['glue'] : '_';
  296. $aAddons = array();
  297. if(!empty($aParams['name']))
  298. $aAddons[] = $aParams['name'];
  299. else {
  300. if($bWithView && !empty($aParams['view']))
  301. $aAddons[] = $aParams['view'];
  302. if($bWithType && !empty($aParams['type']))
  303. $aAddons[] = $aParams['type'];
  304. }
  305. if($bWithOwner)
  306. $aAddons[] = $aParams['owner_id'];
  307. return !empty($aAddons) ? implode($sGlue, $aAddons) : '';
  308. }
  309. /**
  310. * Generates unique JS object name for View events block.
  311. *
  312. * @param array $aParams - an array with browsing params received in View block service method
  313. * @return string with JS object name
  314. */
  315. public function getJsObjectView($aParams = array())
  316. {
  317. return parent::getJsObject('view') . bx_gen_method_name($this->getNameView($aParams));
  318. }
  319. public function getHtmlIdView($sKey, $aParams, $aRules = array())
  320. {
  321. $bWhole = !isset($aRules['whole']) || $aRules['whole'] === true;
  322. $sGlue = !empty($aRules['glue']) ? $aRules['glue'] : '_';
  323. return str_replace($sGlue, '-', $this->_sName . $sGlue . $sKey . $sGlue . $this->getNameView($aParams, $aRules) . (!$bWhole ? $sGlue : ''));
  324. }
  325. public function isAllowEdit()
  326. {
  327. return $this->_bAllowEdit;
  328. }
  329. public function isAllowDelete()
  330. {
  331. return $this->_bAllowDelete;
  332. }
  333. public function isInfiniteScroll()
  334. {
  335. return $this->_bInfScroll;
  336. }
  337. public function isShowAll()
  338. {
  339. return $this->_bShowAll;
  340. }
  341. public function isCountAllViews()
  342. {
  343. return $this->_bCountAllViews;
  344. }
  345. public function isDynamicCards()
  346. {
  347. return $this->_bDynamicCards;
  348. }
  349. public function isJumpTo()
  350. {
  351. return $this->_bJumpTo;
  352. }
  353. public function isHot()
  354. {
  355. return $this->_bHot;
  356. }
  357. public function isEmoji()
  358. {
  359. $oMenu = BxDolMenu::getObjectInstance($this->getObject('menu_post_attachments'));
  360. if(!$oMenu)
  361. return false;
  362. return $oMenu->isMenuItem('add-emoji');
  363. }
  364. public function isEditorToolbar()
  365. {
  366. return $this->_bEditorToolbar;
  367. }
  368. public function isUnhideRestored()
  369. {
  370. return $this->_bUnhideRestored;
  371. }
  372. public function isCacheItem()
  373. {
  374. return $this->_bCacheItem;
  375. }
  376. public function isCacheList()
  377. {
  378. return $this->_bCacheList;
  379. }
  380. public function isCacheListException($sType)
  381. {
  382. return in_array($sType, $this->_aCacheListExceptions);
  383. }
  384. public function getCacheItemEngine()
  385. {
  386. return $this->_sCacheItemEngine;
  387. }
  388. public function getCacheItemLifetime()
  389. {
  390. return $this->_iCacheItemLifetime;
  391. }
  392. public function getCacheItemKey($iId, $sPostfix = '')
  393. {
  394. return $this->getPrefix('cache_item') . $iId . (bx_is_mobile() ? '_m' : '') . '_r' . bx_get_device_pixel_ratio() . '_' . (!empty($sPostfix) ? '_' . $sPostfix : '') . '.php';
  395. }
  396. public function getPostFormDisplay($sType)
  397. {
  398. if(empty($sType) || !array_key_exists($sType, $this->_aTypeToFormDisplay))
  399. $sType = BX_TIMELINE_TYPE_DEFAULT;
  400. return $this->_aTypeToFormDisplay[$sType];
  401. }
  402. public function getUploaders($sType)
  403. {
  404. $aResult = array();
  405. switch($sType) {
  406. case 'photo':
  407. $aResult = $this->_aPhotoUploaders;
  408. break;
  409. case 'video':
  410. $aResult = $this->_aVideoUploaders;
  411. break;
  412. }
  413. return $aResult;
  414. }
  415. public function getPerPage($sType = 'default')
  416. {
  417. if($this->isInfiniteScroll())
  418. $sType = 'preload';
  419. return parent::getPerPage($sType);
  420. }
  421. public function getAutoPreloads()
  422. {
  423. return $this->_iInfScrollAutoPreloads;
  424. }
  425. public function getRssLength()
  426. {
  427. return $this->_iRssLength;
  428. }
  429. public function getLiveUpdateLength()
  430. {
  431. return $this->_iLiveUpdateLength;
  432. }
  433. public function getCharsDisplayMinTitle()
  434. {
  435. return $this->_iCharsDisplayMinTitle;
  436. }
  437. public function getCharsDisplayMaxTitle()
  438. {
  439. return $this->_iCharsDisplayMaxTitle;
  440. }
  441. public function getVideosAutoplay()
  442. {
  443. return $this->_sVideosAutoplay;
  444. }
  445. public function getPreloadComments()
  446. {
  447. return $this->_iPreloadComments;
  448. }
  449. public function getAttachmentsLayout()
  450. {
  451. return $this->_sAttachmentsLayout;
  452. }
  453. public function getHotInterval()
  454. {
  455. return $this->_iHotInterval;
  456. }
  457. public function getRepostDefaults()
  458. {
  459. return $this->_aRepostDefaults;
  460. }
  461. public function getPregPattern($sType)
  462. {
  463. return $this->_aPregPatterns[$sType];
  464. }
  465. /**
  466. * Ancillary functions
  467. */
  468. public function getTitle($s, $mixedProfile = false, $sMethodLength = 'getCharsDisplayMaxTitle')
  469. {
  470. if(get_mb_substr($s, 0, 1) == '_' && strcmp($s, _t($s)) != 0)
  471. return $s;
  472. if($mixedProfile !== false) {
  473. if(is_numeric($mixedProfile))
  474. $mixedProfile = BxDolProfile::getInstanceMagic((int)$mixedProfile);
  475. if($mixedProfile instanceof BxDolProfile)
  476. $s = bx_replace_markers($s, array(
  477. 'profile_name' => $mixedProfile->getDisplayName()
  478. ));
  479. }
  480. if(!method_exists($this, $sMethodLength))
  481. $sMethodLength = 'getCharsDisplayMaxTitle';
  482. return strmaxtextlen($s, $this->$sMethodLength(), '...');
  483. }
  484. public function getTitleShort($s, $mixedProfile = false)
  485. {
  486. return $this->getTitle($s, $mixedProfile, 'getCharsDisplayMinTitle');
  487. }
  488. public function getTitleDefault($bL, $bP, $bV)
  489. {
  490. $sResult = '';
  491. if($bL && !$bP && !$bV)
  492. $sResult = 'link';
  493. else if(!$bL && $bP && !$bV)
  494. $sResult = 'image';
  495. else if(!$bL && !$bP && $bV)
  496. $sResult = 'video';
  497. else
  498. $sResult = 'media';
  499. return $this->CNF['T']['txt_sample_with_' . $sResult];
  500. }
  501. public function getViewUrl($iOwnerId)
  502. {
  503. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php', array(
  504. 'i' => $this->CNF['URI_VIEW_LIST'],
  505. 'id' => $iOwnerId
  506. ));
  507. }
  508. public function getHomeViewUrl()
  509. {
  510. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($this->CNF['URL_HOME']);
  511. }
  512. public function getItemViewUrl($aEvent)
  513. {
  514. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php', array(
  515. 'i' => $this->CNF['URI_VIEW_ENTRY'],
  516. 'id' => $aEvent['id']
  517. ));
  518. }
  519. public function getLiveUpdateKey($aParams)
  520. {
  521. return $this->getName() . '_live_update_' . $this->getNameView($aParams, array('with_owner' => true));
  522. }
  523. //TODO: isCommon and isSystem can be updated to use new 'system' db field.
  524. public function isCommon($sType, $sAction)
  525. {
  526. return !$this->isSystem($sType, $sAction);
  527. }
  528. public function isSystem($sType, $sAction)
  529. {
  530. $sPrefix = $this->getPrefix('common_post');
  531. return strpos($sType, $sPrefix) === false && !empty($sAction);
  532. }
  533. public function getSystemData(&$aEvent, $aBrowseParams = array())
  534. {
  535. $aHandler = $this->getHandler($aEvent);
  536. if($aHandler === false)
  537. return false;
  538. return BxDolService::call($aHandler['module_name'], $aHandler['module_method'], array($aEvent, $aBrowseParams), $aHandler['module_class']);
  539. }
  540. public function getSystemDataByDescriptor($sType, $sAction, $iObjectId)
  541. {
  542. $aDescriptor = array(
  543. 'type' => $sType,
  544. 'action' => $sAction,
  545. 'object_id' => $iObjectId
  546. );
  547. return $this->getSystemData($aDescriptor);
  548. }
  549. public function isEqualUrls($sUrl1, $sUrl2)
  550. {
  551. $sUrl1 = trim($sUrl1, "/");
  552. $sUrl2 = trim($sUrl2, "/");
  553. return strncmp($sUrl1, $sUrl2, strlen($sUrl1)) === 0;
  554. }
  555. public function addBrowseParams($sUrl, $aParams, $sKey = 'bp')
  556. {
  557. return bx_append_url_params($sUrl, array($sKey => urlencode(base64_encode(serialize($aParams)))));
  558. }
  559. public function getBrowseParams($sValue)
  560. {
  561. return unserialize(base64_decode(urldecode($sValue)));
  562. }
  563. }
  564. /** @} */