StartpageController.php 3.48 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;
12
use Cache;
Dominik Hebeler's avatar
Dominik Hebeler committed
13
14
15
16
17
18
19
20
21

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

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

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

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

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

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

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

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

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

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

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