• Модуль: mobile
  • Путь к файлу: ~/bitrix/modules/mobile/lib/livefeed/helper.php
  • Класс: BitrixMobileLivefeedHelper
  • Вызов: Helper::getMedalsData
static function getMedalsData(): array
{
	$result = [];

	$mobileSourceDir = Application::getInstance()->getPersonalRoot() . '/templates/mobile_app/images/lenta/medal';
	$sourceDirPath = Application::getDocumentRoot() . $mobileSourceDir;
	$folder = new IODirectory($sourceDirPath);

	if(!$folder->isExists())
	{
		return $result;
	}

	$backgroundColor = '#FFFFFF';
	$descriptionFilePath = Application::getDocumentRoot() . $mobileSourceDir . '/description.json';
	$descriptionFile = new IOFile($descriptionFilePath);
	if($descriptionFile->isExists())
	{
		$descriptionContent = IOFile::getFileContents($descriptionFilePath);
		if ($descriptionContent !== false)
		{
			try
			{
				$descriptionData = Json::decode($descriptionContent);
				if (isset($descriptionData['mobileBackgroundColor']))
				{
					$backgroundColor = $descriptionData['mobileBackgroundColor'];
				}
			}
			catch (Exception $e)
			{
			}
		}
	}

	$items = $folder->getChildren();
	foreach ($items as $item)
	{
		if (!$item->isDirectory())
		{
			continue;
		}

		$folderName = $item->getName();

		if (preg_match('/^(d+)_(.+)$/', $folderName, $matches))
		{
			$result[$matches[2]] =  [
				'sort' => $matches[1],
				'name' => Loc::getMessage('MOBILE_LIVEFEED_MEDAL_NAME_' . mb_strtoupper($matches[2])),
				'medalUrl' => $mobileSourceDir . '/' . $folderName . '/medal_mobile.svg',
				'medalSelectorUrl' => $mobileSourceDir . '/' . $folderName . '/medal_selector_mobile_mono.svg',
				'backgroundUrl' => $mobileSourceDir . '/' . $folderName.'/background_mobile_mono.svg',
				'backgroundColor' => $backgroundColor
			];
		}
	}

	return $result;
}