BxTimelineConfig.php 33 KB

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