summaryrefslogtreecommitdiffstats
path: root/phpfspot.class.php
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2007-12-15 10:49:11 +0000
committerAndreas Unterkircher <unki@netshadow.at>2007-12-15 10:49:11 +0000
commit33dba06cdcb7b66063bb941aa5f2a985de3fed94 (patch)
treec084fc44b9a9fad7f38a749aeb6517e9ea61864a /phpfspot.class.php
parent5ea211de598c1e02a9f5ccb04b83a81ed9b41117 (diff)
when view is limited to some specifc tags, also display all other tags, of which a photo is currently tagged with, arun
git-svn-id: file:///var/lib/svn/phpfspot/trunk@310 fa6a889d-dae6-447d-9e79-4ba9a3039384
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r--phpfspot.class.php46
1 files changed, 35 insertions, 11 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index d67c7e3..8272252 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -196,11 +196,34 @@ class PHPFSPOT {
$this->avail_tags = Array();
$count = 0;
- $result = $this->db->db_query("
- SELECT id,name
- FROM tags
- ORDER BY sort_priority ASC
- ");
+ if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags)) {
+ $query_str="
+ SELECT
+ DISTINCT t1.id,t1.name
+ FROM
+ photo_tags pt1
+ INNER JOIN photo_tags
+ pt2 ON pt1.photo_id=pt2.photo_id
+ INNER JOIN tags t1
+ ON t1.id=pt1.tag_id
+ INNER JOIN tags t2
+ ON t2.id=pt2.tag_id
+ WHERE
+ t2.name IN ('
+ ".implode("','",$this->cfg->show_tags)."
+ ')
+ ORDER BY
+ t1.sort_priority ASC";
+ $result = $this->db->db_query($query_str);
+ }
+ else
+ {
+ $result = $this->db->db_query("
+ SELECT id,name
+ FROM tags
+ ORDER BY sort_priority ASC
+ ");
+ }
while($row = $this->db->db_fetch_object($result)) {
@@ -214,13 +237,14 @@ class PHPFSPOT {
if(in_array($row['name'], $this->cfg->hide_tags))
continue;
- /* if the user has specified to only show certain tags which
- are specified in phpfspot's configuration, ignore all others
- so they will not be added to the tag list.
- */
+ /* if you include the following if-clause and the user has specified
+ to only show certain tags which are specified in phpfspot's
+ configuration, ignore all others so they will not be added to the
+ tag list.
if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags) &&
!in_array($row['name'], $this->cfg->show_tags))
continue;
+ */
$this->tags[$tag_id] = $tag_name;
$this->avail_tags[$count] = $tag_id;
@@ -739,10 +763,10 @@ class PHPFSPOT {
INNER JOIN photos p
ON pt1.photo_id=p.id
";
- $query_str.= "WHERE pt1.tag_id=". $_SESSION['selected_tags'][0];
+ $query_str.= "WHERE pt2.tag_id=". $_SESSION['selected_tags'][0]." ";
for($i = 1; $i < count($_SESSION['selected_tags']); $i++) {
$query_str.= "
- AND pt". ($i+1) .".tag_id=". $_SESSION['selected_tags'][$i] ."
+ AND pt". ($i+2) .".tag_id=". $_SESSION['selected_tags'][$i] ."
";
}
if(isset($additional_where_cond))