| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 | <?php/** * Define a address. * @author Valentin CARRUESCO * @category Plugin * @license copyright */class Address extends Entity{	public $id,$entity_id,$entity,$label,$type,$street,$complement,$city,$zip,$country,$state;	public $fields =	array(		'id' => 'key',		'entity_id' => 'int',		'entity' => 'string',		'label' => 'string',		'type' => 'string',		'street' => 'string',		'complement' => 'string',		'city' => 'string',		'zip' => 'string',		'country' => 'string',		'state' => 'string'	);	public function mapUrl(){		$encoded = urlencode($this->street).', '.urlencode($this->zip).' '.urlencode($this->city);		return 'https://www.google.com/maps/place/'.$encoded;	}	//retourne l'adresse sur une seule ligne au format street, complement, zip city country	public function fullName(){		if($this->id==0) return '';		$fullname = '';		if(!empty($this->street)) $fullname .= $this->street;		if(!empty($this->complement)) $fullname .= ', '.$this->complement;		if($fullname!='') $fullname .= ', ';		if(!empty($this->zip)) $fullname .= $this->zip;		if(!empty($this->city)) $fullname .= ' '.$this->city;		if(!empty($this->country)) $fullname .= ' '.$this->country;		return $fullname;	}	//remplis un composant location à partir des infos de la classe courante	public function toDataAttributes($plainText = true){		$array = array();		$plain = '';		foreach (array('street','complement','city','zip','country') as $key) {			$array[$key] = $this->$key;			$plain = ' data-'.$key.' = "'.(empty($this->$key) ? '' : $this->$key).'"';		}		return !$plainText ? $array : $plain;			}}?>
 |