Overview

Packages

  • Jonah
  • None

Classes

  • Jonah_Application
  • Jonah_Block_Cloud
  • Jonah_Block_Delivery
  • Jonah_Block_News
  • Jonah_Block_NewsPopular
  • Jonah_Block_Story
  • Jonah_View_Base
  • Jonah_View_DeliveryHtml
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Script to handle requests for html delivery of stories.
 4:  *
 5:  * Copyright 2004-2012 Horde LLC (http://www.horde.org/)
 6:  *
 7:  * See the enclosed file LICENSE for license information (BSD). If you did not
 8:  * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE.
 9:  *
10:  * @author Jan Schneider <jan@horde.org>
11:  */
12: class Jonah_View_DeliveryHtml extends Jonah_View_Base
13: {
14:     /**
15:      * $registry
16:      * $notification
17:      * $conf
18:      * $criteria
19:      *
20:      */
21:     public function run()
22:     {
23:         extract($this->_params, EXTR_REFS);
24:         $templates = Horde::loadConfiguration('templates.php', 'templates', 'jonah');
25: 
26:         /* Get requested channel. */
27:         try {
28:             $channel = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($criteria['feed']);
29:         } catch (Exception $e) {
30:             Horde::logMessage($e, 'ERR');
31:             $notification->push(_("Invalid channel."), 'horde.error');
32:             Horde::url('delivery/index.php', true)->redirect();
33:             exit;
34:         }
35: 
36:         $title = sprintf(_("HTML Delivery for \"%s\""), $channel['channel_name']);
37: 
38:         $options = array();
39:         foreach ($templates as $key => $info) {
40:             $options[] = '<option value="' . $key . '"' . ($key == $criteria['format'] ? ' selected="selected"' : '') . '>' . $info['name'] . '</option>';
41:         }
42: 
43:         $template = new Horde_Template();
44:         $template->setOption('gettext', 'true');
45:         $template->set('url', Horde::selfUrl());
46:         $template->set('session', Horde_Util::formInput());
47:         $template->set('channel_id', $criteria['feed']);
48:         $template->set('channel_name', $channel['channel_name']);
49:         $template->set('format', $criteria['format']);
50:         $template->set('options', $options);
51: 
52:         // @TODO: This is ugly. storage driver shouldn't be rendering any display
53:         // refactor this to use individual views possibly with a choice of different templates
54:         $template->set('stories', $GLOBALS['injector']->getInstance('Jonah_Driver')->renderChannel($criteria['feed'], $criteria['format']));
55:         $template->set('menu', Horde::menu(array('menu_obj' => true)));
56: 
57:         // Buffer the notifications and send to the template
58:         Horde::startBuffer();
59:         $GLOBALS['notification']->notify(array('listeners' => 'status'));
60:         $template->set('notify', Horde::endBuffer());
61: 
62:         require $registry->get('templates', 'horde') . '/common-header.inc';
63:         echo $template->fetch(JONAH_TEMPLATES . '/delivery/html.html');
64:         require $registry->get('templates', 'horde') . '/common-footer.inc';
65:     }
66: 
67: }
API documentation generated by ApiGen