Merge branch 'friendlyurl'
authorAndreas Unterkircher <unki@netshadow.at>
Tue, 13 May 2008 17:33:09 +0000 (19:33 +0200)
committerAndreas Unterkircher <unki@netshadow.at>
Tue, 13 May 2008 17:33:09 +0000 (19:33 +0200)
phpfspot.class.php
themes/default/templates/photo_index.tpl
themes/default/templates/search.tpl

index 49d0c7df071da319c16c829bbc9d5be55a101d2e..f938dbc30ef4710640744fa619ec8bf19213d377 100644 (file)
@@ -223,6 +223,11 @@ class PHPFSPOT {
       if(isset($_SESSION['begin_with']) && $this->cfg->thumbs_per_page == 0)
          unset($_SESSION['begin_with']);
 
+      // if user-friendly-url's are enabled, set also a flag for the template handler
+      if($this->is_user_friendly_url()) {
+         $this->tmpl->assign('user_friendly_url', 'true');
+      }
+
    } // __construct()
 
    public function __destruct()
@@ -311,8 +316,8 @@ class PHPFSPOT {
          $this->tmpl->assign('date_search_enabled', true);
 
       $this->tmpl->register_function("sort_select_list", array(&$this, "smarty_sort_select_list"), false);
-      $this->tmpl->assign('from_date', $this->get_calendar('from'));
-      $this->tmpl->assign('to_date', $this->get_calendar('to'));
+      $this->tmpl->assign('search_from_date', $this->get_calendar('from'));
+      $this->tmpl->assign('search_to_date', $this->get_calendar('to'));
 
       $this->tmpl->assign('preset_selected_tags', $this->getSelectedTags());
       $this->tmpl->assign('preset_available_tags', $this->getAvailableTags());
@@ -776,12 +781,12 @@ class PHPFSPOT {
                   <div style=\"display: table-cell;\">
                    <div style=\"display: table-row; text-align: center;\">
                     <a href=\"javascript:Tags('del', ". $tag .");\" title=\"". $this->tags[$tag] ."\">
-                     <img src=\"phpfspot_img.php?tagidx=". $tag ."\" />
+                     <img src=\"". $this->cfg->web_path ."/phpfspot_img.php?tagidx=". $tag ."\" />
                     </a>
                    </div>
                    <div style=\"display: table-row; text-align: center;\">
                     <a href=\"javascript:Tags('del', ". $tag .");\" title=\"". $this->tags[$tag] ."\">
-                     <img src=\"resources/underbar.png\" />
+                     <img src=\"". $this->cfg->web_path ."/resources/underbar.png\" />
                     </a>
                    </div>
                   </div>
@@ -1294,7 +1299,16 @@ class PHPFSPOT {
             else
                $style = "";
 
-            $select = "<a href=\"javascript:showPhotoIndex(". (($i*$photo_per_page)-$photo_per_page) .");\"";
+            $start_with = ($i*$photo_per_page)-$photo_per_page;
+
+            if($this->is_user_friendly_url()) {
+               $select = "<a href=\"". $this->cfg->web_path ."/tag/205/". $start_with ."\"";
+            }
+            else {
+               $select = "<a href=\"". $this->cfg->web_path ."/index.php?mode=showpi&nbsp;tags=". $current_tags ."&nbsp;begin_with=". $begin_with ."\"";
+            }
+            $select.= " onclick=\"showPhotoIndex(". $start_with ."); return false;\"";
+
                if($style != "")
                   $select.= $style;
             $select.= ">". $i ."</a>&nbsp;";
@@ -1332,7 +1346,6 @@ class PHPFSPOT {
          if($last_page > 1)
             $this->tmpl->assign('page_selector', $page_select);
       }
-
       
       $current_tags = $this->getCurrentTags();
       $extern_link = "index.php?mode=showpi";
@@ -2711,7 +2724,9 @@ class PHPFSPOT {
     */
    private function ts2str($timestamp)
    {
-      return strftime("%Y-%m-%d", $timestamp);
+      if(!empty($timestamp) && is_numeric($timestamp))
+         return strftime("%Y-%m-%d", $timestamp);
+
    } // ts2str()
 
    /**
@@ -3129,8 +3144,11 @@ class PHPFSPOT {
                break;
             case 'tag':
                if(is_numeric($options[2])) {
+                  $this->session_cleanup();
                   $_GET['tags'] = $options[2];
                   $_SESSION['selected_tags'] = Array($options[2]);
+                  if(isset($options[3]) && is_numeric($options[3]))
+                     $_SESSION['begin_with'] = $options[3];
                   return $this->showPhotoIndex();
                }
                break;
@@ -3155,6 +3173,21 @@ class PHPFSPOT {
 
    } // is_user_friendly_url()
 
+   /**
+    * session cleanup
+    *
+    * this function will cleanup user's session information
+    */
+   private function session_cleanup()
+   {
+      unset($_SESSION['begin_with']);
+      $this->resetDateSearch();
+      $this->resetPhotoView();
+      $this->resetTagSearch();
+      $this->resetNameSearch();
+      $this->resetDateSearch();
+
+   } // session_cleanup()
 
 } // class PHPFSPOT
 
index 333d80eec4f11ced10c39e643ed484ddfc590b9a..9f0531e960f60eff2c93939f5483bdc04543f58b 100644 (file)
   {if $images[thumb] }
 
    <div class="thumb" onmouseover="setBackGrdColor(this, 'mouseover');" onmouseout="setBackGrdColor(this, 'mouseout');" style="width: { $thumb_container_width }px; height: { $thumb_container_height }px;">
-    <a href="javascript:showImage({$images[thumb]}, 'scrollup');" id="thumblink{$images[thumb]}" name="image{$img_id[thumb]}" class="thumblink" onclick="click(this);" title="{$img_title[thumb]}">
-     <img class="thumb" id="thumbimg{$images[thumb]}" width="{$img_width[thumb]}" height="{$img_height[thumb]}" />
+    { if $user_friendly_url }
+    <a href="{$web_path}/photoview/{$images[thumb]}" onclick="showImage({$images[thumb]}, 'scrollup'); return false;" id="thumblink{$images[thumb]}" name="image{$img_id[thumb]}" class="thumblink" onfocus="click(this);" title="{$img_title[thumb]}">
+    { else }
+    <a href="{$web_path}/index.php?mode=showp&amp;id={$images[thumb]}" onclick="showImage({$images[thumb]}, 'scrollup'); return false;" id="thumblink{$images[thumb]}" name="image{$img_id[thumb]}" class="thumblink" onfocus="click(this);" title="{$img_title[thumb]}">
+    { /if }
+     <img class="thumb" id="thumbimg{$images[thumb]}" width="{$img_width[thumb]}" height="{$img_height[thumb]}" src="{$web_path}/phpfspot_img.php?idx={$images[thumb]}&width={$width}" />
      <br />
     {$img_name[thumb]}
     </a>
index 401d9af937ae3b61addcaa2402fc5699419196fb..767cbcf708175316ced302b4909d8a8d9e034a07 100644 (file)
  </tr>
  <tr>
   <td>&nbsp;</td>
-  <td>{$from_date} <a href="javascript:showCalendar('from');" onclick="click(this);"><img src="{$web_path}/resources/date.png" id="frompic" alt="from" /></a></td>
+  <td>{$search_from_date} <a href="javascript:showCalendar('from');" onclick="click(this);"><img src="{$web_path}/resources/date.png" id="frompic" alt="from" /></a></td>
  </tr>
  <tr>
   <td>&nbsp;</td>
-  <td>
-   {$to_date} <a href="javascript:showCalendar('to');" onclick="click(this);"><img src="{$web_path}/resources/date.png" id="topic" alt="to" /></a>
-  </td>
+  <td>{$search_to_date} <a href="javascript:showCalendar('to');" onclick="click(this);"><img src="{$web_path}/resources/date.png" id="topic" alt="to" /></a></td>
   <td>
    <input type="image" class="submit" src="{$web_path}/resources/doit.png" alt="start search" title="start search" onclick="click(this);" />
   </td>