From e7595391cd689a69881b67c0916f32ba01b19e2d Mon Sep 17 00:00:00 2001 From: Teromene Date: Tue, 19 Jan 2016 12:34:21 +0000 Subject: [PATCH 1/2] Ignore emacs save files. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2359a6d5..4c658bf7 100644 --- a/.gitignore +++ b/.gitignore @@ -170,6 +170,7 @@ App_Data/*.ldf ## Other ide stuff ################# .idea/* +[#]*[#] ############# ## Windows detritus From 4deefdfd7d52843e7cf80d0134c1172ececa25a0 Mon Sep 17 00:00:00 2001 From: Teromene Date: Tue, 19 Jan 2016 12:34:38 +0000 Subject: [PATCH 2/2] Add enclosures support, see example in DemoBridge. --- bridges/DemoBridge.php | 12 +++++++++++- formats/AtomFormat.php | 10 ++++++++++ lib/Item.php | 12 ++++++++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/bridges/DemoBridge.php b/bridges/DemoBridge.php index 24cd3891..b1d8515e 100644 --- a/bridges/DemoBridge.php +++ b/bridges/DemoBridge.php @@ -53,6 +53,16 @@ class DemoBridge extends BridgeAbstract{ 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() { @@ -68,6 +78,6 @@ class DemoBridge extends BridgeAbstract{ } public function getCacheDuration(){ - return 3600; // 1 hour + return 00; // 1 hour } } diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php index f3797e29..536c16a7 100644 --- a/formats/AtomFormat.php +++ b/formats/AtomFormat.php @@ -36,6 +36,15 @@ class AtomFormat extends FormatAbstract{ // We prevent content from closing the CDATA too early. $entryContent = is_null($data->content) ? '' : 'sanitizeHtml(str_replace(']]>','',$data->content)) . ']]>'; + // We generate a list of the enclosure links + $entryEnclosure = ""; + + foreach($data->enclosures as $enclosure) { + + $entryEnclosures .= ""; + + } + $entries .= << @@ -48,6 +57,7 @@ class AtomFormat extends FormatAbstract{ {$entryUri} {$entryTimestamp} {$entryContent} + {$entryEnclosures} EOD; diff --git a/lib/Item.php b/lib/Item.php index 2e15ffc3..699ec3da 100644 --- a/lib/Item.php +++ b/lib/Item.php @@ -2,15 +2,19 @@ interface ItemInterface{} /** -* Object to store datas collect informations -* FIXME : not sur this logic is the good, I think recast all is necessary -*/ + * Object to store datas collect informations + * FIXME : not sur this logic is the good, I think recast all is necessary + */ class Item implements ItemInterface{ + + // FIXME : use the arrayInterface instead + public $enclosures = array(); + public function __set($name, $value){ $this->$name = $value; } public function __get($name){ - return isset($this->$name) ? $this->$name : null; + return (isset($this->$name) ? $this->$name : null); } }