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

namespace App\Http\Controllers;

5
6
use Jenssegers\Agent\Agent;

Dominik Hebeler's avatar
Dominik Hebeler committed
7
use App\Http\Controllers\Controller;
karl's avatar
karl committed
8
use Illuminate\Http\Request;
9
use Response;
10
use App;
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
    /* public function loadStartPage($locale = "de")
Dominik Hebeler's avatar
Dominik Hebeler committed
21
22
    {
        \App::setLocale($locale);
23
24
25
        return view('index', [ 
            'title' => 'MetaGer: Sicher suchen & finden, Privatsphäre schützen', 
            'homeIcon']);
karl's avatar
karl committed
26
27
28
29
30
31
32
33
34
35
36
37
38
    } */

    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);
            }
        }

39
40
41
        $agent = new Agent();
        $browser = $agent->browser();

karl's avatar
karl committed
42
43
44
45
46
47
48
49
        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'))
50
            ->with('tab', $request->input('param_tab', 'off'))
51
            ->with('focusPages', $focusPages)
52
            ->with('browser', $browser)
53
54
            ->with('navbarFocus', 'suche');

55
56
    }

karl's avatar
karl committed
57
    public function loadPage($subpage)
58
    {
karl's avatar
karl committed
59
60
61
62
63
64
65
66
67
68
        /* 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']);
        }*/
69
70
71
72
73
74
75
        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
76
    }
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

    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;
    }
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131

    public function loadSettings (Request $request)
    {
        $sumaFile = "";
        if(App::isLocale('en'))
            $sumaFile = config_path() . "/sumasEn.xml";
        else
            $sumaFile = config_path() . "/sumas.xml";

        $xml = simplexml_load_file($sumaFile);
        $sumas = $xml->xpath("suma");

        $foki = [];
        foreach($sumas as $suma)
        {
            if( (!isset($suma['disabled']) || $suma['disabled'] === "") && ( !isset($suma['userSelectable']) || $suma['userSelectable']->__toString() === "1") )
            {
                if( isset($suma['type']) )
                {
                    $f = explode(",", $suma['type']->__toString());
                    foreach($f as $tmp)
                    {
                        $displayName = $suma['displayName']->__toString();
                        $url = isset($suma['homepage']) ? $suma['homepage']->__toString() : "https://metager.de";
132
                        $foki[$tmp][$suma['name']->__toString()] = [ 'displayName' => $displayName, 'url' => $url];
133
134
135
136
137
                    }
                }else
                {
                    $displayName = $suma['displayName']->__toString();
                    $url = isset($suma['homepage']) ? $suma['homepage']->__toString() : "https://metager.de";
138
                    $foki["andere"][$suma['name']->__toString()] = [ 'displayName' => $displayName, 'url' => $url];
139
140
141
142
                }
            }
        }

143
        return view('settings')
144
145
146
            ->with('foki', $foki)
            ->with('title', 'Einstellungen')
            ->with('css', 'settings.css')
147
148
            ->with('js', ['settings.js'])
            ->with('navbarFocus', 'suche');
149
150
151
152
        die(var_dump($foki));

        return $xml->saveXML();
    }
Dominik Hebeler's avatar
Dominik Hebeler committed
153
}