Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
wiki.php
1<?php
2
4
9
10final class Wiki extends Provider
11{
12 public const PROVIDER_ID = 'WIKI';
13 public const CONTENT_TYPE_ID = 'WIKI';
14
15 protected static $wikiClass = \CWiki::class;
16 protected static $logTableClass = LogTable::class;
17
18 public static function getId(): string
19 {
20 return static::PROVIDER_ID;
21 }
22
23 public function getEventId(): array
24 {
25 return [ 'wiki', 'wiki_del' ];
26 }
27
28 public function getType(): string
29 {
31 }
32
33 public function getCommentProvider(): Provider
34 {
35 return new ForumPost();
36 }
37
38 public function initSourceFields()
39 {
40 static $wikiParser = false;
41 static $cache = [];
42
43 $elementId = $this->entityId;
44
45 if ($elementId <= 0)
46 {
47 return;
48 }
49
50 $sourceFields = [];
51
52 if (isset($cache[$elementId]))
53 {
54 $sourceFields = $cache[$elementId];
55 }
56 elseif (Loader::includeModule('wiki'))
57 {
58 $res = self::$logTableClass::getList([
59 'filter' => [
60 'SOURCE_ID' => $elementId,
61 '@EVENT_ID' => $this->getEventId(),
62 ],
63 'select' => [ 'ID', 'URL', 'TITLE' ]
64 ]);
65 if ($logEntryFields = $res->fetch())
66 {
68 'LOG_ID' => $logEntryFields['ID'],
69 'URL' => $logEntryFields['URL']
70 ];
71
72 $element = self::$wikiClass::getElementById($elementId, [
73 'CHECK_PERMISSIONS' => 'N',
74 'ACTIVE' => 'Y'
75 ]);
76
77 if ($element)
78 {
79 $sourceFields = array_merge($element, $sourceFields);
80 }
81 else
82 {
83 $sourceFields['~NAME'] = htmlspecialcharsback($logEntryFields['TITLE']);
84 }
85 }
86
87 $cache[$elementId] = $sourceFields;
88 }
89
90 $this->setLogId($sourceFields['LOG_ID']);
92
93 $this->setSourceTitle($sourceFields['NAME']);
94 if (!$wikiParser)
95 {
96 $wikiParser = new \CWikiParser();
97 }
98 $this->setSourceDescription(\CTextParser::clearAllTags(\CWikiParser::clear($wikiParser->parse($sourceFields['DETAIL_TEXT'], $sourceFields['DETAIL_TEXT_TYPE'], []))));
99 }
100
101 public function getPinnedTitle(): string
102 {
103 if (empty($this->sourceFields))
104 {
105 $this->initSourceFields();
106 }
107
109
110 return (
111 !empty($sourceFields['ID'])
112 ? Loc::getMessage('SONET_LIVEFEED_WIKI_PINNED_TITLE', [
113 '#TITLE#' => $sourceFields['~NAME']
114 ])
115 : Loc::getMessage('SONET_LIVEFEED_WIKI_DELETED_PINNED_TITLE', [
116 '#TITLE#' => $sourceFields['~NAME']
117 ])
118 );
119 }
120
121 public static function canRead($params): bool
122 {
123 return true;
124 }
125
126 protected function getPermissions(array $post): string
127 {
129 }
130
131 public function getLiveFeedUrl(): string
132 {
133 $pathToWikiArticle = '';
134
135 if (
136 ($message = $this->getSourceFields())
137 && !empty($message)
138 )
139 {
140 $pathToWikiArticle = str_replace(
141 "#GROUPS_PATH#",
142 Option::get('socialnetwork', 'workgroups_page', '/workgroups/', $this->getSiteId()),
143 $message['URL']
144 );
145 }
146
147 return $pathToWikiArticle;
148 }
149}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
Definition forumpost.php:22