Skip to content

Commit

Permalink
Stylize search descriptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
emaijala committed Oct 29, 2023
1 parent 4f7796b commit 42f6861
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion css/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/style.css.map

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ div.function_navi {
font-weight: 600;
}

.search-comparison {
color: $primary;
}

.search-join, .search-join-groups {
color: $success;
}

.list_container {
margin-top: 10px;
max-width: 1400px;
Expand Down Expand Up @@ -1060,4 +1068,9 @@ table.quick-search {
width: 100%;
}

// Fix conflict between Bootstrap dropdown menu and DataTables dropdown menu:
.dt-buttons .dropdown-menu {
display: initial;
}

@import "table";
31 changes: 18 additions & 13 deletions search.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,8 @@ public function resultsAction()
}
$type = $searchData['type'];

$terms = htmlentities(
$this->getSearchDescription($type, $searchData['searchGroups'])
) ?: Translator::translate('NoSearchTerms');
$terms = $this->getSearchDescription($type, $searchData['searchGroups'])
?: Translator::translate('NoSearchTerms');
$searchDesc = Translator::translate(
'ResultsForSearch',
['%%description%%' => $terms]
Expand Down Expand Up @@ -284,7 +283,7 @@ public function editSearchesAction(): void
];
header('Location: index.php?' . http_build_query($params));
exit();
} elseif ('delete' === $action && ($searchId = getPost('search') > 0)) {
} elseif ('delete' === $action && ($searchId = getPost('search')) > 0) {
deleteQuickSearch($searchId);
} elseif ('search' === $action) {
$params = [
Expand Down Expand Up @@ -730,17 +729,23 @@ protected function getSearchDescription(string $type, array $searchGroups)
}

$joins = [
'eq' => ' = ',
'ne' => ' != ',
'lt' => ' < ',
'lte' => ' <= ',
'gt' => ' > ',
'gte' => ' >= '
'eq' => '=',
'ne' => '!=',
'lt' => '<',
'lte' => '<=',
'gt' => '>',
'gte' => '>='
];
$expressions[] = Translator::translate($type) . ($joins[$field['comparison']] ?? ' = ') . $value;
$expressions[] = '<span class="search-type">'
. Translator::translate($type)
. '</span> <span class="search-comparison">'
. ($joins[$field['comparison']] ?? '=')
. '</span> <span class="search-value">'
. htmlspecialchars($value)
. '</span>';
}
$groups[] = implode(
' ' . Translator::translate('Search' . $groupOperator) . ' ',
' <span class="search-join">' . Translator::translate('Search' . $groupOperator) . '</span> ',
$expressions
);
}
Expand All @@ -753,7 +758,7 @@ function ($s) {
);
}
return implode(
' ' . Translator::translate('Search' . $operator) . ' ',
' <span class="search-join-groups">' . Translator::translate('Search' . $operator) . '</span> ',
$groups
);
}
Expand Down

0 comments on commit 42f6861

Please sign in to comment.