BxTimelineConfig.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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('BxBaseModNotificationsConfig');
  13. class BxTimelineConfig extends BxBaseModNotificationsConfig
  14. {
  15. protected $_bAllowDelete;
  16. protected $_iRssLength;
  17. protected $_iCharsDisplayMax;
  18. protected $_sStorageObject;
  19. protected $_sTranscoderObjectPreview;
  20. protected $_sTranscoderObjectView;
  21. protected $_aImageUploaders;
  22. protected $_sMenuItemManage;
  23. protected $_sMenuItemActions;
  24. protected $_bJsMode;
  25. protected $_aShareDefaults;
  26. protected $_iTimelineVisibilityThreshold;
  27. protected $_aPregPatterns;
  28. /**
  29. * Constructor
  30. */
  31. public function __construct($aModule)
  32. {
  33. parent::__construct($aModule);
  34. $this->CNF = array (
  35. // objects
  36. 'OBJECT_COMMENTS' => $this->_sName,
  37. // some language keys
  38. 'T' => array (
  39. 'txt_sample_single' => '_bx_timeline_txt_sample',
  40. 'txt_sample_comment_single' => '_bx_timeline_txt_sample_comment_single',
  41. ),
  42. );
  43. $this->_aPrefixes = array(
  44. 'style' => 'bx-tl',
  45. 'language' => '_bx_timeline',
  46. 'option' => 'bx_timeline_',
  47. 'common_post' => 'timeline_common_'
  48. );
  49. $this->_aObjects = array(
  50. 'alert' => $this->_sName,
  51. 'comment' => $this->CNF['OBJECT_COMMENTS'],
  52. 'vote' => $this->_sName,
  53. 'storage' => $this->_sName . '_photos',
  54. 'transcoder_preview' => $this->_sName . '_photos_preview',
  55. 'transcoder_view' => $this->_sName . '_photos_view',
  56. 'conn_subscriptions' => 'sys_profiles_subscriptions',
  57. 'menu_item_manage' => $this->_sName . '_menu_item_manage',
  58. 'menu_item_actions' => $this->_sName . '_menu_item_actions'
  59. );
  60. $this->_aHandlerDescriptor = array('module_name' => '', 'module_method' => '', 'module_class' => '', 'groupable' => '', 'group_by' => '');
  61. $this->_sHandlersMethod = 'get_timeline_data';
  62. $this->_aImageUploaders = array($this->_sName . '_simple');
  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. 'main' => $sHtmlPrefix,
  79. 'item' => $sHtmlPrefix . '-item-',
  80. 'menu_popup' => $sHtmlPrefix . '-menu-popup-',
  81. 'photo_popup' => $sHtmlPrefix . '-photo-popup',
  82. ),
  83. 'post' => array(
  84. 'attach_link_popup' => $sHtmlPrefix . '-attach-link-popup',
  85. 'attach_link_form_field' => $sHtmlPrefix . '-attach-link-form_field',
  86. 'attach_link_item' => $sHtmlPrefix . '-attach-link-item-',
  87. ),
  88. 'share' => array(
  89. 'main' => $sHtmlPrefix . '-share-',
  90. 'counter' => $sHtmlPrefix . '-share-counter-',
  91. 'by_popup' => $sHtmlPrefix . '-share-by-',
  92. )
  93. );
  94. $this->_aShareDefaults = array(
  95. 'show_do_share_as_button' => false,
  96. 'show_do_share_as_button_small' => false,
  97. 'show_do_share_icon' => true,
  98. 'show_do_share_label' => false,
  99. 'show_counter' => true
  100. );
  101. $this->_iTimelineVisibilityThreshold = 0;
  102. $this->_aPregPatterns = array(
  103. "meta_title" => "/<title>(.*)<\/title>/",
  104. "meta_description" => "/<meta[\s]+[^>]*?name[\s]?=[\s\"\']+description[\s\"\']+content[\s]?=[\s\"\']+(.*?)[\"\']+.*?>/",
  105. "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_]*)?/"
  106. );
  107. }
  108. public function init(&$oDb)
  109. {
  110. parent::init($oDb);
  111. $sOptionPrefix = $this->getPrefix('option');
  112. $this->_bAllowDelete = getParam($sOptionPrefix . 'enable_delete') == 'on';
  113. $this->_aPerPage = array(
  114. 'default' => 10,
  115. 'profile' => (int)getParam($sOptionPrefix . 'events_per_page_profile'),
  116. 'account' => (int)getParam($sOptionPrefix . 'events_per_page_account'),
  117. 'home' => (int)getParam($sOptionPrefix . 'events_per_page_home')
  118. );
  119. $this->_iRssLength = (int)getParam($sOptionPrefix . 'rss_length');
  120. $this->_iCharsDisplayMax = (int)getParam($sOptionPrefix . 'chars_display_max');
  121. }
  122. public function isAllowDelete()
  123. {
  124. return $this->_bAllowDelete;
  125. }
  126. public function getUploaders($sType)
  127. {
  128. $aResult = '';
  129. switch($sType) {
  130. case 'image':
  131. $aResult = $this->_aImageUploaders;
  132. break;
  133. }
  134. return $aResult;
  135. }
  136. public function getRssLength()
  137. {
  138. return $this->_iRssLength;
  139. }
  140. public function getCharsDisplayMax()
  141. {
  142. return $this->_iCharsDisplayMax;
  143. }
  144. public function isJsMode()
  145. {
  146. return $this->_bJsMode;
  147. }
  148. public function getJsMode()
  149. {
  150. return $this->_bJsMode;
  151. }
  152. public function setJsMode($bJsMode)
  153. {
  154. $this->_bJsMode = $bJsMode;
  155. }
  156. public function getShareDefaults()
  157. {
  158. return $this->_aShareDefaults;
  159. }
  160. public function getPregPattern($sType)
  161. {
  162. return $this->_aPregPatterns[$sType];
  163. }
  164. /**
  165. * Ancillary functions
  166. */
  167. public function getViewUrl($iOwnerId)
  168. {
  169. bx_import('BxDolPermalinks');
  170. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=timeline-view&id=' . $iOwnerId);
  171. }
  172. public function getItemViewUrl(&$aEvent)
  173. {
  174. bx_import('BxDolPermalinks');
  175. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=timeline-item&id=' . $aEvent['id']);
  176. }
  177. public function isSystem($sType, $sAction)
  178. {
  179. $sPrefix = $this->getPrefix('common_post');
  180. return strpos($sType, $sPrefix) === false && !empty($sAction);
  181. }
  182. }
  183. /** @} */