/usr/share/php/sabre21/Sabre/DAV/Property/ResponseList.php is in php-sabre-dav-2.1 2.1.10-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | <?php
namespace Sabre\DAV\Property;
use Sabre\DAV;
/**
* ResponseList property
*
* This class represents multiple {DAV:}response XML elements.
* This is used by the Server class to encode items within a multistatus
* response.
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
class ResponseList extends DAV\Property {
/**
* Response objects.
*
* @var array
*/
private $responses;
/**
* The only valid argument is a list of Sabre\DAV\Property\Response
* objects.
*
* @param array $responses;
*/
function __construct($responses) {
foreach($responses as $response) {
if (!($response instanceof Response)) {
throw new \InvalidArgumentException('You must pass an array of Sabre\DAV\Property\Response objects');
}
}
$this->responses = $responses;
}
/**
* Returns the list of Response properties.
*
* @return Response[]
*/
function getResponses() {
return $this->responses;
}
/**
* serialize
*
* @param DAV\Server $server
* @param \DOMElement $dom
* @return void
*/
function serialize(DAV\Server $server,\DOMElement $dom) {
foreach($this->responses as $response) {
$response->serialize($server, $dom);
}
}
/**
* Unserializes the property.
*
* This static method should return a an instance of this object.
*
* @param \DOMElement $prop
* @param array $propertyMap
* @return DAV\IProperty
*/
static function unserialize(\DOMElement $prop, array $propertyMap) {
$xpath = new \DOMXPath( $prop->ownerDocument );
$xpath->registerNamespace('d','urn:DAV');
// Finding the 'response' element
$xResponses = $xpath->evaluate(
'd:response',
$prop
);
$result = [];
for($jj=0; $jj < $xResponses->length; $jj++) {
$xResponse = $xResponses->item($jj);
// Parsing 'href'
$href = Href::unserialize($xResponse, $propertyMap);
$properties = [];
// Parsing 'status' in 'd:response'
$responseStatus = $xpath->evaluate('string(d:status)', $xResponse);
if ($responseStatus) {
list(, $responseStatus,) = explode(' ', $responseStatus, 3);
}
// Parsing 'propstat'
$xPropstat = $xpath->query('d:propstat', $xResponse);
for($ii=0; $ii < $xPropstat->length; $ii++) {
// Parsing 'status'
$status = $xpath->evaluate('string(d:status)', $xPropstat->item($ii));
list(,$statusCode,) = explode(' ', $status, 3);
$usedPropertyMap = $statusCode == '200' ? $propertyMap : [];
// Parsing 'prop'
$properties[$statusCode] = DAV\XMLUtil::parseProperties($xPropstat->item($ii), $usedPropertyMap);
}
$result[] = new Response($href->getHref(), $properties, $responseStatus?$responseStatus:null);
}
return new self($result);
}
}
|