river.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * Main activity stream list page
  4. *
  5. * Translation strings for Spanish by psy@faeries
  6. *
  7. * @package Lorea
  8. */
  9. $options = array();
  10. $page_type = preg_replace('[\W]', '', get_input('page_type', 'all'));
  11. $type = preg_replace('[\W]', '', get_input('type', 'all'));
  12. $subtype = preg_replace('[\W]', '', get_input('subtype', ''));
  13. if ($subtype) {
  14. $selector = "type=$type&subtype=$subtype";
  15. } else {
  16. $selector = "type=$type";
  17. }
  18. if ($type != 'all') {
  19. $options['type'] = $type;
  20. if ($subtype) {
  21. $options['subtype'] = $subtype;
  22. }
  23. }
  24. switch ($page_type) {
  25. case 'mine':
  26. $title = elgg_echo('river:mine');
  27. $page_filter = 'mine';
  28. $options['subject_guid'] = elgg_get_logged_in_user_guid();
  29. break;
  30. case 'friends':
  31. $title = elgg_echo('river:friends');
  32. $page_filter = 'friends';
  33. $options['relationship_guid'] = elgg_get_logged_in_user_guid();
  34. $options['relationship'] = 'friend';
  35. break;
  36. default:
  37. $title = elgg_echo('river:all');
  38. $page_filter = 'all';
  39. break;
  40. }
  41. $options['count'] = true;
  42. $count = elgg_get_river($options);
  43. $options['count'] = false;
  44. $options['pagination'] = false;
  45. $options['offset'] = 0;
  46. $options['limit'] = LIMIT;
  47. if (elgg_get_viewtype() == 'default') {
  48. echo '<script type="text/javascript">';
  49. echo 'var options = ' . json_encode($options) . ';';
  50. echo 'var numactivities = ' . $count . ';';
  51. echo '</script>';
  52. }
  53. if (elgg_get_viewtype() == 'default') {
  54. $activity = '<div id="river_auto_update_activity">';
  55. } else {
  56. $activity = '';
  57. }
  58. $activity .= elgg_list_river($options);
  59. if (!$activity) {
  60. $activity = elgg_echo('river:none');
  61. }
  62. if (elgg_get_viewtype() == 'default') {
  63. $activity .= '</div>';
  64. if ($count > $options['limit']) {
  65. // show load more button
  66. $activity .= '<center id="river_auto_update_load_more_button"><button style="padding:0 50px;" onClick="loadMore()">Cargar M&aacute;s</button></center>';
  67. echo '<script type="text/javascript">';
  68. echo 'var istheremore = true;';
  69. echo '</script>';
  70. } else {
  71. echo '<script type="text/javascript">';
  72. echo 'var istheremore = false;';
  73. echo '</script>';
  74. }
  75. // show the loading gif
  76. $activity .= '<img id="river_auto_update_loading" src="' . elgg_get_site_url() . '/mod/riverautoupdate/_graphics/loading.gif" height="25px;" style="display:none; margin-left:auto; margin-right:auto;" />';
  77. }
  78. $content = elgg_view('core/river/filter', array('selector' => $selector));
  79. $sidebar = elgg_view('core/river/sidebar');
  80. $params = array(
  81. 'title' => $title,
  82. 'content' => $content . $activity,
  83. 'sidebar' => $sidebar,
  84. 'filter_context' => $page_filter,
  85. 'class' => 'elgg-river-layout',
  86. );
  87. $body = elgg_view_layout('content', $params);
  88. echo elgg_view_page($title, $body);
  89. if (elgg_get_viewtype() == 'default') {
  90. ?>
  91. <script type="text/javascript">
  92. window.setInterval(function(){
  93. updateRiver();
  94. }, <?php echo REFRESH_RATE; ?>);
  95. $(window).scroll(function() {
  96. if($(window).scrollTop() + $(window).height() == $(document).height()) {
  97. loadMore();
  98. }
  99. });
  100. </script>
  101. <?php
  102. }
  103. ?>