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] ?? null;
$a['icon'] = $args[2] ?? null;
$a['text'] = $args[3] ?? null;
$a['class_add'] = $args[4] ?? null;
$a['target'] = $args[5] ?? null;
$a['no_text'] = $args[6] ?? null;
// 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'] ?? null) ?: ($a['href'] ?? null);
}
if (($a['href'] ?? null) && substr($a['href'], 0, strlen('http')) !== 'http' && substr($a['href'], 0, strlen('//')) !== '//') {
$a['href'] = url($a['href']);
}
// conf can change after _init() (demo and test pages); follow it as form2 / table2 do, so they agree
(conf('css_framework') === 'bs5') !== (bool) $this->_is_bs5 && $this->_init();
if ( ! isset($a['class'])) {
$a['class'] = $this->CLASS_LINK_BTN;
}
if ($a['class_add'] ?? null) {
$a['class'] = $this->_is_bs5 ? $this->_bs5_btn_class($a['class'], $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'] ?? null) ? '' : (strlen($a['text']) ? ($icon ? ' ' : '') . _prepare_html($a['text']) : '')) . '</a>';
}