BxTimelineConfig.php 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  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 $_bContentOwnActions;
  20. protected $_bRepostOwnActions;
  21. protected $_bHideUponDelete;
  22. protected $_bCacheItem;
  23. protected $_sCacheItemEngine;
  24. protected $_iCacheItemLifetime;
  25. protected $_bCacheTable;
  26. protected $_iCacheTableInterval;
  27. protected $_aCacheTableCheckFields;
  28. protected $_bInfScroll;
  29. protected $_iInfScrollPerPreload;
  30. protected $_iInfScrollAutoPreloads;
  31. protected $_iRssLength;
  32. protected $_iLiveUpdateLength;
  33. protected $_iCharsDisplayMinTitle;
  34. protected $_iCharsDisplayMaxTitle;
  35. protected $_bBriefCards;
  36. protected $_aBriefCardsTags;
  37. protected $_sVideosPreload;
  38. protected $_sVideosAutoplay;
  39. protected $_iPreloadComments;
  40. protected $_iPreloadCommentsMax;
  41. protected $_bJumpTo;
  42. protected $_bSortByReaction;
  43. protected $_bSortByUnread;
  44. protected $_sAttachmentsLayout;
  45. protected $_bHot;
  46. protected $_iHotInterval;
  47. protected $_iHotThresholdContent;
  48. protected $_iHotThresholdComment;
  49. protected $_iHotThresholdVote;
  50. protected $_aHotSources;
  51. protected $_aHotSourcesList;
  52. protected $_aHotList;
  53. protected $_aForYouSources;
  54. protected $_aForYouSourcesList;
  55. protected $_iForYouThdRecomFrds;
  56. protected $_iForYouThdRecomSbns;
  57. protected $_bEditorToolbar;
  58. protected $_bEditorAutoAttach;
  59. protected $_bEnableMediaPriority;
  60. protected $_iLimitAttachLinks;
  61. protected $_bUnhideRestored;
  62. protected $_sStorageObject;
  63. protected $_sTranscoderObjectPreview;
  64. protected $_sTranscoderObjectView;
  65. protected $_aPhotoUploaders;
  66. protected $_aVideoUploaders;
  67. protected $_aFilesUploaders;
  68. protected $_aItemToUploader;
  69. protected $_sMenuItemManage;
  70. protected $_sMenuItemActions;
  71. protected $_aRepostDefaults;
  72. protected $_iTimelineVisibilityThreshold;
  73. protected $_aPregPatterns;
  74. protected $_sSessionKeyType;
  75. /**
  76. * Constructor
  77. */
  78. public function __construct($aModule)
  79. {
  80. parent::__construct($aModule);
  81. $this->CNF = array (
  82. 'ICON' => 'far clock col-green1',
  83. // database tables
  84. 'TABLE_ENTRIES' => $aModule['db_prefix'] . 'events',
  85. // database fields
  86. 'FIELD_ID' => 'id',
  87. 'FIELD_AUTHOR' => 'object_owner_id',
  88. 'FIELD_OWNER_ID' => 'owner_id',
  89. 'FIELD_SYSTEM' => 'system',
  90. 'FIELD_OBJECT_ID' => 'object_id', //Note. For 'Direct Timeline Posts' ('system' db field == 0) this field contains post's author profile ID.
  91. 'FIELD_OBJECT_OWNER_ID' => 'object_owner_id',
  92. 'FIELD_OBJECT_PRIVACY_VIEW' => 'object_privacy_view',
  93. 'FIELD_CF' => 'object_cf',
  94. 'FIELD_SOURCE' => 'source',
  95. 'FIELD_ADDED' => 'date',
  96. 'FIELD_PUBLISHED' => 'published',
  97. 'FIELD_TITLE' => 'title',
  98. 'FIELD_TEXT' => 'description',
  99. 'FIELD_ATTACHMENTS' => 'attachments',
  100. 'FIELD_LINK' => 'link',
  101. 'FIELD_PHOTO' => 'photo',
  102. 'FIELD_VIDEO' => 'video',
  103. 'FIELD_FILE' => 'file',
  104. 'FIELD_STATUS' => 'status',
  105. 'FIELD_STATUS_ADMIN' => 'status_admin',
  106. 'FIELD_STICKED' => 'sticked',
  107. 'FIELD_DATE' => 'date',
  108. 'FIELD_REACTED' => 'reacted',
  109. 'FIELD_ANONYMOUS' => 'anonymous',
  110. 'FIELD_CONTROLS' => 'controls',
  111. 'FIELD_LOCATION' => 'location',
  112. 'FIELD_LOCATION_PREFIX' => 'location',
  113. 'FIELD_LABELS' => 'labels',
  114. 'FIELDS_DELAYED_PROCESSING' => 'video', // can be array of fields or comma separated string of field names
  115. // page URIs
  116. 'URI_VIEW_LIST' => 'timeline-view',
  117. 'URI_VIEW_ENTRY' => 'item',
  118. 'URL_HOME' => 'page.php?i=timeline-view-home',
  119. // some params
  120. 'PARAM_AUTO_APPROVE' => $this->_sName . '_enable_auto_approve',
  121. // objects
  122. 'OBJECT_STORAGE' => $this->_sName . '_photos',
  123. 'OBJECT_STORAGE_VIDEOS' => $this->_sName . '_videos',
  124. 'OBJECT_STORAGE_FILES' => $this->_sName . '_files',
  125. 'OBJECT_IMAGES_TRANSCODER_PREVIEW' => $this->_sName . '_photos_preview',
  126. 'OBJECT_VIDEOS_TRANSCODER_PREVIEW' => $this->_sName . '_proxy_preview',
  127. 'OBJECT_VIDEOS_TRANSCODERS' => array(
  128. 'poster' => 'bx_timeline_videos_poster_view',
  129. 'poster_preview' => 'bx_timeline_videos_poster_preview',
  130. 'mp4' => 'bx_timeline_videos_mp4',
  131. 'mp4_hd' => 'bx_timeline_videos_mp4_hd'
  132. ),
  133. 'OBJECT_UPLOADER_PHOTO_SIMPLE' => $this->_sName . '_simple_photo',
  134. 'OBJECT_UPLOADER_PHOTO_HTML5' => $this->_sName . '_html5_photo',
  135. 'OBJECT_UPLOADER_VIDEO_SIMPLE' => $this->_sName . '_simple_video',
  136. 'OBJECT_UPLOADER_VIDEO_HTML5' => $this->_sName . '_html5_video',
  137. 'OBJECT_UPLOADER_VIDEO_RECORD' => $this->_sName . '_record_video',
  138. 'OBJECT_UPLOADER_FILE_HTML5' => $this->_sName . '_html5_file',
  139. 'OBJECT_UPLOADER_FILE_SIMPLE' => $this->_sName . '_simple_file',
  140. 'OBJECT_GRID_ADMINISTRATION' => $this->_sName . '_administration',
  141. 'OBJECT_GRID_COMMON' => $this->_sName . '_common',
  142. 'OBJECT_GRID_MUTE' => $this->_sName . '_mute',
  143. 'OBJECT_MENU_ENTRY_ATTACHMENTS' => $this->_sName . '_menu_post_attachments',
  144. 'OBJECT_METATAGS' => $this->_sName,
  145. 'OBJECT_COMMENTS' => $this->_sName,
  146. 'OBJECT_NOTES' => $this->_sName . '_notes',
  147. 'OBJECT_VIEWS' => $this->_sName,
  148. 'OBJECT_VOTES' => $this->_sName,
  149. 'OBJECT_REACTIONS' => $this->_sName . '_reactions',
  150. 'OBJECT_SCORES' => $this->_sName,
  151. 'OBJECT_REPORTS' => $this->_sName,
  152. 'OBJECT_PRIVACY_VIEW' => $this->_sName . '_privacy_view',
  153. 'OBJECT_CONNECTIONS_MUTE' => $this->_sName . '_mute',
  154. // some language keys
  155. 'T' => array (
  156. 'txt_status_deleted' => '_bx_timeline_txt_status_deleted',
  157. 'txt_sample_single' => '_bx_timeline_txt_sample',
  158. 'txt_sample_single_ext' => '_bx_timeline_txt_sample_ext',
  159. 'txt_sample_comment_single' => '_bx_timeline_txt_sample_comment_single',
  160. 'txt_sample_vote_single' => '_bx_timeline_txt_sample_vote_single',
  161. 'txt_sample_reaction_single' => '_bx_timeline_txt_sample_reaction_single',
  162. 'txt_sample_score_up_single' => '_bx_timeline_txt_sample_score_up_single',
  163. 'txt_sample_score_down_single' => '_bx_timeline_txt_sample_score_down_single',
  164. 'txt_sample_with_link' => '_bx_timeline_txt_sample_with_link',
  165. 'txt_sample_with_image' => '_bx_timeline_txt_sample_with_image',
  166. 'txt_sample_with_video' => '_bx_timeline_txt_sample_with_video',
  167. 'txt_sample_with_file' => '_bx_timeline_txt_sample_with_file',
  168. 'txt_sample_with_media' => '_bx_timeline_txt_sample_with_media',
  169. 'grid_action_err_delete' => '_bx_timeline_grid_action_err_delete',
  170. 'grid_txt_account_manager' => '_bx_timeline_grid_txt_account_manager',
  171. 'filter_item_active' => '_bx_timeline_grid_filter_item_title_adm_active',
  172. 'filter_item_hidden' => '_bx_timeline_grid_filter_item_title_adm_hidden',
  173. 'filter_item_pending' => '_bx_timeline_grid_filter_item_title_adm_pending',
  174. 'filter_item_select_one_filter1' => '_bx_timeline_grid_filter_item_title_adm_select_one_filter1',
  175. 'form_input_title_object_privacy_view' => '_bx_timeline_form_post_input_object_privacy_view',
  176. 'option_vp_auto' => '_bx_timeline_option_videos_preload_auto',
  177. 'option_vp_metadata' => '_bx_timeline_option_videos_preload_metadata',
  178. 'option_vp_none' => '_bx_timeline_option_videos_preload_none',
  179. 'option_vap_off' => '_bx_timeline_option_videos_autoplay_off',
  180. 'option_vap_on_mute' => '_bx_timeline_option_videos_autoplay_on_mute',
  181. 'option_vap_on' => '_bx_timeline_option_videos_autoplay_on',
  182. 'option_al_gallery' => '_bx_timeline_option_attachments_layout_gallery',
  183. 'option_al_showcase' => '_bx_timeline_option_attachments_layout_showcase',
  184. 'option_hfs_content' => '_bx_timeline_option_hot_sources_content',
  185. 'option_hfs_comment' => '_bx_timeline_option_hot_sources_comment',
  186. 'option_hfs_vote' => '_bx_timeline_option_hot_sources_vote',
  187. 'option_fyfs_feed' => '_bx_timeline_option_for_you_sources_feed',
  188. 'option_fyfs_hot' => '_bx_timeline_option_for_you_sources_hot',
  189. 'option_fyfs_recom_friends' => '_bx_timeline_option_for_you_sources_recom_friends',
  190. 'option_fyfs_recom_subscriptions' => '_bx_timeline_option_for_you_sources_recom_subscriptions',
  191. ),
  192. );
  193. $this->_aTypeToFormDisplay = array(
  194. BX_BASE_MOD_NTFS_TYPE_OWNER => 'form_display_post_add_profile',
  195. BX_BASE_MOD_NTFS_TYPE_PUBLIC => 'form_display_post_add_public',
  196. BX_TIMELINE_TYPE_CHANNELS => 'form_display_post_add',
  197. BX_TIMELINE_TYPE_FEED => 'form_display_post_add',
  198. BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS => 'form_display_post_add'
  199. );
  200. $this->_aPrefixes = array(
  201. 'style' => 'bx-tl',
  202. 'language' => '_bx_timeline',
  203. 'option' => 'bx_timeline_',
  204. 'common_post' => 'timeline_common_',
  205. 'cache_list_hot' => 'bx_timeline_list_hot',
  206. 'cache_item' => 'bx_timeline_item_'
  207. );
  208. $this->_aObjects = array_merge($this->_aObjects, array(
  209. 'comment' => $this->CNF['OBJECT_COMMENTS'],
  210. 'view' => $this->CNF['OBJECT_VIEWS'],
  211. 'vote' => $this->CNF['OBJECT_VOTES'],
  212. 'reaction' => $this->CNF['OBJECT_REACTIONS'],
  213. 'score' => $this->CNF['OBJECT_SCORES'],
  214. 'report' => $this->CNF['OBJECT_REPORTS'],
  215. 'privacy_view' => $this->CNF['OBJECT_PRIVACY_VIEW'],
  216. 'metatags' => $this->_sName,
  217. 'storage_photos' => $this->CNF['OBJECT_STORAGE'],
  218. 'storage_videos' => $this->CNF['OBJECT_STORAGE_VIDEOS'],
  219. 'storage_files' => $this->CNF['OBJECT_STORAGE_FILES'],
  220. 'transcoder_photos_preview' => $this->CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW'],
  221. 'transcoder_photos_view' => $this->_sName . '_photos_view',
  222. 'transcoder_photos_medium' => $this->_sName . '_photos_medium',
  223. 'transcoder_photos_big' => $this->_sName . '_photos_big',
  224. 'transcoder_videos_preview' => $this->CNF['OBJECT_VIDEOS_TRANSCODER_PREVIEW'],
  225. 'transcoder_videos_poster' => $this->CNF['OBJECT_VIDEOS_TRANSCODERS']['poster'],
  226. 'transcoder_videos_mp4' => $this->CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4'],
  227. 'transcoder_videos_mp4_hd' => $this->CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4_hd'],
  228. 'transcoder_videos_photo_view' => $this->_sName . '_videos_photo_view',
  229. 'transcoder_videos_photo_big' => $this->_sName . '_videos_photo_big',
  230. 'page_item_brief' => $this->_sName . '_item_brief',
  231. 'menu_view' => $this->_sName . '_menu_view',
  232. 'menu_feeds' => $this->_sName . '_menu_feeds',
  233. 'menu_set_feeds' => $this->_sName . '_menu_feeds',
  234. 'menu_item_manage' => $this->_sName . '_menu_item_manage',
  235. 'menu_item_actions' => $this->_sName . '_menu_item_actions',
  236. 'menu_item_actions_all' => $this->_sName . '_menu_item_actions_all',
  237. 'menu_item_counters' => $this->_sName . '_menu_item_counters',
  238. 'menu_item_meta' => $this->_sName . '_menu_item_meta',
  239. 'menu_post_attachments' => $this->CNF['OBJECT_MENU_ENTRY_ATTACHMENTS'],
  240. 'form_post' => $this->_sName . '_post',
  241. 'form_attach_link' => $this->_sName . '_attach_link',
  242. 'form_repost' => $this->_sName . '_repost',
  243. 'form_display_post_add' => $this->_sName . '_post_add',
  244. 'form_display_post_add_public' => $this->_sName . '_post_add_public',
  245. 'form_display_post_add_profile' => $this->_sName . '_post_add_profile',
  246. 'form_display_post_edit' => $this->_sName . '_post_edit',
  247. 'form_display_post_view' => $this->_sName . '_post_view',
  248. 'form_display_attach_link_add' => $this->_sName . '_attach_link_add',
  249. 'form_display_repost_with' => $this->_sName . '_repost_with',
  250. 'form_display_repost_to' => $this->_sName . '_repost_to',
  251. 'grid_mute' => $this->CNF['OBJECT_GRID_MUTE'],
  252. 'connection_mute' => $this->CNF['OBJECT_CONNECTIONS_MUTE'],
  253. ));
  254. $this->_aHandlerDescriptor = array('module_name' => '', 'module_method' => '', 'module_class' => '', 'groupable' => '', 'group_by' => '');
  255. $this->_sHandlersMethod = 'get_timeline_data';
  256. $this->_aPhotoUploaders = array($this->CNF['OBJECT_UPLOADER_PHOTO_SIMPLE']);
  257. $this->_aVideoUploaders = array($this->CNF['OBJECT_UPLOADER_VIDEO_SIMPLE']);
  258. $this->_aFilesUploaders = array($this->CNF['OBJECT_UPLOADER_FILE_SIMPLE']);
  259. $this->_aItemToUploader = array(
  260. 'add-photo-simple' => $this->CNF['OBJECT_UPLOADER_PHOTO_SIMPLE'],
  261. 'add-photo-html5' => $this->CNF['OBJECT_UPLOADER_PHOTO_HTML5'],
  262. 'add-video-simple' => $this->CNF['OBJECT_UPLOADER_VIDEO_SIMPLE'],
  263. 'add-video-html5' => $this->CNF['OBJECT_UPLOADER_VIDEO_HTML5'],
  264. 'add-video-record' => $this->CNF['OBJECT_UPLOADER_VIDEO_RECORD'],
  265. 'add-file-simple' => $this->CNF['OBJECT_UPLOADER_FILE_SIMPLE'],
  266. 'add-file-html5' => $this->CNF['OBJECT_UPLOADER_FILE_HTML5'],
  267. );
  268. $this->_aJsClasses = array(
  269. 'main' => 'BxTimelineMain',
  270. 'view' => 'BxTimelineView',
  271. 'post' => 'BxTimelinePost',
  272. 'repost' => 'BxTimelineRepost',
  273. 'manage_tools' => 'BxTimelineManageTools'
  274. );
  275. $this->_aJsObjects = array(
  276. 'view' => 'oTimelineView',
  277. 'post' => 'oTimelinePost',
  278. 'repost' => 'oTimelineRepost',
  279. 'manage_tools' => 'oBxTimelineManageTools'
  280. );
  281. $this->_aGridObjects = array(
  282. 'administration' => $this->CNF['OBJECT_GRID_ADMINISTRATION'],
  283. 'common' => $this->CNF['OBJECT_GRID_COMMON']
  284. );
  285. $sHp = str_replace('_', '-', $this->_sName);
  286. $sHpT = BX_TIMELINE_VIEW_TIMELINE;
  287. $sHpO = BX_TIMELINE_VIEW_OUTLINE;
  288. $this->_aHtmlIds = array(
  289. 'view' => array(
  290. 'edit_form' => $sHp . '-edit-',
  291. 'attach_link_form_field' => $sHp . '-attach-link-form-field-',
  292. 'menu_popup' => $sHp . '-menu-popup-',
  293. 'video_iframe' => $sHp . '-video-iframe-',
  294. 'video' => $sHp . '-video-',
  295. 'live_update_popup' => $sHp . '-live-update-popup-',
  296. ),
  297. 'post' => array(
  298. 'attach_link_popup' => $sHp . '-attach-link-popup',
  299. 'attach_link_form_field' => $sHp . '-attach-link-form-field-',
  300. 'attach_link_item' => $sHp . '-attach-link-item-',
  301. 'textarea' => $sHp . '-textarea-',
  302. 'main_' . $sHpT => $sHp . '-' . $sHpT,
  303. 'main_' . $sHpO => $sHp . '-' . $sHpO,
  304. ),
  305. 'repost' => array(
  306. 'main' => $sHp . '-repost-',
  307. 'counter' => $sHp . '-repost-counter-',
  308. 'by_popup' => $sHp . '-repost-by-',
  309. 'with_popup' => $sHp . '-repost-with',
  310. 'to_popup' => $sHp . '-repost-to',
  311. )
  312. );
  313. $this->_aRepostDefaults = array(
  314. 'do' => 'repost',
  315. 'show_do_repost_as_button' => false,
  316. 'show_do_repost_as_button_small' => false,
  317. 'show_do_repost_icon' => true,
  318. 'show_do_repost_text' => false,
  319. //--- Counter
  320. 'show_counter_label_icon' => false,
  321. 'show_counter_label_text' => true,
  322. 'show_counter' => true,
  323. //--- JS script
  324. 'show_script' => true,
  325. //--- Icons
  326. 'icon_do_repost' => 'redo',
  327. 'icon_do_repost_with' => 'redo',
  328. 'icon_do_repost_to' => 'redo',
  329. //--- Texts
  330. 'text_do_repost' => '_bx_timeline_txt_do_repost',
  331. 'text_do_repost_with' => '_bx_timeline_txt_do_repost_with',
  332. 'text_do_repost_to' => '_bx_timeline_txt_do_repost_to',
  333. //--- Templates
  334. 'template_do_repost_label' => '',
  335. 'template_do_repost_label_name' => 'repost_do_repost_label.html',
  336. );
  337. $this->_iTimelineVisibilityThreshold = 0;
  338. $this->_aPregPatterns = array(
  339. "meta_title" => "/<title>(.*)<\/title>/",
  340. "meta_description" => "/<meta[\s]+[^>]*?name[\s]?=[\s\"\']+description[\s\"\']+content[\s]?=[\s\"\']+(.*?)[\"\']+.*?>/",
  341. "url" => "/(([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%#\/\.\w\-_!\(\)]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?/"
  342. );
  343. $this->_aBriefCardsTags = array('a', 'b', 'i');
  344. $this->_sSessionKeyType = $this->_sName . '_type_';
  345. $this->_aHotSourcesList = [
  346. BX_TIMELINE_HFS_CONTENT,
  347. BX_TIMELINE_HFS_COMMENT,
  348. BX_TIMELINE_HFS_VOTE
  349. ];
  350. $this->_aForYouSourcesList = [
  351. BX_TIMELINE_FYFS_FEED,
  352. BX_TIMELINE_FYFS_HOT,
  353. BX_TIMELINE_FYFS_RECOM_FRIENDS,
  354. BX_TIMELINE_FYFS_RECOM_SUBSCRIPTIONS
  355. ];
  356. }
  357. public function init(&$oDb)
  358. {
  359. parent::init($oDb);
  360. $sOptionPrefix = $this->getPrefix('option');
  361. $this->_bAllowEdit = getParam($sOptionPrefix . 'enable_edit') == 'on';
  362. $this->_bAllowDelete = getParam($sOptionPrefix . 'enable_delete') == 'on';
  363. $this->_bShowAll = getParam($sOptionPrefix . 'enable_show_all') == 'on';
  364. $this->_bCountAllViews = getParam($sOptionPrefix . 'enable_count_all_views') == 'on';
  365. $this->_bContentOwnActions = getParam($sOptionPrefix . 'enable_content_own_actions') == 'on';
  366. $this->_bRepostOwnActions = getParam($sOptionPrefix . 'enable_repost_own_actions') == 'on';
  367. $this->_bHideUponDelete = getParam($sOptionPrefix . 'enable_hide_upon_delete') == 'on';
  368. $this->_bCacheItem = getParam($sOptionPrefix . 'enable_cache_item') == 'on';
  369. $this->_sCacheItemEngine = getParam($sOptionPrefix . 'cache_item_engine');
  370. $this->_iCacheItemLifetime = (int)getParam($sOptionPrefix . 'cache_item_lifetime');
  371. $this->_bCacheTable = getParam($sOptionPrefix . 'enable_cache_table') == 'on';
  372. $this->_iCacheTableInterval = (int)getParam($sOptionPrefix . 'cache_table_interval');
  373. $this->_aCacheTableCheckFields = [
  374. 'date' => 'date',
  375. 'reacted' => 'date',
  376. 'sticked' => 'flag'
  377. ];
  378. $iPerPagePublic = (int)getParam($sOptionPrefix . 'events_per_page_home');
  379. $iPerPageContext = (int)getParam($sOptionPrefix . 'events_per_page_profile');
  380. $iPerPageFeed = (int)getParam($sOptionPrefix . 'events_per_page_account');
  381. $this->_aPerPage = [
  382. 'default' => (int)getParam($sOptionPrefix . 'events_per_page'),
  383. BX_BASE_MOD_NTFS_TYPE_PUBLIC => $iPerPagePublic,
  384. BX_TIMELINE_TYPE_HOT => $iPerPagePublic,
  385. BX_BASE_MOD_NTFS_TYPE_OWNER => $iPerPageContext,
  386. BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS => $iPerPageFeed,
  387. BX_TIMELINE_TYPE_FEED => $iPerPageFeed,
  388. BX_TIMELINE_TYPE_FOR_YOU => $iPerPageFeed,
  389. BX_TIMELINE_TYPE_CHANNELS => $iPerPageFeed,
  390. ];
  391. $this->_bInfScroll = getParam($sOptionPrefix . 'enable_infinite_scroll') == 'on';
  392. $this->_iInfScrollPerPreload = (int)getParam($sOptionPrefix . 'events_per_preload');
  393. $this->_iInfScrollAutoPreloads = (int)getParam($sOptionPrefix . 'auto_preloads');
  394. $this->_iRssLength = (int)getParam($sOptionPrefix . 'rss_length');
  395. $this->_iLiveUpdateLength = (int)getParam($sOptionPrefix . 'live_updates_length');
  396. $this->_bBriefCards = getParam($sOptionPrefix . 'enable_brief_cards') == 'on';
  397. $this->_iCharsDisplayMinTitle = (int)getParam($sOptionPrefix . 'title_chars_short');
  398. $this->_iCharsDisplayMaxTitle = (int)getParam($sOptionPrefix . 'title_chars');
  399. $this->_sVideosPreload = getParam($sOptionPrefix . 'videos_preload');
  400. $this->_sVideosAutoplay = getParam($sOptionPrefix . 'videos_autoplay');
  401. $this->_iPreloadCommentsMax = 7;
  402. $this->_iPreloadComments = (int)getParam($sOptionPrefix . 'preload_comments');
  403. if($this->_iPreloadComments > $this->_iPreloadCommentsMax)
  404. $this->_iPreloadComments = $this->_iPreloadCommentsMax;
  405. $this->_bJumpTo = getParam($sOptionPrefix . 'enable_jump_to_switcher') == 'on';
  406. $this->_bSortByReaction = getParam($sOptionPrefix . 'enable_sort_by_reaction') == 'on';
  407. $this->_bSortByUnread = getParam($sOptionPrefix . 'enable_sort_by_unread') == 'on';
  408. $this->_sAttachmentsLayout = getParam($sOptionPrefix . 'attachments_layout');
  409. $this->_bHot = getParam($sOptionPrefix . 'enable_hot') == 'on';
  410. $this->_iHotThresholdContent = (int)getParam($sOptionPrefix . 'hot_threshold_age');
  411. $this->_iHotThresholdComment = (int)getParam($sOptionPrefix . 'hot_threshold_comment');
  412. $this->_iHotThresholdVote = (int)getParam($sOptionPrefix . 'hot_threshold_vote');
  413. $this->_iHotInterval = (int)getParam($sOptionPrefix . 'hot_interval');
  414. $this->_aHotSources = explode(',', getParam($sOptionPrefix . 'hot_sources'));
  415. $this->_aHotList = $this->_bHot ? $this->_oDb->getHot() : [];
  416. $this->_aForYouSources = explode(',', getParam($sOptionPrefix . 'for_you_sources'));
  417. $this->_iForYouThdRecomFrds = (int)getParam($sOptionPrefix . 'for_you_threshold_recom_friends');
  418. $this->_iForYouThdRecomSbns = (int)getParam($sOptionPrefix . 'for_you_threshold_recom_subscriptions');
  419. $this->_bEditorToolbar = getParam($sOptionPrefix . 'enable_editor_toolbar') == 'on';
  420. $this->_bEditorAutoAttach = getParam($sOptionPrefix . 'editor_auto_attach_insertion') == 'on';
  421. $this->_bEnableMediaPriority = getParam($sOptionPrefix . 'enable_media_priority') == 'on';
  422. $this->_iLimitAttachLinks = (int)getParam($sOptionPrefix . 'limit_attach_links');
  423. $this->_bUnhideRestored = false;
  424. }
  425. /**
  426. * Generate name from parameters.
  427. *
  428. * @param type $aParams - parameters whose values will be used during generation.
  429. * @param type $aRules - generation rules.
  430. * @return string
  431. */
  432. protected function getNameView($aParams, $aRules = array())
  433. {
  434. $bWithView = !isset($aRules['with_view']) || $aRules['with_view'] === true;
  435. $bWithType = !isset($aRules['with_type']) || $aRules['with_type'] === true;
  436. $bWithOwner = isset($aRules['with_owner']) && $aRules['with_owner'] === true;
  437. $sGlue = !empty($aRules['glue']) ? $aRules['glue'] : '_';
  438. $aAddons = array();
  439. if(!empty($aParams['name']))
  440. $aAddons[] = bx_process_output($aParams['name']);
  441. else {
  442. if($bWithView && !empty($aParams['view']))
  443. $aAddons[] = bx_process_output($aParams['view']);
  444. if($bWithType && !empty($aParams['type']))
  445. $aAddons[] = bx_process_output($aParams['type']);
  446. }
  447. if($bWithOwner)
  448. $aAddons[] = (int)$aParams['owner_id'];
  449. return !empty($aAddons) ? implode($sGlue, $aAddons) : '';
  450. }
  451. /**
  452. * Generates unique JS object name for View events block.
  453. *
  454. * @param array $aParams - an array with browsing params received in View block service method
  455. * @return string with JS object name
  456. */
  457. public function getJsObjectView($aParams = array())
  458. {
  459. return parent::getJsObject('view') . bx_gen_method_name($this->getNameView($aParams));
  460. }
  461. public function getHtmlIdView($sKey, $aParams, $aRules = array())
  462. {
  463. $bWhole = !isset($aRules['whole']) || $aRules['whole'] === true;
  464. $sGlue = !empty($aRules['glue']) ? $aRules['glue'] : '_';
  465. return str_replace($sGlue, '-', $this->_sName . $sGlue . $sKey . $sGlue . $this->getNameView($aParams, $aRules) . (!$bWhole ? $sGlue : ''));
  466. }
  467. public function isAllowEdit()
  468. {
  469. return $this->_bAllowEdit;
  470. }
  471. public function isAllowDelete()
  472. {
  473. return $this->_bAllowDelete;
  474. }
  475. public function isInfiniteScroll()
  476. {
  477. return $this->_bInfScroll;
  478. }
  479. public function isShowAll()
  480. {
  481. return $this->_bShowAll;
  482. }
  483. public function isCountAllViews()
  484. {
  485. return $this->_bCountAllViews;
  486. }
  487. public function isContentOwnActions()
  488. {
  489. return $this->_bContentOwnActions;
  490. }
  491. public function isRepostOwnActions()
  492. {
  493. return $this->_bRepostOwnActions;
  494. }
  495. public function isHideUponDelete()
  496. {
  497. return $this->_bHideUponDelete;
  498. }
  499. public function isBriefCards()
  500. {
  501. return $this->_bBriefCards;
  502. }
  503. public function isJumpTo()
  504. {
  505. return $this->_bJumpTo;
  506. }
  507. public function isSortByReaction()
  508. {
  509. return $this->_bSortByReaction;
  510. }
  511. public function isSortByUnread()
  512. {
  513. return $this->_bSortByUnread;
  514. }
  515. public function isHot()
  516. {
  517. return $this->_bHot;
  518. }
  519. public function getHotSourcesList()
  520. {
  521. return $this->_aHotSourcesList;
  522. }
  523. public function getHotSources()
  524. {
  525. return $this->_aHotSources;
  526. }
  527. public function isHotSource($sName)
  528. {
  529. return in_array($sName, $this->_aHotSources);
  530. }
  531. public function getHotThreshold($sSource)
  532. {
  533. if(!in_array($sSource, [BX_TIMELINE_HFS_CONTENT, BX_TIMELINE_HFS_COMMENT, BX_TIMELINE_HFS_VOTE]))
  534. return false;
  535. return $this->{'_iHotThreshold' . ucfirst($sSource)};
  536. }
  537. public function isHotEvent($iEventId)
  538. {
  539. return in_array($iEventId, $this->_aHotList);
  540. }
  541. public function getForYouSourcesList()
  542. {
  543. return $this->_aForYouSourcesList;
  544. }
  545. public function getForYouSources()
  546. {
  547. return $this->_aForYouSources;
  548. }
  549. public function getForYouThresholdRecomFrds()
  550. {
  551. return $this->_iForYouThdRecomFrds >= 0 ? $this->_iForYouThdRecomFrds : 0;
  552. }
  553. public function getForYouThresholdRecomSbns()
  554. {
  555. return $this->_iForYouThdRecomSbns >= 0 ? $this->_iForYouThdRecomSbns : 0;
  556. }
  557. public function isEditorToolbar()
  558. {
  559. return $this->_bEditorToolbar;
  560. }
  561. public function isEditorAutoAttach()
  562. {
  563. return $this->_bEditorAutoAttach;
  564. }
  565. public function isMediaPriority()
  566. {
  567. return $this->_bEnableMediaPriority;
  568. }
  569. public function isUnhideRestored()
  570. {
  571. return $this->_bUnhideRestored;
  572. }
  573. public function isCacheItem()
  574. {
  575. return $this->_bCacheItem;
  576. }
  577. public function isCacheTable()
  578. {
  579. return $this->_bCacheTable;
  580. }
  581. public function getCacheItemEngine()
  582. {
  583. return $this->_sCacheItemEngine;
  584. }
  585. public function getCacheItemLifetime()
  586. {
  587. return $this->_iCacheItemLifetime;
  588. }
  589. public function getCacheItemKey($iId, $sPostfix = '')
  590. {
  591. return $this->getPrefix('cache_item') . $iId . (bx_is_mobile() ? '_m' : '') . '_r' . bx_get_device_pixel_ratio() . (!empty($sPostfix) ? '_' . $sPostfix : '') . '_' . bx_site_hash() . '.php';
  592. }
  593. public function getCacheItemKeys($iId, $sPostfix = '')
  594. {
  595. $aVariants = ['_r1', '_r2', '_m_r1', '_m_r2'];
  596. return array_map(function($sValue) use ($iId, $sPostfix) {
  597. return $this->getPrefix('cache_item') . $iId . $sValue . (!empty($sPostfix) ? '_' . $sPostfix : '') . '_' . bx_site_hash() . '.php';
  598. }, $aVariants);
  599. }
  600. public function getCacheHotKey()
  601. {
  602. return $this->getPrefix('cache_list_hot');
  603. }
  604. public function getCacheTableInterval()
  605. {
  606. return 86400 * $this->_iCacheTableInterval;
  607. }
  608. public function getCacheTableCheckFields()
  609. {
  610. $mixedResult = null;
  611. bx_alert($this->getName(), 'cache_table_check_fields', 0, 0, ['check_fields' => $this->_aCacheTableCheckFields, 'override_result' => &$mixedResult]);
  612. if($mixedResult !== null)
  613. return $mixedResult;
  614. return $this->_aCacheTableCheckFields;
  615. }
  616. public function getPostFormDisplay($sType)
  617. {
  618. if(empty($sType) || !array_key_exists($sType, $this->_aTypeToFormDisplay))
  619. $sType = BX_TIMELINE_TYPE_DEFAULT;
  620. return $this->_aTypeToFormDisplay[$sType];
  621. }
  622. public function getUploaders($sField)
  623. {
  624. $aResult = array();
  625. switch($sField) {
  626. case 'photo':
  627. $aResult = $this->_aPhotoUploaders;
  628. break;
  629. case 'video':
  630. $aResult = $this->_aVideoUploaders;
  631. break;
  632. case 'file':
  633. $aResult = $this->_aFilesUploaders;
  634. break;
  635. }
  636. return $aResult;
  637. }
  638. public function getUploaderByMenuItem($sMenuItem)
  639. {
  640. if(!isset($this->_aItemToUploader[$sMenuItem]))
  641. return false;
  642. return $this->_aItemToUploader[$sMenuItem];
  643. }
  644. public function getExtenalsEvery($sType = 'default')
  645. {
  646. if($this->isInfiniteScroll())
  647. $sType .= '_preload';
  648. $iExtenalsEvery = (int)getParam($this->getPrefix('option') . 'extenals_every_' . $sType);
  649. if(!$iExtenalsEvery)
  650. return $iExtenalsEvery;
  651. $iPerPage = $this->getPerPage($sType);
  652. if(empty($iPerPage))
  653. $iPerPage = $this->getPerPage();
  654. if($iExtenalsEvery > $iPerPage)
  655. $iExtenalsEvery = $iPerPage;
  656. return $iExtenalsEvery;
  657. }
  658. public function getPerPreload()
  659. {
  660. return $this->_iInfScrollPerPreload;
  661. }
  662. public function getAutoPreloads()
  663. {
  664. return $this->_iInfScrollAutoPreloads;
  665. }
  666. public function getRssLength()
  667. {
  668. return $this->_iRssLength;
  669. }
  670. public function getLiveUpdateLength()
  671. {
  672. return $this->_iLiveUpdateLength;
  673. }
  674. public function getCharsDisplayMinTitle()
  675. {
  676. return $this->_iCharsDisplayMinTitle;
  677. }
  678. public function getCharsDisplayMaxTitle()
  679. {
  680. return $this->_iCharsDisplayMaxTitle;
  681. }
  682. public function getBriefCardsTags($bAsString = false)
  683. {
  684. return !$bAsString ? $this->_aBriefCardsTags : '<' . implode('><', $this->_aBriefCardsTags) . '>';
  685. }
  686. public function getVideosPreload()
  687. {
  688. return $this->_sVideosPreload;
  689. }
  690. public function getVideosAutoplay()
  691. {
  692. return $this->_sVideosAutoplay;
  693. }
  694. public function getPreloadComments()
  695. {
  696. return $this->_iPreloadComments;
  697. }
  698. public function getAttachmentsLayout()
  699. {
  700. return $this->_sAttachmentsLayout;
  701. }
  702. public function getHotInterval()
  703. {
  704. return $this->_iHotInterval;
  705. }
  706. public function getLimitAttachLinks()
  707. {
  708. return $this->_iLimitAttachLinks;
  709. }
  710. public function getRepostDefaults()
  711. {
  712. return $this->_aRepostDefaults;
  713. }
  714. public function getPregPattern($sType)
  715. {
  716. return $this->_aPregPatterns[$sType];
  717. }
  718. /**
  719. * Ancillary functions
  720. */
  721. public function getTitle($s, $mixedProfile = false, $sMethodLength = 'getCharsDisplayMaxTitle')
  722. {
  723. if(get_mb_substr($s, 0, 1) == '_' && strcmp($s, _t($s)) != 0)
  724. return $s;
  725. if($mixedProfile !== false) {
  726. if(is_numeric($mixedProfile))
  727. $mixedProfile = BxDolProfile::getInstanceMagic((int)$mixedProfile);
  728. if($mixedProfile instanceof BxDolProfile)
  729. $s = bx_replace_markers($s, array(
  730. 'profile_name' => $mixedProfile->getDisplayName()
  731. ));
  732. }
  733. if(!method_exists($this, $sMethodLength))
  734. $sMethodLength = 'getCharsDisplayMaxTitle';
  735. return strmaxtextlen($s, $this->$sMethodLength(), '...');
  736. }
  737. public function getTitleShort($s, $mixedProfile = false)
  738. {
  739. return $this->getTitle($s, $mixedProfile, 'getCharsDisplayMinTitle');
  740. }
  741. public function getTitleDefault($bL, $bP, $bV, $bF)
  742. {
  743. $sResult = '';
  744. if($bL && !$bP && !$bV && !$bF)
  745. $sResult = 'link';
  746. else if(!$bL && $bP && !$bV && !$bF)
  747. $sResult = 'image';
  748. else if(!$bL && !$bP && $bV && !$bF)
  749. $sResult = 'video';
  750. else if(!$bL && !$bP && !$bV && $bF)
  751. $sResult = 'file';
  752. else
  753. $sResult = 'media';
  754. return $this->CNF['T']['txt_sample_with_' . $sResult];
  755. }
  756. public function getViewUrl($iOwnerId, $bAbsolute = true)
  757. {
  758. $sUrl = BxDolPermalinks::getInstance()->permalink('page.php?i=' . $this->CNF['URI_VIEW_LIST'], ['id' => $iOwnerId]);
  759. return $bAbsolute ? bx_absolute_url($sUrl) : $sUrl;
  760. }
  761. public function getHomeViewUrl($bAbsolute = true)
  762. {
  763. $sUrl = BxDolPermalinks::getInstance()->permalink($this->CNF['URL_HOME']);
  764. return $bAbsolute ? bx_absolute_url($sUrl) : $sUrl;
  765. }
  766. public function getItemViewUrl($aEvent, $bAbsolute = true)
  767. {
  768. $sUrl = BxDolPermalinks::getInstance()->permalink('page.php?i=' . $this->CNF['URI_VIEW_ENTRY'], ['id' => $aEvent['id']]);
  769. return $bAbsolute ? bx_absolute_url($sUrl) : $sUrl;
  770. }
  771. public function getLiveUpdateKey($aParams)
  772. {
  773. return $this->getName() . '_live_update_' . $this->getNameView($aParams, array('with_owner' => true));
  774. }
  775. public function isCommon($sType, $sAction)
  776. {
  777. return !$this->isSystem($sType, $sAction);
  778. }
  779. public function isSystem($sType, $sAction)
  780. {
  781. $sPrefix = $this->getPrefix('common_post');
  782. return strpos($sType, $sPrefix) === false && !empty($sAction);
  783. }
  784. public function getSystemData(&$aEvent, $aBrowseParams = array())
  785. {
  786. $aHandler = $this->getHandler($aEvent);
  787. if($aHandler === false)
  788. return false;
  789. return BxDolService::call($aHandler['module_name'], $aHandler['module_method'], array($aEvent, $aBrowseParams), $aHandler['module_class']);
  790. }
  791. public function getSystemDataByDescriptor($sType, $sAction, $iObjectId)
  792. {
  793. $aDescriptor = array(
  794. 'type' => $sType,
  795. 'action' => $sAction,
  796. 'object_id' => $iObjectId
  797. );
  798. return $this->getSystemData($aDescriptor);
  799. }
  800. public function isEqualUrls($sUrl1, $sUrl2)
  801. {
  802. $sUrl1 = trim($sUrl1, "/");
  803. $sUrl2 = trim($sUrl2, "/");
  804. return strncmp($sUrl1, $sUrl2, strlen($sUrl1)) === 0;
  805. }
  806. public function addBrowseParams($sUrl, $aParams, $sKey = 'bp')
  807. {
  808. return bx_append_url_params($sUrl, [$sKey => base64_encode(json_encode($aParams))]);
  809. }
  810. public function getBrowseParams($sValue)
  811. {
  812. return json_decode(base64_decode(urldecode($sValue)), true);
  813. }
  814. public function setUserChoice($aChoices = array())
  815. {
  816. if(!isLogged() || empty($aChoices))
  817. return;
  818. $iUserId = bx_get_logged_profile_id();
  819. $oSession = BxDolSession::getInstance();
  820. foreach($aChoices as $sKey => $mixedValue) {
  821. $sField = '_sSessionKey' . bx_gen_method_name($sKey);
  822. if(isset($this->$sField) && !empty($mixedValue))
  823. $oSession->setValue($this->$sField . $iUserId, $mixedValue);
  824. }
  825. }
  826. public function getUserChoice($sKey, $iUserId = 0)
  827. {
  828. $sField = '_sSessionKey' . bx_gen_method_name($sKey);
  829. if(!isLogged() || !isset($this->$sField))
  830. return false;
  831. if(!$iUserId)
  832. $iUserId = bx_get_logged_profile_id();
  833. return BxDolSession::getInstance()->getValue($this->$sField . $iUserId);
  834. }
  835. public function prepareParam($sName, $sPattern = "/^[\d\w_]+$/")
  836. {
  837. return $this->processParam(bx_get($sName), $sPattern);
  838. }
  839. public function prepareParamWithDefault($sName, $sDefault, $sPattern = "/^[\d\w_]+$/")
  840. {
  841. return ($sValue = $this->prepareParam($sName, $sPattern)) != '' ? $sValue : $sDefault;
  842. }
  843. public function processParam($sValue, $sPattern = "/^[\d\w_]+$/")
  844. {
  845. return bx_process_url_param($sValue, $sPattern);
  846. }
  847. public function processParamWithDefault($sValue, $sDefault, $sPattern = "/^[\d\w_]+$/")
  848. {
  849. return ($sValue = $this->processParam($sValue, $sPattern)) != '' ? $sValue : $sDefault;
  850. }
  851. }
  852. /** @} */