• Модуль: dav
  • Путь к файлу: ~/bitrix/modules/dav/classes/general/resource.php
  • Класс: CDavResource
  • Вызов: CDavResource::RenderProperty
static function RenderProperty($arProp, &$xmlnsHash, &$response, &$request)
{
	if (!is_array($arProp))
		return;
	if (!isset($arProp["tagname"]))
		return;

	if (!isset($arProp["content"]) || $arProp["content"] === "" || $arProp["content"] === false)
	{
		if ($arProp["xmlns"] == "DAV:")
			$response->AddLine("     ", $arProp["tagname"]);
		elseif (!empty($arProp["xmlns"]))
			$response->AddLine("     <%s:%s/>", $xmlnsHash[$arProp["xmlns"]], $arProp["tagname"]);
		else
			$response->AddLine("     <%s xmlns=""/>", $arProp["tagname"]);
	}
	elseif ($arProp["xmlns"] == "DAV:")
	{
		switch ($arProp["tagname"])
		{
			case "creationdate":
				$response->AddLine("     %s", gmdate("Y-m-d\TH:i:s\Z", $arProp["content"]));
				break;
			case "getlastmodified":
				$response->AddLine("     %sGMT", gmdate("D, d M Y H:i:s ", $arProp["content"]));
				break;
			case "supportedlock":
				$response->AddLine("     %s", $arProp["content"]);
				break;
			case "lockdiscovery":
				$response->AddLine("     ");
				$response->AddLine($arProp["content"]);
				$response->AddLine("     ");
				break;
			default:
				$xmlnsDefs = '';
				if (is_array($arProp["content"]))
				{
					$xmlnsHashTmp = $xmlnsHash;
					$val = self::EncodeHierarchicalProp($arProp["content"], 'DAV:', $xmlnsDefs, $xmlnsHashTmp, $response, $request);
				}
				elseif ($arProp['raw'])
				{
					$val = $response->Encode(sprintf('Encode(htmlspecialcharsbx($arProp["content"]));
				}
				$response->AddLine("     %s", $arProp["tagname"], $xmlnsDefs, $val, $arProp["tagname"]);
				break;
		}
	}
	else
	{
		if (is_array($arProp["content"]))
		{
			$vals = '';
			$extraXmlns = '';
			foreach ($arProp["content"] as $arSubProp)
			{
				if ($arSubProp['xmlns'] && $arSubProp['xmlns'] != 'DAV:')
				{
					if (!isset($xmlnsHash[$arSubProp['xmlns']]))
					{
						$ns = "ns".(count($xmlnsHash) + 1);
						$xmlnsHash[$arSubProp['xmlns']] = $ns;
					}
					else
					{
						$ns = $xmlnsHash[$arSubProp['xmlns']];
					}
					if (mb_strpos($extraXmlns, $extra = ' xmlns:'.$ns.'="'.$arSubProp['xmlns'].'"') === false)
						$extraXmlns .= $extra;
					$ns .= ':';
				}
				elseif ($arSubProp['xmlns'] == 'DAV:')
				{
					$ns = 'D:';
				}
				else
				{
					$ns = '';
				}
				$vals .= sprintf("<%s%s", $ns, $arSubProp["tagname"]);
				if (is_array($arSubProp['content']))
				{
					foreach ($arSubProp['content'] as $attr => $val)
						$vals .= ' '.$attr.'="'.$response->Encode(htmlspecialcharsbx($val)).'"';
					$vals .= '/>';
				}
				else
				{
					$vals .= '>';
					if ($arSubProp['raw'])
						$vals .= $response->Encode(sprintf('Encode(htmlspecialcharsbx($arSubProp['content']));
					$vals .= sprintf("", $ns, $arSubProp["tagname"]);
				}
			}
			$response->AddLine("     <%s:%s%s>%s", $xmlnsHash[$arProp['xmlns']], $arProp['tagname'], $extraXmlns, $vals, $xmlnsHash[$arProp['xmlns']], $arProp['tagname']);
		}
		else
		{
			if ($arProp['raw'])
				$val = sprintf('Encode($val);
			if ($arProp['xmlns'])
				$response->AddLine("     <%s:%s>%s", $xmlnsHash[$arProp['xmlns']], $arProp['tagname'], $val, $xmlnsHash[$arProp['xmlns']], $arProp['tagname']);
			else
				$response->AddLine("     <%s xmlns="">%s", $arProp['tagname'], $val, $arProp['tagname']);
		}
	}
}