show_results = true;
// Use eval instead of echo to allow user defined php code in the templates.
eval('?>' . $this->get_HTML_search_page_results());
}
elseif (array_key_exists('btn_clear', $_GET))
{
$this->new_search = true;
// Use eval instead of echo to allow user defined php code in the templates.
eval('?>' . $this->get_HTML_search_page());
}
else
{
// Use eval instead of echo to allow user defined php code in the templates.
eval('?>' . $this->get_HTML_search_page());
}
// Calculate page load time
$time_end = microtime_float();
$time = $time_end - $time_start;
// Print page load time
// echo "Page loaded in $time seconds\n";
}
//-------------------------------------------------------------------
// Read input data
//-------------------------------------------------------------------
function extract_search_get_data()
{
global $search_items, $start;
// Read start value
if (array_key_exists('start', $_GET) && (! empty($_GET['start'])))
{
$start = $_GET['start'];
if (($start < 1) || (! is_numeric($start)))
{
$start = 1;
}
}
else
{
$start = 1;
}
// Read search item values from GET variables
foreach ($search_items as $search_item)
{
$search_name = $search_item['name'];
if (array_key_exists($search_name, $_GET) && (! empty($_GET[$search_name])))
{
$search_items[$search_name]['value'] = $_GET[$search_name];
}
}
// Save search items in session
// Only save if search button has been clicked.
if ($this->show_results)
{
$_SESSION['session_search_items'] = $search_items;
}
elseif ($this->new_search)
{
unset($_SESSION['session_search_items']);
}
}
//-------------------------------------------------------------------
// Build new URL GET part from current search items
//-------------------------------------------------------------------
function get_navigation_URL($astart)
{
global $search_items, $jdata;
$arguments = '';
// Add search settings
foreach ($search_items as $search_item)
{
if ($arguments != '')
{
$arguments .= '&';
}
$arguments .= $search_item['name'] . '=' . $search_item['value'];
}
// Add sorting argument
if ($this->do_sort)
{
if ($arguments != '')
{
$arguments .= '&';
}
$arguments .= 'sort' . '=' . $jdata->sort_column;
if ($jdata->sort_reversed)
{
$arguments .= '-reversed';
}
}
$url = 'search.php?btn_search=Search&' . $arguments . '&start=' . $astart;
return $url;
}
//-------------------------------------------------------------------
// Extract sort data from HTTP GET info
//-------------------------------------------------------------------
function extract_sort_get_data()
{
global $jdata, $search_items;
if (array_key_exists('sort', $_GET) && (! empty($_GET['sort'])))
{
$sort_id = $_GET['sort'];
$pos = strpos($sort_id, '-reversed');
if ($pos === false)
{
$jdata->sort_column = $sort_id;
}
else
{
$jdata->sort_reversed = true;
$jdata->sort_column = substr($sort_id, 0, $pos);
}
$this->do_sort = true;
// Get sort type
$ltype = $search_items[$jdata->sort_column]['type'];
if (('int_max' == $ltype) || ('int_min' == $ltype)) {
$this->sort_type = 'integer';
}
else
{
$this->sort_type = 'string';
}
}
else
{
// No sorting information found
$this->do_sort = false;
}
// Save search items in session. Only save if search button has been clicked.
if ($this->show_results)
{
if ($this->do_sort)
{
$_SESSION['session_sort_field'] = $jdata->sort_column;
$_SESSION['session_sort_reversed'] = $jdata->sort_reversed;
}
else
{
unset($_SESSION['session_sort_field']);
unset($_SESSION['session_sort_reversed']);
}
}
}
//-------------------------------------------------------------------
// Set form defaults
//-------------------------------------------------------------------
function set_search_form_defaults(&$aform)
{
// Read search item values from SESSION
if (isset($_SESSION['session_search_items']))
{
$stored_search_items = $_SESSION['session_search_items'];
}
if (! empty($stored_search_items))
{
// Loop through search items
foreach ($stored_search_items as $search_item)
{
// Use htmlentities to prevent HTML injection
$search_value = htmlentities($search_item['value']);
// Match if search value is not empty
if (! empty($search_value))
{
$search_name = $search_item['name'];
// Find tags and add value attribute
set_input_tag_default($aform, $search_name, $search_value);
// Find and set