<?php
/*
 * Software Name: Eorisis Setup
 * Software URI: https://eorisis.com/shop/software/joomla/setup
 * Author: Eorisis
 * Author URI: https://eorisis.com
 * Copyright: Copyright (C) 2011-2025 EORISIS. All Rights Reserved.
 * License: GNU General Public License version 2; See https://eorisis.com/gpl
 * Terms of Service: https://eorisis.com/tos
 */
defined('_JEXEC') or die;

if (!class_exists('eorisis_setup\framework\lib\eorisis', false))
{
	// Executing the autoloader
	$namespace_path = JPATH_PLUGINS.'/installer/eorisis_setup/framework/lib';
	require_once $namespace_path.'/eorisis.php';
	$eorisis = new \eorisis_setup\framework\lib\eorisis($namespace_path);
	$eorisis->register();
}

use eorisis_setup\framework\lib\core\cms\form as cms_form;
use eorisis_setup\framework\lib\core\view\help;

if (!class_exists('EorisisFormField', false))
{
	if (version_compare(JVERSION, '3.8', '>='))
	{
		JLoader::registerAlias('EorisisFormField', '\\Joomla\\CMS\\Form\\FormField');
	}
	else
	{
		JLoader::registerAlias('EorisisFormField', 'JFormField');
	}
}

class JFormFieldOnoff extends EorisisFormField
{
	protected $type = 'onoff';
	protected $form;

	// --------------------------------------------------

	protected function getLabel() : string
	{
		return parent::getLabel().help::icon($this->element);
	}

	// --------------------------------------------------

	protected function getInput() : string
	{
		\eorisis_setup\framework\lib\core\model\form::set($this->form);

		if (!$this->default)
		{
			$this->default = 0;
		}

		$options[1] = 'JON';
		$options[0] = 'JOFF';
		return cms_form::switcher((string)$this->element['name'], $options, $this->default, ['is_binary' => true]);
	}
}
