- Модуль: tasksmobile
- Путь к файлу: ~/bitrix/modules/tasksmobile/lib/TextFragmentParser.php
- Класс: BitrixTasksMobileTextFragmentParser
- Вызов: TextFragmentParser::parseFiles
private function parseFiles(string $text): string
{
if (
preg_match_all("/[DISK FILE ID=(d+|nd+)]/", $text, $matches)
&& !empty($matches)
)
{
if (empty($this->files))
{
foreach ($matches[0] as $index => $search)
{
$fileName = Loc::getMessage(
'TASKSMOBILE_TEXT_FRAGMENT_PARSER_FILE_REPLACED_NAME',
['#INDEX#' => $index + 1]
);
$replace = "[URL=/?openFile&fileId={$matches[1][$index]}]{$fileName}[/URL]";
$text = str_replace($search, $replace, $text);
}
}
else
{
foreach ($matches[0] as $index => $search)
{
if (array_key_exists($matches[1][$index], $this->files))
{
$file = $this->files[$matches[1][$index]];
$replace = "[URL=/?openFile&fileId={$file['ID']}]{$file['NAME']}[/URL]";
$text = str_replace($search, $replace, $text);
}
}
}
}
return $text;
}