• Модуль: fileman
  • Путь к файлу: ~/bitrix/modules/fileman/classes/general/editor_utils.php
  • Класс: CEditorUtils
  • Вызов: CEditorUtils::_RenderOneComponent
static function _RenderOneComponent($arParams, $bLPA)
{
	global $APPLICATION, $USER;

	$arProperties = CEditorUtils::GetCompProperties($arParams['name'], $arParams['template'], $arParams['siteTemplateId']);
	$code = '$APPLICATION->IncludeComponent("'.$arParams['name'].'","'.$arParams['template'].'",';
	$arProperties['BX_EDITOR_RENDER_MODE'] = Array('NAME' => 'Workin in render mode *For Visual editor rendering only*', 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'Y'); // Add description of the system parameter

	$arProps = $arParams['params'];
	if (!$arProps) // Get default properties
	{
		$arProps = array();
		foreach($arProperties as $key => $Prop)
			$arProps[$key] = $Prop['DEFAULT'];
	}
	else
	{
		if ($bLPA)
		{
			$arPHPparams = Array();
			CMain::LPAComponentChecker($arProps, $arPHPparams);
			$len = count($arPHPparams);

			// Replace values from 'DEFAULT' field
			for ($e = 0; $e < $len; $e++)
			{
				$par_name = $arPHPparams[$e];
				$arProps[$par_name] = isset($arProperties[$par_name]['DEFAULT']) ? $arProperties[$par_name]['DEFAULT'] : '';
			}
		}
	}

	foreach($arProps as $key => $val)
	{
		$val = trim($val);
		if ($key != addslashes($key))
		{
			unset($arProps[$key]);
			continue;
		}

		if (mb_strtolower($val) == 'array()')
		{
			$arProps[$key] = Array();
		}
		elseif (mb_substr(mb_strtolower($val), 0, 6) == 'array(')
		{
			$str = array();
			$tArr = array();
			PHPParser::GetParamsRec($val, $str, $tArr);

			if (is_array($tArr))
			{
				foreach($tArr as $k => $v)
				{
					if(mb_substr($v, 0, 2) == "={" && mb_substr($v, -1, 1) == "}" && mb_strlen($v) > 3)
						$v = mb_substr($v, 2, -1);
					unset($tArr[$k]);
					$tArr[addslashes($k)] = addslashes(trim($v, " "'"));
				}
			}
			$arProps[$key] = $tArr;
		}
		else
		{
			$arProps[$key] = addslashes($val);
		}
	}

	$arProps['BX_EDITOR_RENDER_MODE'] = 'Y'; //Set system parameter
	$params = PHPParser::ReturnPHPStr2($arProps, $arParameters);
	$code .= 'Array('.$params.')';
	$code .= ');';

	ob_start();
	echo '#BX_RENDERED_COMPONENT#';
	eval($code);
	echo  '#BX_RENDERED_COMPONENT#';
	$s = ob_get_contents();
	ob_end_clean();

	return $s;
}