<?php
/**
 *---------------------------------------------------------------------------------------
 * @package       VP Smart Template
 *---------------------------------------------------------------------------------------
 * @copyright     Copyright (C) 2012-2021 VirtuePlanet Services LLP. All rights reserved.
 * @license       GNU General Public License version 2 or later; see LICENSE.txt
 * @authors       Abhishek Das
 * @email         info@virtueplanet.com
 * @link          https://www.virtueplanet.com
 *---------------------------------------------------------------------------------------
 */
defined('_JEXEC') or die;

// Note. It is important to remove spaces between elements.
$class = $item->anchor_css ? 'class="' . $item->anchor_css . '" ' : '';
$title = $item->anchor_title ? 'title="' . $item->anchor_title . '" ' : '';

if ($item->menu_image)
{
	$item->params->get('menu_text', 1) ?
	$linktype = '<img src="' . $item->menu_image . '" alt="' . $item->title . '" /><span class="image-title">' . $item->title . '</span> ' :
	$linktype = '<img src="' . $item->menu_image . '" alt="' . $item->title . '" />';
}
else
{
	$linktype = $item->title;
}

if($item->deeper)
{
	$linktype .= '<span class="opener"></span>';
}

$dataTag = '';

if($item->params->get('vpf_modal_login', 0))
{
	if ($item->params->get('loginredirectchoice', 0))
	{
		$login_return = VPFrameworkLogin::getReturnURL($item->params, 'login_redirect_menuitem');
	}
	else
	{
		$login_return = VPFrameworkLogin::getReturnURL($item->params->get('login_redirect_url'));
	}
	
	if ($item->params->get('logoutredirectchoice', 0))
	{
		$logout_return = VPFrameworkLogin::getReturnURL($item->params, 'logout_redirect_menuitem');
	}
	else
	{
		$logout_return = VPFrameworkLogin::getReturnURL($item->params->get('logout_redirect_url'));
	}
	
	$dataTag  = ' data-modallogin="1"';
	$dataTag .= ' data-loginreturn="' . htmlspecialchars($login_return) . '"';
	$dataTag .= ' data-logoutreturn="' . htmlspecialchars($logout_return) . '" ';
}

switch ($item->browserNav)
{
	default:
	case 0:
?><a <?php echo $class . $dataTag; ?>href="<?php echo $item->flink; ?>" <?php echo $title; ?>><?php echo $linktype; ?></a><?php
		break;
	case 1:
		// _blank
?><a <?php echo $class . $dataTag; ?>href="<?php echo $item->flink; ?>" target="_blank" <?php echo $title; ?>><?php echo $linktype; ?></a><?php
		break;
	case 2:
	// Use JavaScript "window.open"
?><a <?php echo $class . $dataTag; ?>href="<?php echo $item->flink; ?>" onclick="window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');return false;" <?php echo $title; ?>><?php echo $linktype; ?></a>
<?php
		break;
}
