<?php
// declare(encoding='UTF-8');
/**
 * Service gérant la completion des noms de lieux.
 *
 * Cas d'utilisation :
 * Service completion nom de commune (plus tard de lieu en général)
 *
 * 1 : L'application recoit un debut de nom de lieu
 * 2 : Si la longueur du prefixe est > 2, l'application retourne les 50 premieres lieux commencant par ce prefixe
 *
 * @internal   Mininum PHP version : 5.2
 * @category   CEL
 * @package    Services
 * @subpackage Auto-complétions
 * @version    0.1
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
 */

class LocationSearch extends Cel {

	public function getElement($uid){
		$retour = array();

		if (isset($uid[0])) {
			$retour = $this->executerRequeteLieu($uid[0]);
		}

		$this->envoyerJson($retour);
		return true;
	}

	public function getRessource() {
		print '[]';
		return;
	}

	private function executerRequeteLieu($lieu) {
		$recherche_infos_zone_geo = new RechercheInfosZoneGeo($this->config);
		return $recherche_infos_zone_geo->obtenirListeInfosPourNom($lieu);
	}
}