if(!isset($_SESSION['tag_condition']))
$_SESSION['tag_condition'] = 'or';
+ if(!isset($_SESSION['sort_order']))
+ $_SESSION['sort_order'] = 'date_asc';
+
if(!isset($_SESSION['searchfor']))
$_SESSION['searchfor'] = '';
$this->tmpl->assign('from_date', $this->get_calendar('from'));
$this->tmpl->assign('to_date', $this->get_calendar('to'));
+ $this->tmpl->assign('sort_field', $this->get_sort_field());
$this->tmpl->assign('content_page', 'welcome.tpl');
$this->tmpl->show("index.tpl");
";
}
+ if(isset($_SESSION['sort_order'])) {
+ $order_str = $this->get_sort_order();
+ }
+
/* return a search result */
if(isset($_SESSION['searchfor']) && $_SESSION['searchfor'] != '') {
$query_str = "
if(isset($additional_where_cond))
$query_str.= "AND ". $additional_where_cond ." ";
- $query_str.= "
- ORDER BY p.time ASC
- ";
+ if(isset($order_str))
+ $query_str.= $order_str;
+
$result = $this->db->db_query($query_str);
while($row = $this->db->db_fetch_object($result)) {
array_push($matched_photos, $row['photo_id']);
";
if(isset($additional_where_cond))
$query_str.= "AND ". $additional_where_cond ." ";
-
- $query_str.= "
- ORDER BY p.time ASC
- ";
+ if(isset($order_str))
+ $query_str.= $order_str;
}
elseif($_SESSION['tag_condition'] == 'and') {
}
if(isset($additional_where_cond))
$query_str.= "AND ". $additional_where_cond;
+ if(isset($order_str))
+ $query_str.= $order_str;
}
$result = $this->db->db_query($query_str);
";
if(isset($additional_where_cond))
$query_str.= "WHERE ". $additional_where_cond ." ";
- $query_str.= "
- ORDER BY p.time ASC
- ";
+ if(isset($order_str))
+ $query_str.= $order_str;
+
$result = $this->db->db_query($query_str);
while($row = $this->db->db_fetch_object($result)) {
array_push($matched_photos, $row['photo_id']);
* getPhotoSelection() will then only return the matching
* photos.
*/
- public function startSearch($searchfor, $from, $to)
+ public function startSearch($searchfor, $from, $to, $sort_order)
{
$_SESSION['searchfor'] = $searchfor;
$_SESSION['from_date'] = $from;
$_SESSION['to_date'] = $to;
+ $_SESSION['sort_order'] = $sort_order;
if($searchfor != "") {
/* new search, reset the current selected tags */
} // getuid()
+ /**
+ * returns a select-dropdown box to select photo index sort parameters
+ */
+ private function get_sort_field()
+ {
+ $output = "<select name=\"sort_order\">";
+ foreach(array('date_asc', 'date_desc', 'name_asc', 'name_desc') as $sort_order) {
+ $output.= "<option value=\"". $sort_order ."\"";
+ if($sort_order == $_SESSION['sort_order']) {
+ $output.= " selected=\"selected\"";
+ }
+ $output.= ">". $sort_order ."</option>";
+ }
+ $output.= "</select>";
+ return $output;
+
+ } // get_sort_field()
+
+ /**
+ * returns the currently selected sort order
+ */
+ private function get_sort_order()
+ {
+ switch($_SESSION['sort_order']) {
+ case 'date_asc':
+ return "ORDER BY p.time ASC";
+ break;
+ case 'date_desc':
+ return "ORDER BY p.time DESC";
+ break;
+ case 'name_asc':
+ return "ORDER BY p.name ASC";
+ break;
+ case 'name_desc':
+ return "ORDER BY p.name DESC";
+ break;
+ }
+
+ return $_SESSION['sort_order'];
+
+ } // get_sort_order()
}
?>