From a365277996cdf00751fb0908dfb77264fb823da1 Mon Sep 17 00:00:00 2001
From: Dominik Pfennig <dominik@suma-ev.de>
Date: Wed, 15 Jun 2016 13:40:38 +0200
Subject: [PATCH] =?UTF-8?q?Settings=20Seite=20zeigt=20nun=20nur=20noch=20v?=
 =?UTF-8?q?erf=C3=BCgbare=20Suchmaschinen=20aus=20der=20XML-Datei?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/Http/Controllers/StartpageController.php | 47 +++++++++++++++
 app/Http/routes.php                          |  8 +--
 resources/views/settings1.blade.php          | 63 ++++++++++++++++++++
 3 files changed, 111 insertions(+), 7 deletions(-)
 create mode 100644 resources/views/settings1.blade.php

diff --git a/app/Http/Controllers/StartpageController.php b/app/Http/Controllers/StartpageController.php
index 9df592c56..6627a7ebd 100644
--- a/app/Http/Controllers/StartpageController.php
+++ b/app/Http/Controllers/StartpageController.php
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
 use App\Http\Controllers\Controller;
 use Illuminate\Http\Request;
 use Response;
+use App;
 
 class StartpageController extends Controller
 {
@@ -96,4 +97,50 @@ class StartpageController extends Controller
         return $response;
         return $link;
     }
+
+    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();
+    }
 }
\ No newline at end of file
diff --git a/app/Http/routes.php b/app/Http/routes.php
index 356452402..23648ff86 100644
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -86,13 +86,7 @@
                 ->with('css', 'widget.css');
         });
         
-        Route::get('settings', function()
-        {
-            return view('settings')
-                ->with('title', trans('titles.settings'))
-                ->with('css', 'settings.css')
-                ->with('js', ['settings.js']);
-        });
+        Route::get('settings', 'StartpageController@loadSettings');
 
         
         Route::get('meta/meta.ger3', 'MetaGerSearch@search');
diff --git a/resources/views/settings1.blade.php b/resources/views/settings1.blade.php
new file mode 100644
index 000000000..b09f689a9
--- /dev/null
+++ b/resources/views/settings1.blade.php
@@ -0,0 +1,63 @@
+@extends('layouts.subPages')
+
+@section('title', $title )
+
+@section('content')
+<form action="/" method="get">
+  <h1>{{ trans('settings.head.1') }}</h1>
+  <p id="lead">{{ trans('settings.head.2') }} <a href="#unten">{{ trans('settings.head.3') }}</a> {{ trans('settings.head.4') }}</p>
+  <h2>{{ trans('settings.allgemein.1') }}</h2>
+  <input type="hidden" name="focus" value="angepasst">
+  <div class="checkbox">
+    <label>
+      <input type="checkbox" name="param_sprueche">{{ trans('settings.allgemein.2') }}</label></div>
+  <div class="checkbox">
+    <label>
+      <input type="checkbox" name="param_tab">{{ trans('settings.allgemein.3') }}</label></div>
+  <label class="select-label">{{ trans('settings.allgemein.4') }}:</label>
+  <select class="form-control" name="param_lang">
+    <option value="all">{{ trans('settings.allgemein.5') }}</option>
+    <option value="de">{{ trans('settings.allgemein.6') }}</option></select>
+  <label class="select-label">{{ trans('settings.allgemein.7') }}:</label>
+  <select class="form-control" name="param_resultCount">
+    <option value="10">10</option>
+    <option value="20" selected>20</option>
+    <option value="50">50</option>
+    <option value="100">100</option>
+    <option value="0">{{ trans('settings.allgemein.8') }}</option></select>
+  <label class="select-label">{{ trans('settings.allgemein.9') }}:</label>
+  <select class="form-control" name="param_time">
+    <option value="1000" selected>1 {{ trans('settings.allgemein.10') }}</option>
+    <option value="2000">2 {{ trans('settings.allgemein.11') }}</option>
+    <option value="5000">5 {{ trans('settings.allgemein.11') }}</option>
+    <option value="10000">10 {{ trans('settings.allgemein.11') }}</option>
+    <option value="20000">20 {{ trans('settings.allgemein.11') }}</option></select>
+  <h2>{{ trans('settings.suchmaschinen.1') }}</h2>
+	@foreach( $foki as $fokus => $sumas )
+	<div class="headingGroup {{ $fokus }}">
+		<h3>
+			{{ ucfirst($fokus) }}
+			<small>
+				<a class="checker" data-type="{{ $fokus }}">(alle an-/abwählen)</a>
+			</small>
+		</h3>
+		<div class="row">
+			@foreach( $sumas as $name => $data )
+			<div class="col-sm-6 col-md-4 col-lg-3">
+				<div class="checkbox">
+					<label>
+						<input name="param_{{ $data['service'] }}" type="checkbox" />{{ $data['displayName'] }}
+					</label>
+					<a class="glyphicon glyphicon-link" target="_blank" href="{{ $data['url'] }}"></a>
+				</div>
+			</div>
+			@endforeach
+		</div>
+	</div>
+	@endforeach
+	<input id="unten" type="submit" class="btn btn-primary" value="Startseite f&uuml;r einmalige Nutzung generieren">
+	<input type="button" class="btn btn-primary hidden" id="save" value="Einstellungen dauerhaft speichern">
+	<input id="plugin" type="submit" class="btn btn-primary" value="Plugin mit diesen Einstellungen generieren.">
+	<input type="button" class="btn btn-danger hidden" id="reset" value="Einstellungen Zur&uuml;cksetzen">
+</form>
+@endsection
\ No newline at end of file
-- 
GitLab