Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
wiki.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Livefeed
;
4
5
use
Bitrix\Main\Config\Option
;
6
use
Bitrix\Main\Loader
;
7
use
Bitrix\Main\Localization\Loc
;
8
use
Bitrix\Socialnetwork\LogTable
;
9
10
final
class
Wiki
extends
Provider
11
{
12
public
const
PROVIDER_ID
=
'WIKI'
;
13
public
const
CONTENT_TYPE_ID
=
'WIKI'
;
14
15
protected
static
$wikiClass
= \CWiki::class;
16
protected
static
$logTableClass
= LogTable::class;
17
18
public
static
function
getId
(): string
19
{
20
return
static::PROVIDER_ID;
21
}
22
23
public
function
getEventId
(): array
24
{
25
return
[
'wiki'
,
'wiki_del'
];
26
}
27
28
public
function
getType
(): string
29
{
30
return
Provider::TYPE_POST
;
31
}
32
33
public
function
getCommentProvider
():
Provider
34
{
35
return
new
ForumPost
();
36
}
37
38
public
function
initSourceFields
()
39
{
40
static
$wikiParser =
false
;
41
static
$cache = [];
42
43
$elementId =
$this->entityId
;
44
45
if
($elementId <= 0)
46
{
47
return
;
48
}
49
50
$sourceFields
= [];
51
52
if
(isset($cache[$elementId]))
53
{
54
$sourceFields
= $cache[$elementId];
55
}
56
elseif (Loader::includeModule(
'wiki'
))
57
{
58
$res = self::$logTableClass::getList([
59
'filter'
=> [
60
'SOURCE_ID'
=> $elementId,
61
'@EVENT_ID'
=> $this->
getEventId
(),
62
],
63
'select'
=> [
'ID'
,
'URL'
,
'TITLE'
]
64
]);
65
if
($logEntryFields = $res->fetch())
66
{
67
$sourceFields
= [
68
'LOG_ID'
=> $logEntryFields[
'ID'
],
69
'URL'
=> $logEntryFields[
'URL'
]
70
];
71
72
$element = self::$wikiClass::getElementById($elementId, [
73
'CHECK_PERMISSIONS'
=>
'N'
,
74
'ACTIVE'
=>
'Y'
75
]);
76
77
if
($element)
78
{
79
$sourceFields
= array_merge($element,
$sourceFields
);
80
}
81
else
82
{
83
$sourceFields
[
'~NAME'
] = htmlspecialcharsback($logEntryFields[
'TITLE'
]);
84
}
85
}
86
87
$cache[$elementId] =
$sourceFields
;
88
}
89
90
$this->
setLogId
(
$sourceFields
[
'LOG_ID'
]);
91
$this->
setSourceFields
(
$sourceFields
);
92
93
$this->
setSourceTitle
(
$sourceFields
[
'NAME'
]);
94
if
(!$wikiParser)
95
{
96
$wikiParser = new \CWikiParser();
97
}
98
$this->
setSourceDescription
(\CTextParser::clearAllTags(\CWikiParser::clear($wikiParser->parse(
$sourceFields
[
'DETAIL_TEXT'
],
$sourceFields
[
'DETAIL_TEXT_TYPE'
], []))));
99
}
100
101
public
function
getPinnedTitle
(): string
102
{
103
if
(empty($this->sourceFields))
104
{
105
$this->
initSourceFields
();
106
}
107
108
$sourceFields
= $this->
getSourceFields
();
109
110
return
(
111
!empty(
$sourceFields
[
'ID'
])
112
?
Loc::getMessage
(
'SONET_LIVEFEED_WIKI_PINNED_TITLE'
, [
113
'#TITLE#'
=>
$sourceFields
[
'~NAME'
]
114
])
115
:
Loc::getMessage
(
'SONET_LIVEFEED_WIKI_DELETED_PINNED_TITLE'
, [
116
'#TITLE#'
=>
$sourceFields
[
'~NAME'
]
117
])
118
);
119
}
120
121
public
static
function
canRead
($params): bool
122
{
123
return
true
;
124
}
125
126
protected
function
getPermissions
(array $post): string
127
{
128
return
self::PERMISSION_READ
;
129
}
130
131
public
function
getLiveFeedUrl
(): string
132
{
133
$pathToWikiArticle =
''
;
134
135
if
(
136
($message = $this->
getSourceFields
())
137
&& !empty($message)
138
)
139
{
140
$pathToWikiArticle = str_replace(
141
"#GROUPS_PATH#"
,
142
Option::get(
'socialnetwork'
,
'workgroups_page'
,
'/workgroups/'
, $this->
getSiteId
()),
143
$message[
'URL'
]
144
);
145
}
146
147
return
$pathToWikiArticle;
148
}
149
}
Bitrix\Main\Config\Option
Definition
option.php:15
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Socialnetwork\Livefeed\ForumPost
Definition
forumpost.php:22
Bitrix\Socialnetwork\Livefeed\Provider
Definition
provider.php:22
Bitrix\Socialnetwork\Livefeed\Provider\setLogId
setLogId($logId)
Definition
provider.php:612
Bitrix\Socialnetwork\Livefeed\Provider\setSourceFields
setSourceFields(array $fields)
Definition
provider.php:627
Bitrix\Socialnetwork\Livefeed\Provider\setSourceTitle
setSourceTitle($title)
Definition
provider.php:665
Bitrix\Socialnetwork\Livefeed\Provider\getSiteId
getSiteId()
Definition
provider.php:94
Bitrix\Socialnetwork\Livefeed\Provider\$sourceFields
$sourceFields
Definition
provider.php:55
Bitrix\Socialnetwork\Livefeed\Provider\PERMISSION_READ
const PERMISSION_READ
Definition
provider.php:47
Bitrix\Socialnetwork\Livefeed\Provider\getSourceFields
getSourceFields()
Definition
provider.php:637
Bitrix\Socialnetwork\Livefeed\Provider\TYPE_POST
const TYPE_POST
Definition
provider.php:25
Bitrix\Socialnetwork\Livefeed\Provider\setSourceDescription
setSourceDescription($description)
Definition
provider.php:642
Bitrix\Socialnetwork\Livefeed\Provider\$entityId
$entityId
Definition
provider.php:52
Bitrix\Socialnetwork\Livefeed\Wiki
Definition
wiki.php:11
Bitrix\Socialnetwork\Livefeed\Wiki\initSourceFields
initSourceFields()
Definition
wiki.php:38
Bitrix\Socialnetwork\Livefeed\Wiki\getCommentProvider
getCommentProvider()
Definition
wiki.php:33
Bitrix\Socialnetwork\Livefeed\Wiki\CONTENT_TYPE_ID
const CONTENT_TYPE_ID
Definition
wiki.php:13
Bitrix\Socialnetwork\Livefeed\Wiki\getPinnedTitle
getPinnedTitle()
Definition
wiki.php:101
Bitrix\Socialnetwork\Livefeed\Wiki\getPermissions
getPermissions(array $post)
Definition
wiki.php:126
Bitrix\Socialnetwork\Livefeed\Wiki\$wikiClass
static $wikiClass
Definition
wiki.php:15
Bitrix\Socialnetwork\Livefeed\Wiki\getType
getType()
Definition
wiki.php:28
Bitrix\Socialnetwork\Livefeed\Wiki\getLiveFeedUrl
getLiveFeedUrl()
Definition
wiki.php:131
Bitrix\Socialnetwork\Livefeed\Wiki\getEventId
getEventId()
Definition
wiki.php:23
Bitrix\Socialnetwork\Livefeed\Wiki\canRead
static canRead($params)
Definition
wiki.php:121
Bitrix\Socialnetwork\Livefeed\Wiki\getId
static getId()
Definition
wiki.php:18
Bitrix\Socialnetwork\Livefeed\Wiki\PROVIDER_ID
const PROVIDER_ID
Definition
wiki.php:12
Bitrix\Socialnetwork\Livefeed\Wiki\$logTableClass
static $logTableClass
Definition
wiki.php:16
Bitrix\Socialnetwork\LogTable
Definition
log.php:36
Bitrix\Socialnetwork\Livefeed
Definition
bitrix24newuser.php:3
modules
socialnetwork
lib
livefeed
wiki.php
Создано системой
1.10.0