Changeset 2626


Ignore:
Timestamp:
Jan 31, 2012, 10:11:29 PM (8 years ago)
Author:
goya
Message:

fix reco avec M. Mme

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/lib/model/doctrine/PersonnaliteTable.class.php

    r2617 r2626  
    88  protected $all = null;
    99
    10   public function similarToCheckPrenom($str, $sexe = null, $return_array = 0, $year = 0) {
     10  public function cleanString($str) {
     11    $str = preg_replace('/^\s+/', '', preg_replace('/\s+$/', '', $str));
    1112    $str = preg_replace('/\(.*\)/', '', $str);
    1213    $str = preg_replace('/[\(\)]/', '', $str);
     14    $strcl = array('str' => $str);
     15    if (preg_match('/^M([\.Mmle]+) (.*)$/', $str, $match)) {
     16      $strcl['str'] = $match[2];
     17      $strcl['sexe'] = "H";
     18      if (preg_match('/e/', $match[1]))
     19        $strcl['sexe'] = "F";
     20    }
     21    return $strcl;
     22  }
     23
     24  public function similarToCheckPrenom($str, $sexe = null, $return_array = 0, $year = 0) {
     25    $strcl = $this->cleanString($str);
     26    $str = $strcl['str'];
     27    if (!$sexe && isset($strcl['sexe']))
     28      $sexe = $strcl['sexe'];
    1329    $first = preg_replace('/[\WàÀéèÉÈêÊîÎïÏôÔüÜùÙ]/', '.', strtolower(preg_replace('/^\s*(\S{4}).*$/i', '\\1', $str)));
    1430    $res = $this->similarTo($str, $sexe, $return_array, $year);
     
    2238    if (preg_match('/^\s*$/', $str))
    2339      return null;
    24     $str = preg_replace('/\(.*\)/', '', $str);
     40    $strcl = $this->cleanString($str);
     41    $str = $strcl['str'];
     42    if (!$sexe && isset($strcl['sexe']))
     43      $sexe = $strcl['sexe'];
    2544    $word = preg_replace('/^.*\s(\S+)\s*$/i', '\\1', $str);
    2645    $q = $this->createQuery('p')->where('nom LIKE ?', '% '.$word.'%');
Note: See TracChangeset for help on using the changeset viewer.