miniflux-legacy/app/core/template.php
Frederic Guillot 82df35a59b Change the database structure to have a single database
This is a major change for the next release of Miniflux.

- There is now only one database that can supports multiple users
- There is no automated schema migration for this release
- A migration procedure is available in the ChangeLog file
2016-12-26 09:51:38 -05:00

40 lines
898 B
PHP

<?php
namespace Miniflux\Template;
use Miniflux\Model;
const PATH = 'app/templates/';
// Template\load('template_name', ['bla' => 'value']);
function load()
{
if (func_num_args() < 1 || func_num_args() > 2) {
die('Invalid template arguments');
}
if (! file_exists(PATH.func_get_arg(0).'.php')) {
die('Unable to load the template: "'.func_get_arg(0).'"');
}
if (func_num_args() === 2) {
if (! is_array(func_get_arg(1))) {
die('Template variables must be an array');
}
extract(func_get_arg(1));
}
ob_start();
include PATH.func_get_arg(0).'.php';
return ob_get_clean();
}
function layout($template_name, array $template_args = array(), $layout_name = 'layout')
{
return load(
$layout_name,
$template_args + array('content_for_layout' => load($template_name, $template_args))
);
}