From 9f0433b31ea8c6e00b314f511ef4ca0d8a9c4ce7 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Thu, 27 Aug 2009 11:34:03 +0000 Subject: step 2 in moving views code to library completed - now using library code --- languages/en.php | 5 ++-- views/default/object/image.php | 60 +++++++++++++++--------------------------- 2 files changed, 24 insertions(+), 41 deletions(-) diff --git a/languages/en.php b/languages/en.php index 674c71207..c233e8090 100644 --- a/languages/en.php +++ b/languages/en.php @@ -43,8 +43,9 @@ 'tidypics:friendmostviewed' => "%s's most viewed images", 'tidypics:friendmostrecent' => "%s's most recent images", 'tidypics:highestrated' => "Highest rated images", - 'tidypics:viewsbyowner' => "Views: %s by %s users (not including you)", - 'tidypics:viewsbyothers' => "Views: %s (%s by you)", + 'tidypics:views' => "Views: %s", + 'tidypics:viewsbyowner' => "by %s users (not including you)", + 'tidypics:viewsbyothers' => "(%s by you)", 'tidypics:administration' => 'Tidypics Administration', 'tidypics:stats' => 'Stats', diff --git a/views/default/object/image.php b/views/default/object/image.php index 025f37d40..db39bb4fa 100644 --- a/views/default/object/image.php +++ b/views/default/object/image.php @@ -14,7 +14,6 @@ $desc = $image->description; $owner = $image->getOwnerEntity(); $friendlytime = friendly_time($image->time_created); - $mime = $image->mimetype; /******************************************************************** @@ -24,6 +23,7 @@ ********************************************************************/ if (get_context() == "search") { + // gallery view is a matrix view showing just the image - size: small if (get_input('search_viewtype') == "gallery") { ?>
@@ -32,7 +32,7 @@ '.$title.'

'; $info .= "

username}\">{$owner->name} {$friendlytime}"; $numcomments = elgg_count_comments($image); @@ -40,17 +40,21 @@ $info .= ", getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")"; $info .= "

"; $icon = "getURL()}\">" . '' . $title . ''; - + echo elgg_view_listing($icon, $info); } + /*************************************************************** * * front page view * ****************************************************************/ } else if (get_context() == "front") { + // the front page view is a clikcable thumbnail of the image ?> - <?php echo $title; ?> + +<?php echo $title; ?> + guid) { - $the_viewer = $viewer->guid; - } else { - $the_viewer = 0; - } - - // only non-owner views count - if ($owner->guid != $view->owner_guid) - create_annotation($image_guid, "tp_view", "1", "integer", $the_viewer, ACCESS_PUBLIC); - $views_a = get_annotations($image_guid, "object", "image", "tp_view", "", 0, 9999); - $views = count($views_a); - - $my_views = 0; - $owner_views = 0; - $diff_viewers = array(); - // echo "
"; var_dump($owner); echo "
"; - foreach($views_a as $view) { - if($view->owner_guid == $the_viewer && $the_viewer != 0) $my_views++; - if($owner->guid == $view->owner_guid) $owner_views++; - //count how many different people have viewed it - if($owner->guid != $view->owner_guid) $diff_viewers[$view->owner_guid] = 1; - } - //remove the owner's views from the total count (prevents artificially inflated view counts) - $views = $views - $owner_views; - } // Build back and next links $back = ''; @@ -143,11 +117,19 @@
$album,) ); ?>
guid == $the_viewer) { - echo sprintf(elgg_echo("tidypics:viewsbyowner"), $views, count($diff_viewers)); - } else { - echo sprintf(elgg_echo("tidypics:viewsbyothers"), $views, $my_views); + if (get_plugin_setting('view_count', 'tidypics') != "disabled") { + + $image->addView($viewer->guid); + $views = $image->getViews($viewer->guid); + if (is_array($views)) { + echo sprintf(elgg_echo("tidypics:views"), $views['total']); + if ($owner->guid == $viewer->guid) { + echo ' ' . sprintf(elgg_echo("tidypics:viewsbyowner"), $views['unique']); + } + else { + if ($views['mine']) + echo ' ' . sprintf(elgg_echo("tidypics:viewsbyothers"), $views['mine']); + } } } ?> -- cgit v1.2.3