• Модуль: fileman
  • Путь к файлу: ~/bitrix/modules/fileman/classes/general/component_params_manager.php
  • Класс: CComponentParamsManager
  • Вызов: CComponentParamsManager::GetComponentProperties
static function GetComponentProperties($name = '', $template = '', $siteTemplate = '', $currentValues = array())
{
	$template = (!$template || $template == '.default') ? '' : $template;
	$arTemplates = CComponentUtil::GetTemplatesList($name, $siteTemplate);

	$result = array(
		'templates' => array()
	);

	$arSiteTemplates = array(".default" => GetMessage("PAR_MAN_DEFAULT"));
	if(!empty($siteTemplate))
	{
		$dbst = CSiteTemplate::GetList(array(), array("ID" => $siteTemplate), array());
		while($siteTempl = $dbst->Fetch())
			$arSiteTemplates[$siteTempl['ID']] = $siteTempl['NAME'];
 		}

 		foreach($arTemplates as $k => $templ)
	{
		$showTemplateName = ($templ["TEMPLATE"] !== '' && $arSiteTemplates[$templ["TEMPLATE"]] <> '') ? 				$arSiteTemplates[$templ["TEMPLATE"]] : GetMessage("PAR_MAN_DEF_TEMPLATE");
		$arTemplates[$k]['DISPLAY_NAME'] = $templ['NAME'].' ('.$showTemplateName.')';
	}

	$arTemplateProps = array();
	if (is_array($arTemplates))
	{
		foreach ($arTemplates as $arTemplate)
		{
			$result['templates'][] = $arTemplate;
			$tName = (!$arTemplate['NAME'] || $arTemplate['NAME'] == '.default') ? '' : $arTemplate['NAME'];

			if ($tName == $template)
			{
				$arTemplateProps = CComponentUtil::GetTemplateProps($name, $arTemplate['NAME'], $siteTemplate, $currentValues);
			}
		}
	}

	$result['parameters'] = array();
	$arProps = CComponentUtil::GetComponentProps($name, $currentValues, $arTemplateProps);
	$result['tooltips'] = self::FetchHelp($name);

	if (!isset($arProps['GROUPS']) || !is_array($arProps['GROUPS']))
	{
		$arProps['GROUPS'] = array();
	}
	if (!isset($arProps['PARAMETERS']) || !is_array($arProps['PARAMETERS']))
	{
		$arProps['PARAMETERS'] = array();
	}

	$result['groups'] = array();
	foreach ($arProps['GROUPS'] as $k => $arGroup)
	{
		$arGroup['ID'] = $k;
		$result['groups'][] = $arGroup;
	}

	foreach ($arProps['PARAMETERS'] as $k => $arParam)
	{
		$arParam['ID'] = preg_replace("/[^a-zA-Z0-9_-]/is", "_", $k);
		if (!isset($arParam['PARENT']))
		{
			$arParam['PARENT'] = 'ADDITIONAL_SETTINGS';
		}
		$result['parameters'][] = $arParam;

		if (($arParam['TYPE'] ?? null) == 'FILE')
		{
			self::$fileDialogs[] = array(
				'NAME' => $arParam['ID'],
				'TARGET' => isset($arParam['FD_TARGET']) ? $arParam['FD_TARGET'] : 'F',
				'EXT' => isset($arParam['FD_EXT']) ? $arParam['FD_EXT'] : '',
				'UPLOAD' => isset($arParam['FD_UPLOAD']) && $arParam['FD_UPLOAD'] && $arParam['FD_TARGET'] == 'F',
				'USE_ML' => isset($arParam['FD_USE_MEDIALIB']) && $arParam['FD_USE_MEDIALIB'],
				'ONLY_ML' => isset($arParam['FD_USE_ONLY_MEDIALIB']) && $arParam['FD_USE_ONLY_MEDIALIB'],
				'ML_TYPES' => isset($arParam['FD_MEDIALIB_TYPES']) ? $arParam['FD_MEDIALIB_TYPES'] : false
			);
		}

		// TOOLTIPS FROM .parameters langs
		if (!isset($result['tooltips'][$arParam['ID'].'_TIP']))
		{
			$tip = GetMessage($arParam['ID'].'_TIP');
			if ($tip)
			{
				$result['tooltips'][$arParam['ID'].'_TIP'] = $tip;
			}
		}
	}

	return $result;
}