server/onyx/modules/templates/smarty/plugins/function.link.php

64 lines
1.4 KiB
PHP
Raw Normal View History

2013-11-29 02:10:12 +00:00
<?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'];
2015-01-14 11:35:37 +00:00
if (!defined("DEBUG") || !DEBUG)
2013-11-29 02:10:12 +00:00
{
$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'];
2015-01-16 20:01:42 +00:00
else
$href .= "/";
2013-11-29 02:10:12 +00:00
}
$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;
}