<?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\Problems;

defined('_JEXEC') or die;

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

/**
 * 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->title = Text::_('COM_MEFISASSETBRIDGE_PROBLEMS_TITLE');
        $this->description = Text::_('COM_MEFISASSETBRIDGE_PROBLEMS_DESC');
        $this->buttonLink = Uri::base() . 'index.php?option=com_mefisassetbridge&view=auth';
        $this->buttonText = Text::_('COM_MEFISASSETBRIDGE_PROBLEMS_BUTTON_TEXT');
        $this->addToolbar();

        parent::display($tpl);
    }

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

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

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

}