StartpageController.php 4.81 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;
8
use App;
Dominik Hebeler's avatar
Dominik Hebeler committed
9
10
11
12
13
14
15
16
17

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

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

karl's avatar
karl committed
49
    public function loadPage($subpage)
50
    {
karl's avatar
karl committed
51
52
53
54
55
56
57
58
59
60
        /* 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']);
        }*/
61
62
63
64
65
66
67
        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
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
99

    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;
    }
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

    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";
                        $service = $suma['service']->__toString();
                        $foki[$tmp][$suma['name']->__toString()] = [ 'displayName' => $displayName, 'url' => $url, 'service' => $service];
                    }
                }else
                {
                    $displayName = $suma['displayName']->__toString();
                    $url = isset($suma['homepage']) ? $suma['homepage']->__toString() : "https://metager.de";
                    $service = $suma['service']->__toString();
                    $foki["andere"][$suma['name']->__toString()] = [ 'displayName' => $displayName, 'url' => $url, 'service' => $service];
                }
            }
        }

        return view('settings1')
            ->with('foki', $foki)
            ->with('title', 'Einstellungen')
            ->with('css', 'settings.css')
            ->with('js', ['settings.js']);
        die(var_dump($foki));

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