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

namespace App\Http\Controllers;

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

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

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

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

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

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

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

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

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

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

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

80
    public function loadPlugin(Request $request, $locale = "de")
81
    {
82
        $link = action('MetaGerSearch@search', []);
83
        $key = Cookie::get('key');
84
85

        $response = Response::make(
86
87
            view('plugin')
                ->with('link', $link)
88
                ->with('key', $key)
89
            , "200");
90
        $response->header('Content-Type', "application/opensearchdescription+xml");
91
92
        return $response;
    }
93

94
95
    public function berlin(Request $request)
    {
96
        $link = "";
97
        $password = "";
Dominik Hebeler's avatar
Dominik Hebeler committed
98
        if ($request->filled('eingabe')) {
99
100
            $password = getenv('berlin');
            $password = md5($request->input('eingabe') . " -host:userpage.fu-berlin.de" . $password);
101
            $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";
102
103
104
105
106
107
        }
        return view('berlin')
            ->with('title', 'Testseite für die FU-Berlin')
            ->with('link', $link)
            ->with('password', $password);
    }
108
}