X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=phpfspot.class.php;h=797c6047abbe299d2d15ad432550b5967c6eb775;hp=3f06a8772c28de6e091d6a49e3f66f50558ffd12;hb=bba20b67709ecf7aab8a6da9e44b6e64352d2475;hpb=9609cbda7f2a5ed1bcd0f3a5540b287a3654f4b9 diff --git a/phpfspot.class.php b/phpfspot.class.php index 3f06a87..797c604 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -142,7 +142,9 @@ class PHPFSPOT { /* 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"; + print "Error: ". $this->cfg->fspot_db ." is not writeable for user ". $this->getuid() .".\n"; + print "Please fix permissions so phpfspot can create indices within the F-Spot database to" + ." speed up some database operations.\n"; exit(1); } @@ -174,13 +176,15 @@ class PHPFSPOT { /* 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"; + print "Error: ". dirname($this->cfg->phpfspot_db) .": directory is not writeable for user ". $this->getuid() .".\n"; + print "Please fix permissions so phpfspot can create its own sqlite database to store some settings.\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"; + print "Error: ". $this->cfg->phpfspot_db ." is not writeable for user ". $this->getuid() .".\n"; + print "Please fix permissions so phpfspot can create its own sqlite database to store some settings.\n"; exit(1); } @@ -299,11 +303,15 @@ class PHPFSPOT { } break; case 'export': - $this->tmpl->show("export.tpl"); + /* fetch export template */ + print $this->tmpl->fetch("export.tpl"); + /* no further execution necessary. */ return; break; case 'slideshow': - $this->tmpl->show("slideshow.tpl"); + /* fetch slideshow template */ + print $this->tmpl->show("slideshow.tpl"); + /* no further execution necessary. */ return; break; case 'rss': @@ -336,18 +344,29 @@ 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()); $this->tmpl->assign('rate_search', $this->get_rate_search()); + /* if no site-content has been set yet... */ if(!isset($content)) { - if(isset($_SESSION['selected_tags']) && !empty($_SESSION['selected_tags'])) + /* if tags are already selected, we can immediately display photo-index */ + if((isset($_SESSION['selected_tags']) && !empty($_SESSION['selected_tags']) && + isset($_SESSION['start_action']) && $_SESSION['start_action'] != 'showp') || + (isset($_SESSION['start_action']) && $_SESSION['start_action'] == 'showpi')) $this->tmpl->assign('initial_content', $this->showPhotoIndex()); - else - $this->tmpl->assign('initial_content', $this->tmpl->fetch('welcome.tpl')); + else { + /* if a photo is already selected, we can immediately display single-photo */ + if(isset($_SESSION['current_photo']) && !empty($_SESSION['current_photo'])) + $this->tmpl->assign('initial_content', $this->showPhoto($_SESSION['current_photo'])); + else { + /* ok, then let us show the welcome page... */ + $this->tmpl->assign('initial_content', $this->tmpl->fetch('welcome.tpl')); + } + } } else $this->tmpl->assign('initial_content', $content); @@ -1990,11 +2009,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 */ @@ -2030,13 +2049,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']); @@ -2346,32 +2365,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 = "