Commit 440288f6 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

English version now uses Scopia

parent a4ce133c
...@@ -10,12 +10,12 @@ class FokiLoader ...@@ -10,12 +10,12 @@ class FokiLoader
{ {
$sumaFile = ""; $sumaFile = "";
if (App::isLocale('en')) { if (App::isLocale('en')) {
$sumaFile = config_path() . "/sumas.xml"; $sumaFile = config_path() . "/sumasEn.xml";
} else { } else {
$sumaFile = config_path() . "/sumas.xml"; $sumaFile = config_path() . "/sumas.xml";
} }
$xml = simplexml_load_file($sumaFile); $xml = simplexml_load_file($sumaFile);
$sumas = $xml->xpath("suma"); $sumas = $xml->xpath("suma");
$foki = []; $foki = [];
...@@ -24,13 +24,13 @@ class FokiLoader ...@@ -24,13 +24,13 @@ class FokiLoader
if (isset($suma['type'])) { if (isset($suma['type'])) {
$f = explode(",", $suma['type']->__toString()); $f = explode(",", $suma['type']->__toString());
foreach ($f as $tmp) { foreach ($f as $tmp) {
$displayName = $suma['displayName']->__toString(); $displayName = $suma['displayName']->__toString();
$url = isset($suma['homepage']) ? $suma['homepage']->__toString() : "https://metager.de"; $url = isset($suma['homepage']) ? $suma['homepage']->__toString() : "https://metager.de";
$foki[$tmp][$suma['name']->__toString()] = ['displayName' => $displayName, 'url' => $url]; $foki[$tmp][$suma['name']->__toString()] = ['displayName' => $displayName, 'url' => $url];
} }
} else { } else {
$displayName = $suma['displayName']->__toString(); $displayName = $suma['displayName']->__toString();
$url = isset($suma['homepage']) ? $suma['homepage']->__toString() : "https://metager.de"; $url = isset($suma['homepage']) ? $suma['homepage']->__toString() : "https://metager.de";
$foki["andere"][$suma['name']->__toString()] = ['displayName' => $displayName, 'url' => $url]; $foki["andere"][$suma['name']->__toString()] = ['displayName' => $displayName, 'url' => $url];
} }
} }
......
...@@ -5,8 +5,8 @@ namespace App\Http\Controllers; ...@@ -5,8 +5,8 @@ namespace App\Http\Controllers;
use App; use App;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Jenssegers\Agent\Agent; use Jenssegers\Agent\Agent;
use Response;
use LaravelLocalization; use LaravelLocalization;
use Response;
class StartpageController extends Controller class StartpageController extends Controller
{ {
...@@ -20,7 +20,7 @@ class StartpageController extends Controller ...@@ -20,7 +20,7 @@ class StartpageController extends Controller
public function loadStartPage(Request $request) public function loadStartPage(Request $request)
{ {
$focusPages = []; $focusPages = [];
$theme = "default"; $theme = "default";
$optionParams = ['param_sprueche', 'param_newtab', 'param_maps', 'param_autocomplete', 'param_lang', 'param_key']; $optionParams = ['param_sprueche', 'param_newtab', 'param_maps', 'param_autocomplete', 'param_lang', 'param_key'];
$option_values = []; $option_values = [];
...@@ -33,12 +33,12 @@ class StartpageController extends Controller ...@@ -33,12 +33,12 @@ class StartpageController extends Controller
} }
$autocomplete = 'on'; $autocomplete = 'on';
if(in_array('autocomplete', array_keys($option_values))) { if (in_array('autocomplete', array_keys($option_values))) {
$autocomplete = $option_values['autocomplete']; $autocomplete = $option_values['autocomplete'];
} }
$lang = LaravelLocalization::getCurrentLocale(); $lang = LaravelLocalization::getCurrentLocale();
if ($lang === 'de') { if ($lang === 'de' || $lang === "en") {
$lang = 'all'; $lang = 'all';
} }
...@@ -78,9 +78,9 @@ class StartpageController extends Controller ...@@ -78,9 +78,9 @@ class StartpageController extends Controller
public function loadPlugin($params, $locale = "de") public function loadPlugin($params, $locale = "de")
{ {
$params = unserialize(base64_decode($params)); $params = unserialize(base64_decode($params));
$requests = $params; $requests = $params;
$params = []; $params = [];
foreach ($requests as $key => $value) { foreach ($requests as $key => $value) {
if (strpos($key, "param_") === 0) { if (strpos($key, "param_") === 0) {
$key = substr($key, strpos($key, "param_") + 6); $key = substr($key, strpos($key, "param_") + 6);
...@@ -135,12 +135,12 @@ class StartpageController extends Controller ...@@ -135,12 +135,12 @@ class StartpageController extends Controller
public function berlin(Request $request) public function berlin(Request $request)
{ {
$link = ""; $link = "";
$password = ""; $password = "";
if ($request->filled('eingabe')) { if ($request->filled('eingabe')) {
$password = getenv('berlin'); $password = getenv('berlin');
$password = md5($request->input('eingabe') . " -host:userpage.fu-berlin.de" . $password); $password = md5($request->input('eingabe') . " -host:userpage.fu-berlin.de" . $password);
$link = "/meta/meta.ger3?eingabe=" . $request->input('eingabe') . " -host:userpage.fu-berlin.de&focus=web&password=" . $password . "&encoding=utf8&lang=all&site=fu-berlin.de&quicktips=off&out=results-with-style"; $link = "/meta/meta.ger3?eingabe=" . $request->input('eingabe') . " -host:userpage.fu-berlin.de&focus=web&password=" . $password . "&encoding=utf8&lang=all&site=fu-berlin.de&quicktips=off&out=results-with-style";
} }
return view('berlin') return view('berlin')
->with('title', 'Testseite für die FU-Berlin') ->with('title', 'Testseite für die FU-Berlin')
......
...@@ -34,6 +34,7 @@ class MetaGer ...@@ -34,6 +34,7 @@ class MetaGer
protected $warnings = []; protected $warnings = [];
protected $errors = []; protected $errors = [];
protected $addedHosts = []; protected $addedHosts = [];
protected $availableFoki = [];
protected $startCount = 0; protected $startCount = 0;
protected $canCache = false; protected $canCache = false;
# Daten über die Abfrage$ # Daten über die Abfrage$
...@@ -525,6 +526,20 @@ class MetaGer ...@@ -525,6 +526,20 @@ class MetaGer
$overtureEnabled = false; $overtureEnabled = false;
$sumaCount = 0; $sumaCount = 0;
/*
* Erstellt eine Liste mit Foki, die verfügbar sind
*/
$this->availableFoki = [];
foreach ($sumas as $suma) {
$foki = explode(",", trim($suma["type"]));
foreach ($foki as $fokus) {
if (!empty($fokus)) {
$this->availableFoki[$fokus] = "available";
}
}
}
$isCustomSearch = $this->startsWith($this->fokus, 'focus_'); $isCustomSearch = $this->startsWith($this->fokus, 'focus_');
# Im Falle einer Custom-Suche ohne mindestens einer selektierter Suchmaschine wird eine Web-Suche durchgeführt # Im Falle einer Custom-Suche ohne mindestens einer selektierter Suchmaschine wird eine Web-Suche durchgeführt
...@@ -646,7 +661,7 @@ class MetaGer ...@@ -646,7 +661,7 @@ class MetaGer
public function sumaIsSelected($suma, $request, $custom) public function sumaIsSelected($suma, $request, $custom)
{ {
if ($custom) { if ($custom) {
if ($request->filled("engine_" . $suma["name"])) { if ($request->filled("engine_" . strtolower($suma["name"]))) {
return true; return true;
} }
} else { } else {
...@@ -950,7 +965,7 @@ class MetaGer ...@@ -950,7 +965,7 @@ class MetaGer
$this->fokus = $request->input('focus', 'web'); $this->fokus = $request->input('focus', 'web');
# Suma-File # Suma-File
if (App::isLocale("en")) { if (App::isLocale("en")) {
$this->sumaFile = config_path() . "/sumas.xml"; $this->sumaFile = config_path() . "/sumasEn.xml";
} else { } else {
$this->sumaFile = config_path() . "/sumas.xml"; $this->sumaFile = config_path() . "/sumas.xml";
} }
...@@ -1561,6 +1576,12 @@ class MetaGer ...@@ -1561,6 +1576,12 @@ class MetaGer
return $this->lang; return $this->lang;
} }
public function getAvailableFoki()
{
return $this->availableFoki;
}
public function getSprueche() public function getSprueche()
{ {
return $this->sprueche; return $this->sprueche;
......
...@@ -31,6 +31,9 @@ abstract class Searchengine ...@@ -31,6 +31,9 @@ abstract class Searchengine
public $startTime; # Die Zeit der Erstellung dieser Suchmaschine public $startTime; # Die Zeit der Erstellung dieser Suchmaschine
public $hash; # Der Hash-Wert dieser Suchmaschine public $hash; # Der Hash-Wert dieser Suchmaschine
private $user; # Username für HTTP-Auth (falls angegeben)
private $password; # Passwort für HTTP-Auth (falls angegeben)
public $fp; # Wird für Artefakte benötigt public $fp; # Wird für Artefakte benötigt
public $socketNumber = null; # Wird für Artefakte benötigt public $socketNumber = null; # Wird für Artefakte benötigt
public $counter = 0; # Wird eventuell für Artefakte benötigt public $counter = 0; # Wird eventuell für Artefakte benötigt
......
...@@ -25,10 +25,10 @@ class Overture extends Searchengine ...@@ -25,10 +25,10 @@ class Overture extends Searchengine
$results = $content->xpath('//Results/ResultSet[@id="inktomi"]/Listing'); $results = $content->xpath('//Results/ResultSet[@id="inktomi"]/Listing');
foreach ($results as $result) { foreach ($results as $result) {
$title = $result["title"]; $title = $result["title"];
$link = $result->{"ClickUrl"}->__toString(); $link = $result->{"ClickUrl"}->__toString();
$anzeigeLink = $result["siteHost"]; $anzeigeLink = $result["siteHost"];
$descr = $result["description"]; $descr = $result["description"];
$this->counter++; $this->counter++;
$this->results[] = new \App\Models\Result( $this->results[] = new \App\Models\Result(
$this->engine, $this->engine,
...@@ -36,7 +36,8 @@ class Overture extends Searchengine ...@@ -36,7 +36,8 @@ class Overture extends Searchengine
$link, $link,
$anzeigeLink, $anzeigeLink,
$descr, $descr,
$this->displayName,$this->homepage, $this->displayName,
$this->homepage,
$this->counter $this->counter
); );
} }
...@@ -44,10 +45,10 @@ class Overture extends Searchengine ...@@ -44,10 +45,10 @@ class Overture extends Searchengine
# Nun noch die Werbeergebnisse: # Nun noch die Werbeergebnisse:
$ads = $content->xpath('//Results/ResultSet[@id="searchResults"]/Listing'); $ads = $content->xpath('//Results/ResultSet[@id="searchResults"]/Listing');
foreach ($ads as $ad) { foreach ($ads as $ad) {
$title = $ad["title"]; $title = $ad["title"];
$link = $ad->{"ClickUrl"}->__toString(); $link = $ad->{"ClickUrl"}->__toString();
$anzeigeLink = $ad["siteHost"]; $anzeigeLink = $ad["siteHost"];
$descr = $ad["description"]; $descr = $ad["description"];
$this->counter++; $this->counter++;
$this->ads[] = new \App\Models\Result( $this->ads[] = new \App\Models\Result(
$this->engine, $this->engine,
...@@ -55,7 +56,7 @@ class Overture extends Searchengine ...@@ -55,7 +56,7 @@ class Overture extends Searchengine
$link, $link,
$anzeigeLink, $anzeigeLink,
$descr, $descr,
$this->displayName,$this->homepage, $this->displayName, $this->homepage,
$this->counter $this->counter
); );
} }
...@@ -87,9 +88,9 @@ class Overture extends Searchengine ...@@ -87,9 +88,9 @@ class Overture extends Searchengine
// Yahoo liefert, wenn es keine weiteren Ergebnisse hat immer wieder die gleichen Ergebnisse // Yahoo liefert, wenn es keine weiteren Ergebnisse hat immer wieder die gleichen Ergebnisse
// Wir müssen also überprüfen, ob wir am Ende der Ergebnisse sind // Wir müssen also überprüfen, ob wir am Ende der Ergebnisse sind
$resultCount = $content->xpath('//Results/ResultSet[@id="inktomi"]/MetaData/TotalHits'); $resultCount = $content->xpath('//Results/ResultSet[@id="inktomi"]/MetaData/TotalHits');
$results = $content->xpath('//Results/ResultSet[@id="inktomi"]/Listing'); $results = $content->xpath('//Results/ResultSet[@id="inktomi"]/Listing');
if (isset($resultCount[0]) && sizeof($results) > 0) { if (isset($resultCount[0]) && sizeof($results) > 0) {
$resultCount = intval($resultCount[0]->__toString()); $resultCount = intval($resultCount[0]->__toString());
$lastResultOnPage = intval($results[sizeof($results) - 1]["rank"]); $lastResultOnPage = intval($results[sizeof($results) - 1]["rank"]);
if ($resultCount <= $lastResultOnPage) { if ($resultCount <= $lastResultOnPage) {
return; return;
...@@ -111,9 +112,9 @@ class Overture extends Searchengine ...@@ -111,9 +112,9 @@ class Overture extends Searchengine
} }
# Erstellen des neuen Suchmaschinenobjekts und anpassen des GetStrings: # Erstellen des neuen Suchmaschinenobjekts und anpassen des GetStrings:
$next = new Overture(simplexml_load_string($this->engine), $metager); $next = new Overture(simplexml_load_string($this->engine), $metager);
$next->getString = preg_replace("/&Keywords=.*?&/si", "&", $next->getString) . "&" . $nextArgs; $next->getString = preg_replace("/&Keywords=.*?&/si", "&", $next->getString) . "&" . $nextArgs;
$next->hash = md5($next->host . $next->getString . $next->port . $next->name); $next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next; $this->next = $next;
} }
} }
...@@ -17,7 +17,10 @@ class Scopia extends Searchengine ...@@ -17,7 +17,10 @@ class Scopia extends Searchengine
public function loadResults($result) public function loadResults($result)
{ {
$result = html_entity_decode($result); $result = html_entity_decode($result);
$result = str_replace("&", "&amp;", $result); $result = preg_replace("/<description>(.*?)<\/description>/si", "<description><![CDATA[ $1 ]]></description>", $result);
$result = preg_replace("/<title>(.*?)<\/title>/si", "<title><![CDATA[ $1 ]]></title>", $result);
$result = preg_replace("/<url>(.*?)<\/url>/si", "<url><![CDATA[ $1 ]]></url>", $result);
try { try {
$content = simplexml_load_string($result); $content = simplexml_load_string($result);
...@@ -38,7 +41,8 @@ class Scopia extends Searchengine ...@@ -38,7 +41,8 @@ class Scopia extends Searchengine
$link, $link,
$anzeigeLink, $anzeigeLink,
$descr, $descr,
$this->gefVon, $this->displayName,
$this->homepage,
$this->counter $this->counter
); );
} }
......
@if( array_has($metager->getAvailableFoki(), "web"))
<div id="web" @if($metager->getFokus() === "web")class="active"@endif> <div id="web" @if($metager->getFokus() === "web")class="active"@endif>
<a href="@if($metager->getFokus() === "web")#@else{!!$metager->generateSearchLink('web')!!}@endif" target="_self" tabindex="2">@lang('index.foki.web')</a> <a href="@if($metager->getFokus() === "web")#@else{!!$metager->generateSearchLink('web')!!}@endif" target="_self" tabindex="2">@lang('index.foki.web')</a>
</div> </div>
@endif
@if( array_has($metager->getAvailableFoki(), "nachrichten"))
<div id="nachrichten" @if($metager->getFokus() === "nachrichten")class="active"@endif> <div id="nachrichten" @if($metager->getFokus() === "nachrichten")class="active"@endif>
<a href="@if($metager->getFokus() === "nachrichten")#@else{!!$metager->generateSearchLink('nachrichten')!!}@endif" target="_self" tabindex="3">@lang('index.foki.nachrichten')</a> <a href="@if($metager->getFokus() === "nachrichten")#@else{!!$metager->generateSearchLink('nachrichten')!!}@endif" target="_self" tabindex="3">@lang('index.foki.nachrichten')</a>
</div> </div>
@endif
@if( array_has($metager->getAvailableFoki(), "wissenschaft"))
<div id="wissenschaft" @if($metager->getFokus() === "wissenschaft")class="active"@endif> <div id="wissenschaft" @if($metager->getFokus() === "wissenschaft")class="active"@endif>
<a href="@if($metager->getFokus() === "wissenschaft")#@else{!!$metager->generateSearchLink('wissenschaft')!!}@endif" target="_self" tabindex="4">@lang('index.foki.wissenschaft')</a> <a href="@if($metager->getFokus() === "wissenschaft")#@else{!!$metager->generateSearchLink('wissenschaft')!!}@endif" target="_self" tabindex="4">@lang('index.foki.wissenschaft')</a>
</div> </div>
@endif
@if( array_has($metager->getAvailableFoki(), "produktsuche"))
<div id="produkte" @if($metager->getFokus() === "produktsuche")class="active"@endif> <div id="produkte" @if($metager->getFokus() === "produktsuche")class="active"@endif>
<a href="@if($metager->getFokus() === "produktsuche")#@else{!!$metager->generateSearchLink('produktsuche')!!}@endif" target="_self" tabindex="5">@lang('index.foki.produkte')</a> <a href="@if($metager->getFokus() === "produktsuche")#@else{!!$metager->generateSearchLink('produktsuche')!!}@endif" target="_self" tabindex="5">@lang('index.foki.produkte')</a>
</div> </div>
@endif
<div id="maps"> <div id="maps">
<a href="https://maps.metager.de/map/{{ $metager->getQ() }}/9.7380161,52.37119740000003,12" target="_self" tabindex="6">@lang('index.foki.maps')</a> <a href="https://maps.metager.de/map/{{ $metager->getQ() }}/9.7380161,52.37119740000003,12" target="_self" tabindex="6">@lang('index.foki.maps')</a>
</div> </div>
......
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