forked from blallo/rss-bridge
[formats] Rename variable 'data' to 'item'
This makes the intend of the variable more clear and is now coherent with all Bridges
This commit is contained in:
parent
a84016bcb6
commit
cf146523be
6 changed files with 27 additions and 28 deletions
|
@ -19,12 +19,12 @@ class AtomFormat extends FormatAbstract{
|
|||
$uri = $this->xml_encode($uri);
|
||||
|
||||
$entries = '';
|
||||
foreach($this->getItems() as $data){
|
||||
$entryAuthor = isset($data['author']) ? $this->xml_encode($data['author']) : '';
|
||||
$entryTitle = isset($data['title']) ? $this->xml_encode($data['title']) : '';
|
||||
$entryUri = isset($data['uri']) ? $this->xml_encode($data['uri']) : '';
|
||||
$entryTimestamp = isset($data['timestamp']) ? $this->xml_encode(date(DATE_ATOM, $data['timestamp'])) : '';
|
||||
$entryContent = isset($data['content']) ? $this->xml_encode($this->sanitizeHtml($data['content'])) : '';
|
||||
foreach($this->getItems() as $item){
|
||||
$entryAuthor = isset($item['author']) ? $this->xml_encode($item['author']) : '';
|
||||
$entryTitle = isset($item['title']) ? $this->xml_encode($item['title']) : '';
|
||||
$entryUri = isset($item['uri']) ? $this->xml_encode($item['uri']) : '';
|
||||
$entryTimestamp = isset($item['timestamp']) ? $this->xml_encode(date(DATE_ATOM, $item['timestamp'])) : '';
|
||||
$entryContent = isset($item['content']) ? $this->xml_encode($this->sanitizeHtml($item['content'])) : '';
|
||||
$entries .= <<<EOD
|
||||
|
||||
<entry>
|
||||
|
|
|
@ -9,12 +9,12 @@ class HtmlFormat extends FormatAbstract{
|
|||
$mrssquery = str_replace('format=Html', 'format=Mrss', htmlentities($_SERVER['QUERY_STRING']));
|
||||
|
||||
$entries = '';
|
||||
foreach($this->getItems() as $data){
|
||||
$entryAuthor = isset($data['author']) ? '<br /><p class="author">by: ' . $data['author'] . '</p>' : '';
|
||||
$entryTitle = isset($data['title']) ? $this->sanitizeHtml(strip_tags($data['title'])) : '';
|
||||
$entryUri = isset($data['uri']) ? $data['uri'] : $uri;
|
||||
$entryTimestamp = isset($data['timestamp']) ? '<time datetime="' . date(DATE_ATOM, $data['timestamp']) . '">' . date(DATE_ATOM, $data['timestamp']) . '</time>' : '';
|
||||
$entryContent = isset($data['content']) ? '<div class="content">' . $this->sanitizeHtml($data['content']). '</div>' : '';
|
||||
foreach($this->getItems() as $item){
|
||||
$entryAuthor = isset($item['author']) ? '<br /><p class="author">by: ' . $item['author'] . '</p>' : '';
|
||||
$entryTitle = isset($item['title']) ? $this->sanitizeHtml(strip_tags($item['title'])) : '';
|
||||
$entryUri = isset($item['uri']) ? $item['uri'] : $uri;
|
||||
$entryTimestamp = isset($item['timestamp']) ? '<time datetime="' . date(DATE_ATOM, $item['timestamp']) . '">' . date(DATE_ATOM, $item['timestamp']) . '</time>' : '';
|
||||
$entryContent = isset($item['content']) ? '<div class="content">' . $this->sanitizeHtml($item['content']). '</div>' : '';
|
||||
$entries .= <<<EOD
|
||||
|
||||
<section class="feeditem">
|
||||
|
|
|
@ -7,9 +7,9 @@ class JsonFormat extends FormatAbstract{
|
|||
|
||||
public function stringify(){
|
||||
// FIXME : sometime content can be null, transform to empty string
|
||||
$datas = $this->getItems();
|
||||
$items = $this->getItems();
|
||||
|
||||
return json_encode($datas, JSON_PRETTY_PRINT);
|
||||
return json_encode($items, JSON_PRETTY_PRINT);
|
||||
}
|
||||
|
||||
public function display(){
|
||||
|
|
|
@ -17,12 +17,12 @@ class MrssFormat extends FormatAbstract{
|
|||
$uri = $this->xml_encode(!empty($extraInfos['uri']) ? $extraInfos['uri'] : 'https://github.com/sebsauvage/rss-bridge');
|
||||
|
||||
$items = '';
|
||||
foreach($this->getItems() as $data){
|
||||
$itemAuthor = isset($data['author']) ? $this->xml_encode($data['author']) : '';
|
||||
$itemTitle = strip_tags(isset($data['title']) ? $this->xml_encode($data['title']) : '');
|
||||
$itemUri = isset($data['uri']) ? $this->xml_encode($data['uri']) : '';
|
||||
$itemTimestamp = isset($data['timestamp']) ? $this->xml_encode(date(DATE_RFC2822, $data['timestamp'])) : '';
|
||||
$itemContent = isset($data['content']) ? $this->xml_encode($this->sanitizeHtml($data['content'])) : '';
|
||||
foreach($this->getItems() as $item){
|
||||
$itemAuthor = isset($item['author']) ? $this->xml_encode($item['author']) : '';
|
||||
$itemTitle = strip_tags(isset($item['title']) ? $this->xml_encode($item['title']) : '');
|
||||
$itemUri = isset($item['uri']) ? $this->xml_encode($item['uri']) : '';
|
||||
$itemTimestamp = isset($item['timestamp']) ? $this->xml_encode(date(DATE_RFC2822, $item['timestamp'])) : '';
|
||||
$itemContent = isset($item['content']) ? $this->xml_encode($this->sanitizeHtml($item['content'])) : '';
|
||||
$items .= <<<EOD
|
||||
|
||||
<item>
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
class PlaintextFormat extends FormatAbstract{
|
||||
|
||||
public function stringify(){
|
||||
$datas = $this->getItems();
|
||||
return print_r($datas, true);
|
||||
$items = $this->getItems();
|
||||
return print_r($items, true);
|
||||
}
|
||||
|
||||
public function display(){
|
||||
|
|
|
@ -16,7 +16,7 @@ abstract class FormatAbstract implements FormatInterface{
|
|||
protected
|
||||
$contentType,
|
||||
$charset,
|
||||
$datas,
|
||||
$items,
|
||||
$extraInfos
|
||||
;
|
||||
|
||||
|
@ -48,17 +48,16 @@ abstract class FormatAbstract implements FormatInterface{
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setItems(array $datas){
|
||||
$this->datas = $datas;
|
||||
public function setItems(array $items){
|
||||
$this->items = $items;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getItems(){
|
||||
if( !is_array($this->datas) ){
|
||||
if(!is_array($this->items))
|
||||
throw new \LogicException('Feed the ' . get_class($this) . ' with "setItems" method before !');
|
||||
}
|
||||
|
||||
return $this->datas;
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue