Browse Source

Improved custom search handling

pull/397/head
Scott Holodak 5 years ago
parent
commit
861d287750
  1. 12
      app/Search.php

12
app/Search.php

@ -89,10 +89,14 @@ abstract class Search
if(empty($app->class)) continue; if(empty($app->class)) continue;
if(($provider = Item::isSearchProvider($app->class)) !== false) { if(($provider = Item::isSearchProvider($app->class)) !== false) {
$name = Item::nameFromClass($app->class); $name = Item::nameFromClass($app->class);
$providers[strtolower($name)] = [ $providers[$app->id] = [
'type' => $provider->type, 'type' => $provider->type,
'class' => $app->class, 'class' => $app->class,
'url' => $app->url, 'url' => $app->url,
'title' => $app->title,
'colour' => $app->colour,
'icon' => $app->icon,
'description' => $app->description
]; ];
} }
@ -130,7 +134,11 @@ abstract class Search
$output .= '<select name="provider">'; $output .= '<select name="provider">';
foreach(self::providers() as $key => $searchprovider) { foreach(self::providers() as $key => $searchprovider) {
$selected = ($key === $user_search_provider) ? ' selected="selected"' : ''; $selected = ($key === $user_search_provider) ? ' selected="selected"' : '';
$output .= '<option value="'.$key.'"'.$selected.'>'.__('app.options.'.$key).'</option>'; if (is_numeric($key)) {
$output .= '<option value="'.$key.'"'.$selected.'>'.$searchprovider['title'].'</option>';
} else {
$output .= '<option value="'.$key.'"'.$selected.'>'.__('app.options.'.$key).'</option>';
}
} }
$output .= '</select>'; $output .= '</select>';
$output .= Form::text('q', null, ['class' => 'homesearch', 'autofocus' => 'autofocus', 'placeholder' => __('app.settings.search').'...']); $output .= Form::text('q', null, ['class' => 'homesearch', 'autofocus' => 'autofocus', 'placeholder' => __('app.settings.search').'...']);

Loading…
Cancel
Save