Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
path.php
1<?php
2
4
6
7class Path
8{
9 public $component = null;
10 public $request = null;
11
12 protected $folderUsers = '';
13 protected $folderWorkgroups = '';
14 protected $pathToUserBlogPost = '';
15 protected $pathToLogEntry = '';
16 protected $pathToMessagesChat = '';
17 protected $pathToVideoCall = '';
18 protected $pathToSmile = '';
19
20 public function __construct($params)
21 {
22 if (!empty($params['component']))
23 {
24 $this->component = $params['component'];
25 }
26
27 if (!empty($params['request']))
28 {
29 $this->request = $params['request'];
30 }
31 else
32 {
33 $this->request = Util::getRequest();
34 }
35 }
36
37 public function getRequest()
38 {
39 return $this->request;
40 }
41
42 public function getComponent()
43 {
44 return $this->component;
45 }
46
47 public function setFolderUsersValue($value = ''): void
48 {
49 $this->folderUsers = $value;
50 }
51 public function getFolderUsersValue(): string
52 {
53 return $this->folderUsers;
54 }
55
56 public function setFolderWorkgroupsValue($value = ''): void
57 {
58 $this->folderWorkgroups = $value;
59 }
60 public function getFolderWorkgroupsValue(): string
61 {
62 return $this->folderWorkgroups;
63 }
64
65 public function preparePathParams(&$componentParams): array
66 {
67 $result = [];
68
69 $extranetSite = $this->getComponent()->getExtranetSiteValue();
70
71 $result['folderUsers'] = Option::get('socialnetwork', 'user_page', false, SITE_ID);
72 $result['folderUsers'] = ($result['folderUsers'] ?: ($extranetSite ? SITE_DIR.'contacts/personal/' : SITE_DIR.'company/personal/'));
73
74 $result['folderWorkgroups'] = Option::get('socialnetwork', 'workgroups_page', false, SITE_ID);
75 $result['folderWorkgroups'] = ($result['folderWorkgroups'] ?: SITE_DIR.'workgroups/');
76
77 $result['pathToUserBlogPost'] = \Bitrix\Socialnetwork\Helper\Path::get('userblogpost_page');
78 $result['pathToUserBlogPost'] = ($result['pathToUserBlogPost'] ?: $result['folderUsers'].'user/#user_id#/blog/#post_id#/');
79
80 $result['pathToLogEntry'] = Option::get('socialnetwork', 'log_entry_page', false, SITE_ID);
81 $result['pathToLogEntry'] = ($result['pathToLogEntry'] ?: $result['folderUsers'].'personal/log/#log_id#/');
82
83 $result['pathToMessagesChat'] = Option::get('main', 'TOOLTIP_PATH_TO_MESSAGES_CHAT', false, SITE_ID);
84 $result['pathToMessagesChat'] = ($result['pathToMessagesChat'] ?: $result['folderUsers'].'messages/chat/#user_id#/');
85
86 $result['pathToVideoCall'] = Option::get('main', 'TOOLTIP_PATH_TO_VIDEO_CALL', false, SITE_ID);
87 $result['pathToVideoCall'] = ($result['pathToVideoCall'] ?: $result['folderUsers'].'video/#user_id#/');
88
89 $result['pathToSmile'] = Option::get('socialnetwork', 'smile_page', false, SITE_ID);
90 $result['pathToSmile'] = ($result['pathToSmile'] ?: '/bitrix/images/socialnetwork/smile/');
91
92 $pathToUser = Option::get('main', 'TOOLTIP_PATH_TO_USER', false, SITE_ID);
93 $pathToUser = ($pathToUser ?: $result['folderUsers'].'user/#user_id#/');
94
95 Util::checkEmptyParamString($componentParams, 'PATH_TO_USER', $pathToUser);
96 Util::checkEmptyParamString($componentParams, 'PATH_TO_USER_MICROBLOG', $result['folderUsers'].'user/#user_id#/blog/');
97 Util::checkEmptyParamString($componentParams, 'PATH_TO_USER_BLOG_POST', $result['pathToUserBlogPost']);
98 Util::checkEmptyParamString($componentParams, 'PATH_TO_USER_BLOG_POST_EDIT', $result['folderUsers'].'user/#user_id#/blog/edit/#post_id#/');
99 Util::checkEmptyParamString($componentParams, 'PATH_TO_USER_BLOG_POST_IMPORTANT', $result['folderUsers'].'user/#user_id#/blog/important/');
100 Util::checkEmptyParamString($componentParams, 'PATH_TO_GROUP', $result['folderWorkgroups'].'group/#group_id#/');
101 Util::checkEmptyParamString($componentParams, 'PATH_TO_GROUP_MICROBLOG', $result['folderWorkgroups'].'group/#group_id#/blog/');
102 Util::checkEmptyParamString($componentParams, 'PATH_TO_GROUP_BLOG_POST', $result['folderWorkgroups'].'group/#group_id#/blog/#post_id#/');
103 Util::checkEmptyParamString($componentParams, 'PATH_TO_LOG_ENTRY', $result['pathToLogEntry']);
104 Util::checkEmptyParamString($componentParams, 'PATH_TO_MESSAGES_CHAT', $result['pathToMessagesChat']);
105 Util::checkEmptyParamString($componentParams, 'PATH_TO_VIDEO_CALL', $result['pathToVideoCall']);
106 Util::checkEmptyParamString($componentParams, 'PATH_TO_SMILE', $result['pathToSmile']);
107
108 $componentParams['PATH_TO_USER_MICROBLOG_POST'] = $componentParams['PATH_TO_USER_BLOG_POST'];
109 $componentParams['PATH_TO_GROUP_MICROBLOG_POST'] = $componentParams['PATH_TO_GROUP_BLOG_POST'];
110
111 return $result;
112 }
113
114 public function setPaths(&$params): void
115 {
116 $pathResult = $this->preparePathParams($params);
117 $this->setFolderUsersValue($pathResult['folderUsers']);
118 $this->setFolderWorkgroupsValue($pathResult['folderWorkgroups']);
119
120 $this->pathToUserBlogPost = $pathResult['pathToUserBlogPost'];
121 $this->pathToLogEntry = $pathResult['pathToLogEntry'];
122 $this->pathToMessagesChat = $pathResult['pathToMessagesChat'];
123 $this->pathToVideoCall = $pathResult['pathToVideoCall'];
124 $this->pathToSmile = $pathResult['pathToSmile'];
125 }
126}