summaryrefslogtreecommitdiff
path: root/vendor/miniflux/picofeed/lib/PicoFeed/Serialization
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2018-02-02 15:39:47 -0800
committerFrédéric Guillot <fred@kanboard.net>2018-02-02 15:39:47 -0800
commitbab2fb3899cc243e2f67ccf787f3657b250f6e61 (patch)
tree07ddb755330b320fbd2e2803fdb978cfff3bd452 /vendor/miniflux/picofeed/lib/PicoFeed/Serialization
parent5c4d06d26b808ea50d08f83ae02ac82373fd2208 (diff)
Remove dependency on PicoFeed
Diffstat (limited to 'vendor/miniflux/picofeed/lib/PicoFeed/Serialization')
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Serialization/Subscription.php175
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionList.php75
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionListBuilder.php204
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionListParser.php100
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionParser.php142
5 files changed, 0 insertions, 696 deletions
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/Subscription.php b/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/Subscription.php
deleted file mode 100644
index 12eccfd5..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/Subscription.php
+++ /dev/null
@@ -1,175 +0,0 @@
-<?php
-
-namespace PicoFeed\Serialization;
-
-/**
- * Class Subscription
- *
- * @package PicoFeed\Serialization
- * @author Frederic Guillot
- */
-class Subscription
-{
- protected $title = '';
- protected $feedUrl = '';
- protected $siteUrl = '';
- protected $category = '';
- protected $description = '';
- protected $type = '';
-
- /**
- * Create object instance
- *
- * @static
- * @access public
- * @return Subscription
- */
- public static function create()
- {
- return new static();
- }
-
- /**
- * Set title
- *
- * @access public
- * @param string $title
- * @return Subscription
- */
- public function setTitle($title)
- {
- $this->title = $title;
- return $this;
- }
-
- /**
- * Get title
- *
- * @access public
- * @return string
- */
- public function getTitle()
- {
- return $this->title;
- }
-
- /**
- * Set feed URL
- *
- * @access public
- * @param string $feedUrl
- * @return Subscription
- */
- public function setFeedUrl($feedUrl)
- {
- $this->feedUrl = $feedUrl;
- return $this;
- }
-
- /**
- * Get feed URL
- *
- * @access public
- * @return string
- */
- public function getFeedUrl()
- {
- return $this->feedUrl;
- }
-
- /**
- * Set site URL
- *
- * @access public
- * @param string $siteUrl
- * @return Subscription
- */
- public function setSiteUrl($siteUrl)
- {
- $this->siteUrl = $siteUrl;
- return $this;
- }
-
- /**
- * Get site URL
- *
- * @access public
- * @return string
- */
- public function getSiteUrl()
- {
- return $this->siteUrl;
- }
-
- /**
- * Set category
- *
- * @access public
- * @param string $category
- * @return Subscription
- */
- public function setCategory($category)
- {
- $this->category = $category;
- return $this;
- }
-
- /**
- * Get category
- *
- * @access public
- * @return string
- */
- public function getCategory()
- {
- return $this->category;
- }
-
- /**
- * Set description
- *
- * @access public
- * @param string $description
- * @return Subscription
- */
- public function setDescription($description)
- {
- $this->description = $description;
- return $this;
- }
-
- /**
- * Get description
- *
- * @access public
- * @return string
- */
- public function getDescription()
- {
- return $this->description;
- }
-
- /**
- * Set type
- *
- * @access public
- * @param string $type
- * @return Subscription
- */
- public function setType($type)
- {
- $this->type = $type;
- return $this;
- }
-
- /**
- * Get type
- *
- * @access public
- * @return string
- */
- public function getType()
- {
- return $this->type;
- }
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionList.php b/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionList.php
deleted file mode 100644
index b173f89b..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionList.php
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-
-namespace PicoFeed\Serialization;
-
-/**
- * Class SubscriptionList
- *
- * @package PicoFeed\Serialization
- * @author Frederic Guillot
- */
-class SubscriptionList
-{
- /**
- * OPML entries
- *
- * @var Subscription[]
- */
- public $subscriptions = array();
-
- /**
- * Title
- *
- * @var string
- */
- protected $title = '';
-
- /**
- * Create object instance
- *
- * @static
- * @access public
- * @return SubscriptionList
- */
- public static function create()
- {
- return new static();
- }
-
- /**
- * Set title
- *
- * @access public
- * @param string $title
- * @return SubscriptionList
- */
- public function setTitle($title)
- {
- $this->title = $title;
- return $this;
- }
-
- /**
- * Get title
- *
- * @access public
- * @return string
- */
- public function getTitle()
- {
- return $this->title;
- }
-
- /**
- * Add subscription
- *
- * @access public
- * @param Subscription $subscription
- * @return SubscriptionList
- */
- public function addSubscription(Subscription $subscription)
- {
- $this->subscriptions[] = $subscription;
- return $this;
- }
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionListBuilder.php b/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionListBuilder.php
deleted file mode 100644
index 838e4cb5..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionListBuilder.php
+++ /dev/null
@@ -1,204 +0,0 @@
-<?php
-
-namespace PicoFeed\Serialization;
-
-use DOMDocument;
-use DOMElement;
-
-/**
- * Class SubscriptionListBuilder
- *
- * @package PicoFeed\Serialization
- * @author Frederic Guillot
- */
-class SubscriptionListBuilder
-{
- /**
- * @var SubscriptionList
- */
- protected $subscriptionList;
-
- /**
- * @var DOMDocument
- */
- protected $document;
-
- /**
- * Constructor.
- *
- * @access public
- * @param SubscriptionList $subscriptionList
- */
- public function __construct(SubscriptionList $subscriptionList)
- {
- $this->subscriptionList = $subscriptionList;
- }
-
- /**
- * Get object instance
- *
- * @static
- * @access public
- * @param SubscriptionList $subscriptionList
- * @return SubscriptionListBuilder
- */
- public static function create(SubscriptionList $subscriptionList)
- {
- return new static($subscriptionList);
- }
-
- /**
- * Build OPML feed
- *
- * @access public
- * @param string $filename
- * @return string
- */
- public function build($filename = '')
- {
- $this->document = new DomDocument('1.0', 'UTF-8');
- $this->document->formatOutput = true;
-
- $opmlElement = $this->document->createElement('opml');
- $opmlElement->setAttribute('version', '1.0');
-
- $headElement = $this->document->createElement('head');
-
- if ($this->subscriptionList->getTitle() !== '') {
- $titleElement = $this->document->createElement('title');
- $titleElement->appendChild($this->document->createTextNode($this->subscriptionList->getTitle()));
- $headElement->appendChild($titleElement);
- }
-
- $opmlElement->appendChild($headElement);
- $opmlElement->appendChild($this->buildBody());
- $this->document->appendChild($opmlElement);
-
- if ($filename !== '') {
- $this->document->save($filename);
- return '';
- }
-
- return $this->document->saveXML();
- }
-
- /**
- * Return true if the list has categories
- *
- * @access public
- * @return bool
- */
- public function hasCategories()
- {
- foreach ($this->subscriptionList->subscriptions as $subscription) {
- if ($subscription->getCategory() !== '') {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Build OPML body
- *
- * @access protected
- * @return DOMElement
- */
- protected function buildBody()
- {
- $bodyElement = $this->document->createElement('body');
-
- if ($this->hasCategories()) {
- $this->buildCategories($bodyElement);
- return $bodyElement;
- }
-
- foreach ($this->subscriptionList->subscriptions as $subscription) {
- $bodyElement->appendChild($this->buildSubscription($subscription));
- }
-
- return $bodyElement;
- }
-
- /**
- * Build categories section
- *
- * @access protected
- * @param DOMElement $bodyElement
- */
- protected function buildCategories(DOMElement $bodyElement)
- {
- $categories = $this->groupByCategories();
-
- foreach ($categories as $category => $subscriptions) {
- $bodyElement->appendChild($this->buildCategory($category, $subscriptions));
- }
- }
-
- /**
- * Build category tag
- *
- * @access protected
- * @param string $category
- * @param array $subscriptions
- * @return DOMElement
- */
- protected function buildCategory($category, array $subscriptions)
- {
- $outlineElement = $this->document->createElement('outline');
- $outlineElement->setAttribute('text', $category);
-
- foreach ($subscriptions as $subscription) {
- $outlineElement->appendChild($this->buildSubscription($subscription));
- }
-
- return $outlineElement;
- }
-
- /**
- * Build subscription entry
- *
- * @access public
- * @param Subscription $subscription
- * @return DOMElement
- */
- protected function buildSubscription(Subscription $subscription)
- {
- $outlineElement = $this->document->createElement('outline');
- $outlineElement->setAttribute('type', $subscription->getType() ?: 'rss');
- $outlineElement->setAttribute('text', $subscription->getTitle() ?: $subscription->getFeedUrl());
- $outlineElement->setAttribute('xmlUrl', $subscription->getFeedUrl());
-
- if ($subscription->getTitle() !== '') {
- $outlineElement->setAttribute('title', $subscription->getTitle());
- }
-
- if ($subscription->getDescription() !== '') {
- $outlineElement->setAttribute('description', $subscription->getDescription());
- }
-
- if ($subscription->getSiteUrl() !== '') {
- $outlineElement->setAttribute('htmlUrl', $subscription->getSiteUrl());
- }
-
- return $outlineElement;
- }
-
- /**
- * Group subscriptions by category
- *
- * @access private
- * @return array
- */
- private function groupByCategories()
- {
- $categories = array();
-
- foreach ($this->subscriptionList->subscriptions as $subscription) {
- $categories[$subscription->getCategory()][] = $subscription;
- }
-
- return $categories;
- }
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionListParser.php b/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionListParser.php
deleted file mode 100644
index 9085588c..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionListParser.php
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-
-namespace PicoFeed\Serialization;
-
-use PicoFeed\Parser\MalformedXmlException;
-use PicoFeed\Parser\XmlParser;
-use SimpleXMLElement;
-
-/**
- * Class SubscriptionListParser
- *
- * @package PicoFeed\Serialization
- * @author Frederic Guillot
- */
-class SubscriptionListParser
-{
- /**
- * @var SubscriptionList
- */
- protected $subscriptionList;
-
- /**
- * @var string
- */
- protected $data;
-
- /**
- * Constructor
- *
- * @access public
- * @param string $data
- */
- public function __construct($data)
- {
- $this->subscriptionList = new SubscriptionList();
- $this->data = trim($data);
- }
-
- /**
- * Get object instance
- *
- * @static
- * @access public
- * @param string $data
- * @return SubscriptionListParser
- */
- public static function create($data)
- {
- return new static($data);
- }
-
- /**
- * Parse a subscription list entry
- *
- * @access public
- * @throws MalformedXmlException
- * @return SubscriptionList
- */
- public function parse()
- {
- $xml = XmlParser::getSimpleXml($this->data);
-
- if (! $xml || !isset($xml->head) || !isset($xml->body)) {
- throw new MalformedXmlException('Unable to parse OPML file: invalid XML');
- }
-
- $this->parseTitle($xml->head);
- $this->parseEntries($xml->body);
-
- return $this->subscriptionList;
- }
-
- /**
- * Parse title
- *
- * @access protected
- * @param SimpleXMLElement $xml
- */
- protected function parseTitle(SimpleXMLElement $xml)
- {
- $this->subscriptionList->setTitle((string) $xml->title);
- }
-
- /**
- * Parse entries
- *
- * @access protected
- * @param SimpleXMLElement $body
- */
- private function parseEntries(SimpleXMLElement $body)
- {
- foreach ($body->outline as $outlineElement) {
- if (isset($outlineElement->outline)) {
- $this->parseEntries($outlineElement);
- } else {
- $this->subscriptionList->subscriptions[] = SubscriptionParser::create($body, $outlineElement)->parse();
- }
- }
- }
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionParser.php b/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionParser.php
deleted file mode 100644
index caff07c2..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionParser.php
+++ /dev/null
@@ -1,142 +0,0 @@
-<?php
-
-namespace PicoFeed\Serialization;
-
-use SimpleXMLElement;
-
-/**
- * Class SubscriptionParser
- *
- * @package PicoFeed\Serialization
- * @author Frederic Guillot
- */
-class SubscriptionParser
-{
- /**
- * @var Subscription
- */
- protected $subscription;
-
- /**
- * @var SimpleXMLElement
- */
- private $outlineElement;
-
- /**
- * @var SimpleXMLElement
- */
- private $parentElement;
-
- /**
- * Constructor
- *
- * @access public
- * @param SimpleXMLElement $parentElement
- * @param SimpleXMLElement $outlineElement
- */
- public function __construct(SimpleXMLElement $parentElement, SimpleXMLElement $outlineElement)
- {
- $this->parentElement = $parentElement;
- $this->outlineElement = $outlineElement;
- $this->subscription = new Subscription();
- }
-
- /**
- * Get object instance
- *
- * @static
- * @access public
- * @param SimpleXMLElement $parentElement
- * @param SimpleXMLElement $outlineElement
- * @return SubscriptionParser
- */
- public static function create(SimpleXMLElement $parentElement, SimpleXMLElement $outlineElement)
- {
- return new static($parentElement, $outlineElement);
- }
-
- /**
- * Parse subscription entry
- *
- * @access public
- * @return Subscription
- */
- public function parse()
- {
- $this->subscription->setCategory($this->findCategory());
- $this->subscription->setTitle($this->findTitle());
- $this->subscription->setFeedUrl($this->findFeedUrl());
- $this->subscription->setSiteUrl($this->findSiteUrl());
- $this->subscription->setType($this->findType());
- $this->subscription->setDescription($this->findDescription());
-
- return $this->subscription;
- }
-
- /**
- * Find category.
- *
- * @access protected
- * @return string
- */
- protected function findCategory()
- {
- return isset($this->parentElement['text']) ? (string) $this->parentElement['text'] : '';
- }
-
- /**
- * Find title.
- *
- * @access protected
- * @return string
- */
- protected function findTitle()
- {
- return isset($this->outlineElement['title']) ? (string) $this->outlineElement['title'] : (string) $this->outlineElement['text'];
- }
-
- /**
- * Find feed url.
- *
- * @access protected
- * @return string
- */
- protected function findFeedUrl()
- {
- return (string) $this->outlineElement['xmlUrl'];
- }
-
- /**
- * Find site url.
- *
- * @access protected
- * @return string
- */
- protected function findSiteUrl()
- {
- return isset($this->outlineElement['htmlUrl']) ? (string) $this->outlineElement['htmlUrl'] : $this->findFeedUrl();
- }
-
- /**
- * Find type.
- *
- * @access protected
- * @return string
- */
- protected function findType()
- {
- return isset($this->outlineElement['version']) ? (string) $this->outlineElement['version'] :
- isset($this->outlineElement['type']) ? (string) $this->outlineElement['type'] : 'rss';
- }
-
- /**
- * Find description.
- *
- * @access protected
- * @return string
- */
- protected function findDescription()
- {
- return isset($this->outlineElement['description']) ? (string) $this->outlineElement['description'] : $this->findTitle();
- }
-}