• Модуль: dav
  • Путь к файлу: ~/bitrix/modules/dav/classes/general/icalendar.php
  • Класс: CDavICalendarComponent
  • Вызов: CDavICalendarComponent::InitializeFromString
public function InitializeFromString($content)
{
	$content = $this->UnwrapComponent($content);

	$type = false;
	$subtype = false;
	$finish = null;
	$subfinish = null;

	$length = mb_strlen($content);
	$linefrom = 0;
	while ($linefrom < $length)
	{
		$lineto = mb_strpos($content, "n", $linefrom);
		if ($lineto === false)
			$lineto = mb_strpos($content, "r", $linefrom);

		if ($lineto > 0)
		{
			$line = mb_substr($content, $linefrom, $lineto - $linefrom);
			$linefrom = $lineto + 1;
		}
		else
		{
			$line = mb_substr($content, $linefrom);
			$linefrom = $length;
		}
		if (preg_match('/^s*$/', $line))
			continue;
		$line = rtrim($line, "rn");

		if ($type === false)
		{
			if (preg_match('/^BEGIN:(.+)$/', $line, $matches))
			{
				$type = $matches[1];
				$finish = "END:$type";
				$this->type = $type;
			}
		}
		elseif ($type == null)
		{
		}
		elseif ($line == $finish)
		{
			$type = null;
		}
		else
		{
			if ($subtype === false && preg_match('/^BEGIN:(.+)$/', $line, $matches))
			{
				$subtype = $matches[1];
				$subfinish = "END:$subtype";
				$subcomponent = $line."rn";
			}
			elseif ($subtype)
			{
				$subcomponent .= $this->WrapComponent($line);
				if ($line == $subfinish)
				{
					$this->arComponents[] = new CDavICalendarComponent($subcomponent);
					$subtype = false;
				}
			}
			else
			{
				$this->arProperties[] = new CDavICalendarProperty($line);
			}
		}
	}
}