fisharebest /
webtrees
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * webtrees: online genealogy |
||
| 5 | * Copyright (C) 2025 webtrees development team |
||
| 6 | * This program is free software: you can redistribute it and/or modify |
||
| 7 | * it under the terms of the GNU General Public License as published by |
||
| 8 | * the Free Software Foundation, either version 3 of the License, or |
||
| 9 | * (at your option) any later version. |
||
| 10 | * This program is distributed in the hope that it will be useful, |
||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | * GNU General Public License for more details. |
||
| 14 | * You should have received a copy of the GNU General Public License |
||
| 15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
| 16 | */ |
||
| 17 | |||
| 18 | declare(strict_types=1); |
||
| 19 | |||
| 20 | namespace Fisharebest\Webtrees\Module; |
||
| 21 | |||
| 22 | use Fisharebest\Webtrees\Auth; |
||
|
0 ignored issues
–
show
|
|||
| 23 | use Fisharebest\Webtrees\Http\RequestHandlers\SearchAdvancedPage; |
||
|
0 ignored issues
–
show
The type
Fisharebest\Webtrees\Htt...lers\SearchAdvancedPage was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 24 | use Fisharebest\Webtrees\Http\RequestHandlers\SearchGeneralPage; |
||
| 25 | use Fisharebest\Webtrees\Http\RequestHandlers\SearchPhoneticPage; |
||
| 26 | use Fisharebest\Webtrees\Http\RequestHandlers\SearchReplacePage; |
||
| 27 | use Fisharebest\Webtrees\I18N; |
||
|
0 ignored issues
–
show
The type
Fisharebest\Webtrees\I18N was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 28 | use Fisharebest\Webtrees\Menu; |
||
| 29 | use Fisharebest\Webtrees\Tree; |
||
| 30 | |||
| 31 | use function route; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Class SearchMenuModule - provide a menu option for the search options |
||
| 35 | */ |
||
| 36 | class SearchMenuModule extends AbstractModule implements ModuleMenuInterface |
||
| 37 | { |
||
| 38 | use ModuleMenuTrait; |
||
| 39 | |||
| 40 | public function title(): string |
||
| 41 | { |
||
| 42 | /* I18N: Name of a module */ |
||
| 43 | return I18N::translate('Search'); |
||
| 44 | } |
||
| 45 | |||
| 46 | public function description(): string |
||
| 47 | { |
||
| 48 | /* I18N: Description of the “Search” module */ |
||
| 49 | return I18N::translate('The search menu.'); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * The default position for this menu. It can be changed in the control panel. |
||
| 54 | * |
||
| 55 | * @return int |
||
| 56 | */ |
||
| 57 | public function defaultMenuOrder(): int |
||
| 58 | { |
||
| 59 | return 6; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * A menu, to be added to the main application menu. |
||
| 64 | * |
||
| 65 | * @param Tree $tree |
||
| 66 | * |
||
| 67 | * @return Menu|null |
||
| 68 | */ |
||
| 69 | public function getMenu(Tree $tree): Menu|null |
||
| 70 | { |
||
| 71 | $submenu = [ |
||
| 72 | $this->menuSearchGeneral($tree), |
||
| 73 | $this->menuSearchPhonetic($tree), |
||
| 74 | $this->menuSearchAdvanced($tree), |
||
| 75 | $this->menuSearchAndReplace($tree), |
||
| 76 | ]; |
||
| 77 | |||
| 78 | $submenu = array_filter($submenu); |
||
| 79 | |||
| 80 | return new Menu(I18N::translate('Search'), '#', 'menu-search', ['rel' => 'nofollow'], $submenu); |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @param Tree $tree |
||
| 85 | * |
||
| 86 | * @return Menu |
||
| 87 | */ |
||
| 88 | protected function menuSearchGeneral(Tree $tree): Menu |
||
| 89 | { |
||
| 90 | return new Menu(I18N::translate('General search'), route(SearchGeneralPage::class, ['tree' => $tree->name()]), 'menu-search-general', ['rel' => 'nofollow']); |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @param Tree $tree |
||
| 95 | * |
||
| 96 | * @return Menu |
||
| 97 | */ |
||
| 98 | protected function menuSearchPhonetic(Tree $tree): Menu |
||
| 99 | { |
||
| 100 | $url = route(SearchPhoneticPage::class, ['tree' => $tree->name()]); |
||
| 101 | |||
| 102 | /* I18N: search using “sounds like”, rather than exact spelling */ |
||
| 103 | return new Menu(I18N::translate('Phonetic search'), $url, 'menu-search-soundex', ['rel' => 'nofollow']); |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @param Tree $tree |
||
| 108 | * |
||
| 109 | * @return Menu |
||
| 110 | */ |
||
| 111 | protected function menuSearchAdvanced(Tree $tree): Menu |
||
| 112 | { |
||
| 113 | $url = route(SearchAdvancedPage::class, ['tree' => $tree->name()]); |
||
| 114 | |||
| 115 | return new Menu(I18N::translate('Advanced search'), $url, 'menu-search-advanced', ['rel' => 'nofollow']); |
||
| 116 | } |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @param Tree $tree |
||
| 120 | * |
||
| 121 | * @return Menu|null |
||
| 122 | */ |
||
| 123 | protected function menuSearchAndReplace(Tree $tree): Menu|null |
||
| 124 | { |
||
| 125 | if (Auth::isEditor($tree)) { |
||
| 126 | $url = route(SearchReplacePage::class, ['tree' => $tree->name()]); |
||
| 127 | |||
| 128 | return new Menu(I18N::translate('Search and replace'), $url, 'menu-search-replace'); |
||
| 129 | } |
||
| 130 | |||
| 131 | return null; |
||
| 132 | } |
||
| 133 | } |
||
| 134 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths