2011-06-02 00:48:29 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
// Load and render template
|
|
|
|
function template_render($file, $data) {
|
|
|
|
if (file_exists($file)) {
|
|
|
|
$template = file_get_contents($file);
|
|
|
|
if (is_array($data))
|
|
|
|
foreach ($data as $name => $content) {
|
|
|
|
$template = str_replace("%" . $name . "%", $content, $template);
|
|
|
|
}
|
|
|
|
return $template;
|
|
|
|
} else {
|
|
|
|
die('Cannot find template file «' . $file . '».');
|
|
|
|
}
|
|
|
|
}
|
2011-06-02 16:56:45 +02:00
|
|
|
|
|
|
|
function html_options($name, $options, $selected = "") {
|
|
|
|
$html = "";
|
|
|
|
foreach ($options as $value => $label)
|
|
|
|
$html .= '<input type="radio"' . ($value == $selected ? ' selected="selected"' : '') . ' name="' . $name . '" value="' . $value . '"> ' . $label;
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
2011-06-02 00:48:29 +02:00
|
|
|
?>
|