From 543b59ccbecdf438b99b888ed775f48046bb9981 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Sun, 14 Dec 2008 18:23:17 +0100 Subject: [PATCH] Adds name suggestions for entreprises in validation interface. --- include/validations/entreprises.inc.php | 39 +++++++++++++++++++++++----- templates/include/form.valid.entreprises.tpl | 4 +++ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/include/validations/entreprises.inc.php b/include/validations/entreprises.inc.php index 2e1cd9a..a16bc7d 100644 --- a/include/validations/entreprises.inc.php +++ b/include/validations/entreprises.inc.php @@ -37,6 +37,7 @@ class EntrReq extends Validate public $tel; public $fax; + public $suggestions; //TODO: addresses // }}} @@ -45,13 +46,37 @@ class EntrReq extends Validate public function __construct(User &$_user, $_id, $_name, $_acronym, $_url, $_email, $_tel, $_fax, $_stamp = 0) { parent::__construct($_user, true, 'entreprise', $_stamp); - $this->id = $_id; - $this->name = $_name; - $this->acronym = $_acronym; - $this->url = $_url; - $this->email = $_email; - $this->tel = $_tel; - $this->fax = $_fax; + $this->id = $_id; + $this->name = $_name; + $this->acronym = $_acronym; + $this->url = $_url; + $this->email = $_email; + $this->tel = $_tel; + $this->fax = $_fax; + + $separators = array("&", "(", ")", "-", "_", ",", ";", ".", ":", "/", "\\", "\'", "\""); + $replacement = array(" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "); + $name = explode(" ", $_name); + $name_array = array_map("trim", $name); + $length = count($name_array); + $where = ""; + for ($i = 0; $i < $length; $i++) { + if (strlen($name_array[$i]) > 2) { + if ($where !== "") { + $where .= " OR "; + } + $where .= "name LIKE '%" . $name_array[$i] . "%'"; + } + } + $res = XDB::iterator("SELECT name + FROM profile_job_enum + WHERE " + . $where); + $this->suggestions = "| "; + while ($sug = $res->next()) { + var_dump($sug); + $this->suggestions .= $sug['name'] . " | "; + } } // }}} diff --git a/templates/include/form.valid.entreprises.tpl b/templates/include/form.valid.entreprises.tpl index f822feb..637d7c3 100644 --- a/templates/include/form.valid.entreprises.tpl +++ b/templates/include/form.valid.entreprises.tpl @@ -26,6 +26,10 @@ {$valid->name} + Noms similaires existants : + {$valid->suggestions} + + Acronyme : {$valid->acronym} -- 2.1.4