mostcommentedimagesthismonth.php 3.0 KB

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