Ignore:
Timestamp:
Jul 1, 2010, 1:15:06 AM (11 years ago)
Author:
teymour
Message:

Correction des emails vides (json + csv) Qd on peut faire simple :)

Location:
cpc/trunk/project/apps/frontend/modules/api
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/apps/frontend/modules/api/actions/actions.class.php

    r1206 r1216  
    108108    $this->multi = array();
    109109    $this->res['depute'] = array();
    110     $this->res['depute']['id'] = $depute->id;
     110    $this->res['depute']['id'] = $depute->id * 1;
    111111    $this->res['depute']['nom'] = $depute->nom;
    112112    $this->res['depute']['nom_de_famille'] = $depute->nom_de_famille;
    113113    $this->res['depute']['nom_circo'] = $depute->nom_circo;
    114     $this->res['depute']['num_circo'] = $depute->num_circo;
     114    $this->res['depute']['num_circo'] = $depute->num_circo * 1;
    115115    $this->res['depute']['mandat_debut'] = $depute->debut_mandat;
    116116    if ($depute->fin_mandat)
  • cpc/trunk/project/apps/frontend/modules/api/templates/csvSuccess.php

    r1198 r1216  
    3030  if (is_array($res)) {
    3131    if (!isset($res[0])) {
    32       return depile_assoc($res, $breakline, $multi);
     32      if (array_keys($res))
     33        return depile_assoc($res, $breakline, $multi);
     34      echo ";";
     35      return;
    3336    }
    3437    foreach($res as $r) {
  • cpc/trunk/project/apps/frontend/modules/api/templates/jsonSuccess.php

    r1195 r1216  
    11<?
    22
    3 function depile_assoc($asso) {
    4   $s = '{';
    5   foreach (array_keys($asso) as $k) {
    6     $s .= '"'.$k.'":';
    7     $s .= depile($asso[$k]);
    8     $s .= ",";
    9   }
    10   return substr($s, 0, -1).'}';
    11 }
    12 
    13 function depile($res) {
    14   if (is_array($res)) {
    15     if (!isset($res[0])) {
    16       return depile_assoc($res);
    17     }else{
    18       $s = '[';
    19       foreach($res as $r) {
    20         $s .= depile($r).',';
    21       }
    22       return substr($s, 0, -1).']';
    23     }
    24   }else{
    25     if (is_numeric($res)) {
    26       return $res;
    27     }
    28     return '"'.$res.'"';
    29   }
    30 }
    31 
    32 echo depile($res);
     3echo json_encode($res);
Note: See TracChangeset for help on using the changeset viewer.