summaryrefslogtreecommitdiffstats
path: root/phpfspot.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r--phpfspot.class.php71
1 files changed, 55 insertions, 16 deletions
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)
{