*/
public function addTag($tag)
{
- // if the result of a date search are displayed, reset them
- $this->resetDateSearch();
-
if(!isset($_SESSION['selected_tags']))
$_SESSION['selected_tags'] = Array();
{
$matched_photos = Array();
+ if(isset($_SESSION['from_date']) && isset($_SESSION['to_date'])) {
+ $from_date = strtotime($_SESSION['from_date']);
+ $to_date = strtotime($_SESSION['to_date']);
+ $additional_where_cond = "
+ p.time>='". $from_date ."'
+ AND
+ p.time<='". $to_date ."'
+ ";
+ }
+
/* return a search result */
if(isset($_SESSION['searchfor']) && $_SESSION['searchfor'] != '') {
- $result = $this->db->db_query("
+ $query_str = "
SELECT DISTINCT photo_id
FROM photo_tags pt
INNER JOIN photos p
ON p.id=pt.photo_id
INNER JOIN tags t
ON pt.tag_id=t.id
- WHERE t.name LIKE '%". $_SESSION['searchfor'] ."%'
- ORDER BY p.time ASC
- ");
+ WHERE t.name LIKE '%". $_SESSION['searchfor'] ."%'";
+
+ if(isset($additional_where_cond))
+ $query_str.= "AND ". $additional_where_cond ." ";
+ $query_str.= "
+ ORDER BY p.time ASC
+ ";
+ $result = $this->db->db_query($query_str);
while($row = $this->db->db_fetch_object($result)) {
array_push($matched_photos, $row['photo_id']);
}
$selected = substr($selected, 0, strlen($selected)-1);
if($_SESSION['tag_condition'] == 'or') {
- $result = $this->db->db_query("
+ $query_str = "
SELECT DISTINCT photo_id
FROM photo_tags pt
INNER JOIN photos p
ON p.id=pt.photo_id
WHERE pt.tag_id IN (". $selected .")
+ ";
+ if(isset($additional_where_cond))
+ $query_str.= "AND ". $additional_where_cond ." ";
+
+ $query_str.= "
ORDER BY p.time ASC
- ");
+ ";
}
elseif($_SESSION['tag_condition'] == 'and') {
AND pt". ($i+1) .".tag_id=". $_SESSION['selected_tags'][$i] ."
";
}
- $result = $this->db->db_query($query_str);
+ if(isset($additional_where_cond))
+ $query_str.= "AND ". $additional_where_cond;
}
+ $result = $this->db->db_query($query_str);
while($row = $this->db->db_fetch_object($result)) {
array_push($matched_photos, $row['photo_id']);
}
return $matched_photos;
}
- if(isset($_SESSION['from_date']) && isset($_SESSION['to_date'])) {
- $from_date = strtotime($_SESSION['from_date']);
- $to_date = strtotime($_SESSION['to_date']);
- $result = $this->db->db_query("
- SELECT DISTINCT photo_id
- FROM photo_tags pt
- INNER JOIN photos p
- ON p.id=pt.photo_id
- WHERE
- time>='". $from_date ."'
- AND
- time<='". $to_date ."'
- ORDER BY p.time ASC
- ");
- while($row = $this->db->db_fetch_object($result)) {
- array_push($matched_photos, $row['photo_id']);
- }
- return $matched_photos;
- }
-
/* return all available photos */
- $result = $this->db->db_query("
+ $query_str = "
SELECT DISTINCT photo_id
FROM photo_tags pt
INNER JOIN photos p
ON p.id=pt.photo_id
+ ";
+ if(isset($additional_where_cond))
+ $query_str.= "WHERE ". $additional_where_cond ." ";
+ $query_str.= "
ORDER BY p.time ASC
- ");
+ ";
+ $result = $this->db->db_query($query_str);
while($row = $this->db->db_fetch_object($result)) {
array_push($matched_photos, $row['photo_id']);
}
} // setTagCondition()
/**
- * invoke tag search
+ * invoke tag & date search
*
* this function will return all matching tags and store
- * them in the session variable selected_tags.
+ * them in the session variable selected_tags. furthermore
+ * it also handles the date search.
* getPhotoSelection() will then only return the matching
* photos.
*/
- public function startTagSearch($searchfor)
+ public function startSearch($searchfor, $from, $to)
{
$_SESSION['searchfor'] = $searchfor;
- $_SESSION['selected_tags'] = Array();
-
- foreach($this->avail_tags as $tag) {
- if(preg_match('/'. $searchfor .'/i', $this->tags[$tag]))
- array_push($_SESSION['selected_tags'], $tag);
- }
-
- $this->resetDateSearch();
-
- } // startTagSearch()
-
- /**
- * invoke date search
- *
- * this function in fact does nothing then only setting
- * the from- and to-date in the users session variables.
- * the result is generated by getPhotoSelection().
- */
- public function startDateSearch($from, $to)
- {
$_SESSION['from_date'] = $from;
$_SESSION['to_date'] = $to;
- }
+
+ if($searchfor != "") {
+ /* new search, reset the current selected tags */
+ $_SESSION['selected_tags'] = Array();
+ foreach($this->avail_tags as $tag) {
+ if(preg_match('/'. $searchfor .'/i', $this->tags[$tag]))
+ array_push($_SESSION['selected_tags'], $tag);
+ }
+ }
+ } // startSearch()
/**
* rotate image
$month = $_SESSION[$mode .'_date'] ? date("m", strtotime($_SESSION[$mode .'_date'])) : date("m");
$day = $_SESSION[$mode .'_date'] ? date("d", strtotime($_SESSION[$mode .'_date'])) : date("d");
- $output = "<input type=\"text\" size=\"3\" id=\"". $mode ."year\" value=\"". $year ."\" />\n";
- $output.= "<input type=\"text\" size=\"1\" id=\"". $mode ."month\" value=\"". $month ."\" />\n";
- $output.= "<input type=\"text\" size=\"1\" id=\"". $mode ."day\" value=\"". $day ."\" />\n";
+ $output = "<input type=\"text\" size=\"3\" id=\"". $mode ."year\" value=\"". $year ."\"";
+ if(!isset($_SESSION[$mode .'_date'])) $output.= " disabled=\"disabled\"";
+ $output.= " />\n";
+ $output.= "<input type=\"text\" size=\"1\" id=\"". $mode ."month\" value=\"". $month ."\"";
+ if(!isset($_SESSION[$mode .'_date'])) $output.= " disabled=\"disabled\"";
+ $output.= " />\n";
+ $output.= "<input type=\"text\" size=\"1\" id=\"". $mode ."day\" value=\"". $day ."\"";
+ if(!isset($_SESSION[$mode .'_date'])) $output.= " disabled=\"disabled\"";
+ $output.= " />\n";
return $output;
} // get_calendar()
}
}
-function startTagSearch(searchfor)
+function startSearch()
{
- HTML_AJAX.grab(encodeURI('rpc.php?action=tag_search&for=' + searchfor));
- refreshAvailableTags();
- refreshSelectedTags();
- showPhotoIndex();
-}
+ var searchfor = document.getElementsByName('searchfor')[0].value
-function startDateSearch()
-{
from_year = document.getElementById('fromyear').value;
from_month = document.getElementById('frommonth').value;
from_day = document.getElementById('fromday').value;
to_day = document.getElementById('today').value;
to = to_year +"-"+ to_month +"-"+ to_day;
- HTML_AJAX.grab(encodeURI('rpc.php?action=date_search&from='+ from +'&to='+ to));
+ var request = 'rpc.php?action=search';
- refreshPhotoIndex();
+ if(searchfor != "") {
+ request = request + '&for=' + searchfor;
+ }
+ if(document.getElementsByName('consider_date')[0].checked == true) {
+ request = request + '&from='+ from +'&to='+ to;
+ }
+
+ HTML_AJAX.grab(encodeURI(request));
+
+ refreshAvailableTags();
+ refreshSelectedTags();
+ showPhotoIndex();
+
+}
+
+function datesearch()
+{
+ var mode = true;
+
+ if(document.getElementsByName('consider_date')[0].checked == true) {
+ mode = false;
+ }
+
+ document.getElementById('fromyear').disabled = mode;
+ document.getElementById('frommonth').disabled = mode;
+ document.getElementById('fromday').disabled = mode;
+ document.getElementById('toyear').disabled = mode;
+ document.getElementById('tomonth').disabled = mode;
+ document.getElementById('today').disabled = mode;
+
}
function setViewMode(mode)
<td colspan="3">
<table style="width: 100%;">
<tr>
- <td class="index_header">
+ <td class="content_title">
<b>Photo Index</b>
{if $searchfor }
{if $count == 1}
- {$count} image is the result for your search about "{$searchfor}"
+ {$count} image is the result for your search about "{$searchfor}".
{else}
- {$count} images are the result for your search about "{$searchfor}"
- {/if}
- {elseif $from_date }
- {if $count == 1}
- {$count} image is the result for your search between {$from_date} to {$to_date}
- {else}
- {$count} images are the result for your search between {$from_date} to {$to_date}
+ {$count} images are the result for your search about "{$searchfor}".
{/if}
{elseif $tag_result}
{if $count == 1}
- {$count} image has been found for the selected tags
+ {$count} image has been found for the selected tags.
{else}
- {$count} images have been found for the selected tags
+ {$count} images have been found for the selected tags.
{/if}
{else}
{if $count == 1}
- {$count} image has been found
+ {$count} image has been found.
{else}
- {$count} images have been found
+ {$count} images have been found.
{/if}
{/if}
+ {if $from_date && $to_date }
+ Results are limited to a date between {$from_date} to {$to_date}.
+ {/if}
</td>
<td class="index_header" style="text-align: right">
{if $extern_link }