finally fixed tags display width problem
[phpfspot.git] / phpfspot.class.php
index cf0fa25686073478295144508e1b2e9eb5ac2718..c70478cd8ec2f5f50d9c1a9f554f73883ca182ee 100644 (file)
@@ -154,8 +154,10 @@ class PHPFSPOT {
       $result = $this->db->db_query("
          SELECT tag_id as id, count(tag_id) as quantity
          FROM photo_tags
+         INNER JOIN tags t
+            ON t.id = tag_id
          GROUP BY tag_id
-         ORDER BY tag_id ASC
+         ORDER BY t.name ASC
       ");
 
       $tags = Array();
@@ -196,7 +198,7 @@ class PHPFSPOT {
           // uncomment if you want sizes in whole %:
          $size = ceil($size);
 
-         print "<a href=\"javascript:Tags('add', ". $key .");\" class=\"tag\" style=\"font-size: ". $size ."%;\">". $this->tags[$key] ."</a>&nbsp;";
+         print "<a href=\"javascript:Tags('add', ". $key .");\" class=\"tag\" style=\"font-size: ". $size ."%;\">". $this->tags[$key] ."</a>";
 
       }
 
@@ -536,50 +538,39 @@ class PHPFSPOT {
 
    } // check_config_table
 
-   public function gen_thumbs($idx = 0, $fromcmd = 0)
+   public function gen_thumb($idx = 0, $fromcmd = 0, $force = 0)
    {
-      if(!$idx) {
-         /* get all available photos */
-         $all = $this->getPhotoSelection();
-      }
-      else
-         $all = Array($idx);
-      
-      foreach($all as $photo) {
+      $details = $this->get_photo_details($idx);
 
-         $details = $this->get_photo_details($photo);
+      $full_path = $this->translate_path($details['directory_path'])  ."/". $details['name'];
+      $file_md5 = md5_file($full_path);
 
-         $full_path = $this->translate_path($details['directory_path'])  ."/". $details['name'];
-         $file_md5 = md5_file($full_path);
+      if($fromcmd) print "Image [". $idx ."] ". $details['name'] ." Thumbnails:";
 
-         if($fromcmd) print "Image [". $photo ."] ". $details['name'] ." Thumbnails:";
-
-         /* if the file hasn't changed there is no need to regen the thumb */
-         if($file_md5 == $this->getMD5($photo)) {
-            if($fromcmd) print " file has not changed - skipping\n";
-            continue;
-         }
-
-         /* set the new/changed MD5 sum for the current photo */
-         $this->setMD5($photo, $file_md5);
+      /* if the file hasn't changed there is no need to regen the thumb */
+      if(!$force && $file_md5 == $this->getMD5($idx)) {
+         if($fromcmd) print " file has not changed - skipping\n";
+         return;
+      }
 
-         $resolutions = Array(
-                           $this->cfg->thumb_width,
-                           $this->cfg->bubble_width,
-                           $this->cfg->photo_width
-                        );
+      /* set the new/changed MD5 sum for the current photo */
+      $this->setMD5($idx, $file_md5);
 
-         /* create thumbnails for the requested resolutions */
-         foreach($resolutions as $resolution) {
-            if($fromcmd) print " ". $resolution ."px";
-            $this->create_thumbnail($full_path, $resolution);
-         }
-
-         if($fromcmd) print "\n";
+      $resolutions = Array(
+         $this->cfg->thumb_width,
+         $this->cfg->bubble_width,
+         $this->cfg->photo_width
+      );
 
+      /* create thumbnails for the requested resolutions */
+      foreach($resolutions as $resolution) {
+         if($fromcmd) print " ". $resolution ."px";
+         $this->create_thumbnail($full_path, $resolution);
       }
 
-   } // gen_thumbs()
+      if($fromcmd) print "\n";
+
+   } // gen_thumb()
 
    private function getMD5($idx)
    {