From 1532cb592eb45670d0d72fe5e9acb1f5b0fb31c9 Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sat, 29 Mar 2008 08:26:34 +0100 Subject: issue107, make sqlite-temp directory configurable issue107, add a note to CHANGE about issue107 (configurable sqlite temp directory) Signed-off-by: Andreas Unterkircher --- phpfspot.class.php | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) (limited to 'phpfspot.class.php') diff --git a/phpfspot.class.php b/phpfspot.class.php index cfa9257..a9e3e68 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -70,19 +70,27 @@ class PHPFSPOT { 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,12 +101,32 @@ 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); } + /* open the database */ + $this->cfg_db = new PHPFSPOT_DB($this, $this->cfg->phpfspot_db); + + /* 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 ."' + "); + } + + /* Check if some tables need to be created */ $this->check_config_table(); /* include Smarty template engine */ -- cgit v1.2.3-18-g5258 From ef48f1930daad7ffc993708ff9e6656135897964 Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sat, 29 Mar 2008 08:29:53 +0100 Subject: check if Smarty engine is available is now done in check_requirements() Signed-off-by: Andreas Unterkircher --- phpfspot.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'phpfspot.class.php') diff --git a/phpfspot.class.php b/phpfspot.class.php index a9e3e68..7cc4e19 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -66,7 +66,7 @@ class PHPFSPOT { ); /* Check necessary requirements */ - if(!$this->checkRequirements()) { + if(!$this->check_requirements()) { exit(1); } @@ -129,12 +129,7 @@ class PHPFSPOT { /* 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); @@ -1794,7 +1789,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
\n"; @@ -1823,6 +1818,11 @@ class PHPFSPOT { print "PEAR Console_Getopt package is missing
\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
\n"; + $missing = true; + } ini_restore('track_errors'); if(isset($missing)) @@ -1830,7 +1830,7 @@ class PHPFSPOT { return true; - } // checkRequirements() + } // check_requirements() private function _debug($text) { -- cgit v1.2.3-18-g5258 From 67f0eb35f6c3fe9bdda3cb585a0fe5e9ccb0e563 Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sat, 29 Mar 2008 08:57:49 +0100 Subject: issue108, a bit more color for tag-cloud Signed-off-by: Andreas Unterkircher --- phpfspot.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'phpfspot.class.php') diff --git a/phpfspot.class.php b/phpfspot.class.php index 7cc4e19..be752ee 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -586,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)); @@ -599,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) { @@ -614,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.= "". $this->tags[$key] .", "; + $output.= "". $this->tags[$key] .", "; } } -- cgit v1.2.3-18-g5258