StartpageController.php 3.45 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 Illuminate\Support\Facades\Redis;
11
use Response;
Dominik Hebeler's avatar
Dominik Hebeler committed
12
13
14
15
16
17
18
19
20

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

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

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

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

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

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

karl's avatar
karl committed
47
48
49
        return view('index')
            ->with('title', trans('titles.index'))
            ->with('homeIcon')
50
            ->with('agent', new Agent())
51
            ->with('navbarFocus', 'suche')
karl's avatar
karl committed
52
            ->with('focus', $request->input('focus', 'web'))
53
            ->with('time', $request->input('param_time', '1500'))
54
55
            ->with('request', $request->input('request', 'GET'))
            ->with('option_values', $option_values)
56
            ->with('autocomplete', $autocomplete)
57
58
            ->with('pluginmodal', $request->input('plugin-modal', 'off'))
            ->with('darkcss', [mix('css/themes/startpage-only-dark.css')]);
59
60
    }

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

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

76
    public function loadPlugin(Request $request, $locale = "de")
77
    {
78
        $link = action('MetaGerSearch@search', []);
79
80
81
82
83
84
        $link .= "?";
        $link .= "eingabe={searchTerms}";
        $key = $request->input('key', '');
        if (!empty($key)) {
            $link .= "&key=" . urlencode($key);
        }
85
        $response = Response::make(
86
            view('plugin')
87
88
89
                ->with('link', $link),
            "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
}