Added search bar to header.

This commit is contained in:
2018-06-15 23:41:25 +02:00
committed by Stefan Rohde-Enslin
parent 916eddc099
commit 2ae4196546
5 changed files with 61 additions and 14 deletions

View File

@ -399,6 +399,10 @@ function searchMDObjects(array $arguments, array $settings):string {
$i = 0;
$lastToDisplay = end($toDisplay);
// Display option to go to start
if (!in_array(0, $toDisplay)) $output .= '<a href="search.php?startwert=0' . write_get_vars(['q', 'id']) . '#mdSearchObjs">1</a>';
while ($i < $contents[0]['total']) {
if (!in_array($i, $toDisplay)) {
@ -408,13 +412,17 @@ function searchMDObjects(array $arguments, array $settings):string {
$output .= '
<a ';
if ($i == $current) $output .= ' class="navicurrent"';
$output .= ' href="search.php?startwert=' . (string)$i . write_get_vars(['q', 'id']) . '#mdSearchObjs">' . strval($i / 24) . '</a>
$output .= ' href="search.php?startwert=' . (string)$i . write_get_vars(['q', 'id']) . '#mdSearchObjs">' . strval(($i / 24) + 1) . '</a>
';
$i += 24;
if ($i == $lastToDisplay) break;
}
// Display option to go to start
$last = $contents[0]["total"] - ($contents[0]["total"] % 24);
if (!in_array($last, $toDisplay)) $output .= '<a href="search.php?startwert=' . (string)$last . write_get_vars(['q', 'id']) . '#mdSearchObjs">' . (string)(($last / 24) + 1) . '</a>';
// Generate pagination
$output .= '

View File

@ -28,15 +28,15 @@ function printPublicHead(array $settings, string $page = "home", string $title =
<meta http-equiv="Content-Security-Policy" content="default-src \'none\'; script-src \'self\'; connect-src \'self\' ' . $settings['mdVersion'] . '; img-src \'self\' ' . $settings['mdVersion'] . '; style-src \'self\' \'unsafe-inline\'; font-src \'self\';" />
<title>' . $title . '</title>
<link rel="stylesheet" type="text/css" href="themes/default/default.css">
<link rel="stylesheet" type="text/css" href="themes/imports.css">
<meta http-equiv="content-type" content="text/html;charset=utf-8">';
<link rel="stylesheet" type="text/css" href="themes/default/default.css" />
<link rel="stylesheet" type="text/css" href="themes/imports.css" />
<meta http-equiv="content-type" content="text/html;charset=utf-8" />';
$output .= $additional;
if ($icon) {
$output .= '
<link rel="shortcut icon" sizes="16x16 32x32" href="' . $icon . '" />
<link rel="shortcut icon" href="' . $icon . '" />
';
}
@ -74,6 +74,8 @@ function printPublicHeader(string $title = "Home"):string {
<h1>' . $title . '</h1>
' . generateSearchBar() . '
</header>
';
@ -190,4 +192,21 @@ function generatePublicNav($pages):string {
return $output;
}
/**
* Function for printing the search bar.
*
* @return string
*/
function generateSearchBar():string {
$output = '
<form action="search.php" method="GET">
<input type="search" name="q" />
</form>
';
return $output;
}
?>