<?php
/**
 * @package     CMGiftCard
 * @subpackage  com_cmgiftcard
 * @copyright   Copyright (C) 2016-2024 CMExension
 * @license     GNU General Public License version 2 or later
 */

defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\MVC\View\HtmlView;

/**
 * View class for QR code scanner.
 *
 * @package     CMGiftCard
 * @subpackage  com_cmgiftcard
 * @since       2.1.0
 */
class CMGiftCardViewScanner extends HtmlView
{
	/**
	 * Method to display the view.
	 *
	 * @param   string  $tpl  A template file to load. [optional]
	 *
	 * @return  mixed  A string if successful, otherwise an Error object.
	 *
	 * @since   2.1.0
	 */
	public function display($tpl = null)
	{
		if (version_compare(JVERSION, '4.0.0-alpha1', '<'))
		{
			CMGiftCardHelper::addSubmenu('scanner');
			$this->sidebar = \JHtmlSidebar::render();
			$this->setLayout('default3');
		}

		$this->addToolbar();

		return parent::display($tpl);
	}

	/**
	 * Add the page title and toolbar.
	 *
	 * @return  void
	 *
	 * @since   2.1.0
	 */
	protected function addToolbar()
	{
		$canDo = JHelperContent::getActions('com_cmgiftcard');
		JToolbarHelper::title(Text::_('COM_CMGIFTCARD_MANAGER_SCANNER'), 'tools');
	}
}
