Ignore:
Timestamp:
06/21/12 09:09:40 (12 years ago)
Author:
acoutinho
Message:

Ticket #2766 - Criacao de recurso unico para contatos dos usuario

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/rest/hypermedia/hypermedia.php

    r6528 r6559  
    1616    } 
    1717 
    18     function getHypermedia($accept = 'json') { 
     18    function toUtf8($data) { 
    1919 
    20         $data = get_object_vars($this); 
     20        if (!is_array($data)) 
     21            return  is_string($data) ? mb_convert_encoding($data, 'UTF-8', 'UTF-8 , ISO-8859-1') : $data; 
    2122 
    22         switch ($accept) { 
    23             case 'json': 
    24                 return json_encode($data); 
    25                 break; 
    26             case 'xml': 
    27                 return $this->generateValidXmlFromArray($data); 
    28             default : 
    29                 return json_encode($data); 
     23        $return = array(); 
     24 
     25        foreach ($data as $i => &$v){ 
     26            if(is_object($v)) 
     27                $v = get_object_vars($v); 
     28            $return[$this->toUtf8($i)] = $this->toUtf8($v); 
    3029        } 
     30        return $return; 
    3131    } 
    3232 
     
    6464    } 
    6565 
     66    function getHypermedia($accept = 'json') { 
     67 
     68        $data = $this->toUtf8(get_object_vars($this)); 
     69 
     70        switch ($accept) { 
     71            case 'json': 
     72                return json_encode($data); 
     73                break; 
     74            case 'xml': 
     75                return $this->generateValidXmlFromArray($data); 
     76            default : 
     77                return json_encode($data); 
     78        } 
     79    } 
     80 
    6681} 
    6782 
Note: See TracChangeset for help on using the changeset viewer.