BxTimelineConfig.php 42 KB

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