Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
listsitem.php
1<?php
2
4
7
8final class ListsItem extends Provider
9{
10 public const PROVIDER_ID = 'LISTS_NEW_ELEMENT';
11 public const CONTENT_TYPE_ID = 'LISTS_NEW_ELEMENT';
12
13 protected static $logTableClass = LogTable::class;
14
15 public static function getId(): string
16 {
17 return static::PROVIDER_ID;
18 }
19
20 public function getEventId(): array
21 {
22 return [ 'lists_new_element' ];
23 }
24
25 public function getType(): string
26 {
28 }
29
30 public function getCommentProvider(): Provider
31 {
32 return new ForumPost();
33 }
34
35 public function initSourceFields()
36 {
37 static $cache = [];
38
39 $elementId = $this->entityId;
40
41 if ($elementId <= 0)
42 {
43 return;
44 }
45
46 if (isset($cache[$elementId]))
47 {
48 $logEntryFields = $cache[$elementId];
49 }
50 else
51 {
52 $res = self::$logTableClass::getList([
53 'filter' => [
54 'SOURCE_ID' => $elementId,
55 '@EVENT_ID' => $this->getEventId(),
56 ],
57 'select' => [ 'ID', 'TITLE', 'MESSAGE', 'TEXT_MESSAGE', 'PARAMS' ]
58 ]);
59
60 $logEntryFields = $res->fetch();
61 $cache[$elementId] = $logEntryFields;
62 }
63
64 if (empty($logEntryFields))
65 {
66 return;
67 }
68
69 $this->setLogId($logEntryFields['ID']);
70 $this->setSourceFields($logEntryFields);
71 $this->setSourceTitle($logEntryFields['TITLE']);
72
73 $description = $logEntryFields['TEXT_MESSAGE'];
74 $description = preg_replace('/<script(.*?)>(.*?)<\/script>/is', '', $description);
75 $description = \CTextParser::clearAllTags($description);
76 $this->setSourceDescription($description);
77 }
78
79 public function getPinnedTitle()
80 {
81 $result = '';
82
83 if (empty($this->sourceFields))
84 {
85 $this->initSourceFields();
86 }
87
88 $logEntryFields = $this->getSourceFields();
89 if (empty($logEntryFields))
90 {
91 return $result;
92 }
93
94 return $logEntryFields['TITLE'];
95 }
96
97 public function getPinnedDescription()
98 {
99 $result = '';
100
101 if (empty($this->sourceFields))
102 {
103 $this->initSourceFields();
104 }
105
106 $logEntryFields = $this->getSourceFields();
107 if (empty($logEntryFields))
108 {
109 return $result;
110 }
111
112 $description = $logEntryFields['TEXT_MESSAGE'];
113 $description = preg_replace('/<script(.*?)>(.*?)<\/script>/is', '', $description);
114 $description = \CTextParser::clearAllTags($description);
115
116 return truncateText(htmlspecialcharsback($description), 100);
117 }
118
119 public function getLiveFeedUrl(): string
120 {
121 $pathToLogEntry = Option::get('socialnetwork', 'log_entry_page');
122 if (!empty($pathToLogEntry))
123 {
124 $pathToLogEntry = \CComponentEngine::makePathFromTemplate($pathToLogEntry, array("log_id" => $this->getLogId()));
125 }
126
127 return $pathToLogEntry;
128 }
129}
Definition forumpost.php:22