66use App \Setting ;
77use Form ;
88use Cache ;
9+ use Yaml ;
910
1011abstract class Search
1112{
@@ -19,7 +20,7 @@ public static function providers()
1920 {
2021 $ providers = self ::standardProviders ();
2122 $ providers = $ providers + self ::appProviders ();
22- return $ providers ;
23+ return collect ( $ providers) ;
2324 }
2425
2526 /**
@@ -41,38 +42,16 @@ public static function providerDetails($provider)
4142 */
4243 public static function standardProviders ()
4344 {
44- return [
45- 'google ' => [
46- 'url ' => 'https://www.google.com/search ' ,
47- 'var ' => 'q ' ,
48- 'method ' => 'get ' ,
49- 'type ' => 'standard ' ,
50- ],
51- 'ddg ' => [
52- 'url ' => 'https://duckduckgo.com/ ' ,
53- 'var ' => 'q ' ,
54- 'method ' => 'get ' ,
55- 'type ' => 'standard ' ,
56- ],
57- 'bing ' => [
58- 'url ' => 'https://www.bing.com/search ' ,
59- 'var ' => 'q ' ,
60- 'method ' => 'get ' ,
61- 'type ' => 'standard ' ,
62- ],
63- 'qwant ' => [
64- 'url ' => 'https://www.qwant.com/ ' ,
65- 'var ' => 'q ' ,
66- 'method ' => 'get ' ,
67- 'type ' => 'standard ' ,
68- ],
69- 'startpage ' => [
70- 'url ' => 'https://www.startpage.com/do/dsearch ' ,
71- 'var ' => 'query ' ,
72- 'method ' => 'get ' ,
73- 'type ' => 'standard ' ,
74- ],
75- ];
45+ // $providers = json_decode(file_get_contents(storage_path('app/searchproviders.json')));
46+ // print_r($providers);
47+ $ providers = Yaml::parseFile (storage_path ('app/searchproviders.yaml ' ));
48+ $ all = [];
49+ foreach ($ providers as $ key => $ provider ) {
50+ $ all [$ key ] = $ provider ;
51+ $ all [$ key ]['type ' ] = 'standard ' ;
52+ }
53+
54+ return $ all ;
7655 }
7756
7857 /**
@@ -90,10 +69,11 @@ public static function appProviders()
9069 if (($ provider = Item::isSearchProvider ($ app ->class )) !== false ) {
9170 $ name = Item::nameFromClass ($ app ->class );
9271 $ providers [$ app ->id ] = [
72+ 'id ' => $ app ->id ,
9373 'type ' => $ provider ->type ,
9474 'class ' => $ app ->class ,
9575 'url ' => $ app ->url ,
96- 'title ' => $ app ->title ,
76+ 'name ' => $ app ->title ,
9777 'colour ' => $ app ->colour ,
9878 'icon ' => $ app ->icon ,
9979 'description ' => $ app ->description
@@ -133,12 +113,8 @@ public static function form()
133113 $ output .= '<div id="search-container" class="input-container"> ' ;
134114 $ output .= '<select name="provider"> ' ;
135115 foreach (self ::providers () as $ key => $ searchprovider ) {
136- $ selected = ($ key === $ user_search_provider ) ? ' selected="selected" ' : '' ;
137- if (is_numeric ($ key )) {
138- $ output .= '<option value=" ' .$ key .'" ' .$ selected .'> ' .$ searchprovider ['title ' ].'</option> ' ;
139- } else {
140- $ output .= '<option value=" ' .$ key .'" ' .$ selected .'> ' .__ ('app.options. ' .$ key ).'</option> ' ;
141- }
116+ $ selected = ((string )$ key === (string )$ user_search_provider ) ? ' selected="selected" ' : '' ;
117+ $ output .= '<option value=" ' .$ key .'" ' .$ selected .'> ' .$ searchprovider ['name ' ].'</option> ' ;
142118 }
143119 $ output .= '</select> ' ;
144120 $ output .= Form::text ('q ' , null , ['class ' => 'homesearch ' , 'autofocus ' => 'autofocus ' , 'placeholder ' => __ ('app.settings.search ' ).'... ' ]);
0 commit comments