2016-07-06 13:19:46 +03:00
|
|
|
<?php
|
2016-09-23 19:20:04 +03:00
|
|
|
/**
|
2017-11-06 17:56:42 +03:00
|
|
|
* @copyright Copyright (c) 2016 Thomas Citharel <tcit@tcit.fr>
|
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2020-03-31 11:49:10 +03:00
|
|
|
* @author Thomas Citharel <nextcloud@tcit.fr>
|
2016-09-23 19:20:04 +03:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2016-09-23 19:20:04 +03:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2017-11-06 17:56:42 +03:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2016-09-23 19:20:04 +03:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-09-23 19:20:04 +03:00
|
|
|
*
|
|
|
|
*/
|
2019-11-22 22:52:10 +03:00
|
|
|
|
2016-07-06 13:19:46 +03:00
|
|
|
namespace OCA\DAV\CalDAV\Publishing\Xml;
|
|
|
|
|
|
|
|
use Sabre\Xml\Writer;
|
|
|
|
use Sabre\Xml\XmlSerializable;
|
|
|
|
|
|
|
|
class Publisher implements XmlSerializable {
|
|
|
|
|
2016-07-31 21:18:35 +03:00
|
|
|
/**
|
|
|
|
* @var string $publishUrl
|
|
|
|
*/
|
|
|
|
protected $publishUrl;
|
2016-07-06 13:19:46 +03:00
|
|
|
|
2016-07-31 21:18:35 +03:00
|
|
|
/**
|
|
|
|
* @var boolean $isPublished
|
|
|
|
*/
|
|
|
|
protected $isPublished;
|
2016-07-06 13:39:07 +03:00
|
|
|
|
2016-07-31 21:18:35 +03:00
|
|
|
/**
|
|
|
|
* @param string $publishUrl
|
|
|
|
* @param boolean $isPublished
|
|
|
|
*/
|
2020-04-10 17:51:06 +03:00
|
|
|
public function __construct($publishUrl, $isPublished) {
|
2016-07-31 21:18:35 +03:00
|
|
|
$this->publishUrl = $publishUrl;
|
|
|
|
$this->isPublished = $isPublished;
|
|
|
|
}
|
2016-07-06 13:19:46 +03:00
|
|
|
|
2016-07-31 21:18:35 +03:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2020-04-10 17:51:06 +03:00
|
|
|
public function getValue() {
|
2016-07-31 21:18:35 +03:00
|
|
|
return $this->publishUrl;
|
|
|
|
}
|
2016-07-06 13:19:46 +03:00
|
|
|
|
2016-07-31 21:18:35 +03:00
|
|
|
/**
|
|
|
|
* The xmlSerialize metod is called during xml writing.
|
|
|
|
*
|
|
|
|
* Use the $writer argument to write its own xml serialization.
|
|
|
|
*
|
|
|
|
* An important note: do _not_ create a parent element. Any element
|
|
|
|
* implementing XmlSerializble should only ever write what's considered
|
|
|
|
* its 'inner xml'.
|
|
|
|
*
|
|
|
|
* The parent of the current element is responsible for writing a
|
|
|
|
* containing element.
|
|
|
|
*
|
|
|
|
* This allows serializers to be re-used for different element names.
|
|
|
|
*
|
|
|
|
* If you are opening new elements, you must also close them again.
|
|
|
|
*
|
|
|
|
* @param Writer $writer
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-04-10 17:51:06 +03:00
|
|
|
public function xmlSerialize(Writer $writer) {
|
2016-07-31 21:18:35 +03:00
|
|
|
if (!$this->isPublished) {
|
|
|
|
// for pre-publish-url
|
|
|
|
$writer->write($this->publishUrl);
|
|
|
|
} else {
|
|
|
|
// for publish-url
|
|
|
|
$writer->writeElement('{DAV:}href', $this->publishUrl);
|
|
|
|
}
|
|
|
|
}
|
2016-07-06 13:19:46 +03:00
|
|
|
}
|