<?php

require_once 'class.callforwardcriteriapropertycapability.php';

class CallForwardCriteriaProperty {

	private $mTitle;
	private $mName;
	private $mType;
	private $mMaxValue = null;
	private $mCapabilities = array();
		
	//returns the Name of the CriteriaProperty
	public function getPropertyName() {
		return $this->mName;
	}

	public function setPropertyName($name) {
		$this->mName = $name;
	}
	
	//returns the Name of the CriteriaProperty
	public function getPropertyTitle() {
		return $this->mTitle;
	}
	
	public function setPropertyTitle($title) {
		$this->mTitle = $title;
	}
	
	
	//returns the Type, eg. text, select, boolean
	public function getPropertyTypeName() {
		return $this->mType;		
	}
	
	public function setPropertyTypeName($type) {
		$this->mType = $type;
	}
	
	//returns the Type, eg. text, select, boolean
	public function getMaxValue() {
		return $this->mMaxValue;		
	}

	public function setMaxValue($len) {
		$this->mMaxValue = $len;		
	}
		
	public function addPropertyCapability(CallForwardCriteriaPropertyCapability $item) {
		$this->mCapabilities[] = $item;
	}
	
	//returns the possible Values, this is just neeeded if the type is select.
	public function getPropertyCapabilities() {
		return $this->mCapabilities;
	}
	
	public function descriptionToJSON() {
		$json_Data = array();
		$json_Data['name'] = CHtml::encode($this->mName);
		$json_Data['title'] = CHtml::encode($this->mTitle);
		$json_Data['type'] = $this->mType;
		if($this->mMaxValue != null) {
			$json_Data['maxvalue'] = $this->mMaxValue;
		}		
		//$json_Data['capabilities'] = array();

		foreach ($this->mCapabilities as $capa) {
			/*1
			$json_Data['propertyTypes'] = array();
			foreach ($this->mCallForwardCriteriaSubProperties as $property) {
				$json_Data['propertyTypes'][] = json_decode($property->descriptionToJSON());
			}	
			*/		
			$json_Data['capabilities'][$capa->getName()] = json_decode($capa->toJSON());
		}		
		
		return json_encode($json_Data);
	}
		
}