BxTimelineConfig.php 34 KB

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