<?php
/*
 * Software Name: Eorisis Pixels
 * Software URI: https://eorisis.com/shop/software/joomla/pixels
 * 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;

use com_eorisis_pixels\framework\lib\core\model\form as form_model;
use com_eorisis_pixels\framework\lib\core\model\params;
use com_eorisis_pixels\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 JFormFieldCustomoff extends EorisisFormField
{
	protected $type = 'customoff';
	protected $form;

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

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

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

	protected function getInput() : string
	{
		form_model::set($this->form);

		$use_global = params::field_value('use_global', $this->element) == 'true';
		if ($use_global)
		{
			$options['global'] = 'EO_USE_GLOBAL';
		}

		$options['custom'] = 'EO_CUSTOM';
		$options['off'] = 'EO_OFF';
		return form_model::select((string)$this->element['name'], $options, $this->default);
	}
}
