• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/lib/integration/rest/configuration/entity/theme.php
  • Класс: BitrixIntranetIntegrationRestConfigurationEntityTheme
  • Вызов: Theme::export
static function export($params)
{
	$result = null;
	if (Helper::checkAccessManifest($params, static::$accessManifest))
	{
		$themePicker = ThemePicker::getInstance(ThemePicker::ENTITY_TYPE_USER);
		$theme = $themePicker->getDefaultTheme();
		if ($theme['id'])
		{
			[$textColor, $subThemeId] = explode(':', $theme['id']);
			$result = [
				'FILE_NAME' => static::ENTITY_INTRANET_THEME,
				'CONTENT' => [
					'TYPE' => static::ENTITY_INTRANET_THEME,
					'ID' => $theme['id'],
					'TEXT_COLOR' => $textColor,
				],
				'NEXT' => false
			];

			if (mb_strpos($subThemeId, $themePicker->getCustomThemePrefix()) === false)
			{
				$result['CONTENT']['CODE'] = $subThemeId;
			}
			else
			{
				$themeData = null;

				$res = ThemeTable::getList([
					'filter' => [
						'=ENTITY_TYPE' => $themePicker->getEntityType(),
						'ENTITY_ID' => 0,
						'=CONTEXT' => $themePicker->getContext(),
					],
					'select' => [ 'ID', 'USER_ID' ]
				]);
				while($themeFields = $res->fetch())
				{
					$themeList = CUserOptions::getOption(
						'intranet',
						$themePicker->getCustomThemesOptionName(),
						[],
						$themeFields['USER_ID']
					);

					if (!empty($themeList[$theme['id']]))
					{
						$themeData = $themeList[$theme['id']];
					}
				}

				if (is_array($themeData))
				{
					if ($themeData['bgImage'] > 0)
					{
						$result['CONTENT']['BACKGROUND_IMAGE'] = $themeData['bgImage'];
						$result['FILES'] = [
							[
								'ID' => $themeData['bgImage']
							]
						];
					}
					if (isset($themeData['bgColor']))
					{
						$result['CONTENT']['BACKGROUND_COLOR'] = $themeData['bgColor'];
					}
				}
			}
		}
	}

	return $result;
}