code cleanup origin/master
authorAndreas Unterkircher <unki@netshadow.at>
Fri, 15 Jan 2010 18:31:10 +0000 (19:31 +0100)
committerAndreas Unterkircher <unki@netshadow.at>
Fri, 15 Jan 2010 18:47:10 +0000 (19:47 +0100)
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
phpfspot.class.php

index e220a7c..5dedc2c 100644 (file)
@@ -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()