X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=phpfspot.class.php;h=d7a76c3a50d9cfd80830dda1553a87f6007d9b52;hp=df984cb9bc076ecdbe686a48d19ad87eebae32c5;hb=5d95b196f7993398d68ad67179eb2d2b2ce1b0f1;hpb=c74587e30a28f01a2c7134cc254964baf8a7fa10 diff --git a/phpfspot.class.php b/phpfspot.class.php index df984cb..d7a76c3 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -122,7 +122,7 @@ class PHPFSPOT { /* set application name and version information */ $this->cfg->product = "phpfspot"; - $this->cfg->version = "1.5"; + $this->cfg->version = "1.6"; $this->sort_orders= array( 'date_asc' => 'Date ↑', @@ -227,8 +227,9 @@ class PHPFSPOT { if(!isset($_SESSION['tag_condition'])) $_SESSION['tag_condition'] = 'or'; + /* if sort-order has not been set yet, get the one specified in the config */ if(!isset($_SESSION['sort_order'])) - $_SESSION['sort_order'] = 'date_desc'; + $_SESSION['sort_order'] = $this->cfg->sort_order; if(!isset($_SESSION['searchfor_tag'])) $_SESSION['searchfor_tag'] = ''; @@ -344,8 +345,8 @@ class PHPFSPOT { } $this->tmpl->register_function("sort_select_list", array(&$this, "smarty_sort_select_list"), false); - $this->tmpl->assign('search_from_date', $this->get_calendar('from')); - $this->tmpl->assign('search_to_date', $this->get_calendar('to')); + $this->tmpl->assign('search_from_date', $this->get_date_text_field('from')); + $this->tmpl->assign('search_to_date', $this->get_date_text_field('to')); $this->tmpl->assign('preset_selected_tags', $this->getSelectedTags()); $this->tmpl->assign('preset_available_tags', $this->getAvailableTags()); @@ -391,6 +392,11 @@ class PHPFSPOT { $this->avail_tags = Array(); $count = 0; + /* if show_tags has been set in the configuration (only show photos + which are tagged by these tags) they following will take care, + that only these other tags are displayed where the photo is also + tagged with one of show_tags. + */ if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags)) { $query_str=" SELECT @@ -458,6 +464,7 @@ class PHPFSPOT { */ public function get_photo_details($idx) { + /* ~ F-Spot version 0.3.x */ if($this->dbver < 9) { $query_str = " SELECT p.id, p.name, p.time, p.directory_path, p.description @@ -480,8 +487,8 @@ class PHPFSPOT { } } - /* if show_tags is set, only return details for photos which - are specified to be shown + /* if show_tags is set, only return details of photos which are + tagged with a tag that has been specified to be shown. */ if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags)) { $query_str.= " @@ -502,6 +509,9 @@ class PHPFSPOT { $row = $this->db->db_fetch_object($result); + /* before F-Spot db version 9 there was no uri column but seperated + columns for directory_path and name (= filename). + */ if($this->dbver < 9) { $row['uri'] = "file://". $row['directory_path'] ."/". $row['name']; } @@ -517,9 +527,10 @@ class PHPFSPOT { /** * returns aligned photo names * - * this function returns aligned (length) names for - * an specific photo. If the length of the name exceeds - * $limit the name will be shrinked (...) + * this function returns aligned (length) names for a specific photo. + * If the length of the name exceeds $limit the name will bei + * shrinked (...). + * * @param integer $idx * @param integer $limit * @return string|null @@ -540,11 +551,11 @@ class PHPFSPOT { /** * get photo rating level * - * this function will return the integer-based rating - * level of the photo. This can only be done, if the F-Spot - * database is at a specific level. If rating value can not - * be found, zero will be returned indicating no rating value - * is available. + * this function will return the integer-based rating level of a + * photo. This can only be done, if the F-Spot database is at a + * specific version. If rating value can not be found, zero will + * be returned indicating no rating value is available. + * * @param integer idx * @return integer */ @@ -562,8 +573,8 @@ class PHPFSPOT { /** * get rate-search bars * - * this function will return the rating-bars for the - * search field. + * this function will return the rating-bars for the search field. + * * @return string */ public function get_rate_search() @@ -609,9 +620,9 @@ class PHPFSPOT { /** * shrink text according provided limit * - * If the length of the name exceeds $limit the - * text will be shortend and some content in between - * will be replaced with "..." + * If the length of the name exceeds $limit, text will be shortend + * and inner content will be replaced with "...". + * * @param string $ext * @param integer $limit * @return string @@ -719,7 +730,6 @@ class PHPFSPOT { $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_size = isset($meta['FileSize']) ? round($meta['FileSize']/1024, 1) ."kbyte" : "n/a"; @@ -747,7 +757,7 @@ class PHPFSPOT { $this->tmpl->assign('width', $info_thumb[0]); $this->tmpl->assign('height', $info_thumb[1]); - $this->tmpl->assign('ExifMadeOn', $meta_date); + $this->tmpl->assign('ExifMadeOn', strftime("%a %x %X", $details['time'])); $this->tmpl->assign('ExifMadeWith', $meta_make); $this->tmpl->assign('ExifOrigResolution', $meta_res); $this->tmpl->assign('ExifFileSize', $meta_size); @@ -841,6 +851,9 @@ class PHPFSPOT { // loop through our tag array foreach ($tags as $key => $value) { + /* has the currently processed tag already been added to + the selected tag list? if so, ignore it here... + */ if(isset($_SESSION['selected_tags']) && in_array($key, $_SESSION['selected_tags'])) continue; @@ -849,7 +862,7 @@ class PHPFSPOT { // multiply by the font-size increment ($size) // and add the $min_size set above $size = $min_size + (($value - $min_qty) * $step); - // uncomment if you want sizes in whole %: + // uncomment if you want sizes in whole %: $size = ceil($size); $color = $min_sat + ($value - $min_qty) * $step_sat; @@ -859,10 +872,20 @@ class PHPFSPOT { $b = '88'; if(isset($this->tags[$key])) { - if($this->is_user_friendly_url()) - $output.= "cfg->web_path ."/tag/". $key ."\" onclick=\"Tags('add', ". $key ."); return false;\" class=\"tag\" style=\"font-size: ". $size ."%; color: #". $r.$g.$b .";\">". $this->tags[$key] .", "; - else - $output.= "cfg->web_path ."/index.php?mode=showpi\" onclick=\"Tags('add', ". $key ."); return false;\" class=\"tag\" style=\"font-size: ". $size ."%; color: #". $r.$g.$b .";\">". $this->tags[$key] .", "; + if($this->is_user_friendly_url()) { + $output.= "cfg->web_path ."/tag/". $key ."\" + onclick=\"Tags('add', ". $key ."); return false;\" + class=\"tag\" + style=\"font-size: ". $size ."%; color: #". $r.$g.$b .";\" + title=\"Tag ". $this->tags[$key] .", ". $tags[$key] ." picture(s)\">". $this->tags[$key] .", "; + } + else { + $output.= "cfg->web_path ."/index.php?mode=showpi\" + onclick=\"Tags('add', ". $key ."); return false;\" + class=\"tag\" + style=\"font-size: ". $size ."%; color: #". $r.$g.$b .";\" + title=\"Tag ". $this->tags[$key] .", ". $tags[$key] ." picture(s)\">". $this->tags[$key] .", "; + } } } @@ -2009,11 +2032,11 @@ class PHPFSPOT { public function startSearch() { /* date search */ - if(isset($_POST['from']) && $this->isValidDate($_POST['from'])) { - $from = $_POST['from']; + if(isset($_POST['date_from']) && $this->isValidDate($_POST['date_from'])) { + $date_from = $_POST['date_from']; } - if(isset($_POST['to']) && $this->isValidDate($_POST['to'])) { - $to = $_POST['to']; + if(isset($_POST['date_to']) && $this->isValidDate($_POST['date_to'])) { + $date_to = $_POST['date_to']; } /* tag-name search */ @@ -2049,13 +2072,13 @@ class PHPFSPOT { $this->get_tags(); - if(isset($from) && !empty($from)) - $_SESSION['from_date'] = strtotime($from ." 00:00:00"); + if(isset($date_from) && !empty($date_from)) + $_SESSION['from_date'] = strtotime($date_from ." 00:00:00"); else unset($_SESSION['from_date']); - if(isset($to) && !empty($to)) - $_SESSION['to_date'] = strtotime($to ." 23:59:59"); + if(isset($date_to) && !empty($date_to)) + $_SESSION['to_date'] = strtotime($date_to ." 23:59:59"); else unset($_SESSION['to_date']); @@ -2365,32 +2388,31 @@ class PHPFSPOT { } // _error() /** - * output calendard input fields + * get calendar input-text fields + * + * this function returns a text-field used for the data selection. + * Either it will be filled with the current date or, if available, + * filled with the date user entered previously. + * * @param string $mode * @return string */ - private function get_calendar($mode) + private function get_date_text_field($mode) { - $year = isset($_SESSION[$mode .'_date']) ? date("Y", $_SESSION[$mode .'_date']) : date("Y"); - $month = isset($_SESSION[$mode .'_date']) ? date("m", $_SESSION[$mode .'_date']) : date("m"); - $day = isset($_SESSION[$mode .'_date']) ? date("d", $_SESSION[$mode .'_date']) : date("d"); + $date = isset($_SESSION[$mode .'_date']) ? date("Y", $_SESSION[$mode .'_date']) : date("Y"); + $date.= "-"; + $date.= isset($_SESSION[$mode .'_date']) ? date("m", $_SESSION[$mode .'_date']) : date("m"); + $date.= "-"; + $date.= isset($_SESSION[$mode .'_date']) ? date("d", $_SESSION[$mode .'_date']) : date("d"); - $output = "get_meta_informations($orig_path); } - $meta_date = isset($meta['FileDateTime']) ? $meta['FileDateTime'] : filemtime($orig_path); - ?> <?php print htmlspecialchars($this->parse_uri($details['uri'], 'filename')); ?> - + - +