HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/api/form/class.field.radio.php
<?php
/**
 * This file contains the iwp_field_radio class
 *
 * @version $Id$
 * 
 *
 * @package IWP
 * @subpackage IWP_FormFields
 */

/**
 * Radio Field Class
 * This class is used by the api form class to generate a set of radio fields.
 * It takes a list of options and outputs a radio field.
 *
 * @package IWP
 * @subpackage IWP_FormFields
 */

class iwp_field_radio extends iwp_field {
	/**
	 * This is the form field type of the field
	 *
	 * @var string
	 */
	public $type = 'radio';

	/**
	 * __construct
	 * The constructor which calls the parent constructor that sets up the field name if it is passed in during the initialization
	 *
	 * @var string
	 */
	function __construct($name=null){
		parent::__construct($name);
	}

	/**
	 * GetFieldOutput
	 * Returns the HTML for this field. It generates the relevant parts, assigns them to template variables and returns a parse template file.
	 *
	 * @return string Returns the field HTML
	 */
	function GetFieldOutput($setOnly=false){
		$inputField = $this->Prepend;
		if(is_array($this->FieldOptions)){
			foreach($this->FieldOptions as $k=>$_val) {
				$checked = '';
				if(is_array($this->FieldValue)){
					if(in_array($k, $this->FieldValue)){
						$checked = 'checked=\'checked\'';
					}
				}else{
					if($this->FieldValue == $k){
						$checked = 'checked=\'checked\'';
					}
				}

				$inputField .= '<input type="radio" id="'. iwp_htmlspecialchars($this->FieldName) .'_'. iwp_htmlspecialchars($k) .'"  style="margin-right:5px;" name="'. iwp_htmlspecialchars($this->FieldName) .'" ';
				$inputField .= $this->GetAttributes();
				$inputField .= ' value="'. iwp_htmlspecialchars($k) .'" ' . $checked . ' /><label for="'. iwp_htmlspecialchars($this->FieldName) .'_'. iwp_htmlspecialchars($k) .'">'. sprintf($this->lang->Get('field_'.$this->FieldName.'_'.$k),$this->template->Get('ContentType', 'name_singular')).'</label><br />';
			}
		}

		$inputField .= $this->Append;

		parent::GetFieldOutput();

		$this->template->Assign('inputField', $inputField);

		if(!$setOnly){
			return $this->template->ParseTemplate('form.field', true);
		}
		return '';
	}

	/**
	 * Validate
	 * This is the function that data for this field is passed to to ensure it was submitted properly.
	 *
	 * @return string|boolean If the data is not valid, it will return false, if it is valid it will return a value
	 */
	function Validate($arrData){
		if(!isset($arrData[$this->FieldName])){
			return false;
		}else{
			return 'checked';
		}
	}

	/**
	 * LoadValue
	 * This is takes an array of data and picks of the value for this specific field and stores in in the FieldValue variable
	 *
	 * @return void Doesn't return anything
	 */
	public function LoadValue($arrData){
		if(isset($arrData[$this->FieldName])){
			if($arrData[$this->FieldName] == "checked" || $arrData[$this->FieldName] == "1" || $arrData[$this->FieldName] == "on"){
				$this->FieldValue = "checked";
			}
		}
	}
}