Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
log.php
1<?
7
11
12class Log
13{
14 const EVENT_ID_WIKI = 'wiki';
15
22 public static function getEventIdList()
23 {
24 return array(
25 self::EVENT_ID_WIKI
26 );
27 }
28
35 public static function onIndexGetContent(Event $event)
36 {
37 static $wikiParser = null;
38
39 $result = new EventResult(
40 EventResult::UNDEFINED,
41 array(),
42 'wiki'
43 );
44
45 $eventId = $event->getParameter('eventId');
46 $sourceId = $event->getParameter('sourceId');
47
48 if (!in_array($eventId, self::getEventIdList()))
49 {
50 return $result;
51 }
52
53 $content = "";
54 $element = false;
55
56 if ((int)($sourceId) > 0)
57 {
58 $element = \CWiki::getElementById($sourceId, array(
59 'CHECK_PERMISSIONS' => 'N',
60 'ACTIVE' => 'Y'
61 ));
62 }
63
64 if ($element)
65 {
66 if (!$wikiParser)
67 {
68 $wikiParser = new \CWikiParser();
69 }
70
71 $element['DETAIL_TEXT'] = $wikiParser->parse($element['DETAIL_TEXT'], $element['DETAIL_TEXT_TYPE'], array());
72 $element['DETAIL_TEXT'] = \CWikiParser::clear($element['DETAIL_TEXT']);
73
74 $content .= LogIndex::getUserName($element["CREATED_BY"])." ";
75 $content .= $element['NAME']." ";
76 $content .= \CTextParser::clearAllTags($element['DETAIL_TEXT']);
77
78 if (
79 !empty($element['_TAGS'])
80 && is_array($element['_TAGS'])
81 )
82 {
83 $tagList = [];
84 foreach($element['_TAGS'] as $tag)
85 {
86 $tagList[] = $tag["NAME"];
87 $tagList[] = '#'.$tag["NAME"];
88 }
89
90 if (!empty($tagList))
91 {
92 $content .= ' '.implode(' ', $tagList);
93 }
94 }
95 }
96
97 $result = new EventResult(
98 EventResult::SUCCESS,
99 array(
100 'content' => $content,
101 ),
102 'wiki'
103 );
104
105 return $result;
106 }
107
108
109}
getParameter($key)
Definition event.php:80
static onIndexGetContent(Event $event)
Definition log.php:35