sort-order is now set via AJAX, not while submit a search-query
[phpfspot.git] / phpfspot.class.php
index 40b65516241fc8141f6c85ecb2aa342b5588994b..eaa788a10b97a9b2e1a2b032f55040340f3e31e7 100644 (file)
@@ -49,6 +49,13 @@ class PHPFSPOT {
       $this->cfg->product = "phpfspot";
       $this->cfg->version = "1.2";
 
       $this->cfg->product = "phpfspot";
       $this->cfg->version = "1.2";
 
+      $this->sort_orders= array(
+         'date_asc' => 'Date ↑',
+         'date_desc' => 'Date ↓',
+         'name_asc' => 'Name ↑',
+         'name_desc' => 'Name ↓'
+      );
+
       /* Check necessary requirements */
       if(!$this->checkRequirements()) {
          exit(1);
       /* Check necessary requirements */
       if(!$this->checkRequirements()) {
          exit(1);
@@ -1420,12 +1427,11 @@ class PHPFSPOT {
     * getPhotoSelection() will then only return the matching
     * photos.
     */
     * getPhotoSelection() will then only return the matching
     * photos.
     */
-   public function startSearch($searchfor, $sort_order, $from = 0, $to = 0)
+   public function startSearch($searchfor, $from = 0, $to = 0)
    {
       $this->get_tags();
 
       $_SESSION['searchfor'] = $searchfor;
    {
       $this->get_tags();
 
       $_SESSION['searchfor'] = $searchfor;
-      $_SESSION['sort_order'] = $sort_order;
       if($from != 0)
          $_SESSION['from_date'] = strtotime($from);
       else
       if($from != 0)
          $_SESSION['from_date'] = strtotime($from);
       else
@@ -1446,6 +1452,23 @@ class PHPFSPOT {
 
    } // startSearch()
 
 
    } // startSearch()
 
+   /**
+    * updates sort order in session variable
+    *
+    * this function is invoked by RPC and will sort the requested
+    * sort order in the session variable.
+    */
+   public function updateSortOrder($order)
+   {
+      if(isset($this->sort_orders[$order])) {
+         $_SESSION['sort_order'] = $order;
+         return "ok";
+      }
+
+      return "unkown error";
+
+   } // updateSortOrder()
+
    /**
     * rotate image
     *
    /**
     * rotate image
     *
@@ -1931,23 +1954,15 @@ class PHPFSPOT {
     */
    public function smarty_sort_select_list($params, &$smarty)
    {
     */
    public function smarty_sort_select_list($params, &$smarty)
    {
-      $output = "<select name=\"sort_order\">";
+      $output = "";
 
 
-      $sorter = array(
-         'date_asc' => 'Date &uarr;',
-         'date_desc' => 'Date &darr;',
-         'name_asc' => 'Name &uarr;',
-         'name_desc' => 'Name &darr;'
-      );
-         
-      foreach($sorter as $key => $value) {
+      foreach($this->sort_orders as $key => $value) {
          $output.= "<option value=\"". $key ."\"";
          if($key == $_SESSION['sort_order']) {
             $output.= " selected=\"selected\"";
          }
          $output.= ">". $value ."</option>";
       }
          $output.= "<option value=\"". $key ."\"";
          if($key == $_SESSION['sort_order']) {
             $output.= " selected=\"selected\"";
          }
          $output.= ">". $value ."</option>";
       }
-      $output.= "</select>";
 
       return $output;
 
 
       return $output;