- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/lpa.php
- Класс: LPA
- Вызов: LPA::PrepareContent
static function PrepareContent($filesrc)
{
$arPHP = PHPParser::ParseFile($filesrc);
$l = count($arPHP);
if ($l > 0)
{
$new_filesrc = '';
$end = 0;
$php_count = 0;
for ($n = 0; $n<$l; $n++)
{
$start = $arPHP[$n][0];
$new_filesrc .= mb_substr($filesrc, $end, $start - $end);
$end = $arPHP[$n][1];
//Trim php tags
$src = $arPHP[$n][2];
if (mb_substr($src, 0, 5) == ""."php")
$src = mb_substr($src, 5);
else
$src = mb_substr($src, 2);
$src = mb_substr($src, 0, -2);
//If it's Component 2, keep the php code. If it's component 1 or ordinary PHP - than replace code by #PHPXXXX# (XXXX - count of PHP scripts)
$isComponent2Begin = false;
$arIncludeComponentFunctionStrings = PHPParser::getComponentFunctionStrings();
foreach($arIncludeComponentFunctionStrings as $functionName)
{
$comp2_begin = mb_strtoupper($functionName).'(';
if(mb_strtoupper(mb_substr($src, 0, mb_strlen($comp2_begin))) == $comp2_begin)
{
$isComponent2Begin = true;
break;
}
}
if ($isComponent2Begin)
$new_filesrc .= $arPHP[$n][2];
else
$new_filesrc .= '#PHP'.str_pad(++$php_count, 4, "0", STR_PAD_LEFT).'#';
}
$new_filesrc .= mb_substr($filesrc, $end);
$filesrc = $new_filesrc;
}
return $filesrc;
}