Browse code

Add search module

Benjamin Roth authored on06/02/2023 12:15:21
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,80 @@
1
+<?php
2
+
3
+declare(strict_types=1);
4
+
5
+/*
6
+ * This file is part of alox bundle for Contao.
7
+ *
8
+ * (c) Benjamin Roth
9
+ *
10
+ * @license commercial
11
+ */
12
+
13
+namespace vossmedien\AloxBundle\Controller\Frontend\Module;
14
+
15
+use Contao\CoreBundle\Controller\FrontendModule\AbstractFrontendModuleController;
16
+use Contao\CoreBundle\ServiceAnnotation\FrontendModule;
17
+use Contao\ModuleModel;
18
+use Contao\PageModel;
19
+use Contao\Template;
20
+use Symfony\Component\HttpFoundation\Request;
21
+use Symfony\Component\HttpFoundation\Response;
22
+use vossmedien\AloxBundle\API\Zvoove;
23
+
24
+/**
25
+ * @FrontendModule(JobSearchModuleController::TYPE, category="miscellaneous")
26
+ */
27
+class JobSearchModuleController extends AbstractFrontendModuleController
28
+{
29
+    public const TYPE = 'alox_jobsearch';
30
+
31
+    /**
32
+     * @var Zvoove
33
+     */
34
+    protected $api;
35
+
36
+    public function __construct(Zvoove $api)
37
+    {
38
+        $this->api = $api;
39
+    }
40
+
41
+
42
+    protected function getResponse(Template $template, ModuleModel $model, Request $request): ?Response
43
+    {
44
+        $limit = null;
45
+        $offset = 0;
46
+
47
+        $strFormId = 'joblist-form';
48
+
49
+        $filterVertragsarten = $this->api->getKatalogByRelationName('StelleVertragsart','ChildEntity');
50
+        $filterAbteilung = $this->api->getKatalogByRelationName('StelleAbteilung','Abteilung');
51
+
52
+
53
+        // Populate template vars
54
+        if ($filterVertragsarten !== null && $filterVertragsarten->TotalItems > 0)
55
+        {
56
+            $template->filterVertragsarten = $filterVertragsarten;
57
+        }
58
+
59
+        if ($filterAbteilung !== null && $filterAbteilung->TotalItems > 0)
60
+        {
61
+            $template->filterAbteilung = $filterAbteilung;
62
+        }
63
+
64
+        $template->formSubmit = $strFormId;
65
+
66
+        // Submit action if jumpTo is defined
67
+        if ($model->jumpTo && ($jumpTo = PageModel::findByPk($model->jumpTo)) !== null)
68
+        {
69
+            $template->formAction = $jumpTo->getFrontendUrl();
70
+        }
71
+
72
+
73
+        // Add scripts
74
+        $GLOBALS['TL_BODY']['tomselect'] = Template::generateScriptTag('bundles/vossmedienalox/lib/tomselect/js/tom-select.base.js',false,null);
75
+        $GLOBALS['TL_CSS']['tomselect'] = 'bundles/vossmedienalox/lib/tomselect/css/tom-select.min.css';
76
+
77
+        return $template->getResponse();
78
+    }
79
+
80
+}