BxTimelineConfig.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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 $_bCacheItem;
  20. protected $_sCacheItemEngine;
  21. protected $_iCacheItemLifetime;
  22. protected $_bCacheList;
  23. protected $_aCacheListExceptions;
  24. protected $_bInfScroll;
  25. protected $_iInfScrollAutoPreloads;
  26. protected $_iRssLength;
  27. protected $_iLiveUpdateLength;
  28. protected $_iCharsDisplayMinTitle;
  29. protected $_iCharsDisplayMaxTitle;
  30. protected $_sVideosAutoplay;
  31. protected $_iPreloadComments;
  32. protected $_iPreloadCommentsMax;
  33. protected $_bJumpTo;
  34. protected $_bHot;
  35. protected $_iHotInterval;
  36. protected $_bEditorToolbar;
  37. protected $_bUnhideRestored;
  38. protected $_sStorageObject;
  39. protected $_sTranscoderObjectPreview;
  40. protected $_sTranscoderObjectView;
  41. protected $_aPhotoUploaders;
  42. protected $_aVideoUploaders;
  43. protected $_sMenuItemManage;
  44. protected $_sMenuItemActions;
  45. protected $_aRepostDefaults;
  46. protected $_iTimelineVisibilityThreshold;
  47. protected $_aPregPatterns;
  48. /**
  49. * Constructor
  50. */
  51. public function __construct($aModule)
  52. {
  53. parent::__construct($aModule);
  54. $this->CNF = array (
  55. 'ICON' => 'far clock col-green1',
  56. // database tables
  57. 'TABLE_ENTRIES' => $aModule['db_prefix'] . 'events',
  58. // database fields
  59. 'FIELD_ID' => 'id',
  60. 'FIELD_OWNER_ID' => 'owner_id',
  61. 'FIELD_SYSTEM' => 'system',
  62. 'FIELD_OBJECT_ID' => 'object_id', //Note. For 'Direct Timeline Posts' ('system' db field == 0) this field contains post's author profile ID.
  63. 'FIELD_OBJECT_PRIVACY_VIEW' => 'object_privacy_view',
  64. 'FIELD_ADDED' => 'date',
  65. 'FIELD_PUBLISHED' => 'published',
  66. 'FIELD_TITLE' => 'title',
  67. 'FIELD_TEXT' => 'description',
  68. 'FIELD_STATUS' => 'status',
  69. 'FIELD_DATE' => 'date',
  70. 'FIELD_ANONYMOUS' => 'anonymous',
  71. 'FIELD_CONTROLS' => 'controls',
  72. 'FIELD_LOCATION' => 'location',
  73. 'FIELD_LOCATION_PREFIX' => 'location',
  74. 'FIELDS_DELAYED_PROCESSING' => 'video', // can be array of fields or comma separated string of field names
  75. // page URIs
  76. 'URI_VIEW_LIST' => 'timeline-view',
  77. 'URI_VIEW_ENTRY' => 'item',
  78. 'URL_HOME' => 'page.php?i=timeline-view-home',
  79. // objects
  80. 'OBJECT_STORAGE' => $this->_sName . '_photos',
  81. 'OBJECT_STORAGE_VIDEOS' => $this->_sName . '_videos',
  82. 'OBJECT_IMAGES_TRANSCODER_PREVIEW' => $this->_sName . '_photos_preview',
  83. 'OBJECT_VIDEOS_TRANSCODERS' => array(
  84. 'poster' => 'bx_timeline_videos_poster',
  85. 'mp4' => 'bx_timeline_videos_mp4',
  86. 'mp4_hd' => 'bx_timeline_videos_mp4_hd'
  87. ),
  88. 'OBJECT_GRID_ADMINISTRATION' => $this->_sName . '_administration',
  89. 'OBJECT_MENU_ENTRY_ATTACHMENTS' => $this->_sName . '_menu_post_attachments',
  90. 'OBJECT_METATAGS' => $this->_sName,
  91. 'OBJECT_COMMENTS' => $this->_sName,
  92. 'OBJECT_VIEWS' => $this->_sName,
  93. 'OBJECT_VOTES' => $this->_sName,
  94. 'OBJECT_REACTIONS' => $this->_sName . '_reactions',
  95. 'OBJECT_SCORES' => $this->_sName,
  96. 'OBJECT_REPORTS' => $this->_sName,
  97. // some language keys
  98. 'T' => array (
  99. 'txt_status_deleted' => '_bx_timeline_txt_status_deleted',
  100. 'txt_sample_single' => '_bx_timeline_txt_sample',
  101. 'txt_sample_single_ext' => '_bx_timeline_txt_sample_ext',
  102. 'txt_sample_comment_single' => '_bx_timeline_txt_sample_comment_single',
  103. 'txt_sample_vote_single' => '_bx_timeline_txt_sample_vote_single',
  104. 'txt_sample_reaction_single' => '_bx_timeline_txt_sample_reaction_single',
  105. 'txt_sample_score_up_single' => '_bx_timeline_txt_sample_score_up_single',
  106. 'txt_sample_score_down_single' => '_bx_timeline_txt_sample_score_down_single',
  107. 'txt_sample_with_link' => '_bx_timeline_txt_sample_with_link',
  108. 'txt_sample_with_image' => '_bx_timeline_txt_sample_with_image',
  109. 'txt_sample_with_video' => '_bx_timeline_txt_sample_with_video',
  110. 'txt_sample_with_media' => '_bx_timeline_txt_sample_with_media',
  111. 'grid_action_err_delete' => '_bx_timeline_grid_action_err_delete',
  112. 'grid_txt_account_manager' => '_bx_timeline_grid_txt_account_manager',
  113. ),
  114. );
  115. $this->_aTypeToFormDisplay = array(
  116. BX_BASE_MOD_NTFS_TYPE_OWNER => 'form_display_post_add_profile',
  117. BX_BASE_MOD_NTFS_TYPE_PUBLIC => 'form_display_post_add_public',
  118. BX_TIMELINE_TYPE_NEWS => 'form_display_post_add',
  119. BX_TIMELINE_TYPE_FEED => 'form_display_post_add',
  120. BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS => 'form_display_post_add'
  121. );
  122. $this->_aPrefixes = array(
  123. 'style' => 'bx-tl',
  124. 'language' => '_bx_timeline',
  125. 'option' => 'bx_timeline_',
  126. 'common_post' => 'timeline_common_',
  127. 'cache_item' => 'bx_timeline_item_'
  128. );
  129. $this->_aObjects = array_merge($this->_aObjects, array(
  130. 'comment' => $this->CNF['OBJECT_COMMENTS'],
  131. 'view' => $this->CNF['OBJECT_VIEWS'],
  132. 'vote' => $this->CNF['OBJECT_VOTES'],
  133. 'reaction' => $this->CNF['OBJECT_REACTIONS'],
  134. 'score' => $this->CNF['OBJECT_SCORES'],
  135. 'report' => $this->CNF['OBJECT_REPORTS'],
  136. 'metatags' => $this->_sName,
  137. 'storage_photos' => $this->CNF['OBJECT_STORAGE'],
  138. 'storage_videos' => $this->CNF['OBJECT_STORAGE_VIDEOS'],
  139. 'transcoder_photos_preview' => $this->CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW'],
  140. 'transcoder_photos_view' => $this->_sName . '_photos_view',
  141. 'transcoder_photos_medium' => $this->_sName . '_photos_medium',
  142. 'transcoder_photos_big' => $this->_sName . '_photos_big',
  143. 'transcoder_videos_poster' => $this->CNF['OBJECT_VIDEOS_TRANSCODERS']['poster'],
  144. 'transcoder_videos_mp4' => $this->CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4'],
  145. 'transcoder_videos_mp4_hd' => $this->CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4_hd'],
  146. 'page_item_brief' => $this->_sName . '_item_brief',
  147. 'menu_view' => $this->_sName . '_menu_view',
  148. 'menu_item_manage' => $this->_sName . '_menu_item_manage',
  149. 'menu_item_actions' => $this->_sName . '_menu_item_actions',
  150. 'menu_item_counters' => $this->_sName . '_menu_item_counters',
  151. 'menu_item_meta' => $this->_sName . '_menu_item_meta',
  152. 'menu_post_attachments' => $this->CNF['OBJECT_MENU_ENTRY_ATTACHMENTS'],
  153. 'form_post' => $this->_sName . '_post',
  154. 'form_attach_link' => $this->_sName . '_attach_link',
  155. 'form_display_post_add' => $this->_sName . '_post_add',
  156. 'form_display_post_add_public' => $this->_sName . '_post_add_public',
  157. 'form_display_post_add_profile' => $this->_sName . '_post_add_profile',
  158. 'form_display_post_edit' => $this->_sName . '_post_edit',
  159. 'form_display_attach_link_add' => $this->_sName . '_attach_link_add'
  160. ));
  161. $this->_aHandlerDescriptor = array('module_name' => '', 'module_method' => '', 'module_class' => '', 'groupable' => '', 'group_by' => '');
  162. $this->_sHandlersMethod = 'get_timeline_data';
  163. $this->_aPhotoUploaders = array($this->_sName . '_simple_photo');
  164. $this->_aVideoUploaders = array($this->_sName . '_simple_video');
  165. $this->_bJsMode = false;
  166. $this->_aJsClasses = array(
  167. 'main' => 'BxTimelineMain',
  168. 'view' => 'BxTimelineView',
  169. 'post' => 'BxTimelinePost',
  170. 'repost' => 'BxTimelineRepost',
  171. 'manage_tools' => 'BxTimelineManageTools'
  172. );
  173. $this->_aJsObjects = array(
  174. 'view' => 'oTimelineView',
  175. 'post' => 'oTimelinePost',
  176. 'repost' => 'oTimelineRepost',
  177. 'manage_tools' => 'oBxTimelineManageTools'
  178. );
  179. $this->_aGridObjects = array(
  180. 'administration' => $this->CNF['OBJECT_GRID_ADMINISTRATION']
  181. );
  182. $sHp = str_replace('_', '-', $this->_sName);
  183. $sHpT = BX_TIMELINE_VIEW_TIMELINE;
  184. $sHpO = BX_TIMELINE_VIEW_OUTLINE;
  185. $this->_aHtmlIds = array(
  186. 'view' => array(
  187. 'edit_form' => $sHp . '-edit-',
  188. 'menu_popup' => $sHp . '-menu-popup-',
  189. 'video_iframe' => $sHp . '-video-iframe-',
  190. 'video' => $sHp . '-video-',
  191. 'live_update_popup' => $sHp . '-live-update-popup-',
  192. ),
  193. 'post' => array(
  194. 'attach_link_popup' => $sHp . '-attach-link-popup',
  195. 'attach_link_form_field' => $sHp . '-attach-link-form_field',
  196. 'attach_link_item' => $sHp . '-attach-link-item-',
  197. 'textarea' => $sHp . '-textarea-',
  198. 'main_' . $sHpT => $sHp . '-' . $sHpT,
  199. 'main_' . $sHpO => $sHp . '-' . $sHpO,
  200. ),
  201. 'repost' => array(
  202. 'main' => $sHp . '-repost-',
  203. 'counter' => $sHp . '-repost-counter-',
  204. 'by_popup' => $sHp . '-repost-by-',
  205. )
  206. );
  207. $this->_aRepostDefaults = array(
  208. 'show_do_repost_as_button' => false,
  209. 'show_do_repost_as_button_small' => false,
  210. 'show_do_repost_image' => false,
  211. 'show_do_repost_icon' => true,
  212. 'show_do_repost_text' => false,
  213. 'show_counter' => true,
  214. //--- Images
  215. 'image_do_repost' => '',
  216. //--- Icons
  217. 'icon_do_repost' => 'sync-alt',
  218. //--- Texts
  219. 'text_do_repost' => '_bx_timeline_txt_do_repost',
  220. //--- Templates
  221. 'template_do_repost_label' => '',
  222. 'template_do_repost_label_name' => 'repost_do_repost_label.html',
  223. );
  224. $this->_iTimelineVisibilityThreshold = 0;
  225. $this->_aPregPatterns = array(
  226. "meta_title" => "/<title>(.*)<\/title>/",
  227. "meta_description" => "/<meta[\s]+[^>]*?name[\s]?=[\s\"\']+description[\s\"\']+content[\s]?=[\s\"\']+(.*?)[\"\']+.*?>/",
  228. "url" => "/(([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?/"
  229. );
  230. }
  231. public function init(&$oDb)
  232. {
  233. parent::init($oDb);
  234. $sOptionPrefix = $this->getPrefix('option');
  235. $this->_bAllowEdit = getParam($sOptionPrefix . 'enable_edit') == 'on';
  236. $this->_bAllowDelete = getParam($sOptionPrefix . 'enable_delete') == 'on';
  237. $this->_bShowAll = getParam($sOptionPrefix . 'enable_show_all') == 'on';
  238. $this->_bCountAllViews = getParam($sOptionPrefix . 'enable_count_all_views') == 'on';
  239. $this->_bCacheItem = getParam($sOptionPrefix . 'enable_cache_item') == 'on';
  240. $this->_sCacheItemEngine = getParam($sOptionPrefix . 'cache_item_engine');
  241. $this->_iCacheItemLifetime = (int)getParam($sOptionPrefix . 'cache_item_lifetime');
  242. $this->_bCacheList = getParam($sOptionPrefix . 'enable_cache_list') == 'on';
  243. $this->_aCacheListExceptions = array(BX_TIMELINE_TYPE_HOT);
  244. $this->_aPerPage = array(
  245. 'default' => (int)getParam($sOptionPrefix . 'events_per_page'),
  246. 'profile' => (int)getParam($sOptionPrefix . 'events_per_page_profile'),
  247. 'account' => (int)getParam($sOptionPrefix . 'events_per_page_account'),
  248. 'home' => (int)getParam($sOptionPrefix . 'events_per_page_home'),
  249. 'preload' => (int)getParam($sOptionPrefix . 'events_per_preload')
  250. );
  251. $this->_bInfScroll = getParam($sOptionPrefix . 'enable_infinite_scroll') == 'on';
  252. $this->_iInfScrollAutoPreloads = (int)getParam($sOptionPrefix . 'auto_preloads');
  253. $this->_iRssLength = (int)getParam($sOptionPrefix . 'rss_length');
  254. $this->_iLiveUpdateLength = 10;
  255. $this->_iCharsDisplayMinTitle = 32;
  256. $this->_iCharsDisplayMaxTitle = 64;
  257. $this->_sVideosAutoplay = getParam($sOptionPrefix . 'videos_autoplay');
  258. $this->_iPreloadCommentsMax = 7;
  259. $this->_iPreloadComments = (int)getParam($sOptionPrefix . 'preload_comments');
  260. if($this->_iPreloadComments > $this->_iPreloadCommentsMax)
  261. $this->_iPreloadComments = $this->_iPreloadCommentsMax;
  262. $this->_bJumpTo = getParam($sOptionPrefix . 'enable_jump_to_switcher') == 'on';
  263. $this->_bHot = getParam($sOptionPrefix . 'enable_hot') == 'on';
  264. $this->_iHotInterval = (int)getParam($sOptionPrefix . 'hot_interval');
  265. $this->_bEditorToolbar = getParam($sOptionPrefix . 'enable_editor_toolbar') == 'on';
  266. $this->_bUnhideRestored = false;
  267. }
  268. /**
  269. * Generate name from parameters.
  270. *
  271. * @param type $aParams - parameters whose values will be used during generation.
  272. * @param type $aRules - generation rules.
  273. * @return string
  274. */
  275. protected function getNameView($aParams, $aRules = array())
  276. {
  277. $bWithView = !isset($aRules['with_view']) || $aRules['with_view'] === true;
  278. $bWithType = !isset($aRules['with_type']) || $aRules['with_type'] === true;
  279. $bWithOwner = isset($aRules['with_owner']) && $aRules['with_owner'] === true;
  280. $sGlue = !empty($aRules['glue']) ? $aRules['glue'] : '_';
  281. $aAddons = array();
  282. if(!empty($aParams['name']))
  283. $aAddons[] = $aParams['name'];
  284. else {
  285. if($bWithView && !empty($aParams['view']))
  286. $aAddons[] = $aParams['view'];
  287. if($bWithType && !empty($aParams['type']))
  288. $aAddons[] = $aParams['type'];
  289. }
  290. if($bWithOwner)
  291. $aAddons[] = $aParams['owner_id'];
  292. return !empty($aAddons) ? implode($sGlue, $aAddons) : '';
  293. }
  294. /**
  295. * Generates unique JS object name for View events block.
  296. *
  297. * @param array $aParams - an array with browsing params received in View block service method
  298. * @return string with JS object name
  299. */
  300. public function getJsObjectView($aParams = array())
  301. {
  302. return parent::getJsObject('view') . bx_gen_method_name($this->getNameView($aParams));
  303. }
  304. public function getHtmlIdView($sKey, $aParams, $aRules = array())
  305. {
  306. $bWhole = !isset($aRules['whole']) || $aRules['whole'] === true;
  307. $sGlue = !empty($aRules['glue']) ? $aRules['glue'] : '_';
  308. return str_replace($sGlue, '-', $this->_sName . $sGlue . $sKey . $sGlue . $this->getNameView($aParams, $aRules) . (!$bWhole ? $sGlue : ''));
  309. }
  310. public function isAllowEdit()
  311. {
  312. return $this->_bAllowEdit;
  313. }
  314. public function isAllowDelete()
  315. {
  316. return $this->_bAllowDelete;
  317. }
  318. public function isInfiniteScroll()
  319. {
  320. return $this->_bInfScroll;
  321. }
  322. public function isShowAll()
  323. {
  324. return $this->_bShowAll;
  325. }
  326. public function isCountAllViews()
  327. {
  328. return $this->_bCountAllViews;
  329. }
  330. public function isJumpTo()
  331. {
  332. return $this->_bJumpTo;
  333. }
  334. public function isHot()
  335. {
  336. return $this->_bHot;
  337. }
  338. public function isEditorToolbar()
  339. {
  340. return $this->_bEditorToolbar;
  341. }
  342. public function isUnhideRestored()
  343. {
  344. return $this->_bUnhideRestored;
  345. }
  346. public function isCacheItem()
  347. {
  348. return $this->_bCacheItem;
  349. }
  350. public function isCacheList()
  351. {
  352. return $this->_bCacheList;
  353. }
  354. public function isCacheListException($sType)
  355. {
  356. return in_array($sType, $this->_aCacheListExceptions);
  357. }
  358. public function getCacheItemEngine()
  359. {
  360. return $this->_sCacheItemEngine;
  361. }
  362. public function getCacheItemLifetime()
  363. {
  364. return $this->_iCacheItemLifetime;
  365. }
  366. public function getCacheItemKey($iId, $sPostfix = '')
  367. {
  368. return $this->getPrefix('cache_item') . $iId . (!empty($sPostfix) ? '_' . $sPostfix : '') . '.php';
  369. }
  370. public function getPostFormDisplay($sType)
  371. {
  372. if(empty($sType) || !array_key_exists($sType, $this->_aTypeToFormDisplay))
  373. $sType = BX_TIMELINE_TYPE_DEFAULT;
  374. return $this->_aTypeToFormDisplay[$sType];
  375. }
  376. public function getUploaders($sType)
  377. {
  378. $aResult = array();
  379. switch($sType) {
  380. case 'photo':
  381. $aResult = $this->_aPhotoUploaders;
  382. break;
  383. case 'video':
  384. $aResult = $this->_aVideoUploaders;
  385. break;
  386. }
  387. return $aResult;
  388. }
  389. public function getPerPage($sType = 'default')
  390. {
  391. if($this->isInfiniteScroll())
  392. $sType = 'preload';
  393. return parent::getPerPage($sType);
  394. }
  395. public function getAutoPreloads()
  396. {
  397. return $this->_iInfScrollAutoPreloads;
  398. }
  399. public function getRssLength()
  400. {
  401. return $this->_iRssLength;
  402. }
  403. public function getLiveUpdateLength()
  404. {
  405. return $this->_iLiveUpdateLength;
  406. }
  407. public function getCharsDisplayMinTitle()
  408. {
  409. return $this->_iCharsDisplayMinTitle;
  410. }
  411. public function getCharsDisplayMaxTitle()
  412. {
  413. return $this->_iCharsDisplayMaxTitle;
  414. }
  415. public function getVideosAutoplay()
  416. {
  417. return $this->_sVideosAutoplay;
  418. }
  419. public function getPreloadComments()
  420. {
  421. return $this->_iPreloadComments;
  422. }
  423. public function getHotInterval()
  424. {
  425. return $this->_iHotInterval;
  426. }
  427. public function getRepostDefaults()
  428. {
  429. return $this->_aRepostDefaults;
  430. }
  431. public function getPregPattern($sType)
  432. {
  433. return $this->_aPregPatterns[$sType];
  434. }
  435. /**
  436. * Ancillary functions
  437. */
  438. public function getTitle($s, $mixedProfile = false, $sMethodLength = 'getCharsDisplayMaxTitle')
  439. {
  440. if(get_mb_substr($s, 0, 1) == '_' && strcmp($s, _t($s)) != 0)
  441. return $s;
  442. if($mixedProfile !== false) {
  443. if(is_numeric($mixedProfile))
  444. $mixedProfile = BxDolProfile::getInstanceMagic((int)$mixedProfile);
  445. if($mixedProfile instanceof BxDolProfile)
  446. $s = bx_replace_markers($s, array(
  447. 'profile_name' => $mixedProfile->getDisplayName()
  448. ));
  449. }
  450. if(!method_exists($this, $sMethodLength))
  451. $sMethodLength = 'getCharsDisplayMaxTitle';
  452. return strmaxtextlen($s, $this->$sMethodLength(), '...');
  453. }
  454. public function getTitleShort($s, $mixedProfile = false)
  455. {
  456. return $this->getTitle($s, $mixedProfile, 'getCharsDisplayMinTitle');
  457. }
  458. public function getTitleDefault($bL, $bP, $bV)
  459. {
  460. $sResult = '';
  461. if($bL && !$bP && !$bV)
  462. $sResult = 'link';
  463. else if(!$bL && $bP && !$bV)
  464. $sResult = 'image';
  465. else if(!$bL && !$bP && $bV)
  466. $sResult = 'video';
  467. else
  468. $sResult = 'media';
  469. return $this->CNF['T']['txt_sample_with_' . $sResult];
  470. }
  471. public function getViewUrl($iOwnerId)
  472. {
  473. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php', array(
  474. 'i' => $this->CNF['URI_VIEW_LIST'],
  475. 'id' => $iOwnerId
  476. ));
  477. }
  478. public function getHomeViewUrl()
  479. {
  480. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($this->CNF['URL_HOME']);
  481. }
  482. public function getItemViewUrl($aEvent)
  483. {
  484. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php', array(
  485. 'i' => $this->CNF['URI_VIEW_ENTRY'],
  486. 'id' => $aEvent['id']
  487. ));
  488. }
  489. public function getLiveUpdateKey($aParams)
  490. {
  491. return $this->getName() . '_live_update_' . $this->getNameView($aParams, array('with_owner' => true));
  492. }
  493. //TODO: isCommon and isSystem can be updated to use new 'system' db field.
  494. public function isCommon($sType, $sAction)
  495. {
  496. return !$this->isSystem($sType, $sAction);
  497. }
  498. public function isSystem($sType, $sAction)
  499. {
  500. $sPrefix = $this->getPrefix('common_post');
  501. return strpos($sType, $sPrefix) === false && !empty($sAction);
  502. }
  503. public function getSystemData(&$aEvent, $aBrowseParams = array())
  504. {
  505. $aHandler = $this->getHandler($aEvent);
  506. if($aHandler === false)
  507. return false;
  508. return BxDolService::call($aHandler['module_name'], $aHandler['module_method'], array($aEvent, $aBrowseParams), $aHandler['module_class']);
  509. }
  510. public function getSystemDataByDescriptor($sType, $sAction, $iObjectId)
  511. {
  512. $aDescriptor = array(
  513. 'type' => $sType,
  514. 'action' => $sAction,
  515. 'object_id' => $iObjectId
  516. );
  517. return $this->getSystemData($aDescriptor);
  518. }
  519. public function isEqualUrls($sUrl1, $sUrl2)
  520. {
  521. $sUrl1 = trim($sUrl1, "/");
  522. $sUrl2 = trim($sUrl2, "/");
  523. return strncmp($sUrl1, $sUrl2, strlen($sUrl1)) === 0;
  524. }
  525. public function addBrowseParams($sUrl, $aParams, $sKey = 'bp')
  526. {
  527. return bx_append_url_params($sUrl, array($sKey => urlencode(base64_encode(serialize($aParams)))));
  528. }
  529. public function getBrowseParams($sValue)
  530. {
  531. return unserialize(base64_decode(urldecode($sValue)));
  532. }
  533. }
  534. /** @} */