aboutsummaryrefslogtreecommitdiff
path: root/views/json
diff options
context:
space:
mode:
Diffstat (limited to 'views/json')
-rw-r--r--views/json/api/output.php17
-rw-r--r--views/json/export/entity.php25
-rw-r--r--views/json/export/metadata.php21
-rw-r--r--views/json/export/relationship.php21
-rw-r--r--views/json/group/default.php9
-rw-r--r--views/json/messages/exceptions/exception.php15
-rw-r--r--views/json/object/default.php9
-rw-r--r--views/json/page/components/list.php14
-rw-r--r--views/json/page/default.php13
-rw-r--r--views/json/river/item.php19
-rw-r--r--views/json/site/default.php9
-rw-r--r--views/json/user/default.php9
12 files changed, 181 insertions, 0 deletions
diff --git a/views/json/api/output.php b/views/json/api/output.php
new file mode 100644
index 000000000..adeb7cc75
--- /dev/null
+++ b/views/json/api/output.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Elgg JSON output
+ * This outputs the api results as JSON
+ *
+ * @package Elgg
+ * @subpackage Core
+ */
+
+$result = $vars['result'];
+$export = $result->export();
+
+global $jsonexport;
+
+// with api calls, we don't want extra baggage found in other json views
+// so we skip the associative array
+$jsonexport = $export; \ No newline at end of file
diff --git a/views/json/export/entity.php b/views/json/export/entity.php
new file mode 100644
index 000000000..36af5eaef
--- /dev/null
+++ b/views/json/export/entity.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Elgg Entity export.
+ * Displays an entity as JSON
+ *
+ * @package Elgg
+ * @subpackage Core
+ */
+
+$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;
+
+// @todo hack to fix #4504
+echo "Fix for bug #4504";
diff --git a/views/json/export/metadata.php b/views/json/export/metadata.php
new file mode 100644
index 000000000..e1e6ceb26
--- /dev/null
+++ b/views/json/export/metadata.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Elgg metadata export.
+ * Displays a metadata item using json
+ *
+ * @package Elgg
+ * @subpackage Core
+ */
+
+$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
new file mode 100644
index 000000000..47b3a390d
--- /dev/null
+++ b/views/json/export/relationship.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Elgg relationship export.
+ * Displays a relationship using JSON.
+ *
+ * @package Elgg
+ * @subpackage Core
+ */
+
+$r = $vars['relationship'];
+
+$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
new file mode 100644
index 000000000..dd190d402
--- /dev/null
+++ b/views/json/group/default.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * JSON group view
+ *
+ * @package Elgg
+ * @subpackage Core
+ */
+
+echo elgg_view('export/entity', $vars);
diff --git a/views/json/messages/exceptions/exception.php b/views/json/messages/exceptions/exception.php
new file mode 100644
index 000000000..4f73212bc
--- /dev/null
+++ b/views/json/messages/exceptions/exception.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Elgg exception
+ * Displays a single exception
+ *
+ * @package Elgg
+ * @subpackage Core
+ *
+ * @uses $vars['object'] An exception
+ */
+
+$export = $vars['object'];
+
+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
new file mode 100644
index 000000000..8b88b3010
--- /dev/null
+++ b/views/json/object/default.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * JSON object view
+ *
+ * @package Elgg
+ * @subpackage Core
+ */
+
+echo elgg_view('export/entity', $vars);
diff --git a/views/json/page/components/list.php b/views/json/page/components/list.php
new file mode 100644
index 000000000..5de4f1f59
--- /dev/null
+++ b/views/json/page/components/list.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * JSON list view
+ *
+ * @uses $vars['items']
+ */
+
+$items = $vars['items'];
+
+if (is_array($items) && sizeof($items) > 0) {
+ foreach ($items as $item) {
+ elgg_view_list_item($item, $vars);
+ }
+} \ No newline at end of file
diff --git a/views/json/page/default.php b/views/json/page/default.php
new file mode 100644
index 000000000..2d0403e11
--- /dev/null
+++ b/views/json/page/default.php
@@ -0,0 +1,13 @@
+<?php
+/**
+ * Elgg JSON output pageshell
+ *
+ * @package Elgg
+ * @subpackage Core
+ *
+ */
+
+header("Content-Type: application/json");
+
+global $jsonexport;
+echo json_encode($jsonexport); \ No newline at end of file
diff --git a/views/json/river/item.php b/views/json/river/item.php
new file mode 100644
index 000000000..64677817f
--- /dev/null
+++ b/views/json/river/item.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * JSON river item view
+ *
+ * @uses $vars['item']
+ */
+
+global $jsonexport;
+
+if (!isset($jsonexport['activity'])) {
+ $jsonexport['activity'] = array();
+}
+
+$item = $vars['item'];
+if (elgg_view_exists($item->view, 'default')) {
+ $item->string = elgg_view('river/elements/summary', array('item' => $item), FALSE, FALSE, 'default');
+}
+
+$jsonexport['activity'][] = $vars['item'];
diff --git a/views/json/site/default.php b/views/json/site/default.php
new file mode 100644
index 000000000..ee4eda489
--- /dev/null
+++ b/views/json/site/default.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * JSON site view
+ *
+ * @package Elgg
+ * @subpackage Core
+ */
+
+echo elgg_view('export/entity', $vars);
diff --git a/views/json/user/default.php b/views/json/user/default.php
new file mode 100644
index 000000000..4d44692c9
--- /dev/null
+++ b/views/json/user/default.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * JSON user view
+ *
+ * @package Elgg
+ * @subpackage Core
+ */
+
+echo elgg_view('export/entity', $vars);