This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Roumen Damianoff
committed
Dec 11, 2015
1 parent
f2087a5
commit 953e9df
Showing
2 changed files
with
15 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* Feed generator class for laravel-feed package. | ||
* | ||
* @author Roumen Damianoff <[email protected]> | ||
* @version 2.9.7 | ||
* @version 2.9.8 | ||
* @link https://roumen.it/projects/laravel-feed | ||
* @license http://opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
|
@@ -16,7 +16,7 @@ | |
class Feed | ||
{ | ||
|
||
public $items = array(); | ||
public $items = []; | ||
public $title = 'My feed title'; | ||
public $description = 'My feed description'; | ||
public $link; | ||
|
@@ -31,7 +31,7 @@ class Feed | |
protected $shortening = false; | ||
protected $shorteningLimit = 150; | ||
protected $dateFormat = 'datetime'; | ||
protected $namespaces = array(); | ||
protected $namespaces = []; | ||
protected $customView = null; | ||
|
||
|
||
|
@@ -67,8 +67,6 @@ public function add($title, $author, $link, $pubdate, $description, $content='', | |
$description = mb_substr($description, 0, $this->shorteningLimit, 'UTF-8'); | ||
} | ||
|
||
$pubdate = $this->formatDate($pubdate); | ||
|
||
$this->items[] = array( | ||
'title' => $title, | ||
'author' => $author, | ||
|
@@ -96,8 +94,6 @@ public function addArray(array $a) | |
$a['description'] = mb_substr($a['description'], 0, $this->shorteningLimit, 'UTF-8'); | ||
} | ||
|
||
$a['pubdate'] = $this->formatDate($a['pubdate']); | ||
|
||
$this->items[] = $a; | ||
} | ||
|
||
|
@@ -121,18 +117,7 @@ public function render($format = null, $cache = null, $key = null) | |
|
||
if ($this->ctype == null) | ||
{ | ||
switch ($format) | ||
{ | ||
case "rss": | ||
$this->ctype = 'application/rss+xml'; | ||
break; | ||
case "atom": | ||
$this->ctype = 'application/atom+xml'; | ||
break; | ||
default: | ||
$this->ctype = 'application/atom+xml'; | ||
break; | ||
} | ||
($format == 'rss') ? $this->ctype = 'application/rss+xml' : $this->ctype = 'application/atom+xml'; | ||
} | ||
|
||
// if cache is on and there is cached feed => return it | ||
|
@@ -147,15 +132,20 @@ public function render($format = null, $cache = null, $key = null) | |
|
||
$this->pubdate = $this->formatDate($this->pubdate, $format); | ||
|
||
$channel = array( | ||
foreach($this->items as $k => $v) | ||
{ | ||
$this->items[$k]['pubdate'] = $this->formatDate($this->items[$k]['pubdate'], $format); | ||
} | ||
|
||
$channel = [ | ||
'title'=>$this->title, | ||
'description'=>$this->description, | ||
'logo' => $this->logo, | ||
'icon' => $this->icon, | ||
'link'=>$this->link, | ||
'pubdate'=>$this->pubdate, | ||
'lang'=>$this->lang | ||
); | ||
]; | ||
|
||
if ($format == 'rss') | ||
{ | ||
|
@@ -170,11 +160,11 @@ public function render($format = null, $cache = null, $key = null) | |
} | ||
} | ||
|
||
$viewData = array( | ||
$viewData = [ | ||
'items' => $this->items, | ||
'channel' => $channel, | ||
'namespaces' => $this->getNamespaces() | ||
); | ||
]; | ||
|
||
// if cache is on put this feed in cache and return it | ||
if ($this->caching > 0) | ||
|
@@ -345,7 +335,7 @@ public function setShortening($b=false) | |
* | ||
* @return string | ||
*/ | ||
protected function formatDate($date, $format="atom") | ||
protected function formatDate($date, $format='atom') | ||
{ | ||
if ($format == "atom") | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters