issue112, preload previous and next photo in single-photo view
[phpfspot.git] / phpfspot.class.php
index a9e3e686ea3e52fa682d6792de91ba8cdfaf9c12..3b4a62e9166abc2a420de0780bcd9b4fea7cb60f 100644 (file)
@@ -66,7 +66,7 @@ class PHPFSPOT {
       );
 
       /* Check necessary requirements */
       );
 
       /* Check necessary requirements */
-      if(!$this->checkRequirements()) {
+      if(!$this->check_requirements()) {
          exit(1);
       }
 
          exit(1);
       }
 
@@ -129,12 +129,7 @@ class PHPFSPOT {
       /* Check if some tables need to be created */
       $this->check_config_table();
 
       /* Check if some tables need to be created */
       $this->check_config_table();
 
-      /* include Smarty template engine */
-      if(!$this->check_readable($this->cfg->smarty_path .'/libs/Smarty.class.php')) {
-         exit(1);
-      }
-      require $this->cfg->smarty_path .'/libs/Smarty.class.php';
-      /* overload Smarty class if our own template handler */
+      /* overload Smarty class with our own template handler */
       require_once "phpfspot_tmpl.php";
       $this->tmpl = new PHPFSPOT_TMPL($this);
 
       require_once "phpfspot_tmpl.php";
       $this->tmpl = new PHPFSPOT_TMPL($this);
 
@@ -551,6 +546,7 @@ class PHPFSPOT {
          $this->tmpl->assign('next_img', $next_img);
       }
       $this->tmpl->assign('mini_width', $this->cfg->mini_width);
          $this->tmpl->assign('next_img', $next_img);
       }
       $this->tmpl->assign('mini_width', $this->cfg->mini_width);
+      $this->tmpl->assign('photo_width', $this->cfg->photo_width);
       $this->tmpl->assign('photo_number', $i);
       $this->tmpl->assign('photo_count', count($all_photos));
 
       $this->tmpl->assign('photo_number', $i);
       $this->tmpl->assign('photo_count', count($all_photos));
 
@@ -591,6 +587,10 @@ class PHPFSPOT {
       $max_size = 125; // max font size in %
       $min_size = 75; // min font size in %
 
       $max_size = 125; // max font size in %
       $min_size = 75; // min font size in %
 
+      // color
+      $max_sat = hexdec('cc');
+      $min_sat = hexdec('44');
+
       // get the largest and smallest array values
       $max_qty = max(array_values($tags));
       $min_qty = min(array_values($tags));
       // get the largest and smallest array values
       $max_qty = max(array_values($tags));
       $min_qty = min(array_values($tags));
@@ -604,6 +604,7 @@ class PHPFSPOT {
       // determine the font-size increment
       // this is the increase per tag quantity (times used)
       $step = ($max_size - $min_size)/($spread);
       // determine the font-size increment
       // this is the increase per tag quantity (times used)
       $step = ($max_size - $min_size)/($spread);
+      $step_sat = ($max_sat - $min_sat)/($spread);
 
       // loop through our tag array
       foreach ($tags as $key => $value) {
 
       // loop through our tag array
       foreach ($tags as $key => $value) {
@@ -619,8 +620,14 @@ class PHPFSPOT {
           // uncomment if you want sizes in whole %:
          $size = ceil($size);
 
           // uncomment if you want sizes in whole %:
          $size = ceil($size);
 
+         $color = $min_sat + ($value - $min_qty) * $step_sat;
+
+         $r = '44';
+         $g = dechex($color);
+         $b = '88';
+
          if(isset($this->tags[$key])) {
          if(isset($this->tags[$key])) {
-            $output.= "<a href=\"javascript:Tags('add', ". $key .");\" class=\"tag\" style=\"font-size: ". $size ."%;\">". $this->tags[$key] ."</a>, ";
+            $output.= "<a href=\"javascript:Tags('add', ". $key .");\" class=\"tag\" style=\"font-size: ". $size ."%; color: #". $r.$g.$b .";\">". $this->tags[$key] ."</a>, ";
          }
 
       }
          }
 
       }
@@ -1794,7 +1801,7 @@ class PHPFSPOT {
    /**
     * check if all requirements are met
     */
    /**
     * check if all requirements are met
     */
-   private function checkRequirements()
+   private function check_requirements()
    {
       if(!function_exists("imagecreatefromjpeg")) {
          print "PHP GD library extension is missing<br />\n";
    {
       if(!function_exists("imagecreatefromjpeg")) {
          print "PHP GD library extension is missing<br />\n";
@@ -1823,6 +1830,11 @@ class PHPFSPOT {
          print "PEAR Console_Getopt package is missing<br />\n";
          $missing = true;
       }
          print "PEAR Console_Getopt package is missing<br />\n";
          $missing = true;
       }
+      @include_once $this->cfg->smarty_path .'/libs/Smarty.class.php';
+      if(isset($php_errormsg) && preg_match('/Failed opening.*for inclusion/i', $php_errormsg)) {
+         print "Smarty template engine can not be found in ". $this->cfg->smarty_path ."/libs/Smarty.class.php<br />\n";
+         $missing = true;
+      }
       ini_restore('track_errors');
 
       if(isset($missing))
       ini_restore('track_errors');
 
       if(isset($missing))
@@ -1830,7 +1842,7 @@ class PHPFSPOT {
 
       return true;
 
 
       return true;
 
-   } // checkRequirements()
+   } // check_requirements()
 
    private function _debug($text)
    {
 
    private function _debug($text)
    {