Changeset 1334


Ignore:
Timestamp:
Sep 8, 2010, 12:36:04 PM (10 years ago)
Author:
goya
Message:

correction risque doublons organismes

File:
1 edited

Legend:

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

    r1333 r1334  
    66{
    77  public function findOneByNomType($nom, $type) {
    8     $nom = strtolower($nom);
    9     $nom = preg_replace('/(’|\')/', '’', $nom);
    10     $nom = preg_replace('/\W+$/', '', $nom);
    11     $nom = preg_replace('/\([^\)]*\)/', '', $nom);
    12     $nom = preg_replace('/\([^\)]*$/', '', $nom);
    13     $nom = preg_replace('/^[^\)]*\)/', '', $nom);
    14     $nom = preg_replace('/’/', '\'', $nom);
    15     $nom = preg_replace('/^\s*assemblée\s+nationale\s*$/i', 'bureau de l\'assemblée nationale', $nom);
    16     trim($nom);
    17     $nom = preg_replace('/^\s*de la /', '', $nom);
    18     $nom = preg_replace('/\s+/', ' ', $nom);
     8    $nom = self::cleanNom($nom);
    199
    2010    if ($option = Doctrine::getTable('VariableGlobale')->findOneByChamp('commissions')) {
     
    6454    $org = new Organisme();
    6555    $org->type = $type;
    66     $org->nom = $nom;
     56    $org->nom = self::cleanNom($nom);
    6757    $org->save();
    6858    return $org;
    6959  }
     60 
     61  private static function cleanNom($nom) {
     62    $nom = strtolower($nom);
     63    $nom = preg_replace('/(’|\')/', '’', $nom);
     64    $nom = preg_replace('/\W+$/', '', $nom);
     65    $nom = preg_replace('/\([^\)]*\)/', '', $nom);
     66    $nom = preg_replace('/\([^\)]*$/', '', $nom);
     67    $nom = preg_replace('/^[^\)]*\)/', '', $nom);
     68    $nom = preg_replace('/’/', '\'', $nom);
     69    $nom = preg_replace('/^\s*assemblée\s+nationale\s*$/i', 'bureau de l\'assemblée nationale', $nom);
     70    trim($nom);
     71    $nom = preg_replace('/^\s*de la /', '', $nom);
     72    $nom = preg_replace('/\s+/', ' ', $nom);
     73    return $nom;
     74  }
    7075}
Note: See TracChangeset for help on using the changeset viewer.