BxTimelineConfig.php 35 KB

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