Util::parseLocation

  1. Bitrix24 API (v. 23.675.0)
  2. calendar
  3. Util
  4. parseLocation
  • Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/rooms/util.php
  • Класс: BitrixCalendarRoomsUtil
  • Вызов: Util::parseLocation
static function parseLocation($location): array
{
	$res = [
		'mrid' => false,
		'mrevid' => false,
		'room_id' => false,
		'room_event_id' => false,
		'str' => $location
	];

	if (!$location || is_array($location))
	{
		$res['str'] = '';

		return $res;
	}

	if (is_string($location))
	{
		$res['str'] = Emoji::decode($location);
	}

	if (
		mb_strlen($location) > 5
		&& mb_strpos($location, 'ECMR_') === 0
	)
	{
		$parsedLocation = explode('_', $location);
		if (count($parsedLocation) >= 2)
		{
			if ((int)$parsedLocation[1] > 0)
			{
				$res['mrid'] = (int)$parsedLocation[1];
			}
			if ((int)$parsedLocation[2] > 0)
			{
				$res['mrevid'] = (int)$parsedLocation[2];
			}
		}
	}
	else if (
		mb_strlen($location) > 9
		&& mb_strpos($location, 'calendar_') === 0
	)
	{
		$parsedLocation = explode('_', $location);
		if (count($parsedLocation) >= 2)
		{
			if ((int)$parsedLocation[1] > 0)
			{
				$res['room_id'] = (int)$parsedLocation[1];
			}
			if (isset($parsedLocation[2]) && (int)$parsedLocation[2] > 0)
			{
				$res['room_event_id'] = (int)$parsedLocation[2];
			}
		}
	}

	return $res;
}

Добавить комментарий