mostviewedimagestoday.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Most viewed images of today
  4. *
  5. */
  6. // set up breadcrumbs
  7. elgg_push_breadcrumb(elgg_echo('photos'), 'photos/siteimagesall');
  8. elgg_push_breadcrumb(elgg_echo('tidypics:mostviewedtoday'));
  9. $offset = (int)get_input('offset', 0);
  10. $limit = (int)get_input('limit', 16);
  11. $start = mktime(0,0,0, date("m"), date("d"), date("Y"));
  12. $end = time();
  13. $options = array(
  14. 'type' => 'object',
  15. 'subtype' => 'image',
  16. 'limit' => $limit,
  17. 'offset' => $offset,
  18. 'annotation_name' => 'tp_view',
  19. 'calculation' => 'count',
  20. 'annotation_created_time_lower' => $start,
  21. 'annotation_created_time_upper' => $end,
  22. 'order_by' => 'annotation_calculation desc',
  23. 'full_view' => false,
  24. 'list_type' => 'gallery',
  25. 'gallery_class' => 'tidypics-gallery'
  26. );
  27. $result = elgg_list_entities_from_annotation_calculation($options);
  28. $title = elgg_echo('tidypics:mostviewedtoday');
  29. if (elgg_is_logged_in()) {
  30. $logged_in_guid = elgg_get_logged_in_user_guid();
  31. elgg_register_menu_item('title', array('name' => 'addphotos',
  32. 'href' => "ajax/view/photos/selectalbum/?owner_guid=" . $logged_in_guid,
  33. 'text' => elgg_echo("photos:addphotos"),
  34. 'link_class' => 'elgg-button elgg-button-action elgg-lightbox'));
  35. }
  36. // only show slideshow link if slideshow is enabled in plugin settings and there are images
  37. if (elgg_get_plugin_setting('slideshow', 'tidypics') && !empty($result)) {
  38. $url = elgg_get_site_url() . "photos/mostviewedtoday?limit=64&offset=$offset&view=rss";
  39. $url = elgg_format_url($url);
  40. $slideshow_link = "javascript:PicLensLite.start({maxScale:0, feedUrl:'$url'})";
  41. elgg_register_menu_item('title', array('name' => 'slideshow',
  42. 'href' => $slideshow_link,
  43. 'text' => "<img src=\"".elgg_get_site_url() ."mod/tidypics/graphics/slideshow.png\" alt=\"".elgg_echo('album:slideshow')."\">",
  44. 'title' => elgg_echo('album:slideshow'),
  45. 'link_class' => 'elgg-button elgg-button-action'));
  46. }
  47. if (!empty($result)) {
  48. $area2 = $result;
  49. } else {
  50. $area2 = elgg_echo('tidypics:mostviewedtoday:nosuccess');
  51. }
  52. $body = elgg_view_layout('content', array(
  53. 'filter_override' => '',
  54. 'content' => $area2,
  55. 'title' => $title,
  56. 'sidebar' => elgg_view('photos/sidebar', array('page' => 'all')),
  57. ));
  58. // Draw it
  59. echo elgg_view_page(elgg_echo('tidypics:mostviewedtoday'), $body);