Changeset 6559
- Timestamp:
- 06/21/12 09:09:40 (11 years ago)
- Location:
- trunk/prototype
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/config/Tonic.srv
r6528 r6559 14 14 ContactResource = /catalog/ContactResource.php 15 15 16 [/sharedcontact/:id] 17 SharedContactsResource = /catalog/SharedContactResource.php 18 16 19 [/groups] 17 20 GroupsResource = /catalog/GroupsResource.php … … 20 23 GroupResource = /catalog/GroupResource.php 21 24 25 [/sharedgroup/:id] 26 SharedGroupsResource = /catalog/SharedGroupResource.php 27 22 28 [/dynamiccontacts] 23 29 DynamicContactsResource = /catalog/DynamicContactsResource.php … … 25 31 [/dynamiccontact/:id] 26 32 DynamicContactResource = /catalog/DynamicContactResource.php 33 34 [/usercontacts] 35 UserContactsResource = /catalog/UserContactsResource.php -
trunk/prototype/rest/hypermedia/collection.php
r6528 r6559 8 8 include_once('error.php'); 9 9 /* 10 Valores padrão10 Valores padrão 11 11 12 Números são enviados como números, sem aspas; 13 Atributos não obrigatórios sem valor serão nulos; 14 Strings vazias serão nulos; 15 Todos os indices / chaves estarão sempre presentes na mensagem; 16 Arrays vazios serão nulos; 17 Objetos vazios serão nulos; 18 Números sem valor serão nulos; 19 valores booleanos são escritos como booleanos (sem aspas); 20 */ 12 Números são enviados como números, sem aspas; 13 Atributos não obrigatórios sem valor serão nulos; 14 Strings vazias serão nulos; 15 Todos os indices / chaves estarão sempre presentes na mensagem; 16 Arrays vazios serão nulos; 17 Objetos vazios serão nulos; 18 Números sem valor serão nulos; 19 valores booleanos são escritos como booleanos (sem aspas); 20 */ 21 21 22 class Collection { 22 23 … … 34 35 foreach ($config as $key => $value) { 35 36 if ($value['class'] == $className) { 36 $uri = ($id ? (preg_replace('/\/[:][a-zA-Z-0-9]+/', '', $key) .'/'.$id ) : $key);37 $uri = ($id ? (preg_replace('/\/[:][a-zA-Z-0-9]+/', '', $key) . '/' . $id ) : $key); 37 38 break; 38 39 } … … 41 42 } 42 43 43 44 function addLink($link) { 44 45 $this->links[] = $link; 45 46 } 46 47 47 48 function addItem($item) { 48 49 $this->itens[] = $item; 49 50 } 50 51 51 52 function addData($data) { 52 53 $this->data[] = $data; 53 54 } … … 56 57 return $this->data; 57 58 } 58 59 59 60 function setTemplate($template) { 60 61 $this->template = $template; -
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 -
trunk/prototype/rest/hypermedia/item.php
r6528 r6559 4 4 5 5 public $href; 6 public $dataType; 6 7 public $data = array(); 7 8 public $links = array(); … … 16 17 } 17 18 $this->href = $uri .'/'. $id; 19 $this->dataType = $uri; 20 } 21 22 function setDataType($dataType) { 23 $this->dataType = $dataType; 24 } 25 26 function getDataType() { 27 return $this->dataType; 18 28 } 19 29
Note: See TracChangeset
for help on using the changeset viewer.