Merge pull request #198 from teromene/rss-bridge-enclosures
Rss bridge enclosures
This commit is contained in:
commit
31177912e0
4 changed files with 30 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -170,6 +170,7 @@ App_Data/*.ldf
|
||||||
## Other ide stuff
|
## Other ide stuff
|
||||||
#################
|
#################
|
||||||
.idea/*
|
.idea/*
|
||||||
|
[#]*[#]
|
||||||
|
|
||||||
#############
|
#############
|
||||||
## Windows detritus
|
## Windows detritus
|
||||||
|
|
|
@ -53,6 +53,16 @@ class DemoBridge extends BridgeAbstract{
|
||||||
|
|
||||||
public function collectData(array $param){
|
public function collectData(array $param){
|
||||||
|
|
||||||
|
$item = new \Item();
|
||||||
|
$item->name = "TestElement";
|
||||||
|
$item->title = "Test";
|
||||||
|
$item->content = "Awesome content !";
|
||||||
|
$item->id = "Lalala";
|
||||||
|
$item->uri = "http://test.test/test";
|
||||||
|
$item->enclosures[] = "http://www.ardmediathek.de/ard/servlet/image/00/32/68/18/38/1135274624/16x9/960";
|
||||||
|
|
||||||
|
$this->items[] = $item;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName() {
|
||||||
|
@ -68,6 +78,6 @@ class DemoBridge extends BridgeAbstract{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCacheDuration(){
|
public function getCacheDuration(){
|
||||||
return 3600; // 1 hour
|
return 00; // 1 hour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,15 @@ class AtomFormat extends FormatAbstract{
|
||||||
// We prevent content from closing the CDATA too early.
|
// We prevent content from closing the CDATA too early.
|
||||||
$entryContent = is_null($data->content) ? '' : '<![CDATA[' . $this->sanitizeHtml(str_replace(']]>','',$data->content)) . ']]>';
|
$entryContent = is_null($data->content) ? '' : '<![CDATA[' . $this->sanitizeHtml(str_replace(']]>','',$data->content)) . ']]>';
|
||||||
|
|
||||||
|
// We generate a list of the enclosure links
|
||||||
|
$entryEnclosure = "";
|
||||||
|
|
||||||
|
foreach($data->enclosures as $enclosure) {
|
||||||
|
|
||||||
|
$entryEnclosures .= "<link rel=\"enclosure\" href=\"".$enclosure."\"></link>";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$entries .= <<<EOD
|
$entries .= <<<EOD
|
||||||
|
|
||||||
<entry>
|
<entry>
|
||||||
|
@ -48,6 +57,7 @@ class AtomFormat extends FormatAbstract{
|
||||||
<id>{$entryUri}</id>
|
<id>{$entryUri}</id>
|
||||||
<updated>{$entryTimestamp}</updated>
|
<updated>{$entryTimestamp}</updated>
|
||||||
<content type="html">{$entryContent}</content>
|
<content type="html">{$entryContent}</content>
|
||||||
|
{$entryEnclosures}
|
||||||
</entry>
|
</entry>
|
||||||
|
|
||||||
EOD;
|
EOD;
|
||||||
|
|
12
lib/Item.php
12
lib/Item.php
|
@ -2,15 +2,19 @@
|
||||||
interface ItemInterface{}
|
interface ItemInterface{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object to store datas collect informations
|
* Object to store datas collect informations
|
||||||
* FIXME : not sur this logic is the good, I think recast all is necessary
|
* FIXME : not sur this logic is the good, I think recast all is necessary
|
||||||
*/
|
*/
|
||||||
class Item implements ItemInterface{
|
class Item implements ItemInterface{
|
||||||
|
|
||||||
|
// FIXME : use the arrayInterface instead
|
||||||
|
public $enclosures = array();
|
||||||
|
|
||||||
public function __set($name, $value){
|
public function __set($name, $value){
|
||||||
$this->$name = $value;
|
$this->$name = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __get($name){
|
public function __get($name){
|
||||||
return isset($this->$name) ? $this->$name : null;
|
return (isset($this->$name) ? $this->$name : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue