1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
commentparser.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\UI\Timeline;
4
5
use Bitrix\Main\Loader;
6
use Bitrix\Main\Localization\Loc;
7
8
class
CommentParser
9
{
10
protected
$parser
;
11
protected
$userFields
;
12
13
public
function
__construct
(
array
$userFields
= [])
14
{
15
$this->userFields =
$userFields
;
16
}
17
18
public
function
setUserFields
(
array
$userFields
):
CommentParser
19
{
20
$this->userFields =
$userFields
;
21
22
return
$this;
23
}
24
25
public
function
getHtml
(
string
$text
): string
26
{
27
$rules =
array
(
28
"HTML"
=>
"N"
,
29
"ALIGN"
=>
"Y"
,
30
"ANCHOR"
=>
"Y"
,
"BIU"
=>
"Y"
,
31
"IMG"
=>
"Y"
,
"QUOTE"
=>
"Y"
,
32
"CODE"
=>
"Y"
,
"FONT"
=>
"Y"
,
33
"LIST"
=>
"Y"
,
"SMILES"
=>
"Y"
,
34
"NL2BR"
=>
"Y"
,
"MULTIPLE_BR"
=>
"N"
,
35
"VIDEO"
=>
"Y"
,
"LOG_VIDEO"
=>
"N"
,
36
"SHORT_ANCHOR"
=>
"Y"
37
);
38
39
$parser
= $this->
getParser
();
40
41
if
(
$parser
instanceof \
blogTextParser
)
42
{
43
$result
=
$parser
->convert(
$text
, [], $rules);
44
}
45
elseif
(
$parser
instanceof \
forumTextParser
)
46
{
47
$result
=
$parser
->convert(
$text
, $rules,
"html"
, []);
48
}
49
elseif
(
$parser
instanceof \
logTextParser
)
50
{
51
$result
=
$parser
->convert(
$text
, [], $rules);
52
}
53
else
54
{
55
$result
=
$parser
->convertText(
$text
);
56
}
57
58
$result
=
\Bitrix\Main\Text\Emoji::decode
(
$result
);
59
$result
= preg_replace(
'/\[[^\]]+\]/'
,
''
,
$result
);
60
61
return
$result
;
62
}
63
64
public
function
getText
(
string
$text
): string
65
{
66
$parser
= $this->
getParser
();
67
if
(
$parser
instanceof \
blogTextParser
||
$parser
instanceof \
forumTextParser
)
68
{
69
$result
= $parser::killAllTags(
$text
);
70
}
71
else
72
{
73
$result
= $parser::clearAllTags(
$text
);
74
}
75
76
return
preg_replace(
'/\[[^\]]+\]/'
,
''
,
$result
);
77
}
78
79
public
function
getMentionedUserIds
(
string
$text
):
array
80
{
81
$mentionedUserIds = [];
82
83
if
(preg_match_all(
"/\[user\s*=\s*([^\]]*)\](.+?)\[\/user\]/isu"
,
$text
,
$matches
) && is_array(
$matches
[1]))
84
{
85
$mentionedUserIds =
$matches
[1];
86
$mentionedUserIds = array_unique($mentionedUserIds);
87
foreach
($mentionedUserIds as &$mentionedUserId)
88
{
89
$mentionedUserId = (int) $mentionedUserId;
90
}
91
}
92
93
return
$mentionedUserIds;
94
}
95
96
protected
function
getParser
(): \
CTextParser
97
{
98
$languageId = Loc::getCurrentLang();
99
if
($this->parser ===
null
&& Loader::includeModule(
'blog'
))
100
{
101
$this->parser = new \blogTextParser($languageId);
102
}
103
if
($this->parser ===
null
&& Loader::includeModule(
'forum'
))
104
{
105
$this->parser = new \forumTextParser($languageId);
106
}
107
if
($this->parser ===
null
&& Loader::includeModule(
'socialnetwork'
))
108
{
109
$this->parser = new \logTextParser($languageId);
110
}
111
if
($this->parser ===
null
)
112
{
113
$this->parser = new \CTextParser();
114
}
115
116
if
(is_array($this->userFields))
117
{
118
$this->parser->arUserfields =
$this->userFields
;
119
}
120
121
return
$this->parser
;
122
}
123
}
Bitrix\Main\Text\Emoji\decode
static decode($text)
Определения
emoji.php:24
Bitrix\UI\Timeline\CommentParser
Определения
commentparser.php:9
Bitrix\UI\Timeline\CommentParser\$parser
$parser
Определения
commentparser.php:10
Bitrix\UI\Timeline\CommentParser\getText
getText(string $text)
Определения
commentparser.php:64
Bitrix\UI\Timeline\CommentParser\$userFields
$userFields
Определения
commentparser.php:11
Bitrix\UI\Timeline\CommentParser\getParser
getParser()
Определения
commentparser.php:96
Bitrix\UI\Timeline\CommentParser\setUserFields
setUserFields(array $userFields)
Определения
commentparser.php:18
Bitrix\UI\Timeline\CommentParser\getHtml
getHtml(string $text)
Определения
commentparser.php:25
Bitrix\UI\Timeline\CommentParser\__construct
__construct(array $userFields=[])
Определения
commentparser.php:13
Bitrix\UI\Timeline\CommentParser\getMentionedUserIds
getMentionedUserIds(string $text)
Определения
commentparser.php:79
CTextParser
Определения
textparser.php:21
blogTextParser
Определения
functions.php:6
forumTextParser
Определения
functions.php:18
logTextParser
Определения
log_tools.php:6352
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$text
$text
Определения
template_pdf.php:79
$matches
$matches
Определения
index.php:22
bitrix
modules
ui
lib
timeline
commentparser.php
Создано системой
1.14.0