server/onyx/modules/templates/smarty/plugins/function.link.php
2015-01-23 01:59:23 +01:00

64 lines
1.4 KiB
PHP

<?php
function smarty_function_link($params, $template)
{
if (!isset($params['href']))
{
trigger_error("link: missing 'href' parameter", E_USER_WARNING);
return;
}
else
$href = $params['href'];
if (!empty($params['href_prefix']))
$href = $params['href_prefix'] . $href;
if (!empty($params['href_suffix']))
$href = $href . $params['href_suffix'];
if (empty($params['label']))
$label = $href;
else
$label = $params['label'];
if (!defined("DEBUG") || !DEBUG)
{
$href_de = $href;
if (!empty($params['href']))
{
$href = hash('whirlpool', $href);
if (!empty($params['href_prefix']))
$href = $params['href_prefix'] . $href;
if (!empty($params['href_suffix']))
$href = $href . $params['href_suffix'];
else
$href .= "/";
}
$urls = Cache::read("urls");
if (empty($urls[$href]) || $urls[$href] != $href_de)
{
$urls[$href] = $href_de;
Cache::set("urls", $urls);
}
unset($urls);
}
$more = "";
if (!empty($params['class']))
$more .= ' class="' . $params['class'] . '"';
if (!empty($params['data-toggle']))
$more .= ' data-toggle="' . $params['data-toggle'] . '"';
if (!empty($params['role']))
$more .= ' role="' . $params['role'] . '"';
if (!isset($params['notag']))
return '<a href="' . $href . '"' . $more . '>' . $label . '</a>';
else
return $href;
}