Commit 05d17390 authored by Phil Höfer's avatar Phil Höfer

Dict.cc-Quicktips-Integration

erscheint in der deutschen Version ganz oben, sonst vor den "Wussten Sie schon?"
parent 3dea31b5
...@@ -165,6 +165,23 @@ class MetaGerSearch extends Controller ...@@ -165,6 +165,23 @@ class MetaGerSearch extends Controller
} }
$mquicktips = array_merge($mquicktips, $quicktips); $mquicktips = array_merge($mquicktips, $quicktips);
# Dict.cc Quicktip
$url = "http://www.dict.cc/metager.php?s=" . urlencode($q);
$decodedResponse = json_decode($this->get($url), true);
if ($decodedResponse["headline"] != "" && $decodedResponse["link"] != "") {
$quicktip = [];
$quicktip["title"] = $decodedResponse["headline"];
$quicktip["URL"] = $decodedResponse["link"];
$quicktip["summary"] = implode(", ", $decodedResponse["translations"]);
$quicktip['gefVon'] = trans('metaGerSearch.quicktips.dictcc.adress');
if (App::isLocale('de')) {
array_unshift($mquicktips, $quicktip);
} else {
$mquicktips[] = $quicktip;
}
}
# wussten Sie schon # wussten Sie schon
$file = storage_path() . "/app/public/tips.txt"; $file = storage_path() . "/app/public/tips.txt";
if (file_exists($file)) { if (file_exists($file)) {
......
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
return [ return [
'quicktips.wikipedia.adress' => 'aus <a href="https://de.wikipedia.org" target="_blank" rel="noopener">Wikipedia, der freien Enzyklopädie</a>', 'quicktips.wikipedia.adress' => 'aus <a href="https://de.wikipedia.org" target="_blank" rel="noopener">Wikipedia, der freien Enzyklopädie</a>',
'quicktips.dictcc.adress' => 'aus <a href="https://www.dict.cc/" target="_blank" rel="noopener">dict.cc</a>',
'quicktips.tips.title' => 'Wussten Sie schon?', 'quicktips.tips.title' => 'Wussten Sie schon?',
]; ];
<?php <?php
return [ return [
"quicktips.wikipedia.adress" => "taken from: <a href=\"https://en.wikipedia.org\" target=\"_blank\" rel=\"noopener\"> Wikipedia, The Free Encyclopedia", "quicktips.wikipedia.adress" => "from <a href=\"https://en.wikipedia.org\" target=\"_blank\" rel=\"noopener\"> Wikipedia, The Free Encyclopedia",
"quicktips.tips.title" => "Did you know ?" "quicktips.dictcc.adress" => 'from <a href="https://www.dict.cc/" target="_blank" rel="noopener">dict.cc</a>',
]; "quicktips.tips.title" => "Did you know ?",
\ No newline at end of file ];
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