river.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * Main activity stream list page
  4. */
  5. $options = array(
  6. 'distinct' => false
  7. );
  8. $page_type = preg_replace('[\W]', '', get_input('page_type', 'all'));
  9. $type = preg_replace('[\W]', '', get_input('type', 'all'));
  10. $subtype = preg_replace('[\W]', '', get_input('subtype', ''));
  11. if ($subtype) {
  12. $selector = "type=$type&subtype=$subtype";
  13. } else {
  14. $selector = "type=$type";
  15. }
  16. if ($type != 'all') {
  17. $options['type'] = $type;
  18. if ($subtype) {
  19. $options['subtype'] = $subtype;
  20. }
  21. }
  22. switch ($page_type) {
  23. case 'mine':
  24. $title = elgg_echo('river:mine');
  25. $page_filter = 'mine';
  26. $options['subject_guid'] = elgg_get_logged_in_user_guid();
  27. break;
  28. case 'owner':
  29. $subject_username = get_input('subject_username', '', false);
  30. $subject = get_user_by_username($subject_username);
  31. if (!$subject) {
  32. register_error(elgg_echo('river:subject:invalid_subject'));
  33. forward('');
  34. }
  35. elgg_set_page_owner_guid($subject->guid);
  36. $title = elgg_echo('river:owner', array(htmlspecialchars($subject->name, ENT_QUOTES, 'UTF-8', false)));
  37. $page_filter = 'subject';
  38. $options['subject_guid'] = $subject->guid;
  39. break;
  40. case 'friends':
  41. $title = elgg_echo('river:friends');
  42. $page_filter = 'friends';
  43. $options['relationship_guid'] = elgg_get_logged_in_user_guid();
  44. $options['relationship'] = 'friend';
  45. break;
  46. default:
  47. $title = elgg_echo('river:all');
  48. $page_filter = 'all';
  49. break;
  50. }
  51. $activity = elgg_list_river($options);
  52. if (!$activity) {
  53. $activity = elgg_echo('river:none');
  54. }
  55. $content = elgg_view('core/river/filter', array('selector' => $selector));
  56. $sidebar = elgg_view('core/river/sidebar');
  57. $params = array(
  58. 'title' => $title,
  59. 'content' => $content . $activity,
  60. 'sidebar' => $sidebar,
  61. 'filter_context' => $page_filter,
  62. 'class' => 'elgg-river-layout',
  63. );
  64. $body = elgg_view_layout('content', $params);
  65. echo elgg_view_page($title, $body);