aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-10 12:49:51 +0000
committerMario <mario@mariovavti.com>2019-11-10 14:10:03 +0100
commit580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch)
tree82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
parentd22766f458a8539a40a57f3946459a9be1f21cd6 (diff)
downloadvolse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php')
-rw-r--r--vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php74
1 files changed, 37 insertions, 37 deletions
diff --git a/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php b/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
index 2d61db6ac..194927c53 100644
--- a/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
+++ b/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV;
use Sabre\DAV;
@@ -8,7 +10,7 @@ use Sabre\HTTP\ResponseInterface;
use Sabre\VObject;
/**
- * VCF Exporter
+ * VCF Exporter.
*
* This plugin adds the ability to export entire address books as .vcf files.
* This is useful for clients that don't support CardDAV yet. They often do
@@ -19,28 +21,27 @@ use Sabre\VObject;
* @author Thomas Tanghus (http://tanghus.net/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class VCFExportPlugin extends DAV\ServerPlugin {
-
+class VCFExportPlugin extends DAV\ServerPlugin
+{
/**
- * Reference to Server class
+ * Reference to Server class.
*
* @var DAV\Server
*/
protected $server;
/**
- * Initializes the plugin and registers event handlers
+ * Initializes the plugin and registers event handlers.
*
* @param DAV\Server $server
- * @return void
*/
- function initialize(DAV\Server $server) {
-
+ public function initialize(DAV\Server $server)
+ {
$this->server = $server;
$this->server->on('method:GET', [$this, 'httpGet'], 90);
- $server->on('browserButtonActions', function($path, $node, &$actions) {
+ $server->on('browserButtonActions', function ($path, $node, &$actions) {
if ($node instanceof IAddressBook) {
- $actions .= '<a href="' . htmlspecialchars($path, ENT_QUOTES, 'UTF-8') . '?export"><span class="oi" data-glyph="book"></span></a>';
+ $actions .= '<a href="'.htmlspecialchars($path, ENT_QUOTES, 'UTF-8').'?export"><span class="oi" data-glyph="book"></span></a>';
}
});
}
@@ -48,20 +49,25 @@ class VCFExportPlugin extends DAV\ServerPlugin {
/**
* Intercepts GET requests on addressbook urls ending with ?export.
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return bool
*/
- function httpGet(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpGet(RequestInterface $request, ResponseInterface $response)
+ {
$queryParams = $request->getQueryParameters();
- if (!array_key_exists('export', $queryParams)) return;
+ if (!array_key_exists('export', $queryParams)) {
+ return;
+ }
$path = $request->getPath();
$node = $this->server->tree->getNodeForPath($path);
- if (!($node instanceof IAddressBook)) return;
+ if (!($node instanceof IAddressBook)) {
+ return;
+ }
$this->server->transactionType = 'get-addressbook-export';
@@ -71,7 +77,7 @@ class VCFExportPlugin extends DAV\ServerPlugin {
}
$nodes = $this->server->getPropertiesForPath($path, [
- '{' . Plugin::NS_CARDDAV . '}address-data',
+ '{'.Plugin::NS_CARDDAV.'}address-data',
], 1);
$format = 'text/directory';
@@ -91,9 +97,9 @@ class VCFExportPlugin extends DAV\ServerPlugin {
'',
$node->getName()
);
- $filename .= '-' . date('Y-m-d') . $filenameExtension;
+ $filename .= '-'.date('Y-m-d').$filenameExtension;
- $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
+ $response->setHeader('Content-Disposition', 'attachment; filename="'.$filename.'"');
$response->setHeader('Content-Type', $format);
$response->setStatus(200);
@@ -101,25 +107,24 @@ class VCFExportPlugin extends DAV\ServerPlugin {
// Returning false to break the event chain
return false;
-
}
/**
- * Merges all vcard objects, and builds one big vcf export
+ * Merges all vcard objects, and builds one big vcf export.
*
* @param array $nodes
+ *
* @return string
*/
- function generateVCF(array $nodes) {
-
- $output = "";
+ public function generateVCF(array $nodes)
+ {
+ $output = '';
foreach ($nodes as $node) {
-
- if (!isset($node[200]['{' . Plugin::NS_CARDDAV . '}address-data'])) {
+ if (!isset($node[200]['{'.Plugin::NS_CARDDAV.'}address-data'])) {
continue;
}
- $nodeData = $node[200]['{' . Plugin::NS_CARDDAV . '}address-data'];
+ $nodeData = $node[200]['{'.Plugin::NS_CARDDAV.'}address-data'];
// Parsing this node so VObject can clean up the output.
$vcard = VObject\Reader::read($nodeData);
@@ -127,11 +132,9 @@ class VCFExportPlugin extends DAV\ServerPlugin {
// Destroy circular references to PHP will GC the object.
$vcard->destroy();
-
}
return $output;
-
}
/**
@@ -142,10 +145,9 @@ class VCFExportPlugin extends DAV\ServerPlugin {
*
* @return string
*/
- function getPluginName() {
-
+ public function getPluginName()
+ {
return 'vcf-export';
-
}
/**
@@ -159,14 +161,12 @@ class VCFExportPlugin extends DAV\ServerPlugin {
*
* @return array
*/
- function getPluginInfo() {
-
+ public function getPluginInfo()
+ {
return [
- 'name' => $this->getPluginName(),
+ 'name' => $this->getPluginName(),
'description' => 'Adds the ability to export CardDAV addressbooks as a single vCard file.',
- 'link' => 'http://sabre.io/dav/vcf-export-plugin/',
+ 'link' => 'http://sabre.io/dav/vcf-export-plugin/',
];
-
}
-
}