From 93e99d5a0080f6ef89192b7d406e013a3b9fe48f Mon Sep 17 00:00:00 2001 From: ben Date: Wed, 4 Feb 2009 18:44:54 +0000 Subject: JSON feeds now work. Fixes #716 git-svn-id: https://code.elgg.org/elgg/trunk@2650 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/json/canvas/default.php | 10 +++------- views/json/export/entity.php | 11 +++++++---- views/json/export/metadata.php | 6 ++++-- views/json/export/relationship.php | 4 +++- views/json/group/default.php | 7 +------ views/json/messages/exceptions/exception.php | 5 +++-- views/json/object/default.php | 2 +- views/json/pageshells/pageshell.php | 13 ++++++++++--- views/json/search/entity_list.php | 10 +++++----- views/json/site/default.php | 7 +------ views/json/user/default.php | 7 +------ 11 files changed, 39 insertions(+), 43 deletions(-) (limited to 'views/json') diff --git a/views/json/canvas/default.php b/views/json/canvas/default.php index 6a1355a92..0c7ab191f 100644 --- a/views/json/canvas/default.php +++ b/views/json/canvas/default.php @@ -10,12 +10,8 @@ * @copyright Curverider Ltd 2008-2009 * @link http://elgg.org/ */ - - for ($i = 1; $i < 8; $i++) { - - if (isset($vars["area{$i}"])) - echo $vars["area{$i}"]; - - } + + + global $jsonexport; ?> \ No newline at end of file diff --git a/views/json/export/entity.php b/views/json/export/entity.php index 3b0ce8367..c5369eea1 100644 --- a/views/json/export/entity.php +++ b/views/json/export/entity.php @@ -11,13 +11,16 @@ * @link http://elgg.org/ */ - $entity = $vars['entity']; + $entity = $vars['entity']; $export = new stdClass; $exportable_values = $entity->getExportableValues(); foreach ($exportable_values as $v) - $export->$v = $entity->$v; - - echo json_encode($export); + $export->$v = $entity->$v; + + $export->url = $entity->getURL(); + + global $jsonexport; + $jsonexport[$entity->getType()][$entity->getSubtype()][] = $export; ?> \ No newline at end of file diff --git a/views/json/export/metadata.php b/views/json/export/metadata.php index 273051d22..d1a5a44d8 100644 --- a/views/json/export/metadata.php +++ b/views/json/export/metadata.php @@ -18,6 +18,8 @@ foreach ($exportable_values as $v) $export->$v = $m->$v; - - echo json_encode($export); + + global $jsonexport; + $jsonexport['metadata'][] = $entity; + // echo json_encode($export); ?> \ No newline at end of file diff --git a/views/json/export/relationship.php b/views/json/export/relationship.php index 1c255ad4d..4b5006d73 100644 --- a/views/json/export/relationship.php +++ b/views/json/export/relationship.php @@ -20,5 +20,7 @@ foreach ($exportable_values as $v) $export->$v = $r->$v; - echo json_encode($export); + global $jsonexport; + $jsonexport['relationships'][] = $export; + ?> \ No newline at end of file diff --git a/views/json/group/default.php b/views/json/group/default.php index 6a1355a92..fd043c6b9 100644 --- a/views/json/group/default.php +++ b/views/json/group/default.php @@ -11,11 +11,6 @@ * @link http://elgg.org/ */ - for ($i = 1; $i < 8; $i++) { - - if (isset($vars["area{$i}"])) - echo $vars["area{$i}"]; - - } + elgg_view('export/entity', $vars); ?> \ No newline at end of file diff --git a/views/json/messages/exceptions/exception.php b/views/json/messages/exceptions/exception.php index 76fb3aea3..55a61f0ff 100644 --- a/views/json/messages/exceptions/exception.php +++ b/views/json/messages/exceptions/exception.php @@ -15,6 +15,7 @@ $export = $vars['object']; - - echo json_encode("$export"); + global $jsonexport; + $jsonexport['exceptions'][] = $export; + ?> \ No newline at end of file diff --git a/views/json/object/default.php b/views/json/object/default.php index ccd9ef497..fd043c6b9 100644 --- a/views/json/object/default.php +++ b/views/json/object/default.php @@ -11,6 +11,6 @@ * @link http://elgg.org/ */ - echo elgg_view('export/entity', $vars); + elgg_view('export/entity', $vars); ?> \ No newline at end of file diff --git a/views/json/pageshells/pageshell.php b/views/json/pageshells/pageshell.php index d9cb52b9b..ae51b49e5 100644 --- a/views/json/pageshells/pageshell.php +++ b/views/json/pageshells/pageshell.php @@ -10,7 +10,14 @@ * @link http://elgg.org/ * */ - - header("Content-Type: application/json"); - echo $vars['body']; + + if(stristr($_SERVER["HTTP_ACCEPT"],"application/json")) { + header("Content-Type: application/json"); + } else { + header("Content-Type: application/javascript"); + } + // echo $vars['body']; + + global $jsonexport; + echo json_encode($jsonexport); ?> \ No newline at end of file diff --git a/views/json/search/entity_list.php b/views/json/search/entity_list.php index 8712f7134..a948f4895 100644 --- a/views/json/search/entity_list.php +++ b/views/json/search/entity_list.php @@ -11,10 +11,10 @@ * @link http://elgg.org/ */ - $entities = $vars['entities']; - if (is_array($entities) && sizeof($entities) > 0) { - foreach($entities as $entity) - echo elgg_view_entity($entity); - } + $entities = $vars['entities']; + if (is_array($entities) && sizeof($entities) > 0) { + foreach($entities as $entity) + echo elgg_view_entity($entity); + } ?> \ No newline at end of file diff --git a/views/json/site/default.php b/views/json/site/default.php index 6a1355a92..fd043c6b9 100644 --- a/views/json/site/default.php +++ b/views/json/site/default.php @@ -11,11 +11,6 @@ * @link http://elgg.org/ */ - for ($i = 1; $i < 8; $i++) { - - if (isset($vars["area{$i}"])) - echo $vars["area{$i}"]; - - } + elgg_view('export/entity', $vars); ?> \ No newline at end of file diff --git a/views/json/user/default.php b/views/json/user/default.php index 6a1355a92..fd043c6b9 100644 --- a/views/json/user/default.php +++ b/views/json/user/default.php @@ -11,11 +11,6 @@ * @link http://elgg.org/ */ - for ($i = 1; $i < 8; $i++) { - - if (isset($vars["area{$i}"])) - echo $vars["area{$i}"]; - - } + elgg_view('export/entity', $vars); ?> \ No newline at end of file -- cgit v1.2.3