1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15: class Jonah_View_ChannelList extends Jonah_View_Base
16: {
17: 18: 19:
20: public function run()
21: {
22: extract($this->_params, EXTR_REFS);
23: try {
24: $channels = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannels();
25: } catch (Exception $e) {
26: $notification->push(sprintf(_("An error occurred fetching channels: %s"), $e->getMessage()), 'horde.error');
27: $channels = false;
28: }
29: if ($channels) {
30: $channels = Jonah::checkPermissions('channels', Horde_Perms::SHOW, $channels);
31:
32: foreach ($channels as $key => $channel) {
33:
34: $url = Horde::url('channels/edit.php')->add('channel_id', $channel['channel_id']);
35: $channels[$key]['edit_link'] = $url->link(array('title' => _("Edit channel"))) . Horde::img('edit.png') . '</a>';
36:
37:
38: $url = Horde::url('channels/delete.php')->add('channel_id', $channel['channel_id']);
39: $channels[$key]['delete_link'] = $url->link(array('title' => _("Delete channel"))) . Horde::img('delete.png') . '</a>';
40:
41:
42: $channels[$key]['stories_url'] = Horde::url('stories/index.php')->add('channel_id', $channel['channel_id']);
43:
44:
45: $channels[$key]['addstory_link'] = '';
46: $channels[$key]['refresh_link'] = '';
47:
48: switch ($channel['channel_type']) {
49: case Jonah::INTERNAL_CHANNEL:
50:
51: $url = Horde::url('stories/edit.php')->add('channel_id', $channel['channel_id']);
52: $channels[$key]['addstory_link'] = $url->link(array('title' => _("Add story"))) . Horde::img('new.png') . '</a>';
53: break;
54: }
55: $channels[$key]['channel_type'] = Jonah::getChannelTypeLabel($channel['channel_type']);
56: $channels[$key]['channel_updated'] = ($channel['channel_updated'] ? strftime($prefs->getValue('date_format'), (int)$channel['channel_updated']) : '-');
57: }
58: }
59:
60: $view = new Horde_View(array('templatePath' => JONAH_TEMPLATES . '/view'));
61: $view->addHelper('Tag');
62: $view->channels = $channels;
63: $view->search_img = Horde::img('search.png');
64: $title = _("Feeds");
65: Horde::addScriptFile('tables.js', 'horde', true);
66: Horde::addScriptFile('quickfinder.js', 'horde', true);
67: require $registry->get('templates', 'horde') . '/common-header.inc';
68: require JONAH_TEMPLATES . '/menu.inc';
69: echo $view->render('channellist');
70: require $registry->get('templates', 'horde') . '/common-footer.inc';
71: }
72:
73: }