do not make get_meta_informations silent - accidently pulled from Arun
[phpfspot.git] / phpfspot.class.php
index 99b0d7b9fe1c767837205385d901ed421d2e5d7d..49d0c7df071da319c16c829bbc9d5be55a101d2e 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,10 +314,17 @@ class PHPFSPOT {
       $this->tmpl->assign('from_date', $this->get_calendar('from'));
       $this->tmpl->assign('to_date', $this->get_calendar('to'));
 
-      if(!isset($content))
-         $this->tmpl->assign('content_page', $this->tmpl->fetch('welcome.tpl'));
+      $this->tmpl->assign('preset_selected_tags', $this->getSelectedTags());
+      $this->tmpl->assign('preset_available_tags', $this->getAvailableTags());
+
+      if(!isset($content)) {
+         if(isset($_SESSION['selected_tags']) && !empty($_SESSION['selected_tags']))
+            $this->tmpl->assign('initial_content', $this->showPhotoIndex());
+         else
+            $this->tmpl->assign('initial_content', $this->tmpl->fetch('welcome.tpl'));
+      }
       else
-         $this->tmpl->assign('content_page', $content);
+         $this->tmpl->assign('initial_content', $content);
 
       $this->tmpl->show("index.tpl");
 
@@ -725,13 +734,15 @@ class PHPFSPOT {
          $b = '88';
 
          if(isset($this->tags[$key])) {
-            $output.= "<a href=\"javascript:Tags('add', ". $key .");\" class=\"tag\" style=\"font-size: ". $size ."%; color: #". $r.$g.$b .";\">". $this->tags[$key] ."</a>, ";
+            if($this->is_user_friendly_url())
+               $output.= "<a href=\"". $this->cfg->web_path ."/tag/". $key ."\" onclick=\"Tags('add', ". $key ."); return false;\" class=\"tag\" style=\"font-size: ". $size ."%; color: #". $r.$g.$b .";\">". $this->tags[$key] ."</a>, ";
+            else
+               $output.= "<a href=\"". $this->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] ."</a>, ";
          }
-
       }
 
       $output = substr($output, 0, strlen($output)-2);
-      print $output;
+      return $output;
 
    } // getAvailableTags()
 
@@ -1171,6 +1182,7 @@ class PHPFSPOT {
     *
     * this function provides all the necessary information
     * for the photo index template.
+    * @return string
     */
    public function showPhotoIndex()
    {
@@ -2437,7 +2449,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 +2457,6 @@ class PHPFSPOT {
          return "showpi";
       }
 
-      return "nothing special";
-
    } // whatToDo()
 
    /**
@@ -2771,15 +2780,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 +2974,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 +3095,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 +3112,7 @@ class PHPFSPOT {
          switch($options[1]) {
             case 'photoview':
                if(is_numeric($options[2])) {
+                  $_GET['mode'] = 'showp';
                   return $this->showPhoto($options[2]);
                }
                break;
@@ -3121,10 +3129,8 @@ class PHPFSPOT {
                break;
             case 'tag':
                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];
+                  $_SESSION['selected_tags'] = Array($options[2]);
                   return $this->showPhotoIndex();
                }
                break;