diff options
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r-- | phpfspot.class.php | 107 |
1 files changed, 52 insertions, 55 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php index e220a7c..5dedc2c 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -551,69 +551,66 @@ class PHPFSPOT { "; } - if($row = $this->db->db_fetchSingleRow($query_str)) { + if(!$row = $this->db->db_fetchSingleRow($query_str)) + return null; - /* before F-Spot db version 9 there was no uri column but - seperated fields for directory_path and name (= filename). - */ - if($this->dbver < 9) { - $row['uri'] = "file://". $row['directory_path'] ."/". $row['name']; - } - /* starting with dbversion >= 17 we need to rawurldecode() uri */ - elseif($this->dbver >= 17) { - $row['uri'] = rawurldecode($row['uri']); - } - - /* if version-idx has not yet been set, get the latest photo version */ - if(!isset($version_idx) || !$this->is_valid_version($idx, $version_idx)) - $version_idx = $this->get_latest_version($idx); + /* before F-Spot db version 9 there was no uri column but + seperated fields for directory_path and name (= filename). + */ + if($this->dbver < 9) { + $row['uri'] = "file://". $row['directory_path'] ."/". $row['name']; + } + /* starting with dbversion >= 17 we need to rawurldecode() uri */ + elseif($this->dbver >= 17) { + $row['uri'] = rawurldecode($row['uri']); + } - /* if an alternative version has been requested. But we - support this only for F-Spot database versions from - v9. - */ - if($version_idx > 0 && $this->dbver >= 9) { - if ($this->dbver < 17) { - /* check for alternative versions */ - if($version = $this->db->db_fetchSingleRow(" - SELECT - version_id, name, uri - FROM - photo_versions - WHERE - photo_id LIKE '". $idx ."' - AND - version_id LIKE '". $version_idx ."'")) { + /* if version-idx has not yet been set, get the latest photo version */ + if(!isset($version_idx) || !$this->is_valid_version($idx, $version_idx)) + $version_idx = $this->get_latest_version($idx); - $row['name'] = $version['name']; - $row['uri'] = $version['uri']; - } + /* if an alternative version has been requested. But we + support this only for F-Spot database versions from + v9. + */ + if($version_idx > 0 && $this->dbver >= 9) { + if ($this->dbver < 17) { + /* check for alternative versions */ + if($version = $this->db->db_fetchSingleRow(" + SELECT + version_id, name, uri + FROM + photo_versions + WHERE + photo_id LIKE '". $idx ."' + AND + version_id LIKE '". $version_idx ."'")) { + + $row['name'] = $version['name']; + $row['uri'] = $version['uri']; } - else { - /* path & filename now splited in base_uri & filename */ - if($version = $this->db->db_fetchSingleRow(" - SELECT - version_id, - name, - base_uri || filename as uri - FROM - photo_versions - WHERE - photo_id LIKE '". $idx ."' - AND - version_id LIKE '". $version_idx ."'")) { - - $row['name'] = $version['name']; - $row['uri'] = rawurldecode($version['uri']); - } + } + else { + /* path & filename now splited in base_uri & filename */ + if($version = $this->db->db_fetchSingleRow(" + SELECT + version_id, + name, + base_uri || filename as uri + FROM + photo_versions + WHERE + photo_id LIKE '". $idx ."' + AND + version_id LIKE '". $version_idx ."'")) { + + $row['name'] = $version['name']; + $row['uri'] = rawurldecode($version['uri']); } } - - return $row; - } - return null; + return $row; } // get_photo_details() |