diff options
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r-- | phpfspot.class.php | 78 |
1 files changed, 76 insertions, 2 deletions
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.= "<a href=\"javascript:Tags('del', ". $tag .");\" class=\"tag\">". $this->tags[$tag] ."</a>, "; + + switch($type) { + default: + case 'link': + $output.= "<a href=\"javascript:Tags('del', ". $tag .");\" class=\"tag\">". $this->tags[$tag] ."</a>, "; + break; + case 'img': + $output.= " + <div style=\"display: table-cell;\"> + <div style=\"display: table-row; text-align: center;\"> + <a href=\"javascript:Tags('del', ". $tag .");\" title=\"". $this->tags[$tag] ."\"> + <img src=\"phpfspot_img.php?tagidx=". $tag ."\" /> + </a> + </div> + <div style=\"display: table-row; text-align: center;\"> + <a href=\"javascript:Tags('del', ". $tag .");\" title=\"". $this->tags[$tag] ."\"> + <img src=\"resources/underbar.png\" /> + </a> + </div> + </div> + "; + 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 */ @@ -2564,6 +2588,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 * * this function validates if the provided date |