add composer's vendor directory
This commit is contained in:
parent
01a3860d73
commit
60b094d5fa
745 changed files with 56017 additions and 1 deletions
65
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/AtomFeedBuilder.php
vendored
Normal file
65
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/AtomFeedBuilder.php
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace PicoFeed\Syndication;
|
||||
|
||||
use DOMAttr;
|
||||
use DOMElement;
|
||||
|
||||
/**
|
||||
* Atom Feed Builder
|
||||
*
|
||||
* @package PicoFeed\Syndication
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class AtomFeedBuilder extends FeedBuilder
|
||||
{
|
||||
/**
|
||||
* @var DOMElement
|
||||
*/
|
||||
protected $feedElement;
|
||||
|
||||
/**
|
||||
* @var AtomHelper
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* Build feed
|
||||
*
|
||||
* @access public
|
||||
* @param string $filename
|
||||
* @return string
|
||||
*/
|
||||
public function build($filename = '')
|
||||
{
|
||||
$this->helper = new AtomHelper($this->getDocument());
|
||||
|
||||
$this->feedElement = $this->getDocument()->createElement('feed');
|
||||
$this->feedElement->setAttributeNodeNS(new DomAttr('xmlns', 'http://www.w3.org/2005/Atom'));
|
||||
|
||||
$generator = $this->getDocument()->createElement('generator', 'PicoFeed');
|
||||
$generator->setAttribute('uri', 'https://github.com/fguillot/picoFeed');
|
||||
$this->feedElement->appendChild($generator);
|
||||
|
||||
$this->helper
|
||||
->buildTitle($this->feedElement, $this->feedTitle)
|
||||
->buildId($this->feedElement, $this->feedUrl)
|
||||
->buildDate($this->feedElement, $this->feedDate)
|
||||
->buildLink($this->feedElement, $this->siteUrl)
|
||||
->buildLink($this->feedElement, $this->feedUrl, 'self', 'application/atom+xml')
|
||||
->buildAuthor($this->feedElement, $this->authorName, $this->authorEmail, $this->authorUrl)
|
||||
;
|
||||
|
||||
foreach ($this->items as $item) {
|
||||
$this->feedElement->appendChild($item->build());
|
||||
}
|
||||
|
||||
$this->getDocument()->appendChild($this->feedElement);
|
||||
|
||||
if ($filename !== '') {
|
||||
$this->getDocument()->save($filename);
|
||||
}
|
||||
|
||||
return $this->getDocument()->saveXML();
|
||||
}
|
||||
}
|
139
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/AtomHelper.php
vendored
Normal file
139
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/AtomHelper.php
vendored
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
namespace PicoFeed\Syndication;
|
||||
|
||||
use DateTime;
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
|
||||
/**
|
||||
* Class AtomHelper
|
||||
*
|
||||
* @package PicoFeed\Syndication
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class AtomHelper
|
||||
{
|
||||
/**
|
||||
* @var DOMDocument
|
||||
*/
|
||||
protected $document;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DOMDocument $document
|
||||
*/
|
||||
public function __construct(DOMDocument $document)
|
||||
{
|
||||
$this->document = $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build node
|
||||
*
|
||||
* @access public
|
||||
* @param DOMElement $element
|
||||
* @param string $tag
|
||||
* @param string $value
|
||||
* @return AtomHelper
|
||||
*/
|
||||
public function buildNode(DOMElement $element, $tag, $value)
|
||||
{
|
||||
$node = $this->document->createElement($tag);
|
||||
$node->appendChild($this->document->createTextNode($value));
|
||||
$element->appendChild($node);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build title
|
||||
*
|
||||
* @access public
|
||||
* @param DOMElement $element
|
||||
* @param string $title
|
||||
* @return AtomHelper
|
||||
*/
|
||||
public function buildTitle(DOMElement $element, $title)
|
||||
{
|
||||
return $this->buildNode($element, 'title', $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build id
|
||||
*
|
||||
* @access public
|
||||
* @param DOMElement $element
|
||||
* @param string $id
|
||||
* @return AtomHelper
|
||||
*/
|
||||
public function buildId(DOMElement $element, $id)
|
||||
{
|
||||
return $this->buildNode($element, 'id', $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build date element
|
||||
*
|
||||
* @access public
|
||||
* @param DOMElement $element
|
||||
* @param DateTime $date
|
||||
* @param string $type
|
||||
* @return AtomHelper
|
||||
*/
|
||||
public function buildDate(DOMElement $element, DateTime $date, $type = 'updated')
|
||||
{
|
||||
return $this->buildNode($element, $type, $date->format(DateTime::ATOM));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build link element
|
||||
*
|
||||
* @access public
|
||||
* @param DOMElement $element
|
||||
* @param string $url
|
||||
* @param string $rel
|
||||
* @param string $type
|
||||
* @return AtomHelper
|
||||
*/
|
||||
public function buildLink(DOMElement $element, $url, $rel = 'alternate', $type = 'text/html')
|
||||
{
|
||||
$node = $this->document->createElement('link');
|
||||
$node->setAttribute('rel', $rel);
|
||||
$node->setAttribute('type', $type);
|
||||
$node->setAttribute('href', $url);
|
||||
$element->appendChild($node);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build author element
|
||||
*
|
||||
* @access public
|
||||
* @param DOMElement $element
|
||||
* @param string $authorName
|
||||
* @param string $authorEmail
|
||||
* @param string $authorUrl
|
||||
* @return AtomHelper
|
||||
*/
|
||||
public function buildAuthor(DOMElement $element, $authorName, $authorEmail, $authorUrl)
|
||||
{
|
||||
if (!empty($authorName)) {
|
||||
$author = $this->document->createElement('author');
|
||||
$this->buildNode($author, 'name', $authorName);
|
||||
|
||||
if (!empty($authorEmail)) {
|
||||
$this->buildNode($author, 'email', $authorEmail);
|
||||
}
|
||||
|
||||
if (!empty($authorUrl)) {
|
||||
$this->buildNode($author, 'uri', $authorUrl);
|
||||
}
|
||||
|
||||
$element->appendChild($author);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
63
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/AtomItemBuilder.php
vendored
Normal file
63
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/AtomItemBuilder.php
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace PicoFeed\Syndication;
|
||||
|
||||
use DOMElement;
|
||||
|
||||
/**
|
||||
* Atom Item Builder
|
||||
*
|
||||
* @package PicoFeed\Syndication
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class AtomItemBuilder extends ItemBuilder
|
||||
{
|
||||
/**
|
||||
* @var DOMElement
|
||||
*/
|
||||
protected $itemElement;
|
||||
|
||||
/**
|
||||
* @var AtomHelper
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* Build item
|
||||
*
|
||||
* @access public
|
||||
* @return DOMElement
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->itemElement = $this->feedBuilder->getDocument()->createElement('entry');
|
||||
$this->helper = new AtomHelper($this->feedBuilder->getDocument());
|
||||
|
||||
if (!empty($this->itemId)) {
|
||||
$this->helper->buildId($this->itemElement, $this->itemId);
|
||||
} else {
|
||||
$this->helper->buildId($this->itemElement, $this->itemUrl);
|
||||
}
|
||||
|
||||
$this->helper
|
||||
->buildTitle($this->itemElement, $this->itemTitle)
|
||||
->buildLink($this->itemElement, $this->itemUrl)
|
||||
->buildDate($this->itemElement, $this->itemUpdatedDate, 'updated')
|
||||
->buildDate($this->itemElement, $this->itemPublishedDate, 'published')
|
||||
->buildAuthor($this->itemElement, $this->authorName, $this->authorEmail, $this->authorUrl)
|
||||
;
|
||||
|
||||
if (!empty($this->itemSummary)) {
|
||||
$this->helper->buildNode($this->itemElement, 'summary', $this->itemSummary);
|
||||
}
|
||||
|
||||
if (!empty($this->itemContent)) {
|
||||
$node = $this->feedBuilder->getDocument()->createElement('content');
|
||||
$node->setAttribute('type', 'html');
|
||||
$node->appendChild($this->feedBuilder->getDocument()->createCDATASection($this->itemContent));
|
||||
$this->itemElement->appendChild($node);
|
||||
}
|
||||
|
||||
return $this->itemElement;
|
||||
}
|
||||
}
|
185
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/FeedBuilder.php
vendored
Normal file
185
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/FeedBuilder.php
vendored
Normal file
|
@ -0,0 +1,185 @@
|
|||
<?php
|
||||
|
||||
namespace PicoFeed\Syndication;
|
||||
|
||||
use DateTime;
|
||||
use DOMDocument;
|
||||
|
||||
/**
|
||||
* Class FeedBuilder
|
||||
*
|
||||
* @package PicoFeed\Syndication
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
abstract class FeedBuilder
|
||||
{
|
||||
/**
|
||||
* @var DOMDocument
|
||||
*/
|
||||
protected $document;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $feedTitle;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $feedUrl;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $siteUrl;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $authorName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $authorEmail;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $authorUrl;
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $feedDate;
|
||||
|
||||
/**
|
||||
* @var ItemBuilder[]
|
||||
*/
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->document = new DomDocument('1.0', 'UTF-8');
|
||||
$this->document->formatOutput = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get new object instance
|
||||
*
|
||||
* @access public
|
||||
* @return static
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
return new static();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add feed title
|
||||
*
|
||||
* @access public
|
||||
* @param string $title
|
||||
* @return $this
|
||||
*/
|
||||
public function withTitle($title)
|
||||
{
|
||||
$this->feedTitle = $title;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add feed url
|
||||
*
|
||||
* @access public
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function withFeedUrl($url)
|
||||
{
|
||||
$this->feedUrl = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add website url
|
||||
*
|
||||
* @access public
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function withSiteUrl($url)
|
||||
{
|
||||
$this->siteUrl = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add feed date
|
||||
*
|
||||
* @access public
|
||||
* @param DateTime $date
|
||||
* @return $this
|
||||
*/
|
||||
public function withDate(DateTime $date)
|
||||
{
|
||||
$this->feedDate = $date;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add feed author
|
||||
*
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @param string $email
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function withAuthor($name, $email = '', $url ='')
|
||||
{
|
||||
$this->authorName = $name;
|
||||
$this->authorEmail = $email;
|
||||
$this->authorUrl = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add feed item
|
||||
*
|
||||
* @access public
|
||||
* @param ItemBuilder $item
|
||||
* @return $this
|
||||
*/
|
||||
public function withItem(ItemBuilder $item)
|
||||
{
|
||||
$this->items[] = $item;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get DOM document
|
||||
*
|
||||
* @access public
|
||||
* @return DOMDocument
|
||||
*/
|
||||
public function getDocument()
|
||||
{
|
||||
return $this->document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build feed
|
||||
*
|
||||
* @abstract
|
||||
* @access public
|
||||
* @param string $filename
|
||||
* @return string
|
||||
*/
|
||||
abstract public function build($filename = '');
|
||||
}
|
209
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/ItemBuilder.php
vendored
Normal file
209
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/ItemBuilder.php
vendored
Normal file
|
@ -0,0 +1,209 @@
|
|||
<?php
|
||||
|
||||
namespace PicoFeed\Syndication;
|
||||
|
||||
use DateTime;
|
||||
use DOMElement;
|
||||
|
||||
/**
|
||||
* Class ItemBuilder
|
||||
*
|
||||
* @package PicoFeed\Syndication
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
abstract class ItemBuilder
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $itemTitle;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $itemId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $itemSummary;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $authorName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $authorEmail;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $authorUrl;
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $itemPublishedDate;
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $itemUpdatedDate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $itemContent;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $itemUrl;
|
||||
|
||||
/**
|
||||
* @var FeedBuilder
|
||||
*/
|
||||
protected $feedBuilder;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param FeedBuilder $feedBuilder
|
||||
*/
|
||||
public function __construct(FeedBuilder $feedBuilder)
|
||||
{
|
||||
$this->feedBuilder = $feedBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get new object instance
|
||||
*
|
||||
* @access public
|
||||
* @param FeedBuilder $feedBuilder
|
||||
* @return static
|
||||
*/
|
||||
public static function create(FeedBuilder $feedBuilder)
|
||||
{
|
||||
return new static($feedBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add item title
|
||||
*
|
||||
* @access public
|
||||
* @param string $title
|
||||
* @return $this
|
||||
*/
|
||||
public function withTitle($title)
|
||||
{
|
||||
$this->itemTitle = $title;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add item id
|
||||
*
|
||||
* @access public
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function withId($id)
|
||||
{
|
||||
$this->itemId = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add item url
|
||||
*
|
||||
* @access public
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function withUrl($url)
|
||||
{
|
||||
$this->itemUrl = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add item summary
|
||||
*
|
||||
* @access public
|
||||
* @param string $summary
|
||||
* @return $this
|
||||
*/
|
||||
public function withSummary($summary)
|
||||
{
|
||||
$this->itemSummary = $summary;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add item content
|
||||
*
|
||||
* @access public
|
||||
* @param string $content
|
||||
* @return $this
|
||||
*/
|
||||
public function withContent($content)
|
||||
{
|
||||
$this->itemContent = $content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add item updated date
|
||||
*
|
||||
* @access public
|
||||
* @param DateTime $date
|
||||
* @return $this
|
||||
*/
|
||||
public function withUpdatedDate(DateTime $date)
|
||||
{
|
||||
$this->itemUpdatedDate = $date;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add item published date
|
||||
*
|
||||
* @access public
|
||||
* @param DateTime $date
|
||||
* @return $this
|
||||
*/
|
||||
public function withPublishedDate(DateTime $date)
|
||||
{
|
||||
$this->itemPublishedDate = $date;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add item author
|
||||
*
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @param string $email
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function withAuthor($name, $email = '', $url ='')
|
||||
{
|
||||
$this->authorName = $name;
|
||||
$this->authorEmail = $email;
|
||||
$this->authorUrl = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build item
|
||||
*
|
||||
* @abstract
|
||||
* @access public
|
||||
* @return DOMElement
|
||||
*/
|
||||
abstract public function build();
|
||||
}
|
76
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/Rss20FeedBuilder.php
vendored
Normal file
76
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/Rss20FeedBuilder.php
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace PicoFeed\Syndication;
|
||||
|
||||
use DOMAttr;
|
||||
use DOMElement;
|
||||
|
||||
/**
|
||||
* Rss20 Feed Builder
|
||||
*
|
||||
* @package PicoFeed\Syndication
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class Rss20FeedBuilder extends FeedBuilder
|
||||
{
|
||||
/**
|
||||
* @var DOMElement
|
||||
*/
|
||||
protected $rssElement;
|
||||
|
||||
/**
|
||||
* @var Rss20Helper
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* @var DOMElement
|
||||
*/
|
||||
protected $channelElement;
|
||||
|
||||
/**
|
||||
* Build feed
|
||||
*
|
||||
* @access public
|
||||
* @param string $filename
|
||||
* @return string
|
||||
*/
|
||||
public function build($filename = '')
|
||||
{
|
||||
$this->helper = new Rss20Helper($this->getDocument());
|
||||
|
||||
$this->rssElement = $this->getDocument()->createElement('rss');
|
||||
$this->rssElement->setAttribute('version', '2.0');
|
||||
$this->rssElement->setAttributeNodeNS(new DomAttr('xmlns:content', 'http://purl.org/rss/1.0/modules/content/'));
|
||||
$this->rssElement->setAttributeNodeNS(new DomAttr('xmlns:atom', 'http://www.w3.org/2005/Atom'));
|
||||
|
||||
$this->channelElement = $this->getDocument()->createElement('channel');
|
||||
$this->helper
|
||||
->buildNode($this->channelElement, 'generator', 'PicoFeed (https://github.com/fguillot/picoFeed)')
|
||||
->buildTitle($this->channelElement, $this->feedTitle)
|
||||
->buildNode($this->channelElement, 'description', $this->feedTitle)
|
||||
->buildDate($this->channelElement, $this->feedDate)
|
||||
->buildAuthor($this->channelElement, 'webMaster', $this->authorName, $this->authorEmail)
|
||||
->buildLink($this->channelElement, $this->siteUrl)
|
||||
;
|
||||
|
||||
$link = $this->getDocument()->createElement('atom:link');
|
||||
$link->setAttribute('href', $this->feedUrl);
|
||||
$link->setAttribute('rel', 'self');
|
||||
$link->setAttribute('type', 'application/rss+xml');
|
||||
$this->channelElement->appendChild($link);
|
||||
|
||||
foreach ($this->items as $item) {
|
||||
$this->channelElement->appendChild($item->build());
|
||||
}
|
||||
|
||||
$this->rssElement->appendChild($this->channelElement);
|
||||
$this->getDocument()->appendChild($this->rssElement);
|
||||
|
||||
if ($filename !== '') {
|
||||
$this->getDocument()->save($filename);
|
||||
}
|
||||
|
||||
return $this->getDocument()->saveXML();
|
||||
}
|
||||
}
|
115
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/Rss20Helper.php
vendored
Normal file
115
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/Rss20Helper.php
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
|
||||
namespace PicoFeed\Syndication;
|
||||
|
||||
use DateTime;
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
|
||||
/**
|
||||
* Class Rss20Helper
|
||||
*
|
||||
* @package PicoFeed\Syndication
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class Rss20Helper
|
||||
{
|
||||
/**
|
||||
* @var DOMDocument
|
||||
*/
|
||||
protected $document;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DOMDocument $document
|
||||
*/
|
||||
public function __construct(DOMDocument $document)
|
||||
{
|
||||
$this->document = $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build node
|
||||
*
|
||||
* @access public
|
||||
* @param DOMElement $element
|
||||
* @param string $tag
|
||||
* @param string $value
|
||||
* @return AtomHelper
|
||||
*/
|
||||
public function buildNode(DOMElement $element, $tag, $value)
|
||||
{
|
||||
$node = $this->document->createElement($tag);
|
||||
$node->appendChild($this->document->createTextNode($value));
|
||||
$element->appendChild($node);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build title
|
||||
*
|
||||
* @access public
|
||||
* @param DOMElement $element
|
||||
* @param string $title
|
||||
* @return AtomHelper
|
||||
*/
|
||||
public function buildTitle(DOMElement $element, $title)
|
||||
{
|
||||
return $this->buildNode($element, 'title', $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build date element
|
||||
*
|
||||
* @access public
|
||||
* @param DOMElement $element
|
||||
* @param DateTime $date
|
||||
* @param string $type
|
||||
* @return AtomHelper
|
||||
*/
|
||||
public function buildDate(DOMElement $element, DateTime $date, $type = 'pubDate')
|
||||
{
|
||||
return $this->buildNode($element, $type, $date->format(DateTime::RSS));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build link element
|
||||
*
|
||||
* @access public
|
||||
* @param DOMElement $element
|
||||
* @param string $url
|
||||
* @return AtomHelper
|
||||
*/
|
||||
public function buildLink(DOMElement $element, $url)
|
||||
{
|
||||
return $this->buildNode($element, 'link', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build author element
|
||||
*
|
||||
* @access public
|
||||
* @param DOMElement $element
|
||||
* @param string $tag
|
||||
* @param string $authorName
|
||||
* @param string $authorEmail
|
||||
* @return AtomHelper
|
||||
*/
|
||||
public function buildAuthor(DOMElement $element, $tag, $authorName, $authorEmail)
|
||||
{
|
||||
if (!empty($authorName)) {
|
||||
$value = '';
|
||||
|
||||
if (!empty($authorEmail)) {
|
||||
$value .= $authorEmail.' ('.$authorName.')';
|
||||
} else {
|
||||
$value = $authorName;
|
||||
}
|
||||
|
||||
$this->buildNode($element, $tag, $value);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
67
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/Rss20ItemBuilder.php
vendored
Normal file
67
vendor/fguillot/picofeed/lib/PicoFeed/Syndication/Rss20ItemBuilder.php
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace PicoFeed\Syndication;
|
||||
|
||||
use DOMElement;
|
||||
|
||||
/**
|
||||
* Rss20 Item Builder
|
||||
*
|
||||
* @package PicoFeed\Syndication
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class Rss20ItemBuilder extends ItemBuilder
|
||||
{
|
||||
/**
|
||||
* @var DOMElement
|
||||
*/
|
||||
protected $itemElement;
|
||||
|
||||
/**
|
||||
* @var Rss20Helper
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* Build item
|
||||
*
|
||||
* @access public
|
||||
* @return DOMElement
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->itemElement = $this->feedBuilder->getDocument()->createElement('item');
|
||||
$this->helper = new Rss20Helper($this->feedBuilder->getDocument());
|
||||
|
||||
if (!empty($this->itemId)) {
|
||||
$guid = $this->feedBuilder->getDocument()->createElement('guid');
|
||||
$guid->setAttribute('isPermaLink', 'false');
|
||||
$guid->appendChild($this->feedBuilder->getDocument()->createTextNode($this->itemId));
|
||||
$this->itemElement->appendChild($guid);
|
||||
} else {
|
||||
$guid = $this->feedBuilder->getDocument()->createElement('guid');
|
||||
$guid->setAttribute('isPermaLink', 'true');
|
||||
$guid->appendChild($this->feedBuilder->getDocument()->createTextNode($this->itemUrl));
|
||||
$this->itemElement->appendChild($guid);
|
||||
}
|
||||
|
||||
$this->helper
|
||||
->buildTitle($this->itemElement, $this->itemTitle)
|
||||
->buildLink($this->itemElement, $this->itemUrl)
|
||||
->buildDate($this->itemElement, $this->itemPublishedDate)
|
||||
->buildAuthor($this->itemElement, 'author', $this->authorName, $this->authorEmail)
|
||||
;
|
||||
|
||||
if (!empty($this->itemSummary)) {
|
||||
$this->helper->buildNode($this->itemElement, 'description', $this->itemSummary);
|
||||
}
|
||||
|
||||
if (!empty($this->itemContent)) {
|
||||
$node = $this->feedBuilder->getDocument()->createElement('content:encoded');
|
||||
$node->appendChild($this->feedBuilder->getDocument()->createCDATASection($this->itemContent));
|
||||
$this->itemElement->appendChild($node);
|
||||
}
|
||||
|
||||
return $this->itemElement;
|
||||
}
|
||||
}
|
Reference in a new issue