BxTimelineConfig.php 8.6 KB

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