display initial available-tag list without the help of AJAX
[phpfspot.git] / phpfspot.class.php
index 99b0d7b9fe1c767837205385d901ed421d2e5d7d..55bd713abedcc4f1818a3eb1a020e991ca90e480 100644 (file)
@@ -201,6 +201,8 @@ class PHPFSPOT {
       require_once "phpfspot_tmpl.php";
       $this->tmpl = new PHPFSPOT_TMPL();
 
+      $this->tmpl->assign('web_path', $this->cfg->web_path);
+
       /* check if all necessary indices exist */
       $this->checkDbIndices();
 
@@ -312,8 +314,11 @@ class PHPFSPOT {
       $this->tmpl->assign('from_date', $this->get_calendar('from'));
       $this->tmpl->assign('to_date', $this->get_calendar('to'));
 
-      if(!isset($content))
+      if(!isset($content)) {
+         $this->tmpl->assign('preset_selected_tags', $this->getSelectedTags());
+         $this->tmpl->assign('preset_available_tags', $this->getAvailableTags());
          $this->tmpl->assign('content_page', $this->tmpl->fetch('welcome.tpl'));
+      }
       else
          $this->tmpl->assign('content_page', $content);
 
@@ -731,7 +736,7 @@ class PHPFSPOT {
       }
 
       $output = substr($output, 0, strlen($output)-2);
-      print $output;
+      return $output;
 
    } // getAvailableTags()
 
@@ -2437,7 +2442,6 @@ class PHPFSPOT {
    public function whatToDo()
    {
       if(isset($_SESSION['current_photo']) && $_SESSION['start_action'] == 'showp') {
-         return "show_photo";
       }
       elseif(isset($_SESSION['selected_tags']) && !empty($_SESSION['selected_tags'])) {
          return "showpi_tags";
@@ -2446,8 +2450,6 @@ class PHPFSPOT {
          return "showpi";
       }
 
-      return "nothing special";
-
    } // whatToDo()
 
    /**
@@ -2771,15 +2773,7 @@ class PHPFSPOT {
     */
    private function get_phpfspot_url()
    {
-      if($this->cfg->web_path == "/")
-         $web_path = "";
-      /* remove trailing slash */
-      elseif(preg_match('/\/$/', $this->cfg->web_path))
-         $web_path = preg_replace('/\/$/', '', $this->cfg->web_path);
-      else
-         $web_path = $this->cfg->web_path;
-
-      return $this->get_web_protocol() ."://". $this->get_server_name() . $web_path;
+      return $this->get_web_protocol() ."://". $this->get_server_name() . $this->cfg->web_path;
 
    } // get_phpfspot_url()
 
@@ -2973,9 +2967,11 @@ class PHPFSPOT {
 
       }
 
-      /* check for pending slash on web_path */
-      if(!preg_match("/\/$/", $this->cfg->web_path))
-         $this->cfg->web_path.= "/";
+      /* remove trailing slash, if set */
+      if($this->cfg->web_path == "/")
+         $this->cfg->web_path = "";
+      elseif(preg_match('/\/$/', $this->cfg->web_path))
+         $this->cfg->web_path = preg_replace('/\/$/', '', $this->cfg->web_path);
 
       return $this->runtime_error;
 
@@ -3092,7 +3088,11 @@ class PHPFSPOT {
       
    } // get_tag_name()
 
-
+   /**
+    * parse user friendly url which got rewritten by the websever
+    * @param string $request_uri
+    * @return string
+    */
    private function parse_user_friendly_url($request_uri)
    {
       if(preg_match('/\/photoview\/|\/photo\/|\/tag\//', $request_uri)) {
@@ -3105,6 +3105,7 @@ class PHPFSPOT {
          switch($options[1]) {
             case 'photoview':
                if(is_numeric($options[2])) {
+                  $_GET['mode'] = 'showp';
                   return $this->showPhoto($options[2]);
                }
                break;
@@ -3123,7 +3124,6 @@ class PHPFSPOT {
                if(is_numeric($options[2])) {
                   $_GET['mode'] = 'showpi';
                   $_SESSION['selected_tags'] = Array($options[2]);
-                  $this->tmpl->assign('preset_selected_tags', $this->getSelectedTags());
                   $_GET['tags'] = $options[2];
                   return $this->showPhotoIndex();
                }