mostcommentedimages.php 2.8 KB

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