BxTimelineConfig.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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 TridentModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolPrivacy');
  12. class BxTimelineConfig extends BxBaseModNotificationsConfig
  13. {
  14. protected $_bAllowDelete;
  15. protected $_iRssLength;
  16. protected $_iCharsDisplayMax;
  17. protected $_sStorageObject;
  18. protected $_sTranscoderObjectPreview;
  19. protected $_sTranscoderObjectView;
  20. protected $_aPhotoUploaders;
  21. protected $_aVideoUploaders;
  22. protected $_sMenuItemManage;
  23. protected $_sMenuItemActions;
  24. protected $_aShareDefaults;
  25. protected $_iTimelineVisibilityThreshold;
  26. protected $_aPregPatterns;
  27. /**
  28. * Constructor
  29. */
  30. public function __construct($aModule)
  31. {
  32. parent::__construct($aModule);
  33. $this->CNF = array (
  34. // database fields
  35. 'FIELD_ID' => 'id',
  36. 'FIELD_LOCATION_PREFIX' => 'location',
  37. // objects
  38. 'OBJECT_COMMENTS' => $this->_sName,
  39. 'OBJECT_VOTES' => $this->_sName,
  40. 'OBJECT_REPORTS' => $this->_sName,
  41. // some language keys
  42. 'T' => array (
  43. 'txt_sample_single' => '_bx_timeline_txt_sample',
  44. 'txt_sample_single_ext' => '_bx_timeline_txt_sample_ext',
  45. 'txt_sample_comment_single' => '_bx_timeline_txt_sample_comment_single',
  46. 'txt_sample_vote_single' => '_bx_timeline_txt_sample_vote_single',
  47. ),
  48. );
  49. $this->_aPrefixes = array(
  50. 'style' => 'bx-tl',
  51. 'language' => '_bx_timeline',
  52. 'option' => 'bx_timeline_',
  53. 'common_post' => 'timeline_common_'
  54. );
  55. $this->_aObjects = array_merge($this->_aObjects, array(
  56. 'comment' => $this->CNF['OBJECT_COMMENTS'],
  57. 'vote' => $this->CNF['OBJECT_VOTES'],
  58. 'report' => $this->CNF['OBJECT_REPORTS'],
  59. 'metatags' => $this->_sName,
  60. 'storage_photos' => $this->_sName . '_photos',
  61. 'storage_videos' => $this->_sName . '_videos',
  62. 'transcoder_photos_preview' => $this->_sName . '_photos_preview',
  63. 'transcoder_photos_view' => $this->_sName . '_photos_view',
  64. 'transcoder_videos_poster' => $this->_sName . '_videos_poster',
  65. 'transcoder_videos_mp4' => $this->_sName . '_videos_mp4',
  66. 'transcoder_videos_webm' => $this->_sName . '_videos_webm',
  67. 'menu_item_manage' => $this->_sName . '_menu_item_manage',
  68. 'menu_item_actions' => $this->_sName . '_menu_item_actions',
  69. 'menu_post_attachments' => $this->_sName . '_menu_post_attachments',
  70. 'form_post' => $this->_sName . '_post',
  71. 'form_attach_link' => $this->_sName . '_attach_link',
  72. 'form_display_post_add' => $this->_sName . '_post_add',
  73. 'form_display_attach_link_add' => $this->_sName . '_attach_link_add'
  74. ));
  75. $this->_aHandlerDescriptor = array('module_name' => '', 'module_method' => '', 'module_class' => '', 'groupable' => '', 'group_by' => '');
  76. $this->_sHandlersMethod = 'get_timeline_data';
  77. $this->_aPhotoUploaders = array($this->_sName . '_simple_photo');
  78. $this->_aVideoUploaders = array($this->_sName . '_simple_video');
  79. $this->_bJsMode = false;
  80. $this->_aJsClass = array(
  81. 'main' => 'BxTimelineMain',
  82. 'view' => 'BxTimelineView',
  83. 'post' => 'BxTimelinePost',
  84. 'share' => 'BxTimelineShare'
  85. );
  86. $this->_aJsObjects = array(
  87. 'view' => 'oTimelineView',
  88. 'post' => 'oTimelinePost',
  89. 'share' => 'oTimelineShare'
  90. );
  91. $sHtmlPrefix = str_replace('_', '-', $this->_sName);
  92. $this->_aHtmlIds = array(
  93. 'view' => array(
  94. 'main' => $sHtmlPrefix,
  95. 'item' => $sHtmlPrefix . '-item-',
  96. 'menu_popup' => $sHtmlPrefix . '-menu-popup-',
  97. 'photo_popup' => $sHtmlPrefix . '-photo-popup',
  98. ),
  99. 'post' => array(
  100. 'attach_link_popup' => $sHtmlPrefix . '-attach-link-popup',
  101. 'attach_link_form_field' => $sHtmlPrefix . '-attach-link-form_field',
  102. 'attach_link_item' => $sHtmlPrefix . '-attach-link-item-',
  103. ),
  104. 'share' => array(
  105. 'main' => $sHtmlPrefix . '-share-',
  106. 'counter' => $sHtmlPrefix . '-share-counter-',
  107. 'by_popup' => $sHtmlPrefix . '-share-by-',
  108. )
  109. );
  110. $this->_aShareDefaults = array(
  111. 'show_do_share_as_button' => false,
  112. 'show_do_share_as_button_small' => false,
  113. 'show_do_share_icon' => true,
  114. 'show_do_share_label' => false,
  115. 'show_counter' => true
  116. );
  117. $this->_iTimelineVisibilityThreshold = 0;
  118. $this->_aPregPatterns = array(
  119. "meta_title" => "/<title>(.*)<\/title>/",
  120. "meta_description" => "/<meta[\s]+[^>]*?name[\s]?=[\s\"\']+description[\s\"\']+content[\s]?=[\s\"\']+(.*?)[\"\']+.*?>/",
  121. "url" => "/(([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?/"
  122. );
  123. }
  124. public function init(&$oDb)
  125. {
  126. parent::init($oDb);
  127. $sOptionPrefix = $this->getPrefix('option');
  128. $this->_bAllowDelete = getParam($sOptionPrefix . 'enable_delete') == 'on';
  129. $this->_aPerPage = array(
  130. 'default' => (int)getParam($sOptionPrefix . 'events_per_page'),
  131. 'profile' => (int)getParam($sOptionPrefix . 'events_per_page_profile'),
  132. 'account' => (int)getParam($sOptionPrefix . 'events_per_page_account'),
  133. 'home' => (int)getParam($sOptionPrefix . 'events_per_page_home')
  134. );
  135. $this->_iRssLength = (int)getParam($sOptionPrefix . 'rss_length');
  136. $this->_iCharsDisplayMax = (int)getParam($sOptionPrefix . 'chars_display_max');
  137. }
  138. public function isAllowDelete()
  139. {
  140. return $this->_bAllowDelete;
  141. }
  142. public function getUploaders($sType)
  143. {
  144. $aResult = array();
  145. switch($sType) {
  146. case 'photo':
  147. $aResult = $this->_aPhotoUploaders;
  148. break;
  149. case 'video':
  150. $aResult = $this->_aVideoUploaders;
  151. break;
  152. }
  153. return $aResult;
  154. }
  155. public function getRssLength()
  156. {
  157. return $this->_iRssLength;
  158. }
  159. public function getCharsDisplayMax()
  160. {
  161. return $this->_iCharsDisplayMax;
  162. }
  163. public function getShareDefaults()
  164. {
  165. return $this->_aShareDefaults;
  166. }
  167. public function getPregPattern($sType)
  168. {
  169. return $this->_aPregPatterns[$sType];
  170. }
  171. /**
  172. * Ancillary functions
  173. */
  174. public function getViewUrl($iOwnerId)
  175. {
  176. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=timeline-view&id=' . $iOwnerId);
  177. }
  178. public function getItemViewUrl(&$aEvent)
  179. {
  180. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=timeline-item&id=' . $aEvent['id']);
  181. }
  182. public function isSystem($sType, $sAction)
  183. {
  184. $sPrefix = $this->getPrefix('common_post');
  185. return strpos($sType, $sPrefix) === false && !empty($sAction);
  186. }
  187. public function getSystemData(&$aEvent)
  188. {
  189. $sHandler = $aEvent['type'] . '_' . $aEvent['action'];
  190. if(!$this->isHandler($sHandler))
  191. return false;
  192. $aHandler = $this->getHandlers($sHandler);
  193. if(empty($aHandler['module_name']) || empty($aHandler['module_class']) || empty($aHandler['module_method']))
  194. return false;
  195. return BxDolService::call($aHandler['module_name'], $aHandler['module_method'], array($aEvent), $aHandler['module_class']);
  196. }
  197. public function getSystemDataByDescriptor($sType, $sAction, $iObjectId)
  198. {
  199. $aDescriptor = array(
  200. 'type' => $sType,
  201. 'action' => $sAction,
  202. 'object_id' => $iObjectId
  203. );
  204. return $this->getSystemData($aDescriptor);
  205. }
  206. }
  207. /** @} */