<?php
/**
 * @package     MefisAssetBridge
 * @subpackage  Joomla_Administrator_Component
 *
 * @copyright   Copyright (C) 2025 Goran Usljebrka. All rights reserved.
 * @license     Proprietary — No resale or incorporation into other projects without explicit written permission. see LICENSE.txt
 */

namespace Mefi\Component\MefisAssetBridge\Administrator\View\Auth;

defined('_JEXEC') or die;

use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Factory;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Uri\Uri;

/**
 * Auth HTML View class for the MefisAssetBridge component
 *
 * @since  1.0.0
 */
class HtmlView extends BaseHtmlView
{
    /**
     * Component parameters
     *
     * @var    \Joomla\Registry\Registry
     * @since  1.0.0
     */
    protected $params;

    /**
     * Application instance
     *
     * @var    CMSApplication
     * @since  1.0.0
     */
    protected $app;

    /**
     * Display the view
     *
     * @param   string  $tpl  The name of the template file to parse
     *
     * @return  void
     *
     * @since   1.0.0
     */
    public function display($tpl = null)
    {

        $this->app = Factory::getApplication();
        $this->params = ComponentHelper::getParams('com_mefisassetbridge');

        $this->addToolbar();
        // get authenticated user
        $this->user = $this->app->getIdentity();

        // Get active tab from URL or default to login
        $this->activeTab = $this->app->input->get('tab', 'login');

        parent::display($tpl);
    }

    /**
     * Add the page title and toolbar
     *
     * @return  void
     *
     * @since   1.0.0
     */
    protected function addToolbar()
    {
        ToolbarHelper::title(Text::_('COM_MEFISASSETBRIDGE_AUTH_TITLE'), 'key');

        // Add logout button
        $toolbar = Toolbar::getInstance('toolbar');

        $toolbar->preferences('com_mefisassetbridge');
    }

}