[ 'url' => 'https://www.google.com/search', 'var' => 'q', 'method' => 'get', 'type' => 'external', ], 'ddg' => [ 'url' => 'https://duckduckgo.com/', 'var' => 'q', 'method' => 'get', 'type' => 'external', ], 'bing' => [ 'url' => 'https://www.bing.com/search', 'var' => 'q', 'method' => 'get', 'type' => 'external', ], ]; } public static function appProviders() { $providers = []; $userapps = Item::all(); foreach($userapps as $app) { if(empty($app->class)) continue; if(($provider = Item::isSearchProvider($app->class)) !== false) { $name = Item::nameFromClass($app->class); $providers[strtolower($name)] = [ 'type' => $provider->type, ]; } } return $providers; } public static function storeSearchProvider($class, $app) { if(!empty($class)) { if(($provider = Item::isSearchProvider($class)) !== false) { $providers = Cache::get('search_providers', []); $name = Item::nameFromClass($class); $search = new $class; $providers[strtolower($name)] = [ 'url' => '', 'var' => '', 'type' => $search->type, ]; } } } /** * @return html */ public static function form() { $output = ''; $homepage_search = Setting::fetch('homepage_search'); $search_provider = Setting::where('key', '=', 'search_provider')->first(); $user_search_provider = Setting::fetch('search_provider'); //die(print_r($search_provider)); //die(var_dump($user_search_provider)); // return early if search isn't applicable if((bool)$homepage_search !== true) return $output; if($user_search_provider === 'none') return $output; if(empty($user_search_provider)) return $output; if(is_null($user_search_provider)) return $output; if((bool)$homepage_search && (bool)$search_provider) { if((bool)$user_search_provider) { $name = 'app.options.'.$user_search_provider; $provider = self::providerDetails($user_search_provider); $output .= '
'; $output .= Form::open(['url' => 'search', 'method' => 'get']); $output .= '
'; $output .= ''; $output .= Form::text('q', null, ['class' => 'homesearch', 'autofocus' => 'autofocus', 'placeholder' => __('app.settings.search').'...']); $output .= ''; $output .= '
'; $output .= Form::close(); $output .= '
'; } } return $output; } }