X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=phpfspot.class.php;h=eba23ca42cb0dbf8f6588c7efb3d17ddacb8dc1a;hp=bae4ae74dbc40ce34899bb4270397a3860000abf;hb=ea7c5f379929222119df54f0f0a9af008bce4d30;hpb=dee52ad356dbabf693686fee2b0dc9138f265a3f
diff --git a/phpfspot.class.php b/phpfspot.class.php
index bae4ae7..eba23ca 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.= "
+
+ ";
+ 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");
@@ -1587,7 +1610,7 @@ class PHPFSPOT {
*/
public function get_meta_informations($file)
{
- return exif_read_data($file);
+ return @exif_read_data($file);
} // get_meta_informations()
@@ -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
*
@@ -2930,7 +3004,7 @@ class PHPFSPOT {
*/
public function get_mime_info($file)
{
- $details = getimagesize($orig_image);
+ $details = getimagesize($file);
/* if getimagesize() returns empty, try at least to find out the
mime type.