<?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
 */
namespace eorisis_setup\framework\lib\core\view;
\defined('_JEXEC') or die;

use eorisis_setup\framework\lib\core\app\config as app_config;
use eorisis_setup\framework\lib\core\cms\language as cms_language;
use eorisis_setup\framework\lib\core\model\params;

app_config::init();
\define('EORISIS_HELP_SRC_URI', app_config::media_uri_relative(false).'/assets/images/help-circle-solid.svg');

class help
{
	public function __construct() {}

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

	public static function label($element) : string
	{
		$key = params::field_value('label', $element);
		if (!$key)
		{
			$key = 'EO_HELP';
		}

		return '<label>'.cms_language::text($key).'</label>'.self::icon($element);
	}

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

	public static function icon($element) : string
	{
		$key = params::field_value('help', $element);
		if (!$key)
		{
			return '';
		}

		$txt = cms_language::text($key);
		$txt = \str_replace(["'",'"'], ['&#39;','&quot;'], $txt);

		$html  = '<div class="help-tip">';
		$html .=	'<img src="'.EORISIS_HELP_SRC_URI.'" alt="help">';
		$html .=	'<span>'.$txt.'</span>';
		$html .= '</div>';
		return $html;
	}
}
