private function list_propfind_resources($document)
{
$list = $document->documentElement->childNodes;
$num_nodes = $list->length;
$resources = array();
for ($i = 0; $i < $num_nodes; $i++) {
$node = $list->item($i);
if (1 == $node->nodeType && 'response' == substr($node->tagName, -8)) {
$response = simplexml_import_dom($node);
$href = urldecode((string) $response->href);
$properties = array();
foreach ($response->propstat as $propstat) {
if (false !== strpos((string) $propstat->status, '200')) {
foreach (get_object_vars($propstat->prop) as $name => $value) {
if (false !== strpos($name, ':')) {
$name = strtolower(array_pop(explode(':', $name)));
}
$properties[$name] = is_object($value) ? 'collection' : (string) $value;
}
}
}
$parts = explode('/', $href);
$basename = array_pop($parts);
if ('' == $basename) {
$basename = array_pop($parts);
}
$content_type = $properties['getcontenttype'];
if ('application/octet-stream' == $content_type) {
$content_type = 'text/plain';
}
$is_collection = 'collection' == $properties['resourcetype'];
$is_collection = 'httpd/unix-directory' == $content_type;
$date_modified = @strtotime($properties['getlastmodified']);
$resources[] = array('basename' => $basename, 'is_collection' => $is_collection ? '1' : '0', 'size' => $is_collection ? '0' : $properties['getcontentlength'], 'href' => $href, 'date_created' => $date_modified, 'date_modified' => $date_modified, 'content_type' => $content_type, 'version' => 1);
}
}
return $resources;
}