Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
logcomment.php
1<?php
9
16
18{
19 const EVENT_ID_COMMENT = 'blog_comment';
20
21 public static function getEventIdList()
22 {
23 return array(
24 self::EVENT_ID_COMMENT
25 );
26 }
27
34 public static function onIndexGetContent(Event $event)
35 {
36 $result = new EventResult(
37 EventResult::UNDEFINED,
38 array(),
39 'blog'
40 );
41
42 $eventId = $event->getParameter('eventId');
43 $sourceId = $event->getParameter('sourceId');
44
45 if (!in_array($eventId, self::getEventIdList()))
46 {
47 return $result;
48 }
49
50 $content = "";
51 $comment = false;
52
53 if (intval($sourceId) > 0)
54 {
55 $comment = Comment::getById($sourceId);
56 }
57
58 if ($comment)
59 {
60 $commentFieldList = $comment->getFields();
61
62 if (!($commentAuxProvider = CommentAux\Base::findProvider($commentFieldList)))
63 {
64 $content .= LogIndex::getUserName($commentFieldList["AUTHOR_ID"])." ";
65 $content .= \blogTextParser::killAllTags($commentFieldList["POST_TEXT"]);
66 }
67
68 if (!empty($commentFieldList['UF_BLOG_COMMENT_FILE']))
69 {
70 $fileNameList = LogIndex::getDiskUFFileNameList($commentFieldList['UF_BLOG_COMMENT_FILE']);
71 if (!empty($fileNameList))
72 {
73 $content .= ' '.join(' ', $fileNameList);
74 }
75 }
76
77 if (!empty($commentFieldList['UF_BLOG_COMM_URL_PRV']))
78 {
79 $metadata = \Bitrix\Main\UrlPreview\UrlMetadataTable::getRowById($commentFieldList['UF_BLOG_COMM_URL_PRV']);
80 if (
81 $metadata
82 && isset($metadata['TITLE'])
83 && $metadata['TITLE'] <> ''
84 )
85 {
86 $content .= ' '.$metadata['TITLE'];
87 }
88 }
89 }
90
91 $result = new EventResult(
92 EventResult::SUCCESS,
93 array(
94 'content' => $content,
95 ),
96 'blog'
97 );
98
99 return $result;
100 }
101}
102
static getById($commentId=0)
Definition comment.php:25
getParameter($key)
Definition event.php:80