aboutsummaryrefslogtreecommitdiff
path: root/mod/infinite_scroll/views/default/infinite_scroll/list.php
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-03-15 15:07:03 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-03-15 15:07:03 -0300
commit6800aad47fb4208289171b1125eba69ccf93c08c (patch)
treeb4edbb7d60a0ab81be446980294f65c183044326 /mod/infinite_scroll/views/default/infinite_scroll/list.php
parent82ca8e9f8839b98a5770a90027adcecbe603d06f (diff)
parentfe7bc5b2fa63f4b8562a961cf3910db1f3b8f7a1 (diff)
downloadelgg-6800aad47fb4208289171b1125eba69ccf93c08c.tar.gz
elgg-6800aad47fb4208289171b1125eba69ccf93c08c.tar.bz2
Merge commit 'fe7bc5b2fa63f4b8562a961cf3910db1f3b8f7a1' as 'mod/infinite_scroll'
Diffstat (limited to 'mod/infinite_scroll/views/default/infinite_scroll/list.php')
-rw-r--r--mod/infinite_scroll/views/default/infinite_scroll/list.php83
1 files changed, 83 insertions, 0 deletions
diff --git a/mod/infinite_scroll/views/default/infinite_scroll/list.php b/mod/infinite_scroll/views/default/infinite_scroll/list.php
new file mode 100644
index 000000000..6a6ab9ec7
--- /dev/null
+++ b/mod/infinite_scroll/views/default/infinite_scroll/list.php
@@ -0,0 +1,83 @@
+<?php
+
+$path = explode('/', $vars['path']);
+array_shift($path);
+
+$list_type = get_input('list_type', 'list');
+set_input('list_type', 'list');
+
+ob_start();
+elgg_set_viewtype('json');
+
+// Check this when #4723 closed.
+if (!$path[0]) {
+ include(elgg_get_root_path().'index.php');
+} else {
+ page_handler(array_shift($path), implode('/', $path));
+}
+
+$json = json_decode(ob_get_clean());
+
+switch(get_input('items_type')){
+ case 'entity':
+ foreach ($json as $child) foreach ($child as $grandchild) $json = $grandchild;
+
+ /* Removing duplicates
+ This is unnecessary when #4504 is fixed. */
+ if (version_compare(get_version(true), '1.8.7', '<')) {
+ $buggy = $json;
+ $json = array();
+ $guids = array();
+ foreach ($buggy as $item) {
+ $guids[] = $item->guid;
+ }
+ $guids = array_unique($guids);
+ foreach (array_keys($guids) as $i) {
+ $json[$i] = $buggy[$i];
+ }
+ }
+ break;
+ case 'annotation':
+ foreach ($json as $child) {
+ $json = $child;
+ }
+ $json = elgg_get_annotations(array(
+ 'items' => $json->guid,
+ 'offset' => get_input('offset'),
+ 'limit' => 25,
+ ));
+ break;
+ case 'river':
+ $json = $json->activity;
+ break;
+}
+
+if (!is_array($json)) {
+ exit();
+}
+
+$items = array();
+foreach($json as $item) {
+ switch(get_input('items_type')) {
+ case 'entity':
+ $type_class = array(
+ 'site' => 'ElggSite',
+ 'user' => 'ElggUser',
+ 'group' => 'ElggGroup',
+ 'object' => 'ElggObject'
+ );
+ $items[] = new $type_class[$item->type]($item);
+ break;
+ case 'annotation':
+ $items = $json;
+ break;
+ case 'river':
+ $items[] = new ElggRiverItem($item);
+ break;
+ }
+}
+
+header('Content-type: text/plain');
+
+elgg_set_viewtype('default');
+echo elgg_view("page/components/$list_type", array("items" => $items));