• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/classes/general/prop_section_auto.php
  • Класс: CIBlockPropertySectionAutoComplete
  • Вызов: CIBlockPropertySectionAutoComplete::PrepareSettings
static function PrepareSettings($arFields)
{
	/*
	 * VIEW				- view type
	 * SHOW_ADD			- show button for add new values in linked iblock
	 * MAX_WIDTH		- max width textarea and input in pixels
	 * MIN_HEIGHT		- min height textarea in pixels
	 * MAX_HEIGHT		- max height textarea in pixels
	 * BAN_SYM			- banned symbols string
	 * REP_SYM			- replace symbol
	 * OTHER_REP_SYM	- non standart replace symbol
	 * IBLOCK_MESS		- get lang mess from linked iblock
	 */
	$arViewsList = static::GetPropertyViewsList(false);
	$strView = (isset($arFields['USER_TYPE_SETTINGS']['VIEW']) && in_array($arFields['USER_TYPE_SETTINGS']['VIEW'],$arViewsList) ? $arFields['USER_TYPE_SETTINGS']['VIEW'] : current($arViewsList));

	$strShowAdd = ($arFields['USER_TYPE_SETTINGS']['SHOW_ADD'] ?? '');
	$strShowAdd = ('Y' == $strShowAdd ? 'Y' : 'N');
	if ((int)($arFields['LINK_IBLOCK_ID'] ?? 0) <= 0)
		$strShowAdd = 'N';

	$intMaxWidth = intval($arFields['USER_TYPE_SETTINGS']['MAX_WIDTH'] ?? 0);
	if (0 >= $intMaxWidth) $intMaxWidth = 0;

	$intMinHeight = intval($arFields['USER_TYPE_SETTINGS']['MIN_HEIGHT'] ?? 0);
	if (0 >= $intMinHeight) $intMinHeight = 24;

	$intMaxHeight = intval($arFields['USER_TYPE_SETTINGS']['MAX_HEIGHT'] ?? 0);
	if (0 >= $intMaxHeight) $intMaxHeight = 1000;

	$strBannedSymbols = trim((string)($arFields['USER_TYPE_SETTINGS']['BAN_SYM'] ?? ',;'));
	$strBannedSymbols = str_replace(' ','',$strBannedSymbols);
	if (false === mb_strpos($strBannedSymbols, ','))
		$strBannedSymbols .= ',';
	if (false === mb_strpos($strBannedSymbols, ';'))
		$strBannedSymbols .= ';';

	$strOtherReplaceSymbol = '';
	$strReplaceSymbol = ($arFields['USER_TYPE_SETTINGS']['REP_SYM'] ?? ' ');
	if (BT_UT_AUTOCOMPLETE_REP_SYM_OTHER == $strReplaceSymbol)
	{
		$strOtherReplaceSymbol = (isset($arFields['USER_TYPE_SETTINGS']['OTHER_REP_SYM'])? mb_substr($arFields['USER_TYPE_SETTINGS']['OTHER_REP_SYM'], 0, 1) : '');
		if ((',' == $strOtherReplaceSymbol) || (';' == $strOtherReplaceSymbol))
			$strOtherReplaceSymbol = '';
		if (('' == $strOtherReplaceSymbol) || in_array($strOtherReplaceSymbol,static::GetReplaceSymList()))
		{
			$strReplaceSymbol = $strOtherReplaceSymbol;
			$strOtherReplaceSymbol = '';
		}
	}
	if ('' == $strReplaceSymbol)
	{
		$strReplaceSymbol = ' ';
		$strOtherReplaceSymbol = '';
	}

	$strIBlockMess = ($arFields['USER_TYPE_SETTINGS']['IBLOCK_MESS'] ?? '');
	if ('Y' != $strIBlockMess) $strIBlockMess = 'N';

	return [
		'VIEW' => $strView,
		'SHOW_ADD' => $strShowAdd,
		'MAX_WIDTH' => $intMaxWidth,
		'MIN_HEIGHT' => $intMinHeight,
		'MAX_HEIGHT' => $intMaxHeight,
		'BAN_SYM' => $strBannedSymbols,
		'REP_SYM' => $strReplaceSymbol,
		'OTHER_REP_SYM' => $strOtherReplaceSymbol,
		'IBLOCK_MESS' => $strIBlockMess,
	];
}