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

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
karl's avatar
karl committed
6
use Illuminate\Http\Request;
7
use Response;
Dominik Hebeler's avatar
Dominik Hebeler committed
8
9
10
11
12
13
14
15
16

class StartpageController extends Controller
{
    /**
     * Load Startpage accordingly to the given URL-Parameter and Mobile
     *
     * @param  int  $id
     * @return Response
     */
karl's avatar
karl committed
17
    /* public function loadStartPage($locale = "de")
Dominik Hebeler's avatar
Dominik Hebeler committed
18
19
    {
        \App::setLocale($locale);
20
21
22
        return view('index', [ 
            'title' => 'MetaGer: Sicher suchen & finden, Privatsphäre schützen', 
            'homeIcon']);
karl's avatar
karl committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    } */

    public function loadStartPage(Request $request) 
    {
        $focusPages = [];
        foreach($request->all() as $key => $value)
        {
            if($value === 'on' && $key != 'param_sprueche' && $key != 'param_tab') 
            {
               $focusPages[] = str_replace('param_', '', $key);
            }
        }

        return view('index')
            ->with('title', trans('titles.index'))
            ->with('homeIcon')
            ->with('focus', $request->input('focus', 'web'))
            ->with('lang', $request->input('param_lang', 'all'))
            ->with('resultCount', $request->input('param_resultCount', '20'))
            ->with('time', $request->input('param_time', '1000'))
            ->with('sprueche', $request->input('param_sprueche', 'off'))
            ->with('tab', $request->input('param_sprueche', 'off'))
            ->with('focusPages', $focusPages);
46
47
    }

karl's avatar
karl committed
48
    public function loadPage($subpage)
49
    {
karl's avatar
karl committed
50
51
52
53
54
55
56
57
58
59
        /* TODO CSS und Titel laden
        $css = array(
            'datenschutz' => 'privacy.css',
        );

        if (in_array($subpage, $css)) {
            return view($subpage, [ 'title' => 'Datenschutz Richtlinien', 'css' => $css[$subpage]]);
        } else {
            return view($subpage, [ 'title' => 'Datenschutz Richtlinien']);
        }*/
60
61
62
63
64
65
66
        return view($subpage, [ 'title' => 'Datenschutz Richtlinien']);
    }

    public function loadLocalPage($locale = "de", $subpage = "datenschutz")
    {
        \App::setLocale($locale);
        return loadPage($subpage);
Dominik Hebeler's avatar
Dominik Hebeler committed
67
    }
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

    public function loadPlugin(Request $request, $locale = "de")
    {
        $requests = $request->all();
        $params = [];
        foreach($requests as $key => $value)
        {
            if( strpos($key, "param_") === 0 )
            {
                $key = substr($key, strpos($key, "param_") + 6 );
            }
            $params[$key] = $value;
        }

        if(!isset($params['focus']))
            $params['focus'] = 'web';
        if(!isset($params['encoding']))
            $params['encoding'] = 'utf8';
        if(!isset($params['lang']))
            $params['lang'] = 'all';
        $params["eingabe"] = "";


        $link = action('MetaGerSearch@search', $params);

        $response = Response::make(
            view('plugin')->with('link', $link), "200");
        $response->header('Content-Type', "application/xml");
        return $response;
        return $link;
    }
Dominik Hebeler's avatar
Dominik Hebeler committed
99
}