• Модуль: report
  • Путь к файлу: ~/bitrix/modules/report/classes/general/report.php
  • Класс: CReport
  • Вызов: CReport::attachLangToColumnTree
static function attachLangToColumnTree(&$tree, $initEntity, $helperClass, $preTitle = array())
{
	foreach($tree as &$treeElem)
	{
		$ownerId = call_user_func(array($helperClass, 'getOwnerId'));

		$humanTitle = '';

		if (!empty($treeElem['field']))
		{
			// detect UF
			$arUF = call_user_func(array($helperClass, 'detectUserField'), $treeElem['field']);
			if ($arUF['isUF'])
			{
				$treeElem['isUF'] = true;
				$treeElem['ufInfo'] = $arUF['ufInfo'];
				$humanTitle = $arUF['ufInfo']['LIST_COLUMN_LABEL'];
			}
			unset($arUF);

			// first: report-defined lang
			$rElementTitle = 'REPORT_'.$ownerId.'_'.$treeElem['fieldName'];

			// second: entity-defined lang
			$eElementTitle = $treeElem['field']->getLangCode();

			// PRCNT hack should not be here
			if (mb_substr($rElementTitle, -12) === '_PRCNT_FIELD')
			{
				$messageCode = mb_substr($rElementTitle, 0, -12).'_FIELD';
			}
			else
			{
				$messageCode = $rElementTitle;
			}

			if (static::isAlternateColumnPhraseExists($helperClass, $messageCode))
			{
				$elementTitle = $rElementTitle;
			}
			else
			{
				$elementMessage = GetMessage($messageCode);
				if (is_string($elementMessage) && $elementMessage !== '')
				{
					$elementTitle = $rElementTitle;
				}
				else
				{
					$elementTitle = $eElementTitle;
				}
			}

			unset($messageCode);
		}
		else
		{
			// virtual field - subtree head
			$elementName = $treeElem['fieldName'];
			$elementTitle = 'REPORT_'.$ownerId.'_COLUMN_TREE_'.$elementName;
		}

		if (!isset($treeElem['isUF']) || !$treeElem['isUF'])
		{
			// PRCNT hack should not be here
			if (mb_substr($elementTitle, -12) === '_PRCNT_FIELD')
			{
				$messageCode = mb_substr($elementTitle, 0, -12).'_FIELD';
			}
			else
			{
				$messageCode = $elementTitle;
			}

			if (static::isAlternateColumnPhraseExists($helperClass, $messageCode))
			{
				$humanTitle = static::getAlternateColumnPhrase($helperClass, $messageCode);
			}
			else
			{
				$humanTitle = GetMessage($messageCode);
			}

			unset($messageCode);
		}

		if (!is_string($humanTitle) || $humanTitle === '')
		{
			$humanTitle = $treeElem['fieldName'];
		}

		if (mb_substr($elementTitle, -12) == '_PRCNT_FIELD')
		{
			$humanTitle .= ' (%)';
		}

		if (empty($treeElem['branch']))
		{
			$fullHumanTitle = $humanTitle;

			if (!empty($preTitle))
			{
				$fullHumanTitle = join(': ', $preTitle) . ': ' . $fullHumanTitle;
			}

			$treeElem['humanTitle'] = $humanTitle;
			$treeElem['fullHumanTitle'] = $fullHumanTitle;
		}
		else
		{
			$treeElem['humanTitle'] = $humanTitle;
			$treeElem['fullHumanTitle'] = $humanTitle;

			$sendPreTitle = array($humanTitle);

			self::attachLangToColumnTree($treeElem['branch'], $initEntity, $helperClass, $sendPreTitle);
		}
	}
}