• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/userconsent/intl.php
  • Класс: BitrixMainUserConsentIntl
  • Вызов: Intl::getLanguages
static function getLanguages()
{
	static $list = null;
	if (is_array($list))
	{
		return $list;
	}

	$list = array();

	// set virtual languages
	foreach (self::$virtualLanguageMap as $virtualLanguageId => $languageId)
	{
		$languageName = Loc::getMessage('MAIN_USER_CONSENT_INTL_LANG_NAME_'.mb_strtoupper($virtualLanguageId));
		if (!$languageName)
		{
			$languageName = $virtualLanguageId;
		}
		$list[$virtualLanguageId] = $languageName;
	}

	// read lang dirs
	$dirLanguages = array();
	$langDir = Application::getDocumentRoot() . '/bitrix/modules/main/lang/';
	$dir = new IODirectory($langDir);
	if (!$dir->isExists())
	{
		return $list;
	}

	foreach($dir->getChildren() as $childDir)
	{
		if (!$childDir->isDirectory())
		{
			continue;
		}

		$dirLanguages[] = $childDir->getName();
	}

	if (empty($dirLanguages))
	{
		return $list;
	}

	// set languages from DB by dir languages
	$listDb = LanguageTable::getList(array(
		'select' => array('LID', 'NAME'),
		'filter' => array(
			'=LID' => $dirLanguages,
			'=ACTIVE' => 'Y'
		),
		'order' => array('SORT' => 'ASC')
	));
	while ($item = $listDb->fetch())
	{
		$list[$item['LID']] = $item['NAME'];
	}

	return $list;
}