aboutsummaryrefslogtreecommitdiff
path: root/mod/lightpics/pages
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2013-11-09 16:22:50 +0100
committerSem <sembrestels@riseup.net>2013-11-09 16:22:50 +0100
commitf448cd91f9ecebea37daf40aada2fa1a20200817 (patch)
tree4636059da6a1be133a4974e5098b7c1e08944dd5 /mod/lightpics/pages
parent52335325e5ea8c89c711e1ba40d9ac1657004e61 (diff)
parent324f39c3a9aa41e9e23bafba38882a2b72f62441 (diff)
downloadelgg-f448cd91f9ecebea37daf40aada2fa1a20200817.tar.gz
elgg-f448cd91f9ecebea37daf40aada2fa1a20200817.tar.bz2
Add 'mod/lightpics/' from commit '324f39c3a9aa41e9e23bafba38882a2b72f62441'
git-subtree-dir: mod/lightpics git-subtree-mainline: 52335325e5ea8c89c711e1ba40d9ac1657004e61 git-subtree-split: 324f39c3a9aa41e9e23bafba38882a2b72f62441
Diffstat (limited to 'mod/lightpics/pages')
-rw-r--r--mod/lightpics/pages/lists/highestrated.php65
-rw-r--r--mod/lightpics/pages/lists/highestvotecount.php50
-rw-r--r--mod/lightpics/pages/lists/mostcommentedimages.php42
-rw-r--r--mod/lightpics/pages/lists/mostcommentedimagesthismonth.php50
-rw-r--r--mod/lightpics/pages/lists/mostcommentedimagestoday.php50
-rw-r--r--mod/lightpics/pages/lists/mostrecentimages.php56
-rw-r--r--mod/lightpics/pages/lists/mostviewedimages.php79
-rw-r--r--mod/lightpics/pages/lists/mostviewedimageslastmonth.php50
-rw-r--r--mod/lightpics/pages/lists/mostviewedimagesthismonth.php50
-rw-r--r--mod/lightpics/pages/lists/mostviewedimagesthisyear.php50
-rw-r--r--mod/lightpics/pages/lists/mostviewedimagestoday.php50
-rw-r--r--mod/lightpics/pages/lists/recentlycommented.php61
-rw-r--r--mod/lightpics/pages/lists/recentlyviewed.php60
-rw-r--r--mod/lightpics/pages/lists/recentvotes.php52
-rw-r--r--mod/lightpics/pages/photos/album/add.php34
-rw-r--r--mod/lightpics/pages/photos/album/edit.php48
-rw-r--r--mod/lightpics/pages/photos/album/sort.php56
-rw-r--r--mod/lightpics/pages/photos/album/view.php63
-rw-r--r--mod/lightpics/pages/photos/all.php38
-rw-r--r--mod/lightpics/pages/photos/batch/edit.php44
-rw-r--r--mod/lightpics/pages/photos/friends.php34
-rw-r--r--mod/lightpics/pages/photos/image/download.php41
-rw-r--r--mod/lightpics/pages/photos/image/edit.php54
-rw-r--r--mod/lightpics/pages/photos/image/thumbnail.php38
-rw-r--r--mod/lightpics/pages/photos/image/upload.php64
-rw-r--r--mod/lightpics/pages/photos/image/view.php61
-rw-r--r--mod/lightpics/pages/photos/owner.php56
27 files changed, 1396 insertions, 0 deletions
diff --git a/mod/lightpics/pages/lists/highestrated.php b/mod/lightpics/pages/lists/highestrated.php
new file mode 100644
index 000000000..e05e7a9ba
--- /dev/null
+++ b/mod/lightpics/pages/lists/highestrated.php
@@ -0,0 +1,65 @@
+<?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 == '') {
+// $groupname = get_input('username');
+// } else {
+// $groupname = page_owner_entity()->name;
+// };
+//
+ //there has to be a better way to do this
+ if(!$groupname) {
+ $page = get_input("page");
+ list($pagename, $groupname) = split("/", $page);
+ }
+
+ list($group_holder, $album_id) = split(":", $groupname);
+// echo "<pre>page: $page\ngroup: $groupname\nalbum: $album_id"; die;
+
+ $user = get_user_by_username($friendname);
+ global $CONFIG;
+ $prefix = $CONFIG->dbprefix;
+ $max = 24;
+
+ $sql = "SELECT ent.guid, count(1) as mycount, avg(ms2.string) as average
+ FROM " . $prefix . "entities ent
+ INNER JOIN " . $prefix . "entity_subtypes sub ON ent.subtype = sub.id
+ AND sub.subtype = 'image' AND ent.container_guid = $album_id
+ 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 = 'generic_rate'
+ INNER JOIN " . $prefix . "metastrings ms2 ON ms2.id = ann1.value_id
+ INNER JOIN " . $prefix . "users_entity u ON ann1.owner_guid = u.guid
+ GROUP BY ent.guid HAVING mycount > 1
+ ORDER BY average DESC
+ LIMIT $max";
+
+ $result = get_data($sql);
+
+ $entities = array();
+ foreach($result as $entity) {
+ $entities[] = get_entity($entity->guid);
+ }
+
+ $album = get_entity($album_id);
+ $title = $album["title"] . ": " . elgg_echo("tidypics:highestrated");
+ $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/mod/lightpics/pages/lists/highestvotecount.php b/mod/lightpics/pages/lists/highestvotecount.php
new file mode 100644
index 000000000..26b907144
--- /dev/null
+++ b/mod/lightpics/pages/lists/highestvotecount.php
@@ -0,0 +1,50 @@
+<?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";
+
+ global $CONFIG;
+ $prefix = $CONFIG->dbprefix;
+ $max = 24;
+
+ $sql = "SELECT ent.guid, u.name as owner, count( 1 ) AS mycount, avg( ms2.string ) AS average
+ 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 = 'generic_rate'
+ INNER JOIN " . $prefix . "metastrings ms2 ON ms2.id = ann1.value_id
+ INNER JOIN " . $prefix . "users_entity u ON ent.owner_guid = u.guid
+ GROUP BY ent.guid
+ ORDER BY mycount DESC
+ LIMIT $max";
+
+ $result = get_data($sql);
+
+ $title = "Most voted images";
+ $area2 = elgg_view_title($title);
+
+ $entities = array();
+ foreach($result as $entity) {
+ $entities[] = get_entity($entity->guid);
+ $full_entity = get_entity($entity->guid);
+ $area2 .= " <div class='tidypics_album_images'>
+ Owner: $entity->owner<br />
+ Votes: $entity->mycount<br />
+ Average: $entity->average
+ </div>
+ ";
+ $area2 .= elgg_view_entity($full_entity);
+
+ }
+
+ $body = elgg_view_layout('two_column_left_sidebar', '', $area2);
+ page_draw($title, $body);
+?> \ No newline at end of file
diff --git a/mod/lightpics/pages/lists/mostcommentedimages.php b/mod/lightpics/pages/lists/mostcommentedimages.php
new file mode 100644
index 000000000..0a4eb9622
--- /dev/null
+++ b/mod/lightpics/pages/lists/mostcommentedimages.php
@@ -0,0 +1,42 @@
+<?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";
+
+global $CONFIG;
+$prefix = $CONFIG->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
+ INNER JOIN " . $prefix . "metastrings ms ON ms.id = ann1.name_id
+ AND ms.string = 'generic_comment'
+ 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:mostcommented");
+$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/mod/lightpics/pages/lists/mostcommentedimagesthismonth.php b/mod/lightpics/pages/lists/mostcommentedimagesthismonth.php
new file mode 100644
index 000000000..d95e2aff5
--- /dev/null
+++ b/mod/lightpics/pages/lists/mostcommentedimagesthismonth.php
@@ -0,0 +1,50 @@
+<?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";
+
+ global $CONFIG;
+ $prefix = $CONFIG->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
+ INNER JOIN " . $prefix . "metastrings ms ON ms.id = ann1.name_id
+ AND ms.string = 'generic_comment'
+ 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:mostcommentedthismonth");
+ $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/mod/lightpics/pages/lists/mostcommentedimagestoday.php b/mod/lightpics/pages/lists/mostcommentedimagestoday.php
new file mode 100644
index 000000000..bd1a0cbec
--- /dev/null
+++ b/mod/lightpics/pages/lists/mostcommentedimagestoday.php
@@ -0,0 +1,50 @@
+<?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";
+
+ global $CONFIG;
+ $prefix = $CONFIG->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
+ INNER JOIN " . $prefix . "metastrings ms ON ms.id = ann1.name_id
+ AND ms.string = 'generic_comment'
+ 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:mostcommentedtoday");
+ $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/mod/lightpics/pages/lists/mostrecentimages.php b/mod/lightpics/pages/lists/mostrecentimages.php
new file mode 100644
index 000000000..83ec3e988
--- /dev/null
+++ b/mod/lightpics/pages/lists/mostrecentimages.php
@@ -0,0 +1,56 @@
+<?php
+
+/**
+ * Most recently uploaded images - individual or world
+ *
+ */
+
+// Load Elgg engine
+include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php";
+
+// start with assumption this is for all site photos
+$title = elgg_echo('tidypics:mostrecent');
+$user_id = 0;
+
+// is this all site or an individuals images
+$username = get_input('username');
+if ($username) {
+ $user = get_user_by_username($username);
+ if ($user) {
+ $user_id = $user->guid;
+
+ if ($user_id == get_loggedin_userid()) {
+ $title = elgg_echo('tidypics:yourmostrecent');
+ } else {
+ $title = sprintf(elgg_echo("tidypics:friendmostrecent"), $user->name);
+ }
+ }
+} else {
+ // world view - set page owner to logged in user
+ if (isloggedin()) {
+ set_page_owner(get_loggedin_userid());
+ }
+}
+
+// how many do we display
+$max = 12;
+
+// grab the html to display the images
+$images = elgg_list_entities(array(
+ "type" => "object",
+ "subtype" => "image",
+ "owner_guid" => $user_id,
+ "limit" => $max,
+ "full_view" => 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);
diff --git a/mod/lightpics/pages/lists/mostviewedimages.php b/mod/lightpics/pages/lists/mostviewedimages.php
new file mode 100644
index 000000000..c113c39e2
--- /dev/null
+++ b/mod/lightpics/pages/lists/mostviewedimages.php
@@ -0,0 +1,79 @@
+<?php
+
+/**
+ * Most viewed images - either for a user or all site
+ *
+ */
+
+// Load Elgg engine
+include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php";
+
+global $CONFIG;
+$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
+ 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);
+ }
+*/
+//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 {
+ // world view - set page owner to logged in user
+ if (isloggedin()) {
+ set_page_owner(get_loggedin_userid());
+ }
+
+ $title = elgg_echo("tidypics:mostviewed");
+}
+$area2 = elgg_view_title($title);
+
+// grab the html to display the images
+$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' => $content,));
+if (empty($area2)) {
+ $area2 = $content;
+}
+
+$body = elgg_view_layout('two_column_left_sidebar', '', $area2);
+page_draw($title, $body);
diff --git a/mod/lightpics/pages/lists/mostviewedimageslastmonth.php b/mod/lightpics/pages/lists/mostviewedimageslastmonth.php
new file mode 100644
index 000000000..1ed9161f7
--- /dev/null
+++ b/mod/lightpics/pages/lists/mostviewedimageslastmonth.php
@@ -0,0 +1,50 @@
+<?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";
+
+ global $CONFIG;
+ $prefix = $CONFIG->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, false);
+ $body = elgg_view_layout('two_column_left_sidebar', '', $area2);
+ page_draw($title, $body);
+?> \ No newline at end of file
diff --git a/mod/lightpics/pages/lists/mostviewedimagesthismonth.php b/mod/lightpics/pages/lists/mostviewedimagesthismonth.php
new file mode 100644
index 000000000..bfe08e1da
--- /dev/null
+++ b/mod/lightpics/pages/lists/mostviewedimagesthismonth.php
@@ -0,0 +1,50 @@
+<?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";
+
+ global $CONFIG;
+ $prefix = $CONFIG->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, false);
+ $body = elgg_view_layout('two_column_left_sidebar', '', $area2);
+ page_draw($title, $body);
+?> \ No newline at end of file
diff --git a/mod/lightpics/pages/lists/mostviewedimagesthisyear.php b/mod/lightpics/pages/lists/mostviewedimagesthisyear.php
new file mode 100644
index 000000000..fe1a63d38
--- /dev/null
+++ b/mod/lightpics/pages/lists/mostviewedimagesthisyear.php
@@ -0,0 +1,50 @@
+<?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";
+
+ global $CONFIG;
+ $prefix = $CONFIG->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, false);
+ $body = elgg_view_layout('two_column_left_sidebar', '', $area2);
+ page_draw($title, $body);
+?> \ No newline at end of file
diff --git a/mod/lightpics/pages/lists/mostviewedimagestoday.php b/mod/lightpics/pages/lists/mostviewedimagestoday.php
new file mode 100644
index 000000000..f8e844753
--- /dev/null
+++ b/mod/lightpics/pages/lists/mostviewedimagestoday.php
@@ -0,0 +1,50 @@
+<?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";
+
+ global $CONFIG;
+ $prefix = $CONFIG->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, false);
+ $body = elgg_view_layout('two_column_left_sidebar', '', $area2);
+ page_draw($title, $body);
+?> \ No newline at end of file
diff --git a/mod/lightpics/pages/lists/recentlycommented.php b/mod/lightpics/pages/lists/recentlycommented.php
new file mode 100644
index 000000000..08f69603a
--- /dev/null
+++ b/mod/lightpics/pages/lists/recentlycommented.php
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * Images recently commented on - world view only
+ *
+ */
+
+// Load Elgg engine
+include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php";
+
+// world view - set page owner to logged in user
+if (isloggedin()) {
+ set_page_owner(get_loggedin_userid());
+}
+
+
+global $CONFIG;
+$prefix = $CONFIG->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 = 'generic_comment'
+ ORDER BY ann1.time_created 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;
+ }
+}
+
+$user = get_loggedin_user();
+$title = elgg_echo("tidypics:recentlycommented");
+$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);
diff --git a/mod/lightpics/pages/lists/recentlyviewed.php b/mod/lightpics/pages/lists/recentlyviewed.php
new file mode 100644
index 000000000..851804e99
--- /dev/null
+++ b/mod/lightpics/pages/lists/recentlyviewed.php
@@ -0,0 +1,60 @@
+<?php
+
+/**
+ * Most recently viewed images - world view only right now
+ *
+ */
+
+// Load Elgg engine
+include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php";
+
+// world view - set page owner to logged in user
+if (isloggedin()) {
+ set_page_owner(get_loggedin_userid());
+}
+
+
+global $CONFIG;
+$prefix = $CONFIG->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);
+
+// 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);
diff --git a/mod/lightpics/pages/lists/recentvotes.php b/mod/lightpics/pages/lists/recentvotes.php
new file mode 100644
index 000000000..3d8eac97e
--- /dev/null
+++ b/mod/lightpics/pages/lists/recentvotes.php
@@ -0,0 +1,52 @@
+<?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";
+
+ global $CONFIG;
+ $prefix = $CONFIG->dbprefix;
+ $max = 24;
+
+ $sql = "SELECT ent.guid, u2.name AS owner, u.name AS voter, ms2.string as vote
+ 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 = 'generic_rate'
+ INNER JOIN " . $prefix . "metastrings ms2 ON ms2.id = ann1.value_id
+ INNER JOIN " . $prefix . "users_entity u ON ann1.owner_guid = u.guid
+ INNER JOIN " . $prefix . "users_entity u2 ON ent.owner_guid = u2.guid
+ ORDER BY ann1.time_created DESC
+ LIMIT $max";
+
+ $result = get_data($sql);
+
+ $title = "Recently rated images";
+ $area2 = elgg_view_title($title);
+
+ $entities = array();
+ foreach($result as $entity) {
+ $entities[] = get_entity($entity->guid);
+ $full_entity = get_entity($entity->guid);
+ $area2 .= " <div class='tidypics_album_images'>
+ Owner: $entity->owner<br />
+ Voter: $entity->voter<br />
+ Rating: $entity->vote
+ </div>
+ ";
+ $area2 .= elgg_view_entity($full_entity);
+
+ }
+
+
+// $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/mod/lightpics/pages/photos/album/add.php b/mod/lightpics/pages/photos/album/add.php
new file mode 100644
index 000000000..d34d39177
--- /dev/null
+++ b/mod/lightpics/pages/photos/album/add.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Create new album page
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$owner = elgg_get_page_owner_entity();
+
+gatekeeper();
+group_gatekeeper();
+
+$title = elgg_echo('photos:add');
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+if (elgg_instanceof($owner, 'user')) {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+}
+elgg_push_breadcrumb($title);
+
+$vars = tidypics_prepare_form_vars();
+$content = elgg_view_form('photos/album/save', array('method' => 'post'), $vars);
+
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/album/edit.php b/mod/lightpics/pages/photos/album/edit.php
new file mode 100644
index 000000000..7efb05ce1
--- /dev/null
+++ b/mod/lightpics/pages/photos/album/edit.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Edit an album
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$guid = (int) get_input('guid');
+
+if (!$entity = get_entity($guid)) {
+ // @todo either deleted or do not have access
+ forward('photos/all');
+}
+
+if (!$entity->canEdit()) {
+ // @todo cannot change it
+ forward('photos/all');
+}
+
+elgg_set_page_owner_guid($entity->getContainerGUID());
+$owner = elgg_get_page_owner_entity();
+
+gatekeeper();
+group_gatekeeper();
+
+$title = elgg_echo('album:edit');
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+if (elgg_instanceof($owner, 'user')) {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+}
+elgg_push_breadcrumb($entity->getTitle(), $entity->getURL());
+elgg_push_breadcrumb($title);
+
+$vars = tidypics_prepare_form_vars($entity);
+$content = elgg_view_form('photos/album/save', array('method' => 'post'), $vars);
+
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/album/sort.php b/mod/lightpics/pages/photos/album/sort.php
new file mode 100644
index 000000000..005205dd5
--- /dev/null
+++ b/mod/lightpics/pages/photos/album/sort.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Album sort page
+ *
+ * This displays a listing of all the photos so that they can be sorted
+ */
+
+gatekeeper();
+group_gatekeeper();
+
+// get the album entity
+$album_guid = (int) get_input('guid');
+$album = get_entity($album_guid);
+
+// panic if we can't get it
+if (!$album) {
+ forward();
+}
+
+// container should always be set, but just in case
+$owner = $album->getContainerEntity();
+elgg_set_page_owner_guid($owner->getGUID());
+
+$title = elgg_echo('tidypics:sort', array($album->getTitle()));
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), 'photos/all');
+if (elgg_instanceof($owner, 'group')) {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+}
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
+elgg_push_breadcrumb(elgg_echo('album:sort'));
+
+elgg_register_menu_item('title', array(
+ 'name' => 'upload',
+ 'href' => 'photos/upload/' . $album->getGUID(),
+ 'text' => elgg_echo('images:upload'),
+ 'link_class' => 'elgg-button elgg-button-action',
+));
+
+if ($album->getSize()) {
+ $content = elgg_view_form('photos/album/sort', array(), array('album' => $album));
+} else {
+ $content = elgg_echo('tidypics:sort:no_images');
+}
+
+$body = elgg_view_layout('content', array(
+ 'filter' => false,
+ 'content' => $content,
+ 'title' => $title,
+ 'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'album')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/album/view.php b/mod/lightpics/pages/photos/album/view.php
new file mode 100644
index 000000000..6e111ab98
--- /dev/null
+++ b/mod/lightpics/pages/photos/album/view.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * This displays the photos that belong to an album
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+group_gatekeeper();
+
+// get the album entity
+$album_guid = (int) get_input('guid');
+$album = get_entity($album_guid);
+if (!$album) {
+ register_error(elgg_echo('noaccess'));
+ $_SESSION['last_forward_from'] = current_page_url();
+ forward('');
+}
+
+elgg_set_page_owner_guid($album->getContainerGUID());
+$owner = elgg_get_page_owner_entity();
+
+$title = elgg_echo($album->getTitle());
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), 'photos/all');
+if (elgg_instanceof($owner, 'group')) {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+}
+elgg_push_breadcrumb($album->getTitle());
+
+$content = elgg_view_entity($album, array('full_view' => true));
+
+if ($album->getContainerEntity()->canWriteToContainer()) {
+ elgg_register_menu_item('title', array(
+ 'name' => 'upload',
+ 'href' => 'photos/upload/' . $album->getGUID(),
+ 'text' => elgg_echo('images:upload'),
+ 'link_class' => 'elgg-button elgg-button-action',
+ ));
+}
+
+// only show sort button if there are images
+if ($album->canEdit() && $album->getSize() > 0) {
+ elgg_register_menu_item('title', array(
+ 'name' => 'sort',
+ 'href' => "photos/sort/" . $album->getGUID(),
+ 'text' => elgg_echo('album:sort'),
+ 'link_class' => 'elgg-button elgg-button-action',
+ 'priority' => 200,
+ ));
+}
+
+$body = elgg_view_layout('content', array(
+ 'filter' => false,
+ 'content' => $content,
+ 'title' => $album->getTitle(),
+ 'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'album')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/all.php b/mod/lightpics/pages/photos/all.php
new file mode 100644
index 000000000..aef7f11c6
--- /dev/null
+++ b/mod/lightpics/pages/photos/all.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * View all albums on the site
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+elgg_push_breadcrumb(elgg_echo('photos'));
+
+$num_albums = 16;
+
+$offset = (int)get_input('offset', 0);
+$content = elgg_list_entities(array(
+ 'type' => 'object',
+ 'subtype' => 'album',
+ 'limit' => $num_albums,
+ 'full_view' => false,
+ 'list_type' => 'gallery',
+ 'list_type_toggle' => false,
+ 'gallery_class' => 'tidypics-gallery',
+));
+if (!$content) {
+ $content = elgg_echo('tidypics:none');
+}
+
+$title = elgg_echo('album:all');
+
+elgg_register_title_button('photos');
+
+$body = elgg_view_layout('content', array(
+ 'filter_context' => 'all',
+ 'content' => $content,
+ 'title' => $title,
+ 'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'all')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/batch/edit.php b/mod/lightpics/pages/photos/batch/edit.php
new file mode 100644
index 000000000..ca9a55b18
--- /dev/null
+++ b/mod/lightpics/pages/photos/batch/edit.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Edit the image information for a batch of images
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+gatekeeper();
+
+$guid = (int) get_input('guid');
+
+if (!$batch = get_entity($guid)) {
+ // @todo either deleted or do not have access
+ forward('photos/all');
+}
+
+if (!$batch->canEdit()) {
+ // @todo cannot change it
+ forward('photos/all');
+}
+
+$album = $batch->getContainerEntity();
+
+elgg_set_page_owner_guid($batch->getContainerEntity()->getContainerGUID());
+$owner = elgg_get_page_owner_entity();
+
+$title = elgg_echo('tidypics:editprops');
+
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
+elgg_push_breadcrumb($title);
+
+$content = elgg_view_form('photos/batch/edit', array(), array('batch' => $batch));
+
+$body = elgg_view_layout('content', array(
+ 'filter' => false,
+ 'content' => $content,
+ 'title' => elgg_echo('tidypics:editprops'),
+ 'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'album')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/friends.php b/mod/lightpics/pages/photos/friends.php
new file mode 100644
index 000000000..e6ac49cc6
--- /dev/null
+++ b/mod/lightpics/pages/photos/friends.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * List all the albums of someone's friends
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$owner = elgg_get_page_owner_entity();
+
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+elgg_push_breadcrumb($owner->name, "photos/friends/$owner->username");
+elgg_push_breadcrumb(elgg_echo('friends'));
+
+$title = elgg_echo('album:friends');
+
+
+$num_albums = 16;
+
+set_input('list_type', 'gallery');
+$content = list_user_friends_objects($owner->guid, 'album', $num_albums, false);
+if (!$content) {
+ $content = elgg_echo('tidypics:none');
+}
+
+elgg_register_title_button();
+
+$body = elgg_view_layout('content', array(
+ 'filter_context' => 'friends',
+ 'content' => $content,
+ 'title' => $title,
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/image/download.php b/mod/lightpics/pages/photos/image/download.php
new file mode 100644
index 000000000..ef47b7638
--- /dev/null
+++ b/mod/lightpics/pages/photos/image/download.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Download a photo
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$guid = (int) get_input('guid');
+$image = get_entity($guid);
+
+$disposition = get_input('disposition', 'attachment');
+
+if ($image) {
+ $filename = $image->originalfilename;
+ $mime = $image->mimetype;
+
+ header("Content-Type: $mime");
+ header("Content-Disposition: $disposition; filename=\"$filename\"");
+
+ $contents = $image->grabFile();
+
+ if (empty($contents)) {
+ echo file_get_contents(dirname(dirname(__FILE__)) . "/graphics/image_error_large.png" );
+ } else {
+
+ // expires every 60 days
+ $expires = 60 * 60*60*24;
+
+ header("Content-Length: " . strlen($contents));
+ header("Cache-Control: public", true);
+ header("Pragma: public", true);
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true);
+
+ echo $contents;
+ }
+
+ exit;
+} else {
+ register_error(elgg_echo("image:downloadfailed"));
+}
diff --git a/mod/lightpics/pages/photos/image/edit.php b/mod/lightpics/pages/photos/image/edit.php
new file mode 100644
index 000000000..76c1381c9
--- /dev/null
+++ b/mod/lightpics/pages/photos/image/edit.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Edit an image
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$guid = (int) get_input('guid');
+
+if (!$entity = get_entity($guid)) {
+ // @todo either deleted or do not have access
+ forward('photos/all');
+}
+
+if (!$entity->canEdit()) {
+ // @todo cannot change it
+ forward($entity->getContainerEntity()->getURL());
+}
+
+$album = $entity->getContainerEntity();
+if (!$album) {
+
+}
+
+elgg_set_page_owner_guid($album->getContainerGUID());
+$owner = elgg_get_page_owner_entity();
+
+gatekeeper();
+group_gatekeeper();
+
+$title = elgg_echo('image:edit');
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+if (elgg_instanceof($owner, 'user')) {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+}
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
+elgg_push_breadcrumb($entity->getTitle(), $entity->getURL());
+elgg_push_breadcrumb($title);
+
+$vars = tidypics_prepare_form_vars($entity);
+$content = elgg_view_form('photos/image/save', array('method' => 'post'), $vars);
+
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/image/thumbnail.php b/mod/lightpics/pages/photos/image/thumbnail.php
new file mode 100644
index 000000000..28fabf7aa
--- /dev/null
+++ b/mod/lightpics/pages/photos/image/thumbnail.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Image thumbnail view
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$guid = (int) get_input('guid');
+$size = get_input('size');
+$image = get_entity($guid);
+if (!$image) {
+ // @todo
+}
+
+if ($size == 'master') {
+ $contents = $image->getImage();
+} else {
+ $contents = $image->getThumbnail($size);
+}
+if (!$contents) {
+ forward("mod/lightpics/graphics/image_error_$size");
+}
+
+// expires every 14 days
+$expires = 14 * 60*60*24;
+
+// overwrite header caused by php session code so images can be cached
+$mime = $image->getMimeType();
+header("Content-Type: $mime");
+header("Content-Length: " . strlen($contents));
+header("Cache-Control: public", true);
+header("Pragma: public", true);
+header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true);
+
+// Return the thumbnail and exit
+echo $contents;
+exit;
diff --git a/mod/lightpics/pages/photos/image/upload.php b/mod/lightpics/pages/photos/image/upload.php
new file mode 100644
index 000000000..c8e57038c
--- /dev/null
+++ b/mod/lightpics/pages/photos/image/upload.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Upload images
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+gatekeeper();
+
+$album_guid = (int) get_input('guid');
+if (!$album_guid) {
+ // @todo
+ forward();
+}
+
+$album = get_entity($album_guid);
+if (!$album) {
+ // @todo
+ // throw warning and forward to previous page
+ forward(REFERER);
+}
+
+if (!$album->getContainerEntity()->canWriteToContainer()) {
+ // @todo have to be able to edit album to upload photos
+ forward(REFERER);
+}
+
+// set page owner based on container (user or group)
+elgg_set_page_owner_guid($album->getContainerGUID());
+$owner = elgg_get_page_owner_entity();
+
+$title = elgg_echo('album:addpix');
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
+elgg_push_breadcrumb(elgg_echo('album:addpix'));
+
+// load javascript dependences
+elgg_load_js('jquery-tmpl');
+elgg_load_js('jquery-load-image');
+elgg_load_js('jquery-canvas-to-blob');
+elgg_load_js('jquery-fileupload');
+elgg_load_js('jquery-fileupload-ui');
+elgg_load_js('tidypics:upload');
+
+$form_vars = array(
+ 'id' => 'fileupload',
+ 'action' => 'action/photos/image/upload',
+ 'enctype' => 'multipart/form-data',
+);
+
+$content = elgg_view_form('photos/basic_upload', $form_vars, array('entity' => $album));
+
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+ 'sidebar' => elgg_view('photos/sidebar', array('page' => 'upload')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/image/view.php b/mod/lightpics/pages/photos/image/view.php
new file mode 100644
index 000000000..e30bed70a
--- /dev/null
+++ b/mod/lightpics/pages/photos/image/view.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * View an image
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+group_gatekeeper();
+
+// get the photo entity
+$photo_guid = (int) get_input('guid');
+$photo = get_entity($photo_guid);
+if (!$photo) {
+ register_error(elgg_echo('noaccess'));
+ $_SESSION['last_forward_from'] = current_page_url();
+ forward('');
+}
+
+$photo->addView();
+
+// set page owner based on owner of photo album
+$album = $photo->getContainerEntity();
+if ($album) {
+ elgg_set_page_owner_guid($album->getContainerGUID());
+}
+$owner = elgg_get_page_owner_entity();
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), 'photos/all');
+if (elgg_instanceof($owner, 'group')) {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+}
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
+elgg_push_breadcrumb($photo->getTitle());
+
+if (elgg_get_plugin_setting('download_link', 'tidypics')) {
+ // add download button to title menu
+ elgg_register_menu_item('title', array(
+ 'name' => 'download',
+ 'href' => "photos/download/$photo_guid",
+ 'text' => elgg_echo('image:download'),
+ 'link_class' => 'elgg-button elgg-button-action',
+ ));
+}
+
+$content = elgg_view_entity($photo, array('full_view' => true));
+
+$body = elgg_view_layout('content', array(
+ 'filter' => false,
+ 'content' => $content,
+ 'title' => $photo->getTitle(),
+ 'sidebar' => elgg_view('photos/sidebar', array(
+ 'page' => 'view',
+ 'image' => $photo,
+ )),
+));
+
+echo elgg_view_page($photo->getTitle(), $body);
diff --git a/mod/lightpics/pages/photos/owner.php b/mod/lightpics/pages/photos/owner.php
new file mode 100644
index 000000000..506cb569b
--- /dev/null
+++ b/mod/lightpics/pages/photos/owner.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Show all the albums that belong to a user or group
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+group_gatekeeper();
+
+$owner = elgg_get_page_owner_entity();
+
+$title = elgg_echo('album:user', array($owner->name));
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), 'photos/all');
+elgg_push_breadcrumb($owner->name);
+
+
+$num_albums = 16;
+
+$content = elgg_list_entities(array(
+ 'type' => 'object',
+ 'subtype' => 'album',
+ 'container_guid' => $owner->getGUID(),
+ 'limit' => $num_albums,
+ 'full_view' => false,
+ 'list_type' => 'gallery',
+ 'list_type_toggle' => false,
+ 'gallery_class' => 'tidypics-gallery',
+));
+if (!$content) {
+ $content = elgg_echo('tidypics:none');
+}
+
+elgg_register_title_button();
+
+$params = array(
+ 'filter_context' => 'mine',
+ 'content' => $content,
+ 'title' => $title,
+ 'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'owner')),
+);
+
+// don't show filter if out of filter context
+if ($owner instanceof ElggGroup) {
+ $params['filter'] = false;
+}
+
+if ($owner->getGUID() != elgg_get_logged_in_user_guid()) {
+ $params['filter_context'] = '';
+}
+
+$body = elgg_view_layout('content', $params);
+
+echo elgg_view_page($title, $body);