40 $this->server->on(
'method:GET', [$this,
'httpGet'], 90);
41 $server->on(
'browserButtonActions',
function(
$path, $node, &$actions) {
43 $actions .=
'<a href="' . htmlspecialchars(
$path, ENT_QUOTES,
'UTF-8') .
'?export"><span class="oi" data-glyph="book"></span></a>';
58 if (!array_key_exists(
'export', $queryParams))
return;
62 $node = $this->server->tree->getNodeForPath(
$path);
66 $this->server->transactionType =
'get-addressbook-export';
69 if (
$aclPlugin = $this->server->getPlugin(
'acl')) {
73 $nodes = $this->server->getPropertiesForPath(
$path, [
80 $filenameExtension = null;
83 case 'text/directory':
85 $filenameExtension =
'.vcf';
90 '/[^a-zA-Z0-9-_ ]/um',
94 $filename .=
'-' . date(
'Y-m-d') . $filenameExtension;
96 $response->
setHeader(
'Content-Disposition',
'attachment; filename="' .
$filename .
'"');
117 foreach ($nodes as $node) {
122 $nodeData = $node[200][
'{' . Plugin::NS_CARDDAV .
'}address-data'];
126 $output .= $vcard->serialize();
166 'description' =>
'Adds the ability to export CardDAV addressbooks as a single vCard file.',
167 'link' =>
'http://sabre.io/dav/vcf-export-plugin/',
This interface represents a HTTP response.
The RequestInterface represents a HTTP request.
The baseclass for all server plugins.
setBody($body)
Updates the body resource with a new stream.
foreach($paths as $path) $request
const NS_CARDDAV
xml namespace for CardDAV elements
initialize(DAV\Server $server)
Initializes the plugin and registers event handlers.
getPluginName()
Returns a plugin name.
getQueryParameters()
Returns the list of query parameters.
setStatus($status)
Sets the HTTP status code.
getPath()
Returns the relative path.
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
generateVCF(array $nodes)
Merges all vcard objects, and builds one big vcf export.
httpGet(RequestInterface $request, ResponseInterface $response)
Intercepts GET requests on addressbook urls ending with ?export.
getPluginInfo()
Returns a bunch of meta-data about the plugin.
setHeader($name, $value)
Updates a HTTP header.