diff options
author | Cash Costello <cash.costello@gmail.com> | 2009-12-12 02:41:16 +0000 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2009-12-12 02:41:16 +0000 |
commit | 1738eb457318068194571f337cff52f9a2bbb29b (patch) | |
tree | ea7d3931ab9419d0babe7571acee0ff875cc1479 /pages/lists | |
parent | 58fd575a7b28936455baea2856b1d5613d29b477 (diff) | |
download | elgg-1738eb457318068194571f337cff52f9a2bbb29b.tar.gz elgg-1738eb457318068194571f337cff52f9a2bbb29b.tar.bz2 |
using image rss view for album display and condensed most viewed pages
Diffstat (limited to 'pages/lists')
-rw-r--r-- | pages/lists/friendmostviewed.php | 59 | ||||
-rw-r--r-- | pages/lists/mostviewedimages.php | 39 | ||||
-rw-r--r-- | pages/lists/yourmostviewed.php | 49 |
3 files changed, 32 insertions, 115 deletions
diff --git a/pages/lists/friendmostviewed.php b/pages/lists/friendmostviewed.php deleted file mode 100644 index 07fcd39b5..000000000 --- a/pages/lists/friendmostviewed.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php - /** - * Tidypics Friends Albums Listing - * - */ - - include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; - - //if no friends were requested, see world pictures instead, or redirect to user's friends -/* if (is_null(get_input('username')) || get_input('username')=='') { - if (!isloggedin()) { - forward('pg/photos/world'); - } else { - forward('pg/photos/friends/' . $_SESSION['user']->username); - } - }*/ - - if (is_null(page_owner_entity()->name) || page_owner_entity()->name == '') { - $friendname = get_input('username'); - } else { - $friendname = page_owner_entity()->name; - }; - - //there has to be a better way to do this - if(!$friendname) { - $page = get_input("page"); - list($pagename, $friendname) = split("/", $page); - } - $user = get_user_by_username($friendname); - global $CONFIG; - $prefix = $CONFIG->dbprefix; - $max = 24; - - $sql = "SELECT ent.guid, count( * ) AS views - FROM " . $prefix . "entities ent - INNER JOIN " . $prefix . "entity_subtypes sub ON ent.subtype = sub.id - AND sub.subtype = 'image' - INNER JOIN " . $prefix . "annotations ann1 ON ann1.entity_guid = ent.guid - INNER JOIN " . $prefix . "metastrings ms ON ms.id = ann1.name_id - AND ms.string = 'tp_view' - WHERE ent.owner_guid = " . $user->guid . " - GROUP BY ent.guid - ORDER BY views DESC - LIMIT $max"; - - $result = get_data($sql); - - $entities = array(); - foreach($result as $entity) { - $entities[] = get_entity($entity->guid); - } - - $title = sprintf(elgg_echo("tidypics:friendmostviewed"), $friendname); - $area2 = elgg_view_title($title); - $area2 .= elgg_view_entity_list($entities, $max, 0, $max, false); - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - page_draw($title, $body); - -?>
\ No newline at end of file diff --git a/pages/lists/mostviewedimages.php b/pages/lists/mostviewedimages.php index b8cc67b51..16b9d7295 100644 --- a/pages/lists/mostviewedimages.php +++ b/pages/lists/mostviewedimages.php @@ -1,8 +1,7 @@ <?php /** - * Tidypics full view of an image - * Given a GUID, this page will try and display any entity + * Most viewed images - either for a user or all site * */ @@ -13,9 +12,24 @@ $prefix = $CONFIG->dbprefix; $max = 24; + $owner_guid = page_owner(); + + //$start = microtime(true); + $photos = tp_get_entities_from_annotations_calculate_x( + 'count', + 'object', + 'image', + 'tp_view', + '', + '', + $owner_guid, + $max); + //error_log("elgg query is " . (float)(microtime(true) - $start)); + //this works but is wildly inefficient //$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); - +/* + $start = microtime(true); $sql = "SELECT ent.guid, count( * ) AS views FROM " . $prefix . "entities ent INNER JOIN " . $prefix . "entity_subtypes sub ON ent.subtype = sub.id @@ -33,15 +47,26 @@ foreach($result as $entity) { $entities[] = get_entity($entity->guid); } - $title = elgg_echo("tidypics:mostviewed"); +*/ + //error_log("custom query is " . (float)(microtime(true) - $start)); + + if ($owner_guid) { + if ($owner_guid == get_loggedin_userid()) { + $title = elgg_echo("tidypics:yourmostviewed"); + } else { + $title = sprintf(elgg_echo("tidypics:friendmostviewed"), page_owner_entity()->name); + } + } else { + $title = elgg_echo("tidypics:mostviewed"); + } $area2 = elgg_view_title($title); // grab the html to display the images - $images = tp_view_entity_list($entities, $max, 0, $max, false); + $content = tp_view_entity_list($photos, $max, 0, $max, false); // this view takes care of the title on the main column and the content wrapper - $area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $images,)); - if( empty( $area2 )) $area2 = $images; + $area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $content,)); + if( empty( $area2 )) $area2 = $content; $body = elgg_view_layout('two_column_left_sidebar', '', $area2); page_draw($title, $body); diff --git a/pages/lists/yourmostviewed.php b/pages/lists/yourmostviewed.php deleted file mode 100644 index 9155c4454..000000000 --- a/pages/lists/yourmostviewed.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php - - /** - * Tidypics full view of an image - * Given a GUID, this page will try and display any entity - * - */ - - // Load Elgg engine - include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; - - $viewer = get_loggedin_user(); - - global $CONFIG; - $prefix = $CONFIG->dbprefix; - $max = 24; - - $sql = "SELECT ent.guid, count( * ) AS views - FROM " . $prefix . "entities ent - INNER JOIN " . $prefix . "entity_subtypes sub ON ent.subtype = sub.id - AND sub.subtype = 'image' - INNER JOIN " . $prefix . "annotations ann1 ON ann1.entity_guid = ent.guid - INNER JOIN " . $prefix . "metastrings ms ON ms.id = ann1.name_id - AND ms.string = 'tp_view' - WHERE ent.owner_guid = " . $viewer->guid . " - GROUP BY ent.guid - ORDER BY views DESC - LIMIT $max"; - - $result = get_data($sql); - - $entities = array(); - foreach($result as $entity) { - $entities[] = get_entity($entity->guid); - } - - $title = elgg_echo("tidypics:yourmostviewed"); - $area2 = elgg_view_title($title); - - // grab the html to display the images - $images = tp_view_entity_list($entities, $max, 0, $max, false); - - // this view takes care of the title on the main column and the content wrapper - $area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $images,)); - if( empty( $area2 )) $area2 = $images; - - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - page_draw($title, $body); -?>
\ No newline at end of file |