• Модуль: dav
  • Путь к файлу: ~/bitrix/modules/dav/classes/general/resource.php
  • Класс: CDavResource
  • Вызов: CDavResource::EncodeHierarchicalProp
static function EncodeHierarchicalProp(array $arProps, $parentXmlns, &$xmlnsDefs, array &$xmlnsHash, &$response, &$request)
{
	$result = '';

	if (isset($arProps['tagname']))
		$arProps = array($arProps);

	$isRNDRequired = $request->IsRedundantNamespaceDeclarationsRequired();
	foreach ($arProps as $arProp)
	{
		if (!isset($xmlnsHash[$arProp['xmlns']]))
		{
			$n = 'ns'.(count($xmlnsHash) + 1);
			$xmlnsHash[$arProp['xmlns']] = $n;
			$xmlnsDefs .= ' xmlns:'.$n.'="'.$arProp['xmlns'].'"';
		}

		$ns = ($arProp['xmlns'] == $parentXmlns ? ($isRNDRequired ? $xmlnsHash[$parentXmlns].':' : '') : $xmlnsHash[$arProp['xmlns']].':');

		if (is_array($arProp['content']))
		{
			$arSubProp = $arProp['content'];
			if (isset($arSubProp['xmlns']) || isset($arSubProp[0]['xmlns']))
			{
				$result .= sprintf('<%s%s', $ns, $arProp['tagname']);
				if (empty($arProp['content']))
				{
					$result .= '/>';
				}
				else
				{
					$result .= '>';
					$result .= self::EncodeHierarchicalProp($arProp['content'], $arProp['xmlns'], $xmlnsDefs, $xmlnsHash, $response, $request);
					$result .= sprintf('', $ns, $arProp['tagname']);
				}
			}
			else
			{
				$vals = '';
				foreach ($arSubProp as $attr => $val)
					$vals .= ' '.$attr.'="'.htmlspecialcharsbx($val).'"';

				$result .= sprintf('<%s%s%s/>', $ns, $arProp['tagname'], $vals);
			}
		}
		else
		{
			if (empty($arProp['content']))
			{
				$val = '';
			}
			else
			{
				if ($arProp['raw'])
					$val = $response->Encode(sprintf('Encode(htmlspecialcharsbx($arProp['content']));
			}

			$result .= sprintf('<%s%s', $ns, $arProp['tagname']);
			if (empty($arProp['content']))
				$result .= '/>';
			else
				$result .= '>'.$val.sprintf('', $ns, $arProp['tagname']);
		}
	}

	return $result;
}