From bab2fb3899cc243e2f67ccf787f3657b250f6e61 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Fri, 2 Feb 2018 15:39:47 -0800 Subject: Remove dependency on PicoFeed --- .../lib/PicoFeed/Serialization/Subscription.php | 175 ------------------ .../PicoFeed/Serialization/SubscriptionList.php | 75 -------- .../Serialization/SubscriptionListBuilder.php | 204 --------------------- .../Serialization/SubscriptionListParser.php | 100 ---------- .../PicoFeed/Serialization/SubscriptionParser.php | 142 -------------- 5 files changed, 696 deletions(-) delete mode 100644 vendor/miniflux/picofeed/lib/PicoFeed/Serialization/Subscription.php delete mode 100644 vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionList.php delete mode 100644 vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionListBuilder.php delete mode 100644 vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionListParser.php delete mode 100644 vendor/miniflux/picofeed/lib/PicoFeed/Serialization/SubscriptionParser.php (limited to 'vendor/miniflux/picofeed/lib/PicoFeed/Serialization') 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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(); - } -} -- cgit v1.2.3