BxTimelineConfig.php 30 KB

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