aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mostrecentimages.php20
-rw-r--r--mostviewedimages.php33
-rw-r--r--start.php34
-rw-r--r--viewimage.php19
-rw-r--r--views/default/object/image.php29
5 files changed, 114 insertions, 21 deletions
diff --git a/mostrecentimages.php b/mostrecentimages.php
new file mode 100644
index 000000000..8cc4a1f51
--- /dev/null
+++ b/mostrecentimages.php
@@ -0,0 +1,20 @@
+<?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(__FILE__))) . "/engine/start.php");
+
+ $max = 8;
+ $images = list_entities("object", "image", 0, $max, false, false, true);
+
+ $title = "Most recent images";
+ $area2 = elgg_view_title($title);
+ $area2 .= $images;
+ $body = elgg_view_layout('two_column_left_sidebar', '', $area2);
+ page_draw($title, $body);
+?> \ No newline at end of file
diff --git a/mostviewedimages.php b/mostviewedimages.php
new file mode 100644
index 000000000..0de7c626f
--- /dev/null
+++ b/mostviewedimages.php
@@ -0,0 +1,33 @@
+<?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(__FILE__))) . "/engine/start.php");
+
+ $prefix = "my_elgg"; //how do you get the global default?
+ $max = 24;
+ //grab the top views (metadata 'tp_views') for $max number of entities
+ //ignores entity subtypes
+ $sql = "select md.entity_guid, md.owner_guid, md.enabled, ms.string as views from " . $prefix . "metadata md
+ inner join " . $prefix . "metastrings ms on md.value_id = ms.id
+ inner join " . $prefix . "metastrings ms2 on md.name_id = ms2.id and ms2.string = 'tp_views'
+ order by views desc LIMIT $max";
+
+ $result = get_data($sql);
+
+ $entities = array();
+ foreach($result as $entity) {
+ $entities[] = get_entity($entity->entity_guid);
+ }
+
+ $title = "Most viewed images";
+ $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/start.php b/start.php
index 0d1b167d4..bbe665229 100644
--- a/start.php
+++ b/start.php
@@ -91,12 +91,14 @@
add_submenu_item( elgg_echo("album:yours"),
$CONFIG->wwwroot . "pg/photos/owned/" . $_SESSION['user']->username,
'tidypics' );
- add_submenu_item( sprintf(elgg_echo("album:user"), $page_owner->name),
- $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username,
- 'tidypics' );
- add_submenu_item( sprintf(elgg_echo('album:friends'),$page_owner->name),
- $CONFIG->wwwroot . "pg/photos/friends/". $page_owner->username,
- 'tidypics');
+ if($page_owner->name) {
+ add_submenu_item( sprintf(elgg_echo("album:user"), $page_owner->name),
+ $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username,
+ 'tidypics' );
+ add_submenu_item( sprintf(elgg_echo('album:friends'),$page_owner->name),
+ $CONFIG->wwwroot . "pg/photos/friends/". $page_owner->username,
+ 'tidypics');
+ }
} else if ($page_owner->guid) {
// non logged in user gets "page owners albums", "page owner's friends albums"
add_submenu_item( sprintf(elgg_echo("album:user"), $page_owner->name),
@@ -110,6 +112,11 @@
add_submenu_item( sprintf(elgg_echo('album:all'),$page_owner->name),
$CONFIG->wwwroot . "pg/photos/world/",
'tidypics');
+ add_submenu_item( "Most Viewed Images",
+ $CONFIG->wwwroot . 'pg/photos/mostviewed');
+
+ add_submenu_item( "Most Recent Images",
+ $CONFIG->wwwroot . 'pg/photos/mostrecent');
}
}
@@ -170,7 +177,21 @@
case "world":
include($CONFIG->pluginspath . "tidypics/world.php");
break;
+
+ case "rate": //rate image
+ if (isset($page[1])) set_input('guid',$page[1]);
+ include($CONFIG->pluginspath . "tidypics/actions/rate.php");
+ break;
+ case "mostviewed": //view an image individually
+ if (isset($page[1])) set_input('guid',$page[1]);
+ include($CONFIG->pluginspath . "tidypics/mostviewedimages.php");
+ break;
+
+ case "mostrecent": //view an image individually
+ if (isset($page[1])) set_input('guid',$page[1]);
+ include($CONFIG->pluginspath . "tidypics/mostrecentimages.php");
+ break;
}
}
else
@@ -255,5 +276,6 @@
register_action("tidypics/edit_multi", false, $CONFIG->pluginspath. "tidypics/actions/edit_multi.php");
register_action("tidypics/download", true, $CONFIG->pluginspath . "tidypics/actions/download.php");
register_action("tidypics/addtag", true, $CONFIG->pluginspath . "tidypics/actions/addtag.php");
+ register_action("tidypics/rate", true, $CONFIG->pluginspath . "tidypics/actions/rate.php");
?> \ No newline at end of file
diff --git a/viewimage.php b/viewimage.php
index fa05bda00..5b51725d7 100644
--- a/viewimage.php
+++ b/viewimage.php
@@ -31,6 +31,21 @@
$CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username);
}
+ $views = get_metadata_byname($photo_guid, "tp_views");
+ if(!$views || intval($views["value"] == 0)) $views["value"] = 0;
+ $views["value"] = $views["value"] + 1; //TODO: only add views for non-owner
+ create_metadata($photo_guid, "tp_views", $views["value"], "integer", 0, 2);
+
+ $viewer = get_loggedin_user();
+
+ $metadatas = get_metadata_for_entity($photo_guid);
+ $rating = 0;
+ foreach($metadatas as $metadata) {
+ if($metadata["owner_guid"] == $viewer["guid"]) {
+ if($metadata["name"] == "rating") $rating = $metadata["value"];
+ }
+ }
+
if (can_write_to_container(0, $album->container_guid)) {
add_submenu_item( elgg_echo('image:edit'),
$CONFIG->wwwroot . 'pg/photos/edit/' . $photo_guid,
@@ -41,9 +56,11 @@
true);
}
- $title = $photo->title;
+
+ $title = $photo->title . " - views: $views[value]";
$area2 = elgg_view_title($title);
$area2 .= elgg_view_entity($photo, true);
+ $area2 .= "<a href='$CONFIG->wwwroot" . "pg/photos/rate/$photo_guid'>Rate *</a>";
$body = elgg_view_layout('two_column_left_sidebar', '', $area2);
diff --git a/views/default/object/image.php b/views/default/object/image.php
index 8fd4dca9a..09a121256 100644
--- a/views/default/object/image.php
+++ b/views/default/object/image.php
@@ -179,22 +179,23 @@ if ($photo_tags) {
<?php
$viewer = get_loggedin_user();
- $friends = get_entities_from_relationship('friend', $viewer->getGUID(), false, 'user', '', 0);
-
- $content = "<input type='hidden' name='image_guid' value='{$file_guid}' />";
- $content .= "<input type='hidden' name='coordinates' id='coordinates' value='' />";
- $content .= "<input type='hidden' name='user_id' id='user_id' value='' />";
- $content .= "<input type='hidden' name='word' id='word' value='' />";
-
- $content .= "<ul id='phototagging-menu'>";
- $content .= "<li><a href='javascript:void(0)' onClick='selectUser({$viewer->getGUID()},\"{$viewer->name}\")'> {$viewer->name} (" . elgg_echo('me') . ")</a></li>";
-
- if ($friends) {
- foreach($friends as $friend) {
- $content .= "<li><a href='javascript:void(0)' onClick='selectUser({$friend->getGUID()}, \"{$friend->name}\")'>{$friend->name}</a></li>";
+ if($viewer) {
+ $friends = get_entities_from_relationship('friend', $viewer->getGUID(), false, 'user', '', 0);
+
+ $content = "<input type='hidden' name='image_guid' value='{$file_guid}' />";
+ $content .= "<input type='hidden' name='coordinates' id='coordinates' value='' />";
+ $content .= "<input type='hidden' name='user_id' id='user_id' value='' />";
+ $content .= "<input type='hidden' name='word' id='word' value='' />";
+
+ $content .= "<ul id='phototagging-menu'>";
+ $content .= "<li><a href='javascript:void(0)' onClick='selectUser({$viewer->getGUID()},\"{$viewer->name}\")'> {$viewer->name} (" . elgg_echo('me') . ")</a></li>";
+
+ if ($friends) {
+ foreach($friends as $friend) {
+ $content .= "<li><a href='javascript:void(0)' onClick='selectUser({$friend->getGUID()}, \"{$friend->name}\")'>{$friend->name}</a></li>";
+ }
}
}
-
$content .= "</ul>";
$content .= "<fieldset><button class='submit_button' type='submit'>" . elgg_echo('tidypics:actiontag') . "</button></fieldset>";