Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
2989443f
Commit
2989443f
authored
Apr 04, 2017
by
Dominik Hebeler
Browse files
Merge branch '465-bangs-auf-englisch' into 'development'
Resolve "!bangs auf englisch" Closes
#465
See merge request
!802
parents
a0acabb3
82f0565b
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/MetaGerSearch.php
View file @
2989443f
...
...
@@ -52,40 +52,39 @@ class MetaGerSearch extends Controller
$quicktips
=
[];
$spruch
=
""
;
if
(
APP
::
getLocale
()
===
"de"
)
{
# DuckDuckGo-!bangs
try
{
$placeholder
=
"0X0plchldr0X0"
;
$searchWords
=
explode
(
" "
,
$q
);
$dummyQuery
=
""
;
$realQuery
=
""
;
foreach
(
$searchWords
as
$index
=>
$word
)
{
if
(
$word
[
0
]
===
"!"
)
{
$dummyQuery
.
=
$word
.
" "
;
}
else
{
$realQuery
.
=
$word
;
}
# DuckDuckGo-!bangs
try
{
$placeholder
=
"0X0plchldr0X0"
;
$searchWords
=
explode
(
" "
,
$q
);
$dummyQuery
=
""
;
$realQuery
=
""
;
foreach
(
$searchWords
as
$index
=>
$word
)
{
if
(
$word
[
0
]
===
"!"
)
{
$dummyQuery
.
=
$word
.
" "
;
}
else
{
$realQuery
.
=
$word
;
}
if
(
$dummyQuery
!==
""
)
{
$dummyQuery
.
=
$placeholder
;
$url
=
"https://api.duckduckgo.com/?format=json&no_redirect=1&t=MetaGerDE&q="
.
urlencode
(
$dummyQuery
);
$result
=
json_decode
(
$this
->
get
(
$url
),
true
);
if
(
isset
(
$result
[
"Redirect"
]))
{
$bang
=
[];
$bang
[
"title"
]
=
"!bang-Weiterleitung"
;
$bang
[
"URL"
]
=
str_replace
(
$placeholder
,
urlencode
(
trim
(
$realQuery
)),
$result
[
"Redirect"
]);
$bang
[
"summary"
]
=
'<a href="'
.
$bang
[
"URL"
]
.
'" target=_blank class="btn btn-primary" style="margin-top:5px;color: #fff">Weitersuchen auf '
.
parse_url
(
$bang
[
"URL"
],
PHP_URL_HOST
)
.
'…</a>'
;
$bang
[
"gefVon"
]
=
"von <a href =
\"
https://api.duckduckgo.com/
\"
target=
\"
_blank
\"
rel=
\"
noopener
\"
>DuckDuckGo</a>"
;
$mquicktips
[]
=
$bang
;
}
}
if
(
$dummyQuery
!==
""
)
{
$dummyQuery
.
=
$placeholder
;
$url
=
"https://api.duckduckgo.com/?format=json&no_redirect=1&t=MetaGerDE&q="
.
urlencode
(
$dummyQuery
);
$result
=
json_decode
(
$this
->
get
(
$url
),
true
);
if
(
isset
(
$result
[
"Redirect"
]))
{
$bang
=
[];
$bang
[
"title"
]
=
trans
(
'metaGerSearch.quicktips.bang.title'
);
$bang
[
"URL"
]
=
str_replace
(
$placeholder
,
urlencode
(
trim
(
$realQuery
)),
$result
[
"Redirect"
]);
$bang
[
"summary"
]
=
'<a href="'
.
$bang
[
"URL"
]
.
'" target=_blank class="btn btn-primary" style="margin-top:5px;color: #fff">'
.
trans
(
'metaGerSearch.quicktips.bang.buttonlabel'
)
.
" "
.
parse_url
(
$bang
[
"URL"
],
PHP_URL_HOST
)
.
'…</a>'
;
$bang
[
"gefVon"
]
=
trans
(
'metaGerSearch.quicktips.bang.from'
)
.
" <a href =
\"
https://api.duckduckgo.com/
\"
target=
\"
_blank
\"
rel=
\"
noopener
\"
>DuckDuckGo</a>"
;
$mquicktips
[]
=
$bang
;
}
}
catch
(
\
ErrorException
$e
)
{
}
}
catch
(
\
ErrorException
$e
)
{
}
if
(
APP
::
getLocale
()
===
"de"
)
{
# Spruch
$spruecheFile
=
storage_path
()
.
"/app/public/sprueche.txt"
;
if
(
file_exists
(
$spruecheFile
)
&&
$request
->
has
(
'sprueche'
))
{
...
...
resources/lang/de/metaGerSearch.php
View file @
2989443f
...
...
@@ -4,4 +4,7 @@ return [
'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.bang.title'
=>
'!bang-Weiterleitung'
,
'quicktips.bang.buttonlabel'
=>
'Weitersuchen auf'
,
'quicktips.bang.from'
=>
'von'
,
];
resources/lang/en/metaGerSearch.php
View file @
2989443f
...
...
@@ -4,4 +4,7 @@ return [
"quicktips.wikipedia.adress"
=>
"from <a href=
\"
https://en.wikipedia.org
\"
target=
\"
_blank
\"
rel=
\"
noopener
\"
> Wikipedia, The Free Encyclopedia</a>"
,
"quicktips.dictcc.adress"
=>
'from <a href="https://www.dict.cc/" target="_blank" rel="noopener">dict.cc</a>'
,
"quicktips.tips.title"
=>
"Did you know?"
,
'quicktips.bang.title'
=>
'!bang redirect'
,
'quicktips.bang.buttonlabel'
=>
'Continue to'
,
'quicktips.bang.from'
=>
'from'
,
];
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment