StartpageController.php 3.47 KB
Newer Older
Dominik Hebeler's avatar
Dominik Hebeler committed
1
2
3
4
<?php

namespace App\Http\Controllers;

5
use App;
karl's avatar
karl committed
6
use Illuminate\Http\Request;
7
use Jenssegers\Agent\Agent;
8
use LaravelLocalization;
9
use Response;
Dominik Hebeler's avatar
Dominik Hebeler committed
10
11
12
13
14
15
16
17
18

class StartpageController extends Controller
{
    /**
     * Load Startpage accordingly to the given URL-Parameter and Mobile
     *
     * @param  int  $id
     * @return Response
     */
karl's avatar
karl committed
19

20
    public function loadStartPage(Request $request)
karl's avatar
karl committed
21
22
    {
        $focusPages = [];
23
        $theme = "default";
24

25
        $optionParams = ['param_sprueche', 'param_newtab', 'param_maps', 'param_autocomplete', 'param_lang', 'param_key'];
26
27
28
29
30
31
32
33
34
35
        $option_values = [];

        foreach ($optionParams as $param) {
            $value = $request->input($param);
            if ($value) {
                $option_values[$param] = $value;
            }
        }

        $autocomplete = 'on';
36
        if (in_array('autocomplete', array_keys($option_values))) {
37
38
39
            $autocomplete = $option_values['autocomplete'];
        }

40
        $lang = LaravelLocalization::getCurrentLocale();
41
        if ($lang === 'de' || $lang === "en") {
42
43
            $lang = 'all';
        }
44

karl's avatar
karl committed
45
46
47
        return view('index')
            ->with('title', trans('titles.index'))
            ->with('homeIcon')
48
            ->with('agent', new Agent())
49
            ->with('navbarFocus', 'suche')
karl's avatar
karl committed
50
            ->with('focus', $request->input('focus', 'web'))
51
            ->with('time', $request->input('param_time', '1500'))
52
53
            ->with('request', $request->input('request', 'GET'))
            ->with('option_values', $option_values)
54
55
            ->with('autocomplete', $autocomplete)
            ->with('pluginmodal', $request->input('plugin-modal', 'off'));
56
57
    }

karl's avatar
karl committed
58
    public function loadPage($subpage)
59
    {
karl's avatar
karl committed
60
61
        /* TODO CSS und Titel laden
        $css = array(
62
        'datenschutz' => 'privacy.css',
karl's avatar
karl committed
63
64
65
        );

        if (in_array($subpage, $css)) {
66
        return view($subpage, [ 'title' => 'Datenschutz Richtlinien', 'css' => $css[$subpage]]);
karl's avatar
karl committed
67
        } else {
68
        return view($subpage, [ 'title' => 'Datenschutz Richtlinien']);
69
70
        }*/
        return view($subpage, ['title' => 'Datenschutz Richtlinien']);
71
72
73
74
75
76
    }

    public function loadLocalPage($locale = "de", $subpage = "datenschutz")
    {
        \App::setLocale($locale);
        return loadPage($subpage);
Dominik Hebeler's avatar
Dominik Hebeler committed
77
    }
78

79
    public function loadPlugin(Request $request, $locale = "de")
80
    {
81
        $link = action('MetaGerSearch@search', []);
82
83
84
85
86
87
        $link .= "?";
        $link .= "eingabe={searchTerms}";
        $key = $request->input('key', '');
        if (!empty($key)) {
            $link .= "&key=" . urlencode($key);
        }
88
        $response = Response::make(
89
90
            view('plugin')
                ->with('link', $link)
91
            , "200");
92
        $response->header('Content-Type', "application/opensearchdescription+xml");
93
94
        return $response;
    }
95

96
97
    public function berlin(Request $request)
    {
98
        $link = "";
99
        $password = "";
Dominik Hebeler's avatar
Dominik Hebeler committed
100
        if ($request->filled('eingabe')) {
101
102
            $password = getenv('berlin');
            $password = md5($request->input('eingabe') . " -host:userpage.fu-berlin.de" . $password);
103
            $link = "/meta/meta.ger3?eingabe=" . $request->input('eingabe') . " -host:userpage.fu-berlin.de&focus=web&password=" . $password . "&encoding=utf8&lang=all&site=fu-berlin.de&quicktips=off&out=results-with-style";
104
105
106
107
108
109
        }
        return view('berlin')
            ->with('title', 'Testseite für die FU-Berlin')
            ->with('link', $link)
            ->with('password', $password);
    }
110
}