From 50a8a0b9eae779f0e50530ac984bc6ded17ff5f6 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Tue, 31 Jan 2012 22:54:34 -0800 Subject: add prev/next pictures for easier slide show mode for some reason all new elements show up in the enter-selection of d3. Should really be just the new pics... --- getjson.php | 42 ++++++++++++++++++++++++++++++++++++++++++ index.php | 36 ++++++++++++++++++++++++++++++++++-- style.css | 9 ++++++++- 3 files changed, 84 insertions(+), 3 deletions(-) diff --git a/getjson.php b/getjson.php index 07294ba..d5dab8b 100644 --- a/getjson.php +++ b/getjson.php @@ -23,6 +23,48 @@ if (isset($_REQUEST["S"])) $result = $DB->query("SELECT name FROM tags"); } + else if (isset($_REQUEST["NP"])) + { + /* get +- 5 pics from ordered list to show next to a large image */ + + /* first create a temp table with all images and then use rowid to get +-5 images */ + + if (isset($_REQUEST["T"])) + { + /* single tag or part of tag */ + $tags = $_REQUEST["T"]; + $tags = explode(",",$tags); + $nrtags = count($tags); + + foreach ($tags as $key => $value) + $tags[$key]=sqlite_escape_string(trim($value)); + $tags = "'".implode("','",$tags)."'"; + + $DB->query("CREATE TEMP TABLE NEXTPREV AS SELECT base_uri, filename, p.id as id FROM photo_tags pt, photos p, tags t". + " WHERE pt.tag_id = t.id". + " AND (t.name COLLATE NOCASE IN ($tags))". + " AND p.id = pt.photo_id ". + " GROUP BY p.id HAVING COUNT( p.id )=$nrtags"); + + } + else + { + $DB->query("CREATE TEMP TABLE NEXTPREV AS SELECT base_uri, filename, p.id as id FROM photos p"); + }; + + if (isset($_REQUEST["ID"])) + { + $ID=intval($_REQUEST["ID"]); + $result = $DB->query("SELECT * FROM NEXTPREV". + " WHERE rowid > (select rowid from NEXTPREV where id=$ID) -5". + " AND rowid < (select rowid from NEXTPREV where id=$ID) +5"); + } + else + { + $result = $DB->query("SELECT 1 where 1=2"); + } + + } else if (isset($_REQUEST["ID"])) { $id = intval($_REQUEST["ID"]); diff --git a/index.php b/index.php index 45bf53f..ab62435 100644 --- a/index.php +++ b/index.php @@ -58,7 +58,9 @@ else -
+
+ +