<?php
defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Filter\OutputFilter;

$attributes = [];

// Atributos
if (!empty($item->anchor_title)) {
    $attributes['title'] = $item->anchor_title;
}

$attributes['class'] = !empty($item->anchor_css)
    ? $item->anchor_css
    : "button-circle uk-button uk-button-default uk-button-small uk-border-circle";

if (!empty($item->anchor_rel)) {
    $attributes['rel'] = $item->anchor_rel;
}

$attributes['uk-tooltip'] = $item->title;

$linktype = $item->title;

    $imageAttributes = [];

    if (!empty($item->menu_image_css)) {
        $imageAttributes['class'] = $item->menu_image_css;
    }

    $linktype = HTMLHelper::_('image', $item->menu_image, $item->title, $imageAttributes);

    if (!empty($item->params) && $item->params->get('menu_text')) {
        $linktype .= '<span class="image-title uk-margin-small-bottom uk-margin-small-top">' . $item->title . '</span>';
    }


if ($item->browserNav == 1) {
    $attributes['target'] = '_blank';
    $attributes['rel'] = isset($attributes['rel'])
        ? $attributes['rel'] . ' noopener noreferrer'
        : 'noopener noreferrer';
} elseif ($item->browserNav == 2) {
    $options = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,' . $params->get('window_open');
    $attributes['onclick'] = "window.open(this.href, 'targetWindow', '" . $options . "'); return false;";
}

echo HTMLHelper::_(
    'link',
    OutputFilter::ampReplace(htmlspecialchars($item->flink, ENT_COMPAT, 'UTF-8', false)),
    $linktype,
    $attributes
);
