- Модуль: wiki
- Путь к файлу: ~/bitrix/modules/wiki/classes/general/wiki_parser.php
- Класс: CWikiParser
- Вызов: CWikiParser::_processFileCallback
function _processFileCallback($matches)
{
static $sImageAlign = '';
$bLink = false;
if ($matches[1] == ':')
$bLink = true;
// if the internal file then get it
$sFile = $sFileName = $sPath = CWikiUtils::htmlspecialcharsback(trim($matches[3]));
$bOur = false;
if (is_numeric($sFile) && in_array($sFile, $this->arFile))
{
$arFile = CFile::GetFileArray($sFile);
if ($arFile != false)
{
$bOur = true;
$sPath = $arFile['SRC'];
$sFileName = $arFile['ORIGINAL_NAME'];
}
}
else if (isset($this->arVersionFile[mb_strtolower($sFile)]))
{
$sPath = $this->arVersionFile[mb_strtolower($sFile)];
$sFileName = $sFile;
}
else if (!empty($this->arFile))
{
$arFilter = array(
'@ID' => implode(',', $this->arFile)
);
$rsFile = CFile::GetList(array(), $arFilter);
while($arFile = $rsFile->Fetch())
{
if ($arFile['ORIGINAL_NAME'] == $sFile)
{
$bOur = true;
$sFile = $arFile['ID'];
$sPath = CFile::GetFileSRC($arFile);
$sFileName = $arFile['ORIGINAL_NAME'];
break;
}
}
}
// if the image is processed as a picture
$sName = bx_basename($sPath);
if (CFile::IsImage($sName))
{
if ($bOur)
{
$imageFile = CFile::MakeFileArray($sPath);
$checkRes = CFile::CheckImageFile($imageFile);
if($checkRes != null)
return $checkRes;
if ($bLink)
$sReturn = ''.$s.'';
else
{
$sReturn = CFile::ShowImage($sFile,
COption::GetOptionString('wiki', 'image_max_width', 600),
COption::GetOptionString('wiki', 'image_max_height', 600),
'border="0" align="'.$sImageAlign.'"'
);
}
}
else
{
if ($bLink)
$sReturn = ''.$s.'';
else
$sReturn = '
';
}
}
else if (mb_strpos($sPath, 'http://') === 0)
$sReturn = ' [ '.GetMessage('FILE_DOWNLOAD').' ] ';
// otherwise the file
else
$sReturn = '['.GetMessage('FILE_NAME').':'.htmlspecialcharsbx((is_numeric($sFile) || empty($sFileName) ? $sFile : $sFileName)).']';
return $sReturn;
}