fetch() public method

Fetches a template from the specified file and return the parsed contents.
public fetch ( string $filename = null ) : string
$filename string The file to fetch the template from.
return string The parsed template.
Esempio n. 1
0
 /**
  * $registry
  * $notification
  * $conf
  * $criteria
  *
  */
 public function run()
 {
     extract($this->_params, EXTR_REFS);
     $templates = Horde::loadConfiguration('templates.php', 'templates', 'jonah');
     /* Get requested channel. */
     try {
         $channel = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($criteria['feed']);
     } catch (Exception $e) {
         Horde::log($e, 'ERR');
         $notification->push(_("Invalid channel."), 'horde.error');
         Horde::url('delivery/index.php', true)->redirect();
         exit;
     }
     $title = sprintf(_("HTML Delivery for \"%s\""), $channel['channel_name']);
     $options = array();
     foreach ($templates as $key => $info) {
         $options[] = '<option value="' . $key . '"' . ($key == $criteria['format'] ? ' selected="selected"' : '') . '>' . $info['name'] . '</option>';
     }
     $template = new Horde_Template();
     $template->setOption('gettext', 'true');
     $template->set('url', Horde::selfUrl());
     $template->set('session', Horde_Util::formInput());
     $template->set('channel_id', $criteria['feed']);
     $template->set('channel_name', $channel['channel_name']);
     $template->set('format', $criteria['format']);
     $template->set('options', $options);
     // @TODO: This is ugly. storage driver shouldn't be rendering any display
     // refactor this to use individual views possibly with a choice of different templates
     $template->set('stories', $GLOBALS['injector']->getInstance('Jonah_Driver')->renderChannel($criteria['feed'], $criteria['format']));
     // Buffer the notifications and send to the template
     Horde::startBuffer();
     $GLOBALS['notification']->notify(array('listeners' => 'status'));
     $template->set('notify', Horde::endBuffer());
     $GLOBALS['page_output']->header(array('title' => $title));
     echo $template->fetch(JONAH_TEMPLATES . '/delivery/html.html');
     $GLOBALS['page_output']->footer();
 }
Esempio n. 2
0
File: time.php Progetto: horde/horde
        $item = $vars->get('item');
        if (is_null($item) || !count($item)) {
            $notification->push(_("No timeslices were selected to submit."), 'horde.error');
        } else {
            foreach (array_keys($item) as $id) {
                $time[] = array('id' => $id);
            }
            try {
                $GLOBALS['injector']->getInstance('Hermes_Driver')->markAs('submitted', $time);
                $notification->push(_("Your time was successfully submitted."), 'horde.success');
                $vars = new Horde_Variables();
            } catch (Horde_Exception $e) {
                $notification->push(sprintf(_("There was an error submitting your time: %s"), $e->getMessage()), 'horde.error');
            }
        }
        break;
}
// We are displaying all time.
$tabs = Hermes::tabs();
$criteria = array('employee' => $GLOBALS['registry']->getAuth(), 'submitted' => false, 'link_page' => 'time.php');
$table = new Hermes_Table('week', $vars, array('title' => _("My Unsubmitted Time"), 'name' => 'hermes/hours', 'params' => $criteria));
$template = new Horde_Template();
$template->setOption('gettext', true);
$template->set('postUrl', Horde::url('time.php', false, -1));
$template->set('sessionId', Horde_Util::formInput());
$template->set('table', $table->render());
$page_output->header(array('title' => _("My Time")));
$notification->notify(array('listeners' => 'status'));
echo $tabs;
echo $template->fetch(HERMES_TEMPLATES . '/time/form.html');
$page_output->footer();
Esempio n. 3
0
File: feed.php Progetto: horde/horde
$options = array();
foreach ($templates as $key => $info) {
    $options[] = '<option value="' . $key . '"' . ($key == $criteria['channel_format'] ? ' selected="selected"' : '') . '>' . $info['name'] . '</option>';
}
if (empty($criteria['channel_id']) && !empty($criteria['feed'])) {
    $criteria['channel_id'] = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannelId($criteria['feed']);
}
if (empty($criteria['channel_id'])) {
    $notification->push(_("No valid feed name or ID requested."), 'horde.error');
} else {
    $stories = $GLOBALS['injector']->getInstance('Jonah_Driver')->getStories($criteria);
}
if (!empty($stories)) {
    die(print_r($stories, true));
}
$template = new Horde_Template();
$template->setOption('gettext', 'true');
$template->set('url', Horde::selfUrl());
$template->set('session', Horde_Util::formInput());
$template->set('channel_id', $criteria['channel_id']);
$template->set('channel_name', $channel['channel_name']);
$template->set('format', $criteria['channel_format']);
$template->set('options', $options);
$template->set('stories', $news->renderChannel($criteria['channel_id'], $criteria['channel_format']));
// Buffer the notifications and send to the template
Horde::startBuffer();
$GLOBALS['notification']->notify(array('listeners' => 'status'));
$template->set('notify', Horde::endBuffer());
$page_output->header();
echo $template->fetch(JONAH_TEMPLATES . '/delivery/html.html');
$page_output->footer();
Esempio n. 4
0
    $template->set('channel_name', htmlspecialchars($channel['channel_name']));
}
$template->set('channel_desc', htmlspecialchars($channel['channel_desc']));
$template->set('channel_updated', htmlspecialchars(date('r', $channel['channel_updated'])));
$template->set('channel_official', htmlspecialchars($channel['channel_official']));
$template->set('channel_rss', htmlspecialchars(Horde::url('delivery/rss.php', true, -1)->add(array('type' => 'rss', 'channel_id' => $channel['channel_id']))));
$template->set('channel_rss2', htmlspecialchars(Horde::url('delivery/rss.php', true, -1)->add(array('type' => 'rss2', 'channel_id' => $channel['channel_id']))));
foreach ($stories as &$story) {
    $story['title'] = htmlspecialchars($story['title']);
    $story['description'] = htmlspecialchars($story['description']);
    $story['permalink'] = htmlspecialchars($story['permalink']);
    $story['storylink'] = htmlspecialchars($driver->getStoryLink($channel, $story));
    $story['published'] = htmlspecialchars(date('r', $story['published']));
    $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($story['author']);
    if ($name = $identity->getValue('fullname')) {
        $story['author'] = htmlspecialchars($name);
    } else {
        $story['author'] = htmlspecialchars($story['author']);
    }
    if (!empty($story['body_type']) && $story['body_type'] == 'text') {
        $story['body'] = $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($story['body'], 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO));
    }
}
$template->set('stories', $stories);
$browser->downloadHeaders($channel['channel_name'] . '.rss', 'text/xml', true);
$tpl = JONAH_TEMPLATES . '/delivery/' . $criteria['feed_type'];
if (!empty($channel['channel_full_feed'])) {
    $tpl .= '_full';
}
echo $template->fetch($tpl . '.xml');
Esempio n. 5
0
require_once CLOUDBANK_BASE . '/lib/Cloudbank.php';
require_once CLOUDBANK_BASE . '/lib/Book.php';
/* main() */
$g_isError = FALSE;
try {
    $g_accountsOrCategories = Book::Singleton()->getAccountsOrCategoriesWBalance($g_account_type);
    CloudBank::AddLinks($g_accountsOrCategories, 'events.php', array('ledger_account_id' => 'id', 'ledger_account_type' => 'type'), 'name', 'account_link');
    if ($g_account_type == CloudBankConsts::LedgerAccountType_Account) {
        CloudBank::AddLinks($g_accountsOrCategories, 'account_or_category.php', array('account_id' => 'id', 'name' => 'name', 'account_type' => 'type', 'beginning_balance' => 'beginning_balance'), 'edit_icon', 'edit_icon_link', NULL, 'Edit');
    } else {
        CloudBank::AddLinks($g_accountsOrCategories, 'account_or_category.php', array('account_id' => 'id', 'name' => 'name', 'account_type' => 'type'), 'edit_icon', 'edit_icon_link', NULL, 'Edit');
    }
    CloudBank::AddLinks($g_accountsOrCategories, 'delete_account.php', array('account_id' => 'id', 'account_type' => 'type'), 'delete_icon', 'delete_icon_link', NULL, 'Delete');
    Book::SortResultSet($g_accountsOrCategories, 'name');
    $g_total = $g_account_type == CloudBankConsts::LedgerAccountType_Account ? Book::Singleton()->getAccountsTotal() : Book::Singleton()->getCategoriesTotal();
    $g_template = new Horde_Template();
    $g_template->set('new_account_link', Horde::link(Horde::url('account_or_category.php')->add(array('account_type' => $g_account_type))) . 'New</a>');
    $g_template->set('accounts', $g_accountsOrCategories);
    $g_template->set('total', $g_total);
    $title = _($g_account_type == CloudBankConsts::LedgerAccountType_Account ? "Accounts" : "Categories");
} catch (Exception $v_exception) {
    Cloudbank::PushError(Book::XtractMessage($v_exception));
    $g_isError = TRUE;
}
$page_output->header();
$notification->notify(array('listeners' => 'status'));
if (!$g_isError) {
    //$g_template->setOption('debug', true);
    echo $g_template->fetch(CLOUDBANK_TEMPLATES . '/accounts.html');
}
$page_output->footer();