X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=phpfspot.class.php;h=14dff99eb0ed67e4681e97651c4f4b652bbb8505;hp=d6d3e691902f019bab998e5abd22a291ab4f7de8;hb=e0ff14d4bcc1659675a8c5208d4151a04c2b0de9;hpb=8f3e27ca1aea300a47d35b9474c8f5fd588460da diff --git a/phpfspot.class.php b/phpfspot.class.php index d6d3e69..14dff99 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -55,6 +55,8 @@ class PHPFSPOT { $this->tmpl->assign('searchfor', $_SESSION['searchfor']); $this->tmpl->assign('page_title', $this->cfg->page_title); $this->tmpl->assign('current_condition', $_SESSION['tag_condition']); + $this->tmpl->assign('from_date', $this->get_calendar()); + $this->tmpl->assign('to_date', $this->get_calendar()); switch($_GET['mode']) { case 'showpi': @@ -62,6 +64,11 @@ class PHPFSPOT { $_SESSION['selected_tags'] = split(',', $_GET['tags']); } break; + case 'export': + $this->tmpl->show("export.tpl"); + return; + break; + } $this->tmpl->assign('content_page', 'welcome.tpl'); @@ -114,9 +121,17 @@ class PHPFSPOT { public function getPhotoName($idx) { - $details = $this->get_photo_details($idx); + if($details = $this->get_photo_details($idx)) { + + $name = $details['name']; + + if(strlen($name) > 15) { + $name = substr($name, 0, 10) ."...". substr($name, -10); + } - return $details['name']; + return $name; + + } } // getPhotoName() @@ -169,9 +184,16 @@ class PHPFSPOT { $meta = $this->get_meta_informations($orig_path); + /* If EXIF data are available, use them */ + if(isset($meta['ExifImageWidth'])) { + $meta_res = $meta['ExifImageWidth'] ."x". $meta['ExifImageLength']; + } else { + $info = getimagesize($orig_path); + $meta_res = $info[0] ."x". $info[1]; + } + $meta_date = isset($meta['FileDateTime']) ? strftime("%a %x %X", $meta['FileDateTime']) : "n/a"; $meta_make = isset($meta['Make']) ? $meta['Make'] ." ". $meta['Model'] : "n/a"; - $meta_res = isset($meta['ExifImageWidth']) ? $meta['ExifImageWidth'] ."x". $meta['ExifImageLength'] : "n/a"; $meta_size = isset($meta['FileSize']) ? round($meta['FileSize']/1024, 1) ."kbyte" : "n/a"; if(file_exists($thumb_path)) { @@ -200,11 +222,14 @@ class PHPFSPOT { if($previous_img) { $this->tmpl->assign('previous_url', "javascript:showImage(". $previous_img .");"); + $this->tmpl->assign('prev_img', $previous_img); } if($next_img) { $this->tmpl->assign('next_url', "javascript:showImage(". $next_img .");"); + $this->tmpl->assign('next_img', $next_img); } + $this->tmpl->assign('mini_width', $this->cfg->mini_width); $this->tmpl->show("single_photo.tpl"); @@ -267,15 +292,18 @@ class PHPFSPOT { public function getSelectedTags() { + $output = ""; foreach($this->avail_tags as $tag) { // return all selected tags if(isset($_SESSION['selected_tags']) && in_array($tag, $_SESSION['selected_tags'])) { - print "". $this->tags[$tag] ." "; + $output.= "". $this->tags[$tag] .", "; } - } + $output = substr($output, 0, strlen($output)-2); + print $output; + } // getSelectedTags() public function addTag($tag) @@ -351,6 +379,12 @@ class PHPFSPOT { } elseif($_SESSION['tag_condition'] == 'and') { + if(count($_SESSION['selected_tags']) >= 32) { + print "A SQLite limit of 32 tables within a JOIN SELECT avoids to
\n"; + print "evaluate your tag selection. Please remove some tags from your selection.\n"; + return Array(); + } + /* Join together a table looking like pt1.photo_id pt1.tag_id pt2.photo_id pt2.tag_id ... @@ -481,6 +515,7 @@ class PHPFSPOT { if(isset($_SESSION['searchfor']) && $_SESSION['searchfor'] != '') $this->tmpl->assign('searchfor', $_SESSION['searchfor']); + /* do we have to display the page selector ? */ if($this->cfg->rows_per_page != 0) { /* calculate the page switchers */ @@ -492,19 +527,13 @@ class PHPFSPOT { if($end_with < $count) $this->tmpl->assign("next_url", "javascript:showPhotoIndex(". $next_start .");"); - /* page selector */ $photo_per_page = $this->cfg->rows_per_page * $this->cfg->thumbs_per_row; - - /* until 6 pages we show the selector from 1-6 - everything large will be - 1 ... 2 3 4 (5) 6 7 ... 9 - */ $last_page = ceil($count / $photo_per_page); + /* get the current selected page */ if($begin_with == 0) { $current_page = 1; - } - else { + } else { $current_page = 0; for($i = $begin_with; $i >= 0; $i-=$photo_per_page) { $current_page++; @@ -523,11 +552,34 @@ class PHPFSPOT { else $style = ""; - $page_select.= " "; + $select = " "; + + // until 9 pages we show the selector from 1-9 + if($last_page <= 9) { + $page_select.= $select; + continue; + } else { + if($i == 1 /* first page */ || + $i == $last_page /* last page */ || + $i == $current_page /* current page */ || + $i == ceil($last_page * 0.25) /* first quater */ || + $i == ceil($last_page * 0.5) /* half */ || + $i == ceil($last_page * 0.75) /* third quater */ || + (in_array($i, array(1,2,3,4,5,6)) && $current_page <= 4) /* the first 6 */ || + (in_array($i, array($last_page, $last_page-1, $last_page-2, $last_page-3, $last_page-4, $last_page-5)) && $current_page >= $last_page-4) /* the last 6 */ || + $i == $current_page-3 || $i == $current_page-2 || $i == $current_page-1 /* three before */ || + $i == $current_page+3 || $i == $current_page+2 || $i == $current_page+1 /* three after */) { + + $page_select.= $select; + continue; + + } + } + $page_select.= "."; } /* only show the page selector if we have more then one page */ @@ -547,7 +599,10 @@ class PHPFSPOT { $extern_link.= "&tags=". $current_tags; } + $export_link = "index.php?mode=export"; + $this->tmpl->assign('extern_link', $extern_link); + $this->tmpl->assign('export_link', $export_link); $this->tmpl->assign('count', $count); $this->tmpl->assign('width', $this->cfg->thumb_width); $this->tmpl->assign('images', $images); @@ -781,6 +836,7 @@ class PHPFSPOT { $this->cfg->thumb_width, $this->cfg->bubble_width, $this->cfg->photo_width, + $this->cfg->mini_width, ); /* get details from F-Spot's database */ @@ -1007,10 +1063,15 @@ class PHPFSPOT { /* Check for HTML_AJAX PEAR package, lent from Horde project */ ini_set('track_errors', 1); @include_once 'HTML/AJAX/Server.php'; - if(isset($php_errormsg)) { + if(isset($php_errormsg) && preg_match('/Failed opening.*for inclusion/i', $php_errormsg)) { print "PEAR HTML_AJAX package is missing
\n"; $missing = true; } + @include_once 'Calendar/Calendar.php'; + if(isset($php_errormsg) && preg_match('/Failed opening.*for inclusion/i', $php_errormsg)) { + print "PEAR Calendar package is missing
\n"; + $missing = true; + } ini_restore('track_errors'); if(isset($missing)) @@ -1044,6 +1105,69 @@ class PHPFSPOT { } // _warning() + private function get_calendar() + { +// require_once CALENDAR_ROOT.'Year.php'; +// require_once CALENDAR_ROOT.'Month.php'; +// require_once CALENDAR_ROOT.'Day.php'; + +// $Year = new Calendar_Year(); +// $Month = new Calendar_Month(); +// $Day = new Calendar_Day(); + + $output = "\n"; + + $output.= "\n"; + + $output.= "\n"; + + return $output; + + } // get_calendar() + + public function getExport($mode) + { + $pictures = $this->getPhotoSelection(); + + if(!isset($_SERVER['HTTPS'])) $protocol = "http"; + else $protocol = "https"; + + $server_name = $_SERVER['SERVER_NAME']; + + foreach($pictures as $picture) { + + $orig_url = $protocol ."://". $server_name . $this->cfg->web_path ."phpfspot_img.php?idx=". $picture ."&width=". $this->cfg->photo_width; + $thumb_url = $protocol ."://". $server_name . $this->cfg->web_path ."phpfspot_img.php?idx=". $picture ."&width=". $this->cfg->thumb_width; + + switch($mode) { + + case 'HTML': + //
+ print htmlspecialchars("") ."
\n"; + break; + + case 'MoinMoin': + // [%pictureurl% %thumbnailurl%] + print htmlspecialchars("[$orig_url $thumb_url]") ."
\n"; + break; + } + + } + + } // getExport() + } ?>