Flagbit_FeedReader - Version 1.1.0

Version Notes

* Widgetized the extension

Download this release

Release Info

Developer Magento Core Team
Extension Flagbit_FeedReader
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.0 to 1.1.0

app/code/community/Flagbit/FeedReader/Block/Abstract.php CHANGED
@@ -16,21 +16,6 @@
16
  */
17
  abstract class Flagbit_FeedReader_Block_Abstract extends Mage_Core_Block_Template
18
  {
19
- /**
20
- * @var Zend_Feed_Abstract
21
- */
22
- protected $_feed = null;
23
-
24
- /**
25
- * @var string
26
- */
27
- protected $_title = null;
28
-
29
- /**
30
- * @var int
31
- */
32
- private $_itemCount = 5;
33
-
34
  /**
35
  * The constructor
36
  *
@@ -52,20 +37,40 @@ abstract class Flagbit_FeedReader_Block_Abstract extends Mage_Core_Block_Templat
52
  */
53
  public function setUri($uri)
54
  {
55
- try {
56
- $this->_feed = Zend_Feed::import($uri);
57
- // update the cache tag
58
- $this->setCacheKey($uri);
59
- }
60
- catch (Zend_Http_Client_Exception $e) {
61
- Mage::logException($e);
62
- }
63
- catch (Zend_Feed_Exception $e) {
64
- Mage::logException($e);
65
- }
66
  return $this;
67
  }
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  /**
70
  * Sets the cache key
71
  *
@@ -95,7 +100,7 @@ abstract class Flagbit_FeedReader_Block_Abstract extends Mage_Core_Block_Templat
95
  */
96
  public function setItemCount($itemCount)
97
  {
98
- $this->_itemCount = (int) $itemCount;
99
  return $this;
100
  }
101
 
@@ -107,10 +112,10 @@ abstract class Flagbit_FeedReader_Block_Abstract extends Mage_Core_Block_Templat
107
  public function getItemCount()
108
  {
109
  $itemCount = 0;
110
- if (!is_null($this->_feed)) {
111
- $itemCount = $this->_itemCount;
112
- if ($this->_feed->count() < $itemCount) {
113
- $itemCount = $this->_feed->count();
114
  }
115
  }
116
  return $itemCount;
@@ -126,11 +131,11 @@ abstract class Flagbit_FeedReader_Block_Abstract extends Mage_Core_Block_Templat
126
  public function getTitle()
127
  {
128
  $title = '';
129
- if (!is_null($this->_title)) {
130
- $title = $this->_title;
131
  }
132
- else if (!is_null($this->_feed)) {
133
- $title = $this->_feed->title();
134
  }
135
  return $title;
136
  }
@@ -145,7 +150,7 @@ abstract class Flagbit_FeedReader_Block_Abstract extends Mage_Core_Block_Templat
145
  */
146
  public function setTitle($title)
147
  {
148
- $this->_title = (string) $title;
149
  return $this;
150
  }
151
 
@@ -157,9 +162,9 @@ abstract class Flagbit_FeedReader_Block_Abstract extends Mage_Core_Block_Templat
157
  public function getItems()
158
  {
159
  $return = array();
160
- if (!is_null($this->_feed)) {
161
  $itemCount = 0;
162
- foreach ($this->_feed as $item) {
163
  $return[] = $item;
164
  if (++$itemCount >= $this->getItemCount()) {
165
  break;
16
  */
17
  abstract class Flagbit_FeedReader_Block_Abstract extends Mage_Core_Block_Template
18
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  /**
20
  * The constructor
21
  *
37
  */
38
  public function setUri($uri)
39
  {
40
+ $this->setData('uri', (string) $uri);
 
 
 
 
 
 
 
 
 
 
41
  return $this;
42
  }
43
 
44
+ /**
45
+ * Returns the feed
46
+ *
47
+ * Tries to create the feed from the URI.
48
+ *
49
+ * @return Zend_Feed
50
+ */
51
+ protected function getFeed()
52
+ {
53
+ $feed = $this->getData('feed');
54
+ if (is_null($feed)) {
55
+ $uri = $this->getData('uri');
56
+ if (!is_null($uri)) {
57
+ try {
58
+ $feed = Zend_Feed::import($uri);
59
+ $this->setData('feed', $feed);
60
+ // update the cache tag
61
+ $this->setCacheKey($uri);
62
+ }
63
+ catch (Zend_Http_Client_Exception $e) {
64
+ Mage::logException($e);
65
+ }
66
+ catch (Zend_Feed_Exception $e) {
67
+ Mage::logException($e);
68
+ }
69
+ }
70
+ }
71
+ return $feed;
72
+ }
73
+
74
  /**
75
  * Sets the cache key
76
  *
100
  */
101
  public function setItemCount($itemCount)
102
  {
103
+ $this->setData('item_count', (int) $itemCount);
104
  return $this;
105
  }
106
 
112
  public function getItemCount()
113
  {
114
  $itemCount = 0;
115
+ if (!is_null($this->getFeed())) {
116
+ $itemCount = $this->getData('item_count');
117
+ if ($this->getFeed()->count() < $itemCount || is_null($this->getData('item_count'))) {
118
+ $itemCount = $this->getFeed()->count();
119
  }
120
  }
121
  return $itemCount;
131
  public function getTitle()
132
  {
133
  $title = '';
134
+ if (!is_null($this->getData('title'))) {
135
+ $title = $this->getData('title');
136
  }
137
+ else if (!is_null($this->getFeed())) {
138
+ $title = $this->getFeed()->title();
139
  }
140
  return $title;
141
  }
150
  */
151
  public function setTitle($title)
152
  {
153
+ $this->setData('title', (string) $title);
154
  return $this;
155
  }
156
 
162
  public function getItems()
163
  {
164
  $return = array();
165
+ if (!is_null($this->getFeed())) {
166
  $itemCount = 0;
167
+ foreach ($this->getFeed() as $item) {
168
  $return[] = $item;
169
  if (++$itemCount >= $this->getItemCount()) {
170
  break;
app/code/community/Flagbit/FeedReader/Block/Sidebar.php CHANGED
@@ -14,7 +14,9 @@
14
  * @package Flagbit_FeedReader
15
  * @author David Fuhr <fuhr@flagbit.de>
16
  */
17
- class Flagbit_FeedReader_Block_Sidebar extends Flagbit_FeedReader_Block_Abstract
 
 
18
  {
19
  /**
20
  * The constructor
14
  * @package Flagbit_FeedReader
15
  * @author David Fuhr <fuhr@flagbit.de>
16
  */
17
+ class Flagbit_FeedReader_Block_Sidebar
18
+ extends Flagbit_FeedReader_Block_Abstract
19
+ implements Mage_Widget_Block_Interface
20
  {
21
  /**
22
  * The constructor
app/code/community/Flagbit/FeedReader/Helper/Data.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * @category Flagbit
6
+ * @package Flagbit_FeedReader
7
+ * @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de)
8
+ */
9
+
10
+ /**
11
+ * Feed reader default helper
12
+ *
13
+ * @category Flagbit
14
+ * @package Flagbit_FeedReader
15
+ * @author David Fuhr <fuhr@flagbit.de>
16
+ */
17
+ abstract class Flagbit_FeedReader_Helper_Data extends Mage_Core_Helper_Abstract
18
+ {
19
+ }
app/code/community/Flagbit/FeedReader/etc/config.xml CHANGED
@@ -4,7 +4,7 @@
4
  <Flagbit_FeedReader>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
- <version>1.0.0</version>
8
  </Flagbit_FeedReader>
9
  </modules>
10
 
@@ -14,6 +14,11 @@
14
  <class>Flagbit_FeedReader_Block</class>
15
  </feedreader>
16
  </blocks>
 
 
 
 
 
17
  </global>
18
 
19
  <frontend>
@@ -25,4 +30,16 @@
25
  </updates>
26
  </layout>
27
  </frontend>
 
 
 
 
 
 
 
 
 
 
 
 
28
  </config>
4
  <Flagbit_FeedReader>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
+ <version>1.1.0</version>
8
  </Flagbit_FeedReader>
9
  </modules>
10
 
14
  <class>Flagbit_FeedReader_Block</class>
15
  </feedreader>
16
  </blocks>
17
+ <helpers>
18
+ <feedreader>
19
+ <class>Flagbit_FeedReader_Helper</class>
20
+ </feedreader>
21
+ </helpers>
22
  </global>
23
 
24
  <frontend>
30
  </updates>
31
  </layout>
32
  </frontend>
33
+
34
+ <adminhtml>
35
+ <translate>
36
+ <modules>
37
+ <Flagbit_FeedReader>
38
+ <files>
39
+ <default>Flagbit_FeedReader.csv</default>
40
+ </files>
41
+ </Flagbit_FeedReader>
42
+ </modules>
43
+ </translate>
44
+ </adminhtml>
45
  </config>
app/code/community/Flagbit/FeedReader/etc/widget.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <widgets>
3
+ <feedreader_sidebar type="feedreader/sidebar" translate="name description">
4
+ <name>FeedReader: Sidebar</name>
5
+ <description type="desc">Adds a FeedReader block</description>
6
+ <parameters>
7
+ <uri translate="label">
8
+ <required>1</required>
9
+ <visible>1</visible>
10
+ <label>Feed URI</label>
11
+ <type>text</type>
12
+ </uri>
13
+ <item_count translate="label description">
14
+ <required>0</required>
15
+ <visible>1</visible>
16
+ <label>Item Count</label>
17
+ <type>text</type>
18
+ <value>5</value>
19
+ </item_count>
20
+ <title translate="label description">
21
+ <required>0</required>
22
+ <visible>1</visible>
23
+ <label>Title</label>
24
+ <description>If empty, the feed's title will be used</description>
25
+ <type>text</type>
26
+ </title>
27
+ <template translate="label">
28
+ <required>1</required>
29
+ <visible>0</visible>
30
+ <label>Template</label>
31
+ <type>select</type>
32
+ <value>feedreader/sidebar.phtml</value>
33
+ <values>
34
+ <default translate="label">
35
+ <value>feedreader/sidebar.phtml</value>
36
+ <label>Sidebar</label>
37
+ </default>
38
+ </values>
39
+ </template>
40
+ </parameters>
41
+ </feedreader_sidebar>
42
+ </widgets>
app/locale/de_DE/Flagbit_FeedReader.csv ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ "Adds a FeedReader block","Fügt einen FeedReader Block hinzu"
2
+ "Feed URI","Feed URI"
3
+ "FeedReader: Sidebar","FeedReader: Seitenleiste"
4
+ "If empty, the feed's title will be used","Falls leer, wird der Titel des Feeds verwendet"
5
+ "Item Count","Elementanzahl"
6
+ "Sidebar","Seitenleiste"
7
+ "Template","Vorlage"
8
+ "Title","Titel"
package.xml CHANGED
@@ -1,20 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Flagbit_FeedReader</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>A simple feed reader supporting RSS and Atom feeds. Highly customizable and easy to integrate.</summary>
10
- <description>A simple feed reader supporting RSS and Atom feeds. Highly customizable and easy to integrate.
11
-
12
- Configuration is done in the default/layout/feedreader.xml. Simply reference the block where you want to create the feed. Feed URI and item count and template can be freely configured.</description>
13
- <notes>- Initial release</notes>
14
- <authors><author><name>David Fuhr</name><user>auto-converted</user><email>fuhr@flagbit.de</email></author></authors>
15
- <date>2010-04-14</date>
16
- <time>09:37:02</time>
17
- <contents><target name="magecommunity"><dir name="Flagbit"><dir name="FeedReader"><dir name="Block"><file name="Abstract.php" hash="976c980694b2bc229b06810dd938fb1b"/><file name="Sidebar.php" hash="ea5b419e653db76daefabeebbd41ab3b"/></dir><dir name="etc"><file name="config.xml" hash="dd66389978451c6aad3faddb31703584"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Flagbit_FeedReader.xml" hash="302036c0fe8cc40a093ff3c8bd62b399"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="feedreader.css" hash="eb016f3f670214e6472230290c598372"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="feedreader.xml" hash="c5c3f1bf1e2414db5b73fd7328eed8d8"/></dir><dir name="template"><dir name="feedreader"><file name="sidebar.phtml" hash="bf664391777eadae9a6af2d9b6c207a9"/></dir></dir></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies/>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Flagbit_FeedReader</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>A simple feed reader supporting RSS and Atom feeds. Highly customizable and easy to integrate.</summary>
10
+ <description>A simple feed reader supporting RSS and Atom feeds. Highly customizable and easy to integrate. Configuration is done in the default/layout/feedreader.xml. Simply reference the block where you want to create the feed. Feed URI and item count and template can be freely configured.</description>
11
+ <notes>* Widgetized the extension</notes>
12
+ <authors><author><name>Flagbit GmbH </name><user>auto-converted</user><email>magento@flagbit.de</email></author></authors>
13
+ <date>2010-04-23</date>
14
+ <time>10:12:02</time>
15
+ <contents><target name="magecommunity"><dir name="Flagbit"><dir name="FeedReader"><dir name="Block"><file name="Abstract.php" hash="d7f703f744bb22e102bd270beb53d818"/><file name="Sidebar.php" hash="39b387298e6ff89bc0625cb69b7bcd27"/></dir><dir name="etc"><file name="config.xml" hash="f541d07343f4d542edb26c4054fd468c"/><file name="widget.xml" hash="8adfb0e384380eefbf79d694c9749a2e"/></dir><dir name="Helper"><file name="Data.php" hash="2899ba63543324211967e22e4e13f1e3"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Flagbit_FeedReader.xml" hash="302036c0fe8cc40a093ff3c8bd62b399"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="feedreader.css" hash="eb016f3f670214e6472230290c598372"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="feedreader.xml" hash="c5c3f1bf1e2414db5b73fd7328eed8d8"/></dir><dir name="template"><dir name="feedreader"><file name="sidebar.phtml" hash="bf664391777eadae9a6af2d9b6c207a9"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Flagbit_FeedReader.csv" hash="89f6c13d5e809f9fb504bfe6125ff162"/></dir></target></contents>
 
 
16
  <compatible/>
17
  <dependencies/>
18
  </package>