Added search for objects.

This commit is contained in:
Joshua Ramon Enslin 2018-06-15 22:32:37 +02:00 committed by Stefan Rohde-Enslin
parent 5c4f0eb5d9
commit 916eddc099
4 changed files with 53 additions and 2 deletions

View File

@ -382,8 +382,43 @@ function searchMDObjects(array $arguments, array $settings):string {
$contents = json_decode(queryCachePage($settings['mdVersion'] . "?$srcArgs", "search", $settings), true); $contents = json_decode(queryCachePage($settings['mdVersion'] . "?$srcArgs", "search", $settings), true);
if (!isset($contents[0])) return "";
$output = ' $output = '
<div class="searchGrid"> <div class="searchGrid">
<div class="paginationBar">
';
if (isset($_GET['startwert']) and $_GET['startwert'] % 24 === 0) $current = $_GET['startwert'];
else $current = 0;
$toDisplay = [];
for ($i = 0; $i <= 7; $i++) {
$toDisplay[] = $current + (-72 + 24 * $i);
}
$i = 0;
$lastToDisplay = end($toDisplay);
while ($i < $contents[0]['total']) {
if (!in_array($i, $toDisplay)) {
$i += 24; continue;
}
$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>
';
$i += 24;
if ($i == $lastToDisplay) break;
}
// Generate pagination
$output .= '
</div>
'; ';
foreach ($contents as $object) { foreach ($contents as $object) {

View File

@ -31,6 +31,7 @@ document.addEventListener("DOMContentLoaded", function() {
"SearchingFor" : "Searching for", "SearchingFor" : "Searching for",
"Hits" : "Hits:", "Hits" : "Hits:",
"ResultsInPages" : "Results in texts", "ResultsInPages" : "Results in texts",
"ResultsInObjects" : "Results in objects",
"... who" : "... who", "... who" : "... who",
"... where" : "... where", "... where" : "... where",
"... when" : "... when", "... when" : "... when",
@ -54,6 +55,7 @@ document.addEventListener("DOMContentLoaded", function() {
"SearchingFor" : "Suche nach", "SearchingFor" : "Suche nach",
"Hits" : "Treffer:", "Hits" : "Treffer:",
"ResultsInPages" : "Treffer in Texten", "ResultsInPages" : "Treffer in Texten",
"ResultsInObjects" : "Treffer in Objekten",
"... who" : "... wer", "... who" : "... wer",
"... where" : "... wo", "... where" : "... wo",
"... when" : "... wann", "... when" : "... wann",

View File

@ -51,6 +51,9 @@ if (!isset($_GET['q'])) {
} }
else { else {
$getArgsForMD = [];
foreach ($_GET as $key => $value) $getArgsForMD[] = "$key=$value";
echo ' echo '
<h1><span class="toTranslate" data-content="SearchingFor"></span> "' . $_GET['q'] . '"</h1> <h1><span class="toTranslate" data-content="SearchingFor"></span> "' . $_GET['q'] . '"</h1>
@ -61,7 +64,7 @@ else {
<section id="mdSearchObjs"> <section id="mdSearchObjs">
<h2><span class="toTranslate" data-content="ResultsInObjects"></span></h2> <h2><span class="toTranslate" data-content="ResultsInObjects"></span></h2>
' . searchMDObjects(["sv=" . $_GET['q']], $settings) . ' ' . searchMDObjects(array_merge(["sv=" . $_GET['q']], $getArgsForMD), $settings) . '
</section> </section>
'; ';

View File

@ -11,6 +11,17 @@
.searchGrid .objTile { margin-bottom: 1em; vertical-align: top; } .searchGrid .objTile { margin-bottom: 1em; vertical-align: top; }
.searchGrid .objTile img { max-height: 180px; } .searchGrid .objTile img { max-height: 180px; }
/******
* Pagination bars
*/
.paginationBar { margin: 0 0 2em 0; background: #F2F2F2; border: 1px solid #D6D6D6; text-align: center; }
.paginationBar a { display: inline-block; padding: .3em .8em; transition: background .4s, color .4s; }
.paginationBar a.current:hover,
.paginationBar a:hover { background: #646464; color: #FFF; }
.paginationBar a.current,
a.navicurrent { background: #D6D6D6; }
/********** /**********
* Simple tiles for displaying an object. * Simple tiles for displaying an object.
*/ */