• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/lpa.php
  • Класс: LPA
  • Вызов: LPA::Process
static function Process($filesrc = false, $old_filesrc = false)
{
	if ($filesrc === false)
		return '';

	// Find all php fragments in $filesrc and:
	// 	1. Kill all non-component 2.0 fragments
	// 	2. Get and check params of components
	$arPHP = PHPParser::ParseFile($filesrc);
	$l = count($arPHP);
	if ($l > 0)
	{
		$new_filesrc = '';
		$end = 0;
		for ($n = 0; $n<$l; $n++)
		{
			$start = $arPHP[$n][0];
			$new_filesrc .= self::EncodePHPTags(mb_substr($filesrc, $end, $start - $end));
			$end = $arPHP[$n][1];

			//Trim php tags
			$src = $arPHP[$n][2];
			if (mb_substr($src, 0, 5) == " $v)
						{
							$k = CMain::_ReplaceNonLatin($k);
							$v = CMain::_ReplaceNonLatin($v);
							if ($k <> '' && $v <> '')
								$arExParams[$k] = $v;
						}
						$exParams = PHPParser::ReturnPHPStr2($arExParams);
						$code .= ','.$br."tarray(".$exParams.')';
					}
					$code .= $br.');';
					$code = '';
					$new_filesrc .= $code;
				}
			}
		}
		$new_filesrc .= self::EncodePHPTags(mb_substr($filesrc, $end));
		$filesrc = $new_filesrc;
	}
	else
	{
		$filesrc = self::EncodePHPTags($filesrc);
	}

	if (strpos($filesrc, '#PHP') !== false && $old_filesrc !== false) // We have to handle php fragments
	{
		// Get array of PHP scripts from old saved file
		$arPHP = PHPParser::ParseFile($old_filesrc);
		$arPHPscripts = array();
		$l = count($arPHP);
		if ($l > 0)
		{
			$new_filesrc = '';
			$end = 0;
			for ($n = 0; $n < $l; $n++)
			{
				$start = $arPHP[$n][0];
				$new_filesrc .= mb_substr($old_filesrc, $end, $start - $end);
				$end = $arPHP[$n][1];
				$src = $arPHP[$n][2];
				$src = mb_substr($src, (mb_substr($src, 0, 5) == "';
			}
			else
			{
				$code = '';
			}
			$filesrc = mb_substr($filesrc, 0, $php_begin).$code.mb_substr($filesrc, $php_begin + 9);
		}
	}

	return $filesrc;
}