From 4552617dca9f593137d6785ccd67c6a421df232f Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sat, 26 Apr 2008 10:18:50 +0200 Subject: issue115, display tag-selection in photo-index Signed-off-by: Andreas Unterkircher --- phpfspot.class.php | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 2 deletions(-) (limited to 'phpfspot.class.php') diff --git a/phpfspot.class.php b/phpfspot.class.php index bae4ae7..97deb96 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -726,7 +726,7 @@ class PHPFSPOT { * session-variable $_SESSION['selected_tags'] * @return string */ - public function getSelectedTags() + public function getSelectedTags($type = 'link') { /* retrive tags from database */ $this->get_tags(); @@ -737,7 +737,29 @@ class PHPFSPOT { { // return all selected tags if(isset($_SESSION['selected_tags']) && in_array($tag, $_SESSION['selected_tags'])) { - $output.= "". $this->tags[$tag] .", "; + + switch($type) { + default: + case 'link': + $output.= "". $this->tags[$tag] .", "; + break; + case 'img': + $output.= " +
+
+ tags[$tag] ."\"> + + +
+
+ tags[$tag] ."\"> + + +
+
+ "; + break; + } } } @@ -1315,6 +1337,7 @@ class PHPFSPOT { $this->tmpl->assign('img_fullname', $img_fullname); $this->tmpl->assign('img_title', $img_title); $this->tmpl->assign('thumbs', $thumbs); + $this->tmpl->assign('selected_tags', $this->getSelectedTags('img')); $this->tmpl->show("photo_index.tpl"); @@ -1634,6 +1657,7 @@ class PHPFSPOT { $this->cfg->thumb_width, $this->cfg->photo_width, $this->cfg->mini_width, + 30, ); /* get details from F-Spot's database */ @@ -2563,6 +2587,56 @@ class PHPFSPOT { } // get_random_photo() + /** + * get random photo tag photo + * + * this function will get all photos tagged with the requested + * tag from the fspot database and randomly return ONE entry + * + * saddly there is yet no sqlite3 function which returns + * the bulk result in array, so we have to fill up our + * own here. + * @return array + */ + public function get_random_tag_photo($tagidx) + { + $all = Array(); + + $query_str = " + SELECT p.id + FROM photos p + INNER JOIN photo_tags pt + ON p.id=pt.photo_id + "; + + if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags)) { + $query_str.= " + INNER JOIN tags t + ON pt.tag_id=t.id + "; + } + $query_str.= " + WHERE + pt.tag_id LIKE '". $tagidx ."' + "; + + if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags)) { + $query_str.= " + AND + t.name IN ('".implode("','",$this->cfg->show_tags)."') + "; + } + + $result = $this->db->db_query($query_str); + + while($row = $this->db->db_fetch_object($result)) { + array_push($all, $row['id']); + } + + return $all[array_rand($all)]; + + } // get_random_tag_photo() + /** * validates provided date * -- cgit v1.2.3-18-g5258