BxTimelineConfig.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup Timeline Timeline
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolPrivacy');
  12. bx_import('BxDolModuleConfig');
  13. class BxTimelineConfig extends BxDolModuleConfig
  14. {
  15. protected $_oDb;
  16. protected $_sAlertSystemName;
  17. protected $_sCommentSystemName;
  18. protected $_sVoteSystemName;
  19. protected $_bAllowDelete;
  20. protected $_iPerPageProfile;
  21. protected $_iPerPageAccount;
  22. protected $_iRssLength;
  23. protected $_iCharsDisplayMax;
  24. protected $_aHandlers;
  25. protected $_aHandlersHidden;
  26. protected $_sStorageObject;
  27. protected $_sTranscoderObjectPreview;
  28. protected $_sTranscoderObjectView;
  29. protected $_aImageUploaders;
  30. protected $_sConnObjSubscriptions;
  31. protected $_sMenuItemManage;
  32. protected $_sMenuItemActions;
  33. protected $_bJsMode;
  34. protected $_aJsClass;
  35. protected $_aJsObjects;
  36. protected $_aHtmlIds;
  37. protected $_aShareDefaults;
  38. protected $_sAnimationEffect;
  39. protected $_iAnimationSpeed;
  40. protected $_sStylePrefix;
  41. protected $_sCommonPostPrefix;
  42. protected $_iPrivacyViewDefault;
  43. protected $_iTimelineVisibilityThreshold;
  44. /**
  45. * Constructor
  46. */
  47. public function __construct($aModule)
  48. {
  49. parent::BxDolModuleConfig($aModule);
  50. $this->_sAlertSystemName = $this->_sName;
  51. $this->_sCommentSystemName = $this->_sName;
  52. $this->_sVoteSystemName = $this->_sName;
  53. $this->_aHandlersHidden = array();
  54. $this->_aHandlers = array();
  55. $this->_sStorageObject = $this->_sName . '_photos';
  56. $this->_sTranscoderObjectPreview = $this->_sName . '_photos_preview';
  57. $this->_sTranscoderObjectView = $this->_sName . '_photos_view';
  58. $this->_aImageUploaders = array($this->_sName . '_simple');
  59. $this->_sConnObjSubscriptions = 'sys_profiles_subscriptions';
  60. $this->_sMenuItemManage = $this->_sName . '_menu_item_manage';
  61. $this->_sMenuItemActions = $this->_sName . '_menu_item_actions';
  62. $this->_bJsMode = false;
  63. $this->_aJsClass = array(
  64. 'main' => 'BxTimelineMain',
  65. 'view' => 'BxTimelineView',
  66. 'post' => 'BxTimelinePost',
  67. 'share' => 'BxTimelineShare'
  68. );
  69. $this->_aJsObjects = array(
  70. 'view' => 'oTimelineView',
  71. 'post' => 'oTimelinePost',
  72. 'share' => 'oTimelineShare'
  73. );
  74. $sHtmlPrefix = str_replace('_', '-', $this->_sName);
  75. $this->_aHtmlIds = array(
  76. 'view' => array(
  77. 'item_popup' => $sHtmlPrefix . '-item-popup-',
  78. ),
  79. 'post' => array(),
  80. 'share' => array(
  81. 'main' => $sHtmlPrefix . '-share-',
  82. 'counter' => $sHtmlPrefix . '-share-counter-',
  83. 'by_popup' => $sHtmlPrefix . '-share-by-',
  84. )
  85. );
  86. $this->_aShareDefaults = array(
  87. 'show_do_share_as_button' => false,
  88. 'show_do_share_as_button_small' => false,
  89. 'show_do_share_icon' => true,
  90. 'show_do_share_label' => false,
  91. 'show_counter' => true
  92. );
  93. $this->_sAnimationEffect = 'fade';
  94. $this->_iAnimationSpeed = 'slow';
  95. $this->_sStylePrefix = 'bx-tl';
  96. $this->_sCommonPostPrefix = 'timeline_common_';
  97. $this->_iPrivacyViewDefault = BX_DOL_PG_ALL;
  98. $this->_iTimelineVisibilityThreshold = 0;
  99. }
  100. public function init(&$oDb)
  101. {
  102. $this->_oDb = &$oDb;
  103. $this->_bAllowDelete = $this->_oDb->getParam('bx_timeline_enable_delete') == 'on';
  104. $this->_iPerPageProfile = (int)$this->_oDb->getParam('bx_timeline_events_per_page_profile');
  105. $this->_iPerPageAccount = (int)$this->_oDb->getParam('bx_timeline_events_per_page_account');
  106. $this->_iRssLength = (int)$this->_oDb->getParam('bx_timeline_rss_length');
  107. $this->_iCharsDisplayMax = (int)$this->_oDb->getParam('bx_timeline_chars_display_max');
  108. $aHandlers = $this->_oDb->getHandlers();
  109. foreach($aHandlers as $aHandler) {
  110. if($aHandler['type'] === BX_TIMELINE_HANDLER_TYPE_INSERT && !empty($aHandler['content'])) {
  111. $aContent = unserialize($aHandler['content']);
  112. if(is_array($aContent) && !empty($aContent))
  113. $aHandler = array_merge($aHandler, $aContent);
  114. }
  115. $this->_aHandlers[$aHandler['alert_unit'] . '_' . $aHandler['alert_action']] = $aHandler;
  116. }
  117. $sHideTimeline = $this->_oDb->getParam('bx_timeline_events_hide');
  118. if(!empty($sHideTimeline))
  119. $this->_aHandlersHidden = explode(',', $sHideTimeline);
  120. }
  121. public function isAllowDelete()
  122. {
  123. return $this->_bAllowDelete;
  124. }
  125. public function getSystemName($sType)
  126. {
  127. $sResult = '';
  128. switch($sType) {
  129. case 'alert':
  130. $sResult = $this->_sAlertSystemName;
  131. break;
  132. case 'comment':
  133. $sResult = $this->_sCommentSystemName;
  134. break;
  135. case 'vote':
  136. $sResult = $this->_sVoteSystemName;
  137. break;
  138. }
  139. return $sResult;
  140. }
  141. public function getPrefix($sType)
  142. {
  143. $sResult = '';
  144. switch($sType) {
  145. case 'common_post':
  146. $sResult = $this->_sCommonPostPrefix;
  147. break;
  148. case 'style':
  149. $sResult = $this->_sStylePrefix;
  150. break;
  151. }
  152. return $sResult;
  153. }
  154. public function getObject($sType)
  155. {
  156. $sResult = '';
  157. switch($sType) {
  158. case 'storage':
  159. $sResult = $this->_sStorageObject;
  160. break;
  161. case 'transcoder_preview':
  162. $sResult = $this->_sTranscoderObjectPreview;
  163. break;
  164. case 'transcoder_view':
  165. $sResult = $this->_sTranscoderObjectView;
  166. break;
  167. case 'conn_subscriptions':
  168. $sResult = $this->_sConnObjSubscriptions;
  169. break;
  170. case 'menu_item_manage':
  171. $sResult = $this->_sMenuItemManage;
  172. break;
  173. case 'menu_item_actions':
  174. $sResult = $this->_sMenuItemActions;
  175. break;
  176. }
  177. return $sResult;
  178. }
  179. public function getUploaders($sType)
  180. {
  181. $aResult = '';
  182. switch($sType) {
  183. case 'image':
  184. $aResult = $this->_aImageUploaders;
  185. break;
  186. }
  187. return $aResult;
  188. }
  189. public function getPerPage($sPage = 'profile')
  190. {
  191. $iResult = 10;
  192. switch($sPage) {
  193. case 'profile':
  194. $iResult = $this->_iPerPageProfile;
  195. break;
  196. case 'account':
  197. $iResult = $this->_iPerPageAccount;
  198. break;
  199. }
  200. return $iResult;
  201. }
  202. public function getRssLength()
  203. {
  204. return $this->_iRssLength;
  205. }
  206. public function getCharsDisplayMax()
  207. {
  208. return $this->_iCharsDisplayMax;
  209. }
  210. public function isHandler($sKey = '')
  211. {
  212. return isset($this->_aHandlers[$sKey]);
  213. }
  214. public function getHandlers($sKey = '')
  215. {
  216. if($sKey == '')
  217. return $this->_aHandlers;
  218. return $this->_aHandlers[$sKey];
  219. }
  220. public function getHandlersHidden()
  221. {
  222. return $this->_aHandlersHidden;
  223. }
  224. public function isJsMode()
  225. {
  226. return $this->_bJsMode;
  227. }
  228. public function getJsMode()
  229. {
  230. return $this->_bJsMode;
  231. }
  232. public function setJsMode($bJsMode)
  233. {
  234. $this->_bJsMode = $bJsMode;
  235. }
  236. public function getJsClass($sType)
  237. {
  238. return $this->_aJsClass[$sType];
  239. }
  240. public function getJsObject($sType)
  241. {
  242. return $this->_aJsObjects[$sType];
  243. }
  244. public function getHtmlIds($sType, $sKey = '')
  245. {
  246. if(empty($sKey))
  247. return $this->_aHtmlIds[$sType];
  248. return $this->_aHtmlIds[$sType][$sKey];
  249. }
  250. public function getShareDefaults()
  251. {
  252. return $this->_aShareDefaults;
  253. }
  254. public function getAnimationEffect()
  255. {
  256. return $this->_sAnimationEffect;
  257. }
  258. public function getAnimationSpeed()
  259. {
  260. return $this->_iAnimationSpeed;
  261. }
  262. public function getPrivacyViewDefault()
  263. {
  264. return $this->_iPrivacyViewDefault;
  265. }
  266. /**
  267. * Ancillary functions
  268. */
  269. public function getViewUrl($iOwnerId)
  270. {
  271. bx_import('BxDolPermalinks');
  272. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=timeline-view&id=' . $iOwnerId);
  273. }
  274. public function getItemViewUrl(&$aEvent)
  275. {
  276. bx_import('BxDolPermalinks');
  277. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=timeline-item&id=' . $aEvent['id']);
  278. }
  279. public function isSystem($sType, $sAction)
  280. {
  281. $sPrefix = $this->getPrefix('common_post');
  282. return strpos($sType, $sPrefix) === false && !empty($sAction);
  283. }
  284. }
  285. /** @} */