1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12: class Jonah_Block_News extends Horde_Core_Block
13: {
14: 15:
16: public function __construct($app, $params = array())
17: {
18: parent::__construct($app, $params);
19:
20: $this->_name = _("Feed");
21: }
22:
23: 24:
25: protected function _params()
26: {
27: $templates = Horde::loadConfiguration('templates.php', 'templates', 'jonah');
28: $params['source'] = array('name' => _("Feed"),
29: 'type' => 'enum',
30: 'values' => array());
31:
32: $channels = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannels();
33: foreach ($channels as $channel) {
34: $params['source']['values'][$channel['channel_id']] = $channel['channel_name'];
35: }
36: natcasesort($params['source']['values']);
37:
38: $params['view'] = array('name' => _("View"),
39: 'type' => 'enum',
40: 'values' => array(),
41: );
42: foreach ($templates as $key => $template) {
43: $params['view']['values'][$key] = $template['name'];
44: }
45:
46: $params['max'] = array('name' => _("Maximum Stories"),
47: 'type' => 'int',
48: 'default' => 10,
49: 'required' => false);
50:
51: $params['from'] = array('name' => _("First Story"),
52: 'type' => 'int',
53: 'default' => 0,
54: 'required' => false);
55:
56: return $params;
57: }
58:
59: 60:
61: protected function _title()
62: {
63: try {
64: $channel = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($this->_params['source']);
65: } catch (Jonah_Exception $e) {
66: return htmlspecialchars($e->getMessage());
67: }
68:
69: if (!empty($channel['channel_link'])) {
70: $title = Horde::link(htmlspecialchars($channel['channel_link']), '', '', '_blank')
71: . htmlspecialchars($channel['channel_name'])
72: . '</a>';
73: } else {
74: $title = htmlspecialchars($channel['channel_name']);
75: }
76:
77: return $title;
78: }
79:
80: 81:
82: protected function _content()
83: {
84: if (empty($this->_params['source'])) {
85: return _("No feed specified.");
86: }
87:
88: $view = isset($this->_params['view']) ? $this->_params['view'] : 'standard';
89:
90: return $GLOBALS['injector']->getInstance('Jonah_Driver')->renderChannel(
91: $this->_params['source'],
92: $view,
93: $this->_params['max'],
94: $this->_params['from']);
95: }
96:
97: }
98: