Commit a80e87ce authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Option eingebaut mit der MetaGer über eine POST Request abgefragt werden kann.

parent 6745cd8c
......@@ -2,12 +2,11 @@
namespace App\Http\Controllers;
use Jenssegers\Agent\Agent;
use App;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Jenssegers\Agent\Agent;
use Response;
use App;
class StartpageController extends Controller
{
......@@ -19,24 +18,22 @@ class StartpageController extends Controller
*/
/* public function loadStartPage($locale = "de")
{
\App::setLocale($locale);
return view('index', [
'title' => 'MetaGer: Sicher suchen & finden, Privatsphäre schützen',
'homeIcon']);
\App::setLocale($locale);
return view('index', [
'title' => 'MetaGer: Sicher suchen & finden, Privatsphäre schützen',
'homeIcon']);
} */
public function loadStartPage(Request $request)
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);
foreach ($request->all() as $key => $value) {
if ($value === 'on' && $key != 'param_sprueche' && $key != 'param_tab') {
$focusPages[] = str_replace('param_', '', $key);
}
}
$agent = new Agent();
$agent = new Agent();
$browser = $agent->browser();
return view('index')
......@@ -58,15 +55,15 @@ class StartpageController extends Controller
{
/* TODO CSS und Titel laden
$css = array(
'datenschutz' => 'privacy.css',
'datenschutz' => 'privacy.css',
);
if (in_array($subpage, $css)) {
return view($subpage, [ 'title' => 'Datenschutz Richtlinien', 'css' => $css[$subpage]]);
return view($subpage, [ 'title' => 'Datenschutz Richtlinien', 'css' => $css[$subpage]]);
} else {
return view($subpage, [ 'title' => 'Datenschutz Richtlinien']);
}*/
return view($subpage, [ 'title' => 'Datenschutz Richtlinien']);
}*/
return view($subpage, ['title' => 'Datenschutz Richtlinien']);
}
public function loadLocalPage($locale = "de", $subpage = "datenschutz")
......@@ -77,66 +74,74 @@ class StartpageController extends Controller
public function loadPlugin($params, $locale = "de")
{
$params = unserialize(base64_decode($params));
$params = unserialize(base64_decode($params));
$requests = $params;
$params = [];
foreach($requests as $key => $value)
{
if( strpos($key, "param_") === 0 )
{
$key = substr($key, strpos($key, "param_") + 6 );
$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']))
if (!isset($params['focus'])) {
$params['focus'] = 'web';
if(!isset($params['encoding']))
}
if (!isset($params['encoding'])) {
$params['encoding'] = 'utf8';
if(!isset($params['lang']))
}
if (!isset($params['lang'])) {
$params['lang'] = 'all';
}
if (isset($params['request']) && ($params['request'] === "GET" || $params['request'] === "POST")) {
$request = $params['request'];
} else {
$request = "GET";
}
array_forget($params, 'eingabe');
array_forget($params, 'out');
array_forget($params, 'page');
array_forget($params, 'request');
$link = action('MetaGerSearch@search', $params);
$response = Response::make(
view('plugin')->with('link', $link), "200");
view('plugin')
->with('link', $link)
->with('request', $request), "200");
$response->header('Content-Type', "application/xml");
return $response;
return $link;
}
public function loadSettings (Request $request)
public function loadSettings(Request $request)
{
$sumaFile = "";
if(App::isLocale('en'))
if (App::isLocale('en')) {
$sumaFile = config_path() . "/sumas.xml";
else
} else {
$sumaFile = config_path() . "/sumas.xml";
}
$xml = simplexml_load_file($sumaFile);
$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']) )
{
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";
$foki[$tmp][$suma['name']->__toString()] = [ 'displayName' => $displayName, 'url' => $url];
foreach ($f as $tmp) {
$displayName = $suma['displayName']->__toString();
$url = isset($suma['homepage']) ? $suma['homepage']->__toString() : "https://metager.de";
$foki[$tmp][$suma['name']->__toString()] = ['displayName' => $displayName, 'url' => $url];
}
}else
{
$displayName = $suma['displayName']->__toString();
$url = isset($suma['homepage']) ? $suma['homepage']->__toString() : "https://metager.de";
$foki["andere"][$suma['name']->__toString()] = [ 'displayName' => $displayName, 'url' => $url];
} else {
$displayName = $suma['displayName']->__toString();
$url = isset($suma['homepage']) ? $suma['homepage']->__toString() : "https://metager.de";
$foki["andere"][$suma['name']->__toString()] = ['displayName' => $displayName, 'url' => $url];
}
}
}
......@@ -151,4 +156,4 @@ class StartpageController extends Controller
return $xml->saveXML();
}
}
\ No newline at end of file
}
......@@ -147,7 +147,7 @@ Route::group(
Route::get('settings', 'StartpageController@loadSettings');
Route::get('meta/meta.ger3', 'MetaGerSearch@search');
Route::match(['get', 'post'], 'meta/meta.ger3', 'MetaGerSearch@search');
Route::get('meta/picture', 'Pictureproxy@get');
Route::get('clickstats', 'LogController@clicklog');
Route::get('pluginClose', 'LogController@pluginClose');
......
......@@ -29,4 +29,6 @@ return [
'speichern.2' => 'Einstellungen dauerhaft speichern',
'speichern.3' => 'Plugin mit diesen Einstellungen generieren',
'speichern.4' => 'Einstellungen zurücksetzen',
'request' => 'Mit welcher Methode soll MetaGer abgefragt werden',
];
......@@ -160,7 +160,7 @@
</label>
</fieldset>
<fieldset>
<form id="searchForm" method="GET" action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), "/meta/meta.ger3") }}" accept-charset="UTF-8">
<form id="searchForm" @if(Request::has('request') && Request::input('request') === "POST") method="POST" @elseif(Request::has('request') && Request::input('request') === "GET") method="GET" @else method="GET" @endif action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), "/meta/meta.ger3") }}" accept-charset="UTF-8">
<div class="input-group">
<div class="input-group-addon">
<button type="button" data-toggle="popover" data-html="true" data-container="body" title="{{ trans('index.design') }}" data-content='&lt;ul id="color-chooser" class="list-inline list-unstyled"&gt;
......
......@@ -11,7 +11,7 @@
</div>
</li>
<li class="pull-right">
<form method="get" accept-charset="UTF-8" class="form" id="submitForm">
<form method="{{ Request::method() }}" accept-charset="UTF-8" class="form" id="submitForm">
<div class="input-group">
<input autocomplete="off" class="form-control" form="submitForm" id="eingabeTop" name="eingabe" placeholder="Suchbegriffe erweitern/verändern, oder völlig neue Suche:" tabindex="1" type="text" value="{{ $eingabe }}" required />
<div class="input-group-addon">
......
<?xml version="1.0" encoding="UTF-8"?>
<?xmlversion = "1.0"encoding = "UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>MetaGer</ShortName>
<Description>MetaGer: Sicher suchen &amp; finden, Privatsphäre schützen</Description>
<Contact>office@suma-ev.de</Contact>
<Image width="16" height="16" type="image/x-icon">{{ url('/favicon.ico') }}</Image>
<Url type="text/html" template="{{ $link }}&amp;eingabe={searchTerms}" method="get"></Url>
<Url type="text/html" template="{{ $link }}&amp;eingabe={searchTerms}" method="{{$request}}"></Url>
<InputEncoding>UTF-8</InputEncoding>
</OpenSearchDescription>
\ No newline at end of file
</OpenSearchDescription>
......@@ -33,6 +33,11 @@
<option value="5000">{!! trans('settings.zeit.4') !!}</option>
<option value="10000">{!! trans('settings.zeit.5') !!}</option>
<option value="20000">{!! trans('settings.zeit.6') !!}</option></select>
<label class="select-label">{{ trans('settings.request') }}:</label>
<select class="form-control" name="request">
<option value="GET" selected>GET</option>
<option value="POST">POST</option>
</select>
<h2>{!! trans('settings.suchmaschinen.1') !!} <small><a class="allUnchecker">{!! trans('settings.suchmaschinen.2') !!}</a></small></h2>
@foreach( $foki as $fokus => $sumas )
<div class="headingGroup {{ $fokus }}">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment