mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-06 16:46:30 +02:00
formats: Add getMimeType() function (#1299)
Allows getting the expected MIME type of the format's output. A corresponding MIME_TYPE constant is also defined in FormatAbstract for the format implementations to overwrite.
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
* https://validator.w3.org/feed/
|
||||
*/
|
||||
class AtomFormat extends FormatAbstract{
|
||||
const MIME_TYPE = 'application/atom+xml';
|
||||
|
||||
const LIMIT_TITLE = 140;
|
||||
|
||||
public function stringify(){
|
||||
@@ -147,7 +149,7 @@ EOD;
|
||||
|
||||
public function display(){
|
||||
$this
|
||||
->setContentType('application/atom+xml; charset=' . $this->getCharset())
|
||||
->setContentType(self::MIME_TYPE . '; charset=' . $this->getCharset())
|
||||
->callContentType();
|
||||
|
||||
return parent::display();
|
||||
|
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
class HtmlFormat extends FormatAbstract {
|
||||
const MIME_TYPE = 'text/html';
|
||||
|
||||
public function stringify(){
|
||||
$extraInfos = $this->getExtraInfos();
|
||||
$title = htmlspecialchars($extraInfos['name']);
|
||||
@@ -120,7 +122,7 @@ EOD;
|
||||
|
||||
public function display() {
|
||||
$this
|
||||
->setContentType('text/html; charset=' . $this->getCharset())
|
||||
->setContentType(self::MIME_TYPE . '; charset=' . $this->getCharset())
|
||||
->callContentType();
|
||||
|
||||
return parent::display();
|
||||
|
@@ -8,6 +8,8 @@
|
||||
* https://github.com/vigetlabs/json-feed-validator
|
||||
*/
|
||||
class JsonFormat extends FormatAbstract {
|
||||
const MIME_TYPE = 'application/json';
|
||||
|
||||
const VENDOR_EXCLUDES = array(
|
||||
'author',
|
||||
'title',
|
||||
@@ -119,7 +121,7 @@ class JsonFormat extends FormatAbstract {
|
||||
|
||||
public function display(){
|
||||
$this
|
||||
->setContentType('application/json; charset=' . $this->getCharset())
|
||||
->setContentType(self::MIME_TYPE . '; charset=' . $this->getCharset())
|
||||
->callContentType();
|
||||
|
||||
return parent::display();
|
||||
|
@@ -25,6 +25,8 @@
|
||||
* RSS 2.0 feed that works with feed readers that don't support the extension.
|
||||
*/
|
||||
class MrssFormat extends FormatAbstract {
|
||||
const MIME_TYPE = 'application/rss+xml';
|
||||
|
||||
const ALLOWED_IMAGE_EXT = array(
|
||||
'.gif', '.jpg', '.png'
|
||||
);
|
||||
@@ -150,7 +152,7 @@ EOD;
|
||||
|
||||
public function display(){
|
||||
$this
|
||||
->setContentType('application/rss+xml; charset=' . $this->getCharset())
|
||||
->setContentType(self::MIME_TYPE . '; charset=' . $this->getCharset())
|
||||
->callContentType();
|
||||
|
||||
return parent::display();
|
||||
|
@@ -4,6 +4,8 @@
|
||||
* Returns $this->items as raw php data.
|
||||
*/
|
||||
class PlaintextFormat extends FormatAbstract {
|
||||
const MIME_TYPE = 'text/plain';
|
||||
|
||||
public function stringify(){
|
||||
$items = $this->getItems();
|
||||
$data = array();
|
||||
@@ -22,7 +24,7 @@ class PlaintextFormat extends FormatAbstract {
|
||||
|
||||
public function display(){
|
||||
$this
|
||||
->setContentType('text/plain; charset=' . $this->getCharset())
|
||||
->setContentType(self::MIME_TYPE . '; charset=' . $this->getCharset())
|
||||
->callContentType();
|
||||
|
||||
return parent::display();
|
||||
|
Reference in New Issue
Block a user