From 694781d190fba09437a37983f077d0381a56050b Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 16 Oct 2009 21:25:25 +0000 Subject: Finished standardizing seconday views. git-svn-id: http://code.elgg.org/elgg/trunk@3559 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/json/api/output.php | 34 ++++++++++----------- views/json/canvas/default.php | 20 ++++++------- views/json/export/entity.php | 44 ++++++++++++++-------------- views/json/export/metadata.php | 42 +++++++++++++------------- views/json/export/relationship.php | 41 +++++++++++++------------- views/json/group/default.php | 21 ++++++------- views/json/messages/exceptions/exception.php | 30 +++++++++---------- views/json/object/default.php | 21 ++++++------- views/json/page_elements/contentwrapper.php | 12 ++++++-- views/json/pageshells/pageshell.php | 37 ++++++++++++----------- views/json/river/item/list.php | 42 +++++++++++++------------- views/json/search/entity_list.php | 30 +++++++++---------- views/json/site/default.php | 21 ++++++------- views/json/user/default.php | 21 ++++++------- 14 files changed, 201 insertions(+), 215 deletions(-) (limited to 'views/json') diff --git a/views/json/api/output.php b/views/json/api/output.php index 94aaaae60..49aeb8438 100644 --- a/views/json/api/output.php +++ b/views/json/api/output.php @@ -1,20 +1,18 @@ export(); - - // echo json_encode($export); - global $jsonexport; - $jsonexport['api'][] = $export; - -?> \ No newline at end of file +$result = $vars['result']; +$export = $result->export(); + +// echo json_encode($export); +global $jsonexport; +$jsonexport['api'][] = $export; \ No newline at end of file diff --git a/views/json/canvas/default.php b/views/json/canvas/default.php index 4978b00e7..a7df72778 100644 --- a/views/json/canvas/default.php +++ b/views/json/canvas/default.php @@ -1,15 +1,13 @@ \ No newline at end of file +global $jsonexport; \ No newline at end of file diff --git a/views/json/export/entity.php b/views/json/export/entity.php index 8c253d9b0..750338964 100644 --- a/views/json/export/entity.php +++ b/views/json/export/entity.php @@ -1,24 +1,24 @@ getExportableValues(); - - foreach ($exportable_values as $v) - $export->$v = $entity->$v; - - $export->url = $entity->getURL(); - - global $jsonexport; - $jsonexport[$entity->getType()][$entity->getSubtype()][] = $export; -?> \ No newline at end of file +$entity = $vars['entity']; + +$export = new stdClass; +$exportable_values = $entity->getExportableValues(); + +foreach ($exportable_values as $v) { + $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 10aceb9df..bde62de57 100644 --- a/views/json/export/metadata.php +++ b/views/json/export/metadata.php @@ -1,23 +1,23 @@ getExportableValues(); - - foreach ($exportable_values as $v) - $export->$v = $m->$v; - - global $jsonexport; - $jsonexport['metadata'][] = $entity; - // echo json_encode($export); -?> \ No newline at end of file +$m = $vars['metadata']; + +$export = new stdClass; +$exportable_values = $entity->getExportableValues(); + +foreach ($exportable_values as $v) { + $export->$v = $m->$v; +} + +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 dd1adb4d8..08ed5c008 100644 --- a/views/json/export/relationship.php +++ b/views/json/export/relationship.php @@ -1,24 +1,23 @@ getExportableValues(); - - foreach ($exportable_values as $v) - $export->$v = $r->$v; - - global $jsonexport; - $jsonexport['relationships'][] = $export; - -?> \ No newline at end of file +$export = new stdClass; + +$exportable_values = $entity->getExportableValues(); + +foreach ($exportable_values as $v) { + $export->$v = $r->$v; +} + +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 8c02f7d5e..5466c83b3 100644 --- a/views/json/group/default.php +++ b/views/json/group/default.php @@ -1,14 +1,11 @@ \ No newline at end of file +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 6255f08a6..306b2bc0e 100644 --- a/views/json/messages/exceptions/exception.php +++ b/views/json/messages/exceptions/exception.php @@ -1,19 +1,17 @@ \ No newline at end of file +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 8c02f7d5e..5466c83b3 100644 --- a/views/json/object/default.php +++ b/views/json/object/default.php @@ -1,14 +1,11 @@ \ No newline at end of file +elgg_view('export/entity', $vars); \ No newline at end of file diff --git a/views/json/page_elements/contentwrapper.php b/views/json/page_elements/contentwrapper.php index 15397d552..24048528e 100644 --- a/views/json/page_elements/contentwrapper.php +++ b/views/json/page_elements/contentwrapper.php @@ -1,5 +1,11 @@ \ No newline at end of file +echo $vars['body']; \ No newline at end of file diff --git a/views/json/pageshells/pageshell.php b/views/json/pageshells/pageshell.php index 2d2526e38..16cfa3cdd 100644 --- a/views/json/pageshells/pageshell.php +++ b/views/json/pageshells/pageshell.php @@ -1,21 +1,20 @@ \ No newline at end of file +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/river/item/list.php b/views/json/river/item/list.php index 149212135..908ea7a90 100644 --- a/views/json/river/item/list.php +++ b/views/json/river/item/list.php @@ -1,17 +1,22 @@ view,'default')) { - $body = elgg_view($item->view,array( - 'item' => $item - ),false,false,'default'); + $body = elgg_view($item->view,array('item' => $item), false, false, 'default'); $time = date("r",$item->posted); if ($entity = get_entity($item->object_guid)) { $url = htmlspecialchars($entity->getURL()); @@ -25,25 +30,22 @@ $jsonitem->description = autop($body); $jsonitem->title = $title; unset($jsonitem->view); - + if ($subject = get_entity($item->subject_guid)) { elgg_view_entity($subject); } if ($object = get_entity($item->object_guid)) { elgg_view_entity($object); } - + $jsonexport['activity'][] = $jsonitem; - } - + $i++; - if ($i >= $vars['limit']) break; - + if ($i >= $vars['limit']) { + break; + } } - } - echo "!"; - - -?> \ No newline at end of file +} +echo "!"; \ No newline at end of file diff --git a/views/json/search/entity_list.php b/views/json/search/entity_list.php index 9ca58a8b8..a47bb37fc 100644 --- a/views/json/search/entity_list.php +++ b/views/json/search/entity_list.php @@ -1,18 +1,16 @@ 0) { - foreach($entities as $entity) - echo elgg_view_entity($entity); - } - -?> \ No newline at end of file +$entities = $vars['entities']; +if (is_array($entities) && sizeof($entities) > 0) { + foreach($entities as $entity) { + echo elgg_view_entity($entity); + } +} diff --git a/views/json/site/default.php b/views/json/site/default.php index 8c02f7d5e..5466c83b3 100644 --- a/views/json/site/default.php +++ b/views/json/site/default.php @@ -1,14 +1,11 @@ \ No newline at end of file +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 8c02f7d5e..5466c83b3 100644 --- a/views/json/user/default.php +++ b/views/json/user/default.php @@ -1,14 +1,11 @@ \ No newline at end of file +elgg_view('export/entity', $vars); \ No newline at end of file -- cgit v1.2.3