You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
engelsystem/includes/sys_template.php

58 lines
1.5 KiB
PHTML

14 years ago
<?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 &laquo;' . $file . '&raquo;.');
}
}
14 years ago
function shorten($str) {
if (strlen($str) < 50)
return $str;
13 years ago
return '<span title="' . htmlentities($str, ENT_COMPAT, 'UTF-8') . '">' . substr($str, 0, 47) . '...</span>';
}
function table_body($array) {
$html = "";
foreach ($array as $line) {
$html .= "<tr>";
if (is_array($line)) {
foreach ($line as $td)
$html .= "<td>" . $td . "</td>";
} else {
$html .= "<td>" . $line . "</td>";
}
$html .= "</tr>";
}
return $html;
}
14 years ago
function html_options($name, $options, $selected = "") {
$html = "";
foreach ($options as $value => $label)
14 years ago
$html .= '<input type="radio"' . ($value == $selected ? ' checked="checked"' : '') . ' name="' . $name . '" value="' . $value . '"> ' . $label;
14 years ago
return $html;
}
14 years ago
function html_select_key($name, $rows, $selected) {
$html = '<select name="' . $name . '">';
foreach ($rows as $key => $row)
if (($key == $selected) || ($row == $selected))
$html .= '<option value="' . $key . '" selected="selected">' . $row . '</option>';
else
$html .= '<option value="' . $key . '">' . $row . '</option>';
$html .= '</select>';
return $html;
}
?>