Source of file CwpAtomFeed.php
Size: 1,736 Bytes - Last Modified: 2021-12-24T06:43:15+00:00
/var/www/docs.ssmods.com/process/src/src/Feed/CwpAtomFeed.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 | <?php namespace CWP\Core\Feed; /** * CwpAtomFeed class * * This class is used to create an Atom feed. * @todo Improve documentation * @package cwp-core */ use SilverStripe\Control\Controller; use SilverStripe\Control\RSS\RSSFeed; use SilverStripe\Core\Convert; use SilverStripe\ORM\FieldType\DBHTMLText; use SilverStripe\ORM\SS_List; use SilverStripe\View\Requirements; class CwpAtomFeed extends RSSFeed { public function __construct( SS_List $entries, $link, $title, $description = null, $titleField = "Title", $descriptionField = "Content", $authorField = null, $lastModified = null, $etag = null ) { parent::__construct( $entries, $link, $title, $description, $titleField, $descriptionField, $authorField, $lastModified ); $this->setTemplate(__CLASS__); } /** * Include an link to the feed * * @param string $url URL of the feed * @param string $title Title to show */ public static function linkToFeed($url, $title = null) { $title = Convert::raw2xml($title); Requirements::insertHeadTags( '<link rel="alternate" type="application/atom+xml" title="' . $title . '" href="' . $url . '" />' ); } /** * Output the feed to the browser * * @return DBHTMLText */ public function outputToBrowser() { $output = parent::outputToBrowser(); $response = Controller::curr()->getResponse(); $response->addHeader("Content-Type", "application/atom+xml"); return $output; } } |