From 1738eb457318068194571f337cff52f9a2bbb29b Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 12 Dec 2009 02:41:16 +0000 Subject: using image rss view for album display and condensed most viewed pages --- pages/lists/friendmostviewed.php | 59 ---------------------------------------- pages/lists/mostviewedimages.php | 39 +++++++++++++++++++++----- pages/lists/yourmostviewed.php | 49 --------------------------------- 3 files changed, 32 insertions(+), 115 deletions(-) delete mode 100644 pages/lists/friendmostviewed.php delete mode 100644 pages/lists/yourmostviewed.php (limited to 'pages/lists') 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 @@ -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 @@ 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 @@ -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 -- cgit v1.2.3