mostviewedimages.php 2.5 KB

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