public function traiteMapfileAction($r_controller = null, $r_action = null, $r_id = null)
 {
     parent::newAction($r_controller, $r_action, $r_id);
     if (!$this->request->isPost()) {
         return $this->dispatcher->forward(array("controller" => $this->ctlName, "action" => "index"));
     }
     $this->view->pick("gestion_couche/creation");
     $code = $this->request->getPost("code");
     $code = $this->traiteClass($code);
     $lignes = explode("\n", $code);
     $mf_layer_meta_def = "";
     $mf_layer_def = "";
     $meta = false;
     $projection = false;
     foreach ($lignes as $ligne) {
         if ($projection) {
             $this->tag->setDefault('mf_layer_projection', trim($ligne, " '\"\t\n\r"));
             $projection = false;
             continue;
         }
         if (trim($ligne) == "" || trim($ligne) == "LAYER") {
             continue;
         }
         preg_match("/[\\s]?(?P<element>[^\\s]+)\\s+(?P<contenu>[^#\n]*)/i", $ligne, $matches);
         if (!isset($matches['contenu'])) {
             //echo "Pas de match pour $ligne <br>";
             continue;
         } else {
             //printf ("Élément: %s  Contenu: %s <br>",$matches['element'],$matches['contenu']);
         }
         switch ($matches['element']) {
             case 'NAME':
                 $this->tag->setDefault('mf_layer_name', trim($matches['contenu'], "'\"\n\r"));
                 $this->tag->setDefault('fiche_csw_id', trim($matches['contenu'], "'\"\n\r"));
                 $catalogue = IgoCatalogueCsw::findFirst();
                 $this->tag->setDefault('catalogue_csw_id', $catalogue->id);
                 $igoClasseEntite = IgoClasseEntite::findFirst("nom='" . trim($matches['contenu'], "'\"\n\r") . "'");
                 if ($igoClasseEntite) {
                     $this->tag->setDefault('classe_entite_id', $igoClasseEntite->id);
                 }
                 break;
             case 'TYPE':
                 $igoGeometrieType = IgoGeometrieType::findFirst("layer_type='" . trim($matches['contenu'], "\n\r") . "'");
                 if ($igoGeometrieType) {
                     $this->tag->setDefault('geometrie_type_id', $igoGeometrieType->id);
                 }
                 break;
             case 'GROUP':
                 $this->tag->setDefault('mf_layer_group', trim($matches['contenu'], "'\"\n\r"));
                 break;
             case 'CONNECTIONTYPE':
                 //TODO aller chercher la connection
                 $igoConnexionType = IgoConnexionType::findFirst("nom='" . trim($matches['contenu'], "\n\r") . "'");
                 if ($igoConnexionType) {
                     $this->tag->setDefault('connexion_type_id', $igoConnexionType->id);
                 }
                 break;
             case 'CONNECTION':
                 $this->tag->setDefault('connexion', trim($matches['contenu'], "'\"\n\r"));
                 // TODO bypasser l'erreur de phql
                 $where = "connexion like '" . trim(str_replace("'", "_", trim($matches['contenu'], "'\"\n\r"))) . "'";
                 $igoConnexion = IgoConnexion::findFirst($where);
                 //var_dump($where);
                 if ($igoConnexion) {
                     $this->tag->setDefault('connexion_id', $igoConnexion->id);
                 }
                 break;
             case 'DATA':
                 $this->tag->setDefault('mf_layer_data', trim($matches['contenu'], "'\"\n\r"));
                 break;
             case 'MINSCALE':
                 $this->tag->setDefault('mf_layer_minscale_denom', trim($matches['contenu'], "'\"\n\r"));
                 break;
             case 'MAXSCALE':
                 $this->tag->setDefault('mf_layer_maxscale_denom', trim($matches['contenu'], "'\"\n\r"));
                 break;
             case 'LABELMINSCALE':
                 $this->tag->setDefault('mf_layer_labelminscale_denom', trim($matches['contenu'], "'\"\n\r"));
                 break;
             case 'LABELMAXSCALE':
                 $this->tag->setDefault('mf_layer_labelmaxscale_denom', trim($matches['contenu'], "'\"\n\r"));
                 break;
             case 'OPACITY':
                 $this->tag->setDefault('mf_layer_opacity', trim($matches['contenu'], "'\"\n\r"));
                 break;
             case 'FILTER':
                 $this->tag->setDefault('mf_layer_filter', trim($matches['contenu'], "'\"\n\r"));
                 break;
             case '"wms_group_title"':
                 $this->tag->setDefault('wms_group_title', trim($matches['contenu'], "'\"\n\r"));
                 break;
             case '"wms_name"':
                 $this->tag->setDefault('wms_name', trim($matches['contenu'], "'\"\n\r"));
                 break;
             case '"wms_title"':
                 $this->tag->setDefault('wms_title', trim($matches['contenu'], "'\"\n\r"));
                 break;
             case '"z_order"':
                 $this->tag->setDefault('z_order', trim($matches['contenu'], "'\"\n\r"));
                 break;
             case '"msp_classe_meta"':
                 $this->tag->setDefault('fiche_csw_id', trim($matches['contenu'], "'\"\n\r"));
                 break;
             case 'PROJECTION':
                 $projection = true;
                 break;
             case 'METADATA':
                 $meta = true;
                 break;
             case 'END':
                 $meta = false;
                 break;
             case 'PROCESSING':
                 break;
             default:
                 if ($meta) {
                     $mf_layer_meta_def = $mf_layer_meta_def . "\n" . $ligne;
                 } else {
                     $mf_layer_def = $mf_layer_def . "\n" . $ligne;
                 }
         }
         $this->tag->setDefault('mf_layer_meta_def', trim($mf_layer_meta_def, "'\"\n\r"));
         $this->tag->setDefault('mf_layer_def', trim($mf_layer_def, "'\"\n\r"));
     }
 }