BxTimelineConfig.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. protected $_aPregPatterns;
  45. /**
  46. * Constructor
  47. */
  48. public function __construct($aModule)
  49. {
  50. parent::__construct($aModule);
  51. $this->_sAlertSystemName = $this->_sName;
  52. $this->_sCommentSystemName = $this->_sName;
  53. $this->_sVoteSystemName = $this->_sName;
  54. $this->_aHandlersHidden = array();
  55. $this->_aHandlers = array();
  56. $this->_sStorageObject = $this->_sName . '_photos';
  57. $this->_sTranscoderObjectPreview = $this->_sName . '_photos_preview';
  58. $this->_sTranscoderObjectView = $this->_sName . '_photos_view';
  59. $this->_aImageUploaders = array($this->_sName . '_simple');
  60. $this->_sConnObjSubscriptions = 'sys_profiles_subscriptions';
  61. $this->_sMenuItemManage = $this->_sName . '_menu_item_manage';
  62. $this->_sMenuItemActions = $this->_sName . '_menu_item_actions';
  63. $this->_bJsMode = false;
  64. $this->_aJsClass = array(
  65. 'main' => 'BxTimelineMain',
  66. 'view' => 'BxTimelineView',
  67. 'post' => 'BxTimelinePost',
  68. 'share' => 'BxTimelineShare'
  69. );
  70. $this->_aJsObjects = array(
  71. 'view' => 'oTimelineView',
  72. 'post' => 'oTimelinePost',
  73. 'share' => 'oTimelineShare'
  74. );
  75. $sHtmlPrefix = str_replace('_', '-', $this->_sName);
  76. $this->_aHtmlIds = array(
  77. 'view' => array(
  78. 'item_popup' => $sHtmlPrefix . '-item-popup-',
  79. 'photo_popup' => $sHtmlPrefix . '-photo-popup-',
  80. ),
  81. 'post' => array(
  82. 'attach_link_popup' => $sHtmlPrefix . '-attach-link-popup',
  83. 'attach_link_form_field' => $sHtmlPrefix . '-attach-link-form_field',
  84. 'attach_link_item' => $sHtmlPrefix . '-attach-link-item-',
  85. ),
  86. 'share' => array(
  87. 'main' => $sHtmlPrefix . '-share-',
  88. 'counter' => $sHtmlPrefix . '-share-counter-',
  89. 'by_popup' => $sHtmlPrefix . '-share-by-',
  90. )
  91. );
  92. $this->_aShareDefaults = array(
  93. 'show_do_share_as_button' => false,
  94. 'show_do_share_as_button_small' => false,
  95. 'show_do_share_icon' => true,
  96. 'show_do_share_label' => false,
  97. 'show_counter' => true
  98. );
  99. $this->_sAnimationEffect = 'fade';
  100. $this->_iAnimationSpeed = 'slow';
  101. $this->_sStylePrefix = 'bx-tl';
  102. $this->_sCommonPostPrefix = 'timeline_common_';
  103. $this->_iPrivacyViewDefault = BX_DOL_PG_ALL;
  104. $this->_iTimelineVisibilityThreshold = 0;
  105. $this->_aPregPatterns = array(
  106. "meta_title" => "/<title>(.*)<\/title>/",
  107. "meta_description" => "/<meta[\s]+[^>]*?name[\s]?=[\s\"\']+description[\s\"\']+content[\s]?=[\s\"\']+(.*?)[\"\']+.*?>/",
  108. "url" => "/((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*\.)+(aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|[a-z]{2})|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&amp;]*)?)?(#[a-z][a-z0-9_]*)?/"
  109. );
  110. }
  111. public function init(&$oDb)
  112. {
  113. $this->_oDb = &$oDb;
  114. $this->_bAllowDelete = $this->_oDb->getParam('bx_timeline_enable_delete') == 'on';
  115. $this->_iPerPageProfile = (int)$this->_oDb->getParam('bx_timeline_events_per_page_profile');
  116. $this->_iPerPageAccount = (int)$this->_oDb->getParam('bx_timeline_events_per_page_account');
  117. $this->_iRssLength = (int)$this->_oDb->getParam('bx_timeline_rss_length');
  118. $this->_iCharsDisplayMax = (int)$this->_oDb->getParam('bx_timeline_chars_display_max');
  119. $aHandlers = $this->_oDb->getHandlers();
  120. foreach($aHandlers as $aHandler) {
  121. if($aHandler['type'] === BX_TIMELINE_HANDLER_TYPE_INSERT && !empty($aHandler['content'])) {
  122. $aContent = unserialize($aHandler['content']);
  123. if(is_array($aContent) && !empty($aContent))
  124. $aHandler = array_merge($aHandler, $aContent);
  125. }
  126. $this->_aHandlers[$aHandler['alert_unit'] . '_' . $aHandler['alert_action']] = $aHandler;
  127. }
  128. $sHideTimeline = $this->_oDb->getParam('bx_timeline_events_hide');
  129. if(!empty($sHideTimeline))
  130. $this->_aHandlersHidden = explode(',', $sHideTimeline);
  131. }
  132. public function isAllowDelete()
  133. {
  134. return $this->_bAllowDelete;
  135. }
  136. public function getSystemName($sType)
  137. {
  138. $sResult = '';
  139. switch($sType) {
  140. case 'alert':
  141. $sResult = $this->_sAlertSystemName;
  142. break;
  143. case 'comment':
  144. $sResult = $this->_sCommentSystemName;
  145. break;
  146. case 'vote':
  147. $sResult = $this->_sVoteSystemName;
  148. break;
  149. }
  150. return $sResult;
  151. }
  152. public function getPrefix($sType)
  153. {
  154. $sResult = '';
  155. switch($sType) {
  156. case 'common_post':
  157. $sResult = $this->_sCommonPostPrefix;
  158. break;
  159. case 'style':
  160. $sResult = $this->_sStylePrefix;
  161. break;
  162. }
  163. return $sResult;
  164. }
  165. public function getObject($sType)
  166. {
  167. $sResult = '';
  168. switch($sType) {
  169. case 'storage':
  170. $sResult = $this->_sStorageObject;
  171. break;
  172. case 'transcoder_preview':
  173. $sResult = $this->_sTranscoderObjectPreview;
  174. break;
  175. case 'transcoder_view':
  176. $sResult = $this->_sTranscoderObjectView;
  177. break;
  178. case 'conn_subscriptions':
  179. $sResult = $this->_sConnObjSubscriptions;
  180. break;
  181. case 'menu_item_manage':
  182. $sResult = $this->_sMenuItemManage;
  183. break;
  184. case 'menu_item_actions':
  185. $sResult = $this->_sMenuItemActions;
  186. break;
  187. }
  188. return $sResult;
  189. }
  190. public function getUploaders($sType)
  191. {
  192. $aResult = '';
  193. switch($sType) {
  194. case 'image':
  195. $aResult = $this->_aImageUploaders;
  196. break;
  197. }
  198. return $aResult;
  199. }
  200. public function getPerPage($sPage = 'profile')
  201. {
  202. $iResult = 10;
  203. switch($sPage) {
  204. case 'profile':
  205. $iResult = $this->_iPerPageProfile;
  206. break;
  207. case 'account':
  208. $iResult = $this->_iPerPageAccount;
  209. break;
  210. }
  211. return $iResult;
  212. }
  213. public function getRssLength()
  214. {
  215. return $this->_iRssLength;
  216. }
  217. public function getCharsDisplayMax()
  218. {
  219. return $this->_iCharsDisplayMax;
  220. }
  221. public function isHandler($sKey = '')
  222. {
  223. return isset($this->_aHandlers[$sKey]);
  224. }
  225. public function getHandlers($sKey = '')
  226. {
  227. if($sKey == '')
  228. return $this->_aHandlers;
  229. return $this->_aHandlers[$sKey];
  230. }
  231. public function getHandlersHidden()
  232. {
  233. return $this->_aHandlersHidden;
  234. }
  235. public function isJsMode()
  236. {
  237. return $this->_bJsMode;
  238. }
  239. public function getJsMode()
  240. {
  241. return $this->_bJsMode;
  242. }
  243. public function setJsMode($bJsMode)
  244. {
  245. $this->_bJsMode = $bJsMode;
  246. }
  247. public function getJsClass($sType)
  248. {
  249. return $this->_aJsClass[$sType];
  250. }
  251. public function getJsObject($sType)
  252. {
  253. return $this->_aJsObjects[$sType];
  254. }
  255. public function getHtmlIds($sType, $sKey = '')
  256. {
  257. if(empty($sKey))
  258. return $this->_aHtmlIds[$sType];
  259. return $this->_aHtmlIds[$sType][$sKey];
  260. }
  261. public function getShareDefaults()
  262. {
  263. return $this->_aShareDefaults;
  264. }
  265. public function getAnimationEffect()
  266. {
  267. return $this->_sAnimationEffect;
  268. }
  269. public function getAnimationSpeed()
  270. {
  271. return $this->_iAnimationSpeed;
  272. }
  273. public function getPrivacyViewDefault()
  274. {
  275. return $this->_iPrivacyViewDefault;
  276. }
  277. public function getPregPattern($sType)
  278. {
  279. return $this->_aPregPatterns[$sType];
  280. }
  281. /**
  282. * Ancillary functions
  283. */
  284. public function getViewUrl($iOwnerId)
  285. {
  286. bx_import('BxDolPermalinks');
  287. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=timeline-view&id=' . $iOwnerId);
  288. }
  289. public function getItemViewUrl(&$aEvent)
  290. {
  291. bx_import('BxDolPermalinks');
  292. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=timeline-item&id=' . $aEvent['id']);
  293. }
  294. public function isSystem($sType, $sAction)
  295. {
  296. $sPrefix = $this->getPrefix('common_post');
  297. return strpos($sType, $sPrefix) === false && !empty($sAction);
  298. }
  299. }
  300. /** @} */