%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.141.201.106 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/ui/lib/timeline/ |
Upload File : |
<?php namespace Bitrix\UI\Timeline; use Bitrix\Main\Loader; use Bitrix\Main\Localization\Loc; class CommentParser { protected $parser; protected $userFields; public function __construct(array $userFields = []) { $this->userFields = $userFields; } public function setUserFields(array $userFields): CommentParser { $this->userFields = $userFields; return $this; } public function getHtml(string $text): string { $rules = array( "HTML" => "N", "ALIGN" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N", "SHORT_ANCHOR" => "Y" ); $parser = $this->getParser(); if($parser instanceof \blogTextParser) { $result = $parser->convert($text, [], $rules); } elseif($parser instanceof \forumTextParser) { $result = $parser->convert($text, $rules, "html", []); } elseif($parser instanceof \logTextParser) { $result = $parser->convert($text, [], $rules); } else { $result = $parser->convertText($text); } $result = \Bitrix\Main\Text\Emoji::decode($result); $result = preg_replace('/\[[^\]]+\]/', '', $result); return $result; } public function getText(string $text): string { $parser = $this->getParser(); if($parser instanceof \blogTextParser || $parser instanceof \forumTextParser) { $result = $parser::killAllTags($text); } else { $result = $parser::clearAllTags($text); } return preg_replace('/\[[^\]]+\]/', '', $result); } public function getMentionedUserIds(string $text): array { $mentionedUserIds = []; if(preg_match_all("/\[user\s*=\s*([^\]]*)\](.+?)\[\/user\]/is" . BX_UTF_PCRE_MODIFIER, $text, $matches) && is_array($matches[1])) { $mentionedUserIds = $matches[1]; $mentionedUserIds = array_unique($mentionedUserIds); foreach($mentionedUserIds as &$mentionedUserId) { $mentionedUserId = (int) $mentionedUserId; } } return $mentionedUserIds; } protected function getParser(): \CTextParser { $languageId = Loc::getCurrentLang(); if($this->parser === null && Loader::includeModule('blog')) { $this->parser = new \blogTextParser($languageId); } if($this->parser === null && Loader::includeModule('forum')) { $this->parser = new \forumTextParser($languageId); } if($this->parser === null && Loader::includeModule('socialnetwork')) { $this->parser = new \logTextParser($languageId); } if($this->parser === null) { $this->parser = new \CTextParser(); } if(is_array($this->userFields)) { $this->parser->arUserfields = $this->userFields; } return $this->parser; } }