Changeset 6559 for trunk/prototype/rest/hypermedia/hypermedia.php
- Timestamp:
- 06/21/12 09:09:40 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/rest/hypermedia/hypermedia.php
r6528 r6559 16 16 } 17 17 18 function getHypermedia($accept = 'json') {18 function toUtf8($data) { 19 19 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; 21 22 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); 30 29 } 30 return $return; 31 31 } 32 32 … … 64 64 } 65 65 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 66 81 } 67 82
Note: See TracChangeset
for help on using the changeset viewer.