Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
log.php
1<?php
9
15use Bitrix\Vote\UF\Manager;
16
17class Log
18{
19 const EVENT_ID_POST = 'blog_post';
20 const EVENT_ID_POST_IMPORTANT = 'blog_post_important';
21 const EVENT_ID_POST_VOTE = 'blog_post_vote';
22 const EVENT_ID_POST_GRAT = 'blog_post_grat';
23
30 public static function getEventIdList()
31 {
32 return array(
33 self::EVENT_ID_POST,
34 self::EVENT_ID_POST_IMPORTANT,
35 self::EVENT_ID_POST_VOTE,
36 self::EVENT_ID_POST_GRAT
37 );
38 }
39
46 public static function onIndexGetContent(Event $event)
47 {
48 global $USER_FIELD_MANAGER;
49
50 $result = new EventResult(
51 EventResult::UNDEFINED,
52 array(),
53 'blog'
54 );
55
56 $eventId = $event->getParameter('eventId');
57 $sourceId = $event->getParameter('sourceId');
58
59 if (!in_array($eventId, self::getEventIdList()))
60 {
61 return $result;
62 }
63
64 $content = "";
65 $post = false;
66
67 if (intval($sourceId) > 0)
68 {
69 $post = Post::getById($sourceId);
70 }
71
72 if ($post)
73 {
74 $postFieldList = $post->getFields();
75
76 $content .= LogIndex::getUserName($postFieldList["AUTHOR_ID"])." ";
77 if (
78 $postFieldList["MICRO"] != "Y"
79 && isset($postFieldList["TITLE"])
80 && $postFieldList["TITLE"] <> ''
81 )
82 {
83 $content .= \blogTextParser::killAllTags($postFieldList["TITLE"])." ";
84 }
85 $content .= \blogTextParser::killAllTags($postFieldList["DETAIL_TEXT"]);
86
87 $destinationsList = array();
88 $res = \CBlogPost::getSocNetPerms($sourceId);
89 foreach($res as $group => $list)
90 {
91 foreach($list as $key => $valuesList)
92 {
93 $destinationsList = array_merge($destinationsList, $valuesList);
94 }
95 }
96
97 if (!empty($destinationsList))
98 {
99 $content .= ' '.join(' ', LogIndex::getEntitiesName($destinationsList));
100 }
101
102 if (!empty($postFieldList['UF_BLOG_POST_FILE']))
103 {
104 $fileNameList = LogIndex::getDiskUFFileNameList($postFieldList['UF_BLOG_POST_FILE']);
105 if (!empty($fileNameList))
106 {
107 $content .= ' '.join(' ', $fileNameList);
108 }
109 }
110
111 if (!empty($postFieldList['UF_BLOG_POST_URL_PRV']))
112 {
113 $metadata = \Bitrix\Main\UrlPreview\UrlMetadataTable::getRowById($postFieldList['UF_BLOG_POST_URL_PRV']);
114 if (
115 $metadata
116 && isset($metadata['TITLE'])
117 && $metadata['TITLE'] <> ''
118 )
119 {
120 $content .= ' '.$metadata['TITLE'];
121 }
122 }
123
124 if (
125 !empty($postFieldList['UF_BLOG_POST_VOTE'])
126 && intval($postFieldList['UF_BLOG_POST_VOTE']) > 0
127 && Loader::includeModule('vote')
128 )
129 {
130 $postUFList = $USER_FIELD_MANAGER->getUserFields("BLOG_POST", $sourceId, LANGUAGE_ID);
131
132 if (!empty($postUFList['UF_BLOG_POST_VOTE']))
133 {
134 if (
135 ($userFieldManager = Manager::getInstance($postUFList['UF_BLOG_POST_VOTE']))
136 && ($attach = $userFieldManager->loadFromAttachId(intval($postFieldList['UF_BLOG_POST_VOTE'])))
137 )
138 {
139 foreach ($attach["QUESTIONS"] as $question)
140 {
141 $content .= ' '.$question["QUESTION"];
142 foreach ($question["ANSWERS"] as $answer)
143 {
144 $content .= ' '.$answer["MESSAGE"];
145 }
146 }
147 }
148 }
149 }
150
151 if (!empty($postFieldList['CATEGORY_ID']))
152 {
153 $categoryList = explode(",", $postFieldList["CATEGORY_ID"]);
154 $tagList = array();
155 foreach($categoryList as $value)
156 {
157 $category = \CBlogCategory::getByID($value);
158 $tagList[] = $category["NAME"];
159 $tagList[] = '#'.$category["NAME"];
160 }
161 if (!empty($tagList))
162 {
163 $content .= ' '.implode(' ', $tagList);
164 }
165 }
166 }
167
168 $result = new EventResult(
169 EventResult::SUCCESS,
170 array(
171 'content' => $content,
172 ),
173 'blog'
174 );
175
176 return $result;
177 }
178}
179
static onIndexGetContent(Event $event)
Definition log.php:46
Definition post.php:20
getParameter($key)
Definition event.php:80