<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
<?php

class DATTR_HELP_ITEM
{
	private $name;
	private $desc;
	private $tips;
	private $syntax;
	private $example;

	function __construct($name, $desc, $tips = NULL, $syntax = NULL, $example = NULL) {

		$this->name = $name;
		$this->desc = $desc;
		$this->tips = str_replace('<br>', '<br/>', $tips);
		$this->syntax = $syntax;
		$this->example = $example;
	}

	function render($key, $blocked_reason='')
	{
		$key = str_replace(array(':','_'), '', $key );
		$buf = '<img class="xtip-hover-' . $key . '" src="/static/images/icons/help.png">'
			. '<div id="xtip-note-' . $key . '" class="snp-mouseoffset notedefault"><b>'
			. $this->name
			. '</b>' ;
        if ($blocked_reason) {
            $buf .= " <i>$blocked_reason</i>";
        }
		$buf .= '<hr size=1 color=black>'
			. $this->desc
			. '<br><br>';
		if ($this->syntax) {
			$buf .= '<strong>Syntax:</strong> '
				. $this->syntax
				. '<br><br>';
		}
		if ($this->example) {
			$buf .= '<strong>Example:</strong> '
				. $this->example
				. '<br><br>';
		}
		if ($this->tips) {
			$buf .= '<strong>Tip(s):</strong><ul type=circle>';
			$tips = explode('<br/>', $this->tips);
			foreach($tips as $ti) {
				$ti = trim($ti);
				if ($ti != '')
					$buf .= '<li>' . $ti . '</li>';
			}
			$buf .= '</ul>';
		}

		$buf .= '</div>';
		return $buf;
	}


	function render0($key, $blocked_version=0)
	{
		$key = str_replace(array(':','_'), '', $key );
		$buf = '<img class="xtip-hover-' . $key . '" src="/static/images/icons/help.png">'
			. '<div id="xtip-note-' . $key . '" class="snp-mouseoffset notedefault"><b>'
			. $this->name
			. '</b>' ;
		switch ($blocked_version) {
			case 0: break;
			case 1:  // LSWS ENTERPRISE;
				$buf .= ' <i>This feature is available in Enterprise Edition</i>';
				break;
			case 2: // LSWS 2CPU +
			case 3: // LSLB 2CPU +
				$buf .= ' <i>This feature is available for Multiple-CPU license</i>';
				break;
			//case 4: // NCPU
			//	$buf .= ' <i>This feature is available for Unlimited-CPU license</i>';
			//	break;
		}
		$buf .= '<hr size=1 color=black>'
			. $this->desc
			. '<br><br>';
		if ($this->syntax) {
			$buf .= '<strong>Syntax:</strong> '
				. $this->syntax
				. '<br><br>';
		}
		if ($this->example) {
			$buf .= '<strong>Example:</strong> '
				. $this->example
				. '<br><br>';
		}
		if ($this->tips) {
			$buf .= '<strong>Tip(s):</strong><ul type=circle>';
			$tips = explode('<br/>', $this->tips);
			foreach($tips as $ti) {
				$ti = trim($ti);
				if ($ti != '')
					$buf .= '<li>' . $ti . '</li>';
			}
			$buf .= '</ul>';
		}

		$buf .= '</div>';
		return $buf;
	}

}

