From 2bd7ef20eca36015bd404a94c328c15bc3dd23df Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 22 Aug 2009 19:56:20 +0000 Subject: finished moving lists to pages/lists/ --- pages/lists/friendmostviewed.php | 59 ++++++++++++++++++++++++++++ pages/lists/highestrated.php | 2 +- pages/lists/highestvotecount.php | 2 +- pages/lists/mostcommentedimages.php | 2 +- pages/lists/mostcommentedimagesthismonth.php | 2 +- pages/lists/mostcommentedimagestoday.php | 2 +- pages/lists/mostviewedimages.php | 41 +++++++++++++++++++ pages/lists/mostviewedimageslastmonth.php | 50 +++++++++++++++++++++++ pages/lists/mostviewedimagesthismonth.php | 50 +++++++++++++++++++++++ pages/lists/mostviewedimagesthisyear.php | 50 +++++++++++++++++++++++ pages/lists/mostviewedimagestoday.php | 50 +++++++++++++++++++++++ pages/lists/recentlycommented.php | 2 +- pages/lists/recentlyviewed.php | 45 +++++++++++++++++++++ pages/lists/recentvotes.php | 2 +- pages/lists/yourmostviewed.php | 42 ++++++++++++++++++++ 15 files changed, 394 insertions(+), 7 deletions(-) create mode 100644 pages/lists/friendmostviewed.php create mode 100644 pages/lists/mostviewedimages.php create mode 100644 pages/lists/mostviewedimageslastmonth.php create mode 100644 pages/lists/mostviewedimagesthismonth.php create mode 100644 pages/lists/mostviewedimagesthisyear.php create mode 100644 pages/lists/mostviewedimagestoday.php create mode 100644 pages/lists/recentlyviewed.php create mode 100644 pages/lists/yourmostviewed.php (limited to 'pages/lists') diff --git a/pages/lists/friendmostviewed.php b/pages/lists/friendmostviewed.php new file mode 100644 index 000000000..793304edc --- /dev/null +++ b/pages/lists/friendmostviewed.php @@ -0,0 +1,59 @@ +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); + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + page_draw($title, $body); + +?> \ No newline at end of file diff --git a/pages/lists/highestrated.php b/pages/lists/highestrated.php index e9f0296e2..bacb7ba86 100644 --- a/pages/lists/highestrated.php +++ b/pages/lists/highestrated.php @@ -4,7 +4,7 @@ * */ - include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + 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')=='') { diff --git a/pages/lists/highestvotecount.php b/pages/lists/highestvotecount.php index 694afb32d..26b907144 100644 --- a/pages/lists/highestvotecount.php +++ b/pages/lists/highestvotecount.php @@ -7,7 +7,7 @@ */ // Load Elgg engine - include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; global $CONFIG; $prefix = $CONFIG->dbprefix; diff --git a/pages/lists/mostcommentedimages.php b/pages/lists/mostcommentedimages.php index b3a36a9ac..e22d3863e 100644 --- a/pages/lists/mostcommentedimages.php +++ b/pages/lists/mostcommentedimages.php @@ -7,7 +7,7 @@ */ // Load Elgg engine - include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; global $CONFIG; $prefix = $CONFIG->dbprefix; diff --git a/pages/lists/mostcommentedimagesthismonth.php b/pages/lists/mostcommentedimagesthismonth.php index c47cee2da..88b8371ee 100644 --- a/pages/lists/mostcommentedimagesthismonth.php +++ b/pages/lists/mostcommentedimagesthismonth.php @@ -7,7 +7,7 @@ */ // Load Elgg engine - include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; global $CONFIG; $prefix = $CONFIG->dbprefix; diff --git a/pages/lists/mostcommentedimagestoday.php b/pages/lists/mostcommentedimagestoday.php index 066feb45e..d35ac468d 100644 --- a/pages/lists/mostcommentedimagestoday.php +++ b/pages/lists/mostcommentedimagestoday.php @@ -7,7 +7,7 @@ */ // Load Elgg engine - include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; global $CONFIG; $prefix = $CONFIG->dbprefix; diff --git a/pages/lists/mostviewedimages.php b/pages/lists/mostviewedimages.php new file mode 100644 index 000000000..bd1b3ee92 --- /dev/null +++ b/pages/lists/mostviewedimages.php @@ -0,0 +1,41 @@ +dbprefix; + $max = 24; + + //this works but is wildly inefficient + //$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); + + $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 AND ann1.owner_guid != ent.owner_guid + INNER JOIN " . $prefix . "metastrings ms ON ms.id = ann1.name_id + AND ms.string = 'tp_view' + 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:mostviewed"); + $area2 = elgg_view_title($title); + $area2 .= elgg_view_entity_list($entities, $max, 0, $max); + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + page_draw($title, $body); +?> \ No newline at end of file diff --git a/pages/lists/mostviewedimageslastmonth.php b/pages/lists/mostviewedimageslastmonth.php new file mode 100644 index 000000000..c5edec3d9 --- /dev/null +++ b/pages/lists/mostviewedimageslastmonth.php @@ -0,0 +1,50 @@ +dbprefix; + $max = 24; + + + //find timestamps for first and last days of last month + $time_info = new stdClass(); + $time_info->start = strtotime("-1 months", mktime(0,0,0, date("m"), 1, date("Y"))); + $time_info->end = mktime(0,0,0,date("m"), 0, date("Y")); + + //this works but is wildly inefficient + //$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); + + $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 AND ann1.owner_guid != ent.owner_guid + INNER JOIN " . $prefix . "metastrings ms ON ms.id = ann1.name_id + AND ms.string = 'tp_view' + WHERE ann1.time_created BETWEEN $time_info->start AND $time_info->end + 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); + } + + tidypics_mostviewed_submenus(); + $title = elgg_echo("tidypics:mostviewedlastmonth"); + $area2 = elgg_view_title($title); + $area2 .= elgg_view_entity_list($entities, $max, 0, $max); + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + page_draw($title, $body); +?> \ No newline at end of file diff --git a/pages/lists/mostviewedimagesthismonth.php b/pages/lists/mostviewedimagesthismonth.php new file mode 100644 index 000000000..dfdb6136a --- /dev/null +++ b/pages/lists/mostviewedimagesthismonth.php @@ -0,0 +1,50 @@ +dbprefix; + $max = 24; + + + //find timestamps for first and last days of this month + $time_info = new stdClass(); + $time_info->start = mktime(0,0,0, date("m"), 1, date("Y")); + $time_info->end = mktime(); + + //this works but is wildly inefficient + //$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); + + $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 AND ann1.owner_guid != ent.owner_guid + INNER JOIN " . $prefix . "metastrings ms ON ms.id = ann1.name_id + AND ms.string = 'tp_view' + WHERE ann1.time_created BETWEEN $time_info->start AND $time_info->end + 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); + } + + tidypics_mostviewed_submenus(); + $title = elgg_echo("tidypics:mostviewedthismonth"); + $area2 = elgg_view_title($title); + $area2 .= elgg_view_entity_list($entities, $max, 0, $max); + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + page_draw($title, $body); +?> \ No newline at end of file diff --git a/pages/lists/mostviewedimagesthisyear.php b/pages/lists/mostviewedimagesthisyear.php new file mode 100644 index 000000000..e6c8a53db --- /dev/null +++ b/pages/lists/mostviewedimagesthisyear.php @@ -0,0 +1,50 @@ +dbprefix; + $max = 24; + + + //find timestamps for first day of the year and current date + $time_info = new stdClass(); + $time_info->start = mktime(0,0,0, 1, 1, date("Y")); + $time_info->end = mktime(); + + //this works but is wildly inefficient + //$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); + + $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 AND ann1.owner_guid != ent.owner_guid + INNER JOIN " . $prefix . "metastrings ms ON ms.id = ann1.name_id + AND ms.string = 'tp_view' + WHERE ann1.time_created BETWEEN $time_info->start AND $time_info->end + 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); + } + + tidypics_mostviewed_submenus(); + $title = elgg_echo("tidypics:mostviewedthisyear"); + $area2 = elgg_view_title($title); + $area2 .= elgg_view_entity_list($entities, $max, 0, $max); + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + page_draw($title, $body); +?> \ No newline at end of file diff --git a/pages/lists/mostviewedimagestoday.php b/pages/lists/mostviewedimagestoday.php new file mode 100644 index 000000000..9845506eb --- /dev/null +++ b/pages/lists/mostviewedimagestoday.php @@ -0,0 +1,50 @@ +dbprefix; + $max = 24; + + + //find timestamps for today + $time_info = new stdClass(); + $time_info->start = mktime(0,0,0, date("m"), date("d"), date("Y")); + $time_info->end = mktime(); + + //this works but is wildly inefficient + //$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); + + $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 AND ann1.owner_guid != ent.owner_guid + INNER JOIN " . $prefix . "metastrings ms ON ms.id = ann1.name_id + AND ms.string = 'tp_view' + WHERE ann1.time_created BETWEEN $time_info->start AND $time_info->end + 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); + } + + tidypics_mostviewed_submenus(); + $title = elgg_echo("tidypics:mostviewedtoday"); + $area2 = elgg_view_title($title); + $area2 .= elgg_view_entity_list($entities, $max, 0, $max); + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + page_draw($title, $body); +?> \ No newline at end of file diff --git a/pages/lists/recentlycommented.php b/pages/lists/recentlycommented.php index bfb64981d..da0f2a12a 100644 --- a/pages/lists/recentlycommented.php +++ b/pages/lists/recentlycommented.php @@ -7,7 +7,7 @@ */ // Load Elgg engine - include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; global $CONFIG; $prefix = $CONFIG->dbprefix; diff --git a/pages/lists/recentlyviewed.php b/pages/lists/recentlyviewed.php new file mode 100644 index 000000000..b8a5531b2 --- /dev/null +++ b/pages/lists/recentlyviewed.php @@ -0,0 +1,45 @@ +dbprefix; + $max_limit = 200; //get extra because you'll have multiple views per image in the result set + $max = 16; //controls how many actually show on screen + + //this works but is wildly inefficient + //$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); + + $sql = "SELECT distinct ent.guid, ann1.time_created + 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' + ORDER BY ann1.id DESC + LIMIT $max_limit"; + + $result = get_data($sql); + + $entities = array(); + foreach($result as $entity) { + if(!$entities[$entity->guid]) { + $entities[$entity->guid] = get_entity($entity->guid); + } + if(count($entities) >= $max) break; + } + + $title = elgg_echo("tidypics:recentlyviewed"); + $area2 = elgg_view_title($title); + $area2 .= elgg_view_entity_list($entities, $max, 0, $max); + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + page_draw($title, $body); +?> \ No newline at end of file diff --git a/pages/lists/recentvotes.php b/pages/lists/recentvotes.php index f9ddbdc38..3d8eac97e 100644 --- a/pages/lists/recentvotes.php +++ b/pages/lists/recentvotes.php @@ -7,7 +7,7 @@ */ // Load Elgg engine - include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; global $CONFIG; $prefix = $CONFIG->dbprefix; diff --git a/pages/lists/yourmostviewed.php b/pages/lists/yourmostviewed.php new file mode 100644 index 000000000..6a2114d19 --- /dev/null +++ b/pages/lists/yourmostviewed.php @@ -0,0 +1,42 @@ +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); + $area2 .= elgg_view_entity_list($entities, $max, 0, $max); + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + page_draw($title, $body); +?> \ No newline at end of file -- cgit v1.2.3