summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2008-01-01 12:06:46 +0100
committerAndreas Unterkircher <unki@netshadow.at>2008-01-01 12:06:46 +0100
commit5bc350814a9426a89e8ab06728badad9430d4015 (patch)
treef8d053012af162c18beb14b51b4dcda86b55b0dd
parentbb3bcfbb5f2627788d4ee498ddbd3b7024a2d326 (diff)
sort-order is now set via AJAX, not while submit a search-query
-rw-r--r--phpfspot.class.php39
-rw-r--r--phpfspot.js20
-rw-r--r--rpc.php10
-rw-r--r--themes/default/stylesheet.css13
-rw-r--r--themes/default/templates/search.tpl14
5 files changed, 73 insertions, 23 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index 40b6551..eaa788a 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -49,6 +49,13 @@ class PHPFSPOT {
$this->cfg->product = "phpfspot";
$this->cfg->version = "1.2";
+ $this->sort_orders= array(
+ 'date_asc' => 'Date &uarr;',
+ 'date_desc' => 'Date &darr;',
+ 'name_asc' => 'Name &uarr;',
+ 'name_desc' => 'Name &darr;'
+ );
+
/* Check necessary requirements */
if(!$this->checkRequirements()) {
exit(1);
@@ -1420,12 +1427,11 @@ class PHPFSPOT {
* 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;
- $_SESSION['sort_order'] = $sort_order;
if($from != 0)
$_SESSION['from_date'] = strtotime($from);
else
@@ -1447,6 +1453,23 @@ class PHPFSPOT {
} // 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
*
* this function rotates the image according the
@@ -1931,23 +1954,15 @@ class PHPFSPOT {
*/
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.= "</select>";
return $output;
diff --git a/phpfspot.js b/phpfspot.js
index 6671eb2..b196a68 100644
--- a/phpfspot.js
+++ b/phpfspot.js
@@ -113,9 +113,6 @@ function startSearch()
request = request + '&from='+ from +'&to='+ to;
}
- var sort_order = document.getElementsByName('sort_order')[0];
- request = request + '&sort_order='+ sort_order.options[sort_order.selectedIndex].value;
-
HTML_AJAX.grab(encodeURI(request));
refreshAvailableTags();
@@ -402,6 +399,23 @@ function initSlider()
}
+function update_sort_order(obj)
+{
+ var objTemp = new Object();
+ objTemp['value'] = obj.options[obj.selectedIndex].value;
+
+ var retr = HTML_AJAX.post('rpc.php?action=update_sort_order', objTemp);
+
+ if(retr == "ok") {
+ showPhotoIndex();
+ }
+ else {
+ window.alert(retr);
+ }
+
+} // update_sort_order()
+
+
var startup = 1;
var calendar_shown = 0;
var calendar_mode = '';
diff --git a/rpc.php b/rpc.php
index 0bd04fe..1f01633 100644
--- a/rpc.php
+++ b/rpc.php
@@ -101,13 +101,19 @@ class PHPFSPOT_RPC {
break;
case 'search':
- $fspot->startSearch($_GET['for'], $_GET['sort_order'], $_GET['from'], $_GET['to']);
+ $fspot->startSearch($_GET['for'], $_GET['from'], $_GET['to']);
if((isset($_GET['from']) && $fspot->isValidDate($_GET['from'])) &&
(isset($_GET['to']) && $fspot->isValidDate($_GET['to']))) {
}
else {
- $fspot->startSearch($_GET['for'], $_GET['sort_order']);
+ $fspot->startSearch($_GET['for']);
+ }
+ break;
+
+ case 'update_sort_order':
+ if(isset($_POST['value']) && is_string($_POST['value'])) {
+ print $fspot->updateSortOrder($_POST['value']);
}
break;
diff --git a/themes/default/stylesheet.css b/themes/default/stylesheet.css
index eae8f4a..e12e57d 100644
--- a/themes/default/stylesheet.css
+++ b/themes/default/stylesheet.css
@@ -210,3 +210,16 @@ table.calendar tr td {
border: dashed 1px #888888;
vertical-align: middle;
}
+
+input.submit {
+ background-color: #ffffff;
+ border: 0px;
+}
+
+input, select, textarea {
+ background-color: #eeeeee;
+ color: #333333;
+ border: 1px solid #888888;
+ border-collapse: collapse;
+}
+
diff --git a/themes/default/templates/search.tpl b/themes/default/templates/search.tpl
index e12a099..cd2a93b 100644
--- a/themes/default/templates/search.tpl
+++ b/themes/default/templates/search.tpl
@@ -14,12 +14,12 @@
<input type="text" name="searchfor" value="{$searchfor}" size="15" />
</td>
<td>
- <input type="image" src="resources/doit.png" alt="Tag-Search" onclick="click(this);" />
+ <input type="image" class="submit" src="resources/doit.png" alt="start search" title="start search" onclick="click(this);" />
</td>
</tr>
<tr>
<td>Date:</td>
- <td>
+ <td style="white-space: nowrap;">
{ if ! $date_search_enabled }
<input type="checkbox" name="consider_date" value="Y" onclick="datesearch();">
{ else }
@@ -38,18 +38,20 @@
{$to_date} <a href="javascript:showCalendar('to');" onclick="click(this);"><img src="resources/date.png" id="topic" /></a>
</td>
<td>
- <input type="image" src="resources/doit.png" alt="Tag-Search" onclick="click(this);" />
+ <input type="image" class="submit" src="resources/doit.png" alt="start search" title="start search" onclick="click(this);" />
</td>
</tr>
<tr>
<td>
- Sort-Order:
+ Sort-Order:&nbsp;
</td>
<td>
- { sort_select_list }
+ <select name="sort_order" onchange="update_sort_order(this);">
+ { sort_select_list }
+ </select>
</td>
<td>
- <input type="image" src="resources/doit.png" alt="Tag-Search" onclick="click(this);" />
+ &nbsp;
</td>
</tr>
</form>