Skip to content

Commit

Permalink
Merge branch 'dev' into FAU-443
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyian committed Dec 26, 2024
2 parents 8ab3704 + c3aad86 commit d5790ad
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 40 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add synchronization of 'German language skills for international students' child terms to consuming websites.

### Changed

- Keywords are indexed for searching.

## [2.1.0] - 2024-09-06

### Added
Expand Down
70 changes: 30 additions & 40 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Infrastructure/Component/ComponentModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public function services(): array
AdvancedFilters::class => static fn(ContainerInterface $container) => new AdvancedFilters(
$container->get(Renderer::class),
),
PreAppliedFilters::class => static fn(ContainerInterface $container) => new PreAppliedFilters(
$container->get(Renderer::class),
),
];
}
}
1 change: 1 addition & 0 deletions src/Infrastructure/Component/DegreeProgramsSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function render(array $attributes = self::DEFAULT_ATTRIBUTES): string
'hiddenElements' => $this->excludeDegreeProgramElements->hideElements(
$attributes['hidden_elements']
),
'preAppliedFilters' => $attributes['pre_applied_filters'],
],
);
remove_filter('locale', [$localeHelper, 'filterLocale']);
Expand Down
47 changes: 47 additions & 0 deletions src/Infrastructure/Component/PreAppliedFilters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

namespace Fau\DegreeProgram\Output\Infrastructure\Component;

use Fau\DegreeProgram\Common\Infrastructure\TemplateRenderer\Renderer;

/**
* @psalm-type PreAppliedFilters = array{
* preAppliedFilters: array<string, list<string|int>>,
* }
*/
class PreAppliedFilters implements RenderableComponent
{
private const DEFAULT_ATTRIBUTES = [
'preAppliedFilters' => [],
];

public function __construct(
private Renderer $renderer,
) {
}

public function render(array $attributes = self::DEFAULT_ATTRIBUTES): string
{
/** @var PreAppliedFilters $attributes */
$attributes = wp_parse_args($attributes, self::DEFAULT_ATTRIBUTES);
$preAppliedFilters = [];

foreach ($attributes['preAppliedFilters'] as $name => $values) {
foreach ($values as $value) {
$preAppliedFilters[] = [
'name' => $name,
'value' => (string) $value,
];
}
}

return $this->renderer->render(
'search/filter/pre-applied-filters',
[
'preAppliedFilters' => $preAppliedFilters,
]
);
}
}
1 change: 1 addition & 0 deletions src/Infrastructure/Search/SearchableContentUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private function buildSearchableContent(
$rawView->title()->asString($languageCode),
$rawView->subtitle()->asString($languageCode),
$rawView->content()->about()->description()->asString($languageCode),
...array_values($rawView->keywords()->asArrayOfStrings($languageCode)->getArrayCopy()),
];

return implode(' ', $parts);
Expand Down
24 changes: 24 additions & 0 deletions templates/search/filter/hidden-item.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

/**
* @psalm-var array{
* name: string,
* value: string,
* } $data
* @var array $data
*/

[
'name' => $name,
'value' => $value,
] = $data;

?>

<input
type="hidden"
name="<?= esc_attr($name) ?>[]"
value="<?= esc_attr($value) ?>"
/>
27 changes: 27 additions & 0 deletions templates/search/filter/pre-applied-filters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

use Fau\DegreeProgram\Common\Infrastructure\TemplateRenderer\Renderer;

/**
* @psalm-var array{
* preAppliedFilters: array{name: string, value: string}[],
* } $data
* @var array $data
* @var Renderer $renderer
*/

[
'preAppliedFilters' => $preAppliedFilters,
] = $data;

?>

<?php foreach ($preAppliedFilters as $filter) : ?>
<?php // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?= $renderer->render(
'search/filter/hidden-item',
$filter
) ?>
<?php endforeach;
10 changes: 10 additions & 0 deletions templates/search/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Fau\DegreeProgram\Output\Infrastructure\Component\ActiveFilters;
use Fau\DegreeProgram\Output\Infrastructure\Component\Component;
use Fau\DegreeProgram\Output\Infrastructure\Component\DegreeProgramsCollection;
use Fau\DegreeProgram\Output\Infrastructure\Component\PreAppliedFilters;
use Fau\DegreeProgram\Output\Infrastructure\Component\SearchFilters;
use Fau\DegreeProgram\Output\Infrastructure\Component\SearchForm;
use Fau\DegreeProgram\Output\Infrastructure\Template\HiddenDegreeProgramElements;
Expand All @@ -33,6 +34,7 @@
'activeFilters' => $activeFilters,
'advancedFilters' => $advancedFilters,
'hiddenElements' => $hiddenElements,
'preAppliedFilters' => $preAppliedFilters,
] = $data;

?>
Expand All @@ -57,6 +59,14 @@ class="c-degree-programs-search"
action="<?= esc_url((string) get_permalink((int) get_the_id())) ?>"
method="get"
>
<?= renderComponent(
new Component(
PreAppliedFilters::class,
[
'preAppliedFilters' => $preAppliedFilters,
],
)
) ?>
<?= renderComponent(
new Component(
SearchForm::class,
Expand Down

0 comments on commit d5790ad

Please sign in to comment.