Browse Source

add content locale filter #14

main
ghost 1 year ago
parent
commit
bbd54b3a14
  1. 13
      src/app/controller/module/search.php
  2. 20
      src/app/view/theme/default/module/search.phtml
  3. 6
      src/public/assets/theme/default/css/framework.css

13
src/app/controller/module/search.php

@ -5,6 +5,19 @@ class AppControllerModuleSearch
public function render() public function render()
{ {
$query = empty($_GET['query']) ? false : urldecode($_GET['query']); $query = empty($_GET['query']) ? false : urldecode($_GET['query']);
$locale = empty($_GET['locale']) ? 'all' : urldecode($_GET['locale']);
$locales = [];
foreach (Environment::config('locales') as $key => $value)
{
$locales[$key] = (object)
[
'key' => $key,
'value' => $value[0],
'active' => $key === $locale // false !== stripos($_SERVER['HTTP_ACCEPT_LANGUAGE'], $key) ? true : false,
];
}
include __DIR__ . '../../../view/theme/default/module/search.phtml'; include __DIR__ . '../../../view/theme/default/module/search.phtml';
} }

20
src/app/view/theme/default/module/search.phtml

@ -1,4 +1,20 @@
<form class="margin-t-8" name="search" method="get" action="search"> <form class="margin-t-8" name="search" method="get" action="search">
<input class="min-width-200-px" type="text" name="query" value="<?php echo $query ?>" placeholder="<?php echo _('keyword, file, extension, hash...') ?>" /> <input class="min-width-200-px" type="text" name="query" value="<?php echo $query ?>" placeholder="<?php echo _('Keyword, file, extension, hash...') ?>" />
<input type="submit" value="<?php echo _('search') ?>" /> <select class="min-width-120-px" type="text" name="locale">
<option value="">
<?php echo _('All languages') ?>
</option>
<?php foreach ($locales as $locale) { ?>
<?php if ($locale->active) { ?>
<option value="<?php echo $locale->key ?>" selected="selected">
<?php echo $locale->value ?>
</option>
<?php } else { ?>
<option value="<?php echo $locale->key ?>">
<?php echo $locale->value ?>
</option>
<?php } ?>
<?php } ?>
</select>
<input type="submit" value="<?php echo _('Search') ?>" />
</form> </form>

6
src/public/assets/theme/default/css/framework.css

@ -413,8 +413,12 @@ a:visited.background-color-hover-night-light:hover {
width: 180px; width: 180px;
} }
.min-width-120-px {
min-width: 120px;
}
.min-width-200-px { .min-width-200-px {
width: 200px; min-width: 200px;
} }
@media (max-width: 1220px) { @media (max-width: 1220px) {

Loading…
Cancel
Save