public function a()
{
return _class('html')->a('/docs/html', 'Block me', 'fa fa-lock');
}
public function a()
{
$args = func_get_args();
$a = [];
// numerics params
if (isset($args[0]) && is_array($args[0])) {
$a = $args[0];
} elseif (isset($args[0])) {
$a['href'] = $args[0];
$a['title'] = $args[1];
$a['icon'] = $args[2];
$a['text'] = $args[3];
$a['class_add'] = $args[4];
$a['target'] = $args[5];
$a['no_text'] = $args[6];
// named params
} elseif (isset($args['link'])) {
$a = $args;
}
if (isset($args['extra']) && is_array($args['extra'])) {
foreach ($args['extra'] as $k => $v) {
$a[$k] = $v;
}
}
if ( ! isset($a['text'])) {
$a['text'] = $a['title'] ?: $a['href'];
}
if ($a['href'] && substr($a['href'], 0, strlen('http')) !== 'http' && substr($a['href'], 0, strlen('//')) !== '//') {
$a['href'] = url($a['href']);
}
if ( ! isset($a['class'])) {
$a['class'] = 'btn btn-default btn-mini btn-xs';
}
if ($a['class_add']) {
$a['class'] .= ' ' . $a['class_add'];
}
if ( ! isset($a['target'])) {
$a['target'] = '_blank';
}
$icon = '';
if (isset($a['icon'])) {
$icon = [];
if ( ! is_array($a['icon'])) {
$a['icon'] = [$a['icon']];
}
foreach ((array) $a['icon'] as $i) {
$icon[] = '<i class="' . $i . '"></i>';
}
$icon = implode(' ', $icon);
}
return '<a' . _attrs($a, ['href', 'title', 'class', 'style', 'id', 'rel', 'target', 'disabled']) . '>' . $icon . ($a['no_text'] ? '' : (strlen($a['text']) ? ($icon ? ' ' : '') . _prepare_html($a['text']) : '')) . '</a>';
}