diff options
-rw-r--r-- | CHANGELOG | 10 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | UPGRADE | 6 | ||||
-rw-r--r-- | phpfspot.class.php | 71 | ||||
-rw-r--r-- | phpfspot_cfg.php.dist | 14 | ||||
-rw-r--r-- | phpfspot_tmpl.php | 2 | ||||
-rw-r--r-- | themes/default/templates/header.tpl | 2 | ||||
-rw-r--r-- | themes/default/templates/search.tpl | 2 |
8 files changed, 90 insertions, 19 deletions
@@ -1,3 +1,13 @@ +phpfspot (1.4) + + * feature, support PNG image format. + * feature, auto-completion for tag-search. + * feature, lightbox2 for photo preview out of the photo index. + * feature, a bit more color for tag-cloud. + * bug, SQlite temporary directory can now be set in phpfspot_cfg.php + + -- Andreas Unterkircher <unki@netshadow.at> Sat, 29 Mar 2008 11:00:00 +0100 + phpfspot (1.3) * bug, fixed auto-rotation when EXIF Orientation header is set. @@ -1,5 +1,5 @@ Package Name: phpfspot -Version: 1.3 +Version: 1.4 Author: Andreas Unterkircher <unki@netshadow.at> Website: http://oss.netshadow.at Desc: dynamic PHP gallery for F-Spot @@ -1,3 +1,9 @@ +== Upgrading from 1.3 == + + * nothing special necessary. + * Take a look into phpfspot_cfg.dist for $use_lightbox and + * $use_autocomplete if you want to use the new features. + == Upgrading from 1.2 == * nothing special necessary yet. diff --git a/phpfspot.class.php b/phpfspot.class.php index 3f7f7b2..8260cc9 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -66,23 +66,31 @@ class PHPFSPOT { ); /* Check necessary requirements */ - if(!$this->checkRequirements()) { + if(!$this->check_requirements()) { exit(1); } - $this->db = new PHPFSPOT_DB($this, $this->cfg->fspot_db); + /******* Opening F-Spot's sqlite database *********/ + + /* Check if database file is writeable */ if(!is_writeable($this->cfg->fspot_db)) { print $this->cfg->fspot_db ." is not writeable for user ". $this->getuid() ."\n"; exit(1); } - $this->dbver = $this->getFspotDBVersion(); + /* open the database */ + $this->db = new PHPFSPOT_DB($this, $this->cfg->fspot_db); - if(!is_writeable(dirname($this->cfg->phpfspot_db))) { - print dirname($this->cfg->phpfspot_db) .": directory is not writeable for user ". $this->getuid() ."\n"; - exit(1); + /* change sqlite temp directory, if requested */ + if(isset($this->cfg->sqlite_temp_dir)) { + $this->db->db_exec(" + PRAGMA + temp_store_directory = '". $this->cfg->sqlite_temp_dir ."' + "); } + $this->dbver = $this->getFspotDBVersion(); + if(!is_writeable($this->cfg->base_path ."/templates_c")) { print $this->cfg->base_path ."/templates_c: directory is not writeable for user ". $this->getuid() ."\n"; exit(1); @@ -93,20 +101,35 @@ class PHPFSPOT { exit(1); } - $this->cfg_db = new PHPFSPOT_DB($this, $this->cfg->phpfspot_db); + /******* Opening phpfspot's sqlite database *********/ + + /* Check if directory where the database file is stored is writeable */ + if(!is_writeable(dirname($this->cfg->phpfspot_db))) { + print dirname($this->cfg->phpfspot_db) .": directory is not writeable for user ". $this->getuid() ."\n"; + exit(1); + } + + /* Check if database file is writeable */ if(!is_writeable($this->cfg->phpfspot_db)) { print $this->cfg->phpfspot_db ." is not writeable for user ". $this->getuid() ."\n"; exit(1); } - $this->check_config_table(); + /* open the database */ + $this->cfg_db = new PHPFSPOT_DB($this, $this->cfg->phpfspot_db); - /* include Smarty template engine */ - if(!$this->check_readable($this->cfg->smarty_path .'/libs/Smarty.class.php')) { - exit(1); + /* change sqlite temp directory, if requested */ + if(isset($this->cfg->sqlite_temp_dir)) { + $this->cfg_db->db_exec(" + PRAGMA + temp_store_directory = '". $this->cfg->sqlite_temp_dir ."' + "); } - require $this->cfg->smarty_path .'/libs/Smarty.class.php'; - /* overload Smarty class if our own template handler */ + + /* Check if some tables need to be created */ + $this->check_config_table(); + + /* overload Smarty class with our own template handler */ require_once "phpfspot_tmpl.php"; $this->tmpl = new PHPFSPOT_TMPL($this); @@ -563,6 +586,10 @@ class PHPFSPOT { $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)); @@ -576,6 +603,7 @@ class PHPFSPOT { // 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) { @@ -591,8 +619,14 @@ class PHPFSPOT { // 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])) { - $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>, "; } } @@ -1790,7 +1824,7 @@ class PHPFSPOT { /** * 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"; @@ -1819,6 +1853,11 @@ class PHPFSPOT { 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)) @@ -1826,7 +1865,7 @@ class PHPFSPOT { return true; - } // checkRequirements() + } // check_requirements() private function _debug($text) { diff --git a/phpfspot_cfg.php.dist b/phpfspot_cfg.php.dist index 3583560..75b54ad 100644 --- a/phpfspot_cfg.php.dist +++ b/phpfspot_cfg.php.dist @@ -56,6 +56,15 @@ class PHPFSPOT_CFG { */ var $phpfspot_db = "/var/www/f-spot-dbs/phpfspot.db"; + /* sqlite temp dir. per default sqlite tries /var/tmp, /usr/tmp, /tmp + and the current working directory for creating temporary files. + If you still get error messages when phpfspot tries to create the + indecies in $fspot_db, set this option to another writeable + directory. For example $phpfspot_db directory, which must be + writeable anyway. + */ + // var $sqlite_temp_dir = "/var/www/f-spot-dbs"; + /* don't touch if you haven't changed the base templates */ var $thumb_width = "150"; var $thumb_height = "145"; @@ -89,6 +98,11 @@ class PHPFSPOT_CFG { */ var $use_lightbox = true; + /* Use Ajax Auto Completion for tag search. Maybe, if you have a slow + connectivity for the server, it's a good idea to turn it off. + */ + var $use_autocomplete = true; + /* logging = display || errorlog || logfile */ var $logging = "display"; diff --git a/phpfspot_tmpl.php b/phpfspot_tmpl.php index 52c983e..3fdf2ac 100644 --- a/phpfspot_tmpl.php +++ b/phpfspot_tmpl.php @@ -40,6 +40,8 @@ class PHPFSPOT_TMPL extends Smarty { if(isset($parent->cfg->use_lightbox) && $parent->cfg->use_lightbox == true) $this->assign('use_lightbox', 'true'); + if(isset($parent->cfg->use_autocomplete) && $parent->cfg->use_autocomplete == true) + $this->assign('use_autocomplete', 'true'); } // __construct() diff --git a/themes/default/templates/header.tpl b/themes/default/templates/header.tpl index 72257df..e946a5b 100644 --- a/themes/default/templates/header.tpl +++ b/themes/default/templates/header.tpl @@ -14,7 +14,7 @@ <script type="text/javascript" src="lightbox2/js/lightbox.js"></script> <link rel="stylesheet" href="lightbox2/css/lightbox.css" type="text/css" media="screen" /> { /if } - { if ! $use_autocomplete } + { if $use_autocomplete } <script src="autosuggest/js/bsn.AutoSuggest_2.1.3_comp.js"></script> <link rel="stylesheet" href="autosuggest/css/autosuggest_inquisitor.css" type="text/css" media="screen" charset="utf-8" /> { /if } diff --git a/themes/default/templates/search.tpl b/themes/default/templates/search.tpl index ee9a7e1..f983c40 100644 --- a/themes/default/templates/search.tpl +++ b/themes/default/templates/search.tpl @@ -7,7 +7,7 @@ <tr> <td>Tag:</td> <td> - { if ! $use_autocomplete } + { if $use_autocomplete } <input type="text" name="searchfor_tag" id="searchfor_tag" value="{$searchfor_tag}" size="15" acdropdown="true" autocomplete_list="url:rpc.php?action=getxmltaglist&search=[S]&length=10" /> { literal } <script type="text/javascript"> |