1*46295629SGreg Roach<?php 2*46295629SGreg Roach/** 3*46295629SGreg Roach * webtrees: online genealogy 4*46295629SGreg Roach * Copyright (C) 2019 webtrees development team 5*46295629SGreg Roach * This program is free software: you can redistribute it and/or modify 6*46295629SGreg Roach * it under the terms of the GNU General Public License as published by 7*46295629SGreg Roach * the Free Software Foundation, either version 3 of the License, or 8*46295629SGreg Roach * (at your option) any later version. 9*46295629SGreg Roach * This program is distributed in the hope that it will be useful, 10*46295629SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 11*46295629SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12*46295629SGreg Roach * GNU General Public License for more details. 13*46295629SGreg Roach * You should have received a copy of the GNU General Public License 14*46295629SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 15*46295629SGreg Roach */ 16*46295629SGreg Roachdeclare(strict_types=1); 17*46295629SGreg Roach 18*46295629SGreg Roachnamespace Fisharebest\Webtrees\Module; 19*46295629SGreg Roach 20*46295629SGreg Roachuse Fisharebest\Webtrees\I18N; 21*46295629SGreg Roachuse Fisharebest\Webtrees\Menu; 22*46295629SGreg Roachuse Fisharebest\Webtrees\Tree; 23*46295629SGreg Roach 24*46295629SGreg Roach/** 25*46295629SGreg Roach * Class CalendarMenuModule - provide a menu option for the calendar 26*46295629SGreg Roach */ 27*46295629SGreg Roachclass CalendarMenuModule extends AbstractModule implements ModuleInterface, ModuleMenuInterface 28*46295629SGreg Roach{ 29*46295629SGreg Roach use ModuleMenuTrait; 30*46295629SGreg Roach 31*46295629SGreg Roach /** {@inheritdoc} */ 32*46295629SGreg Roach public function title(): string 33*46295629SGreg Roach { 34*46295629SGreg Roach /* I18N: Name of a module */ 35*46295629SGreg Roach return I18N::translate('Calendar'); 36*46295629SGreg Roach } 37*46295629SGreg Roach 38*46295629SGreg Roach /** {@inheritdoc} */ 39*46295629SGreg Roach public function description(): string 40*46295629SGreg Roach { 41*46295629SGreg Roach /* I18N: Description of the “Reports” module */ 42*46295629SGreg Roach return I18N::translate('The calendar menu.'); 43*46295629SGreg Roach } 44*46295629SGreg Roach 45*46295629SGreg Roach /** 46*46295629SGreg Roach * The default position for this menu. It can be changed in the control panel. 47*46295629SGreg Roach * 48*46295629SGreg Roach * @return int 49*46295629SGreg Roach */ 50*46295629SGreg Roach public function defaultMenuOrder(): int 51*46295629SGreg Roach { 52*46295629SGreg Roach return 40; 53*46295629SGreg Roach } 54*46295629SGreg Roach 55*46295629SGreg Roach /** 56*46295629SGreg Roach * A menu, to be added to the main application menu. 57*46295629SGreg Roach * 58*46295629SGreg Roach * @param Tree $tree 59*46295629SGreg Roach * 60*46295629SGreg Roach * @return Menu|null 61*46295629SGreg Roach */ 62*46295629SGreg Roach public function getMenu(Tree $tree): ?Menu 63*46295629SGreg Roach { 64*46295629SGreg Roach $submenu = [ 65*46295629SGreg Roach $this->calendarDayMenu($tree), 66*46295629SGreg Roach $this->calendarMonthMenu($tree), 67*46295629SGreg Roach $this->calendarYearMenu($tree), 68*46295629SGreg Roach ]; 69*46295629SGreg Roach 70*46295629SGreg Roach return new Menu(I18N::translate('Calendar'), '#', 'menu-calendar', ['rel' => 'nofollow'], $submenu); 71*46295629SGreg Roach } 72*46295629SGreg Roach 73*46295629SGreg Roach /** 74*46295629SGreg Roach * @param Tree $tree 75*46295629SGreg Roach * 76*46295629SGreg Roach * @return Menu 77*46295629SGreg Roach */ 78*46295629SGreg Roach protected function calendarDayMenu(Tree $tree): Menu 79*46295629SGreg Roach { 80*46295629SGreg Roach return new Menu(I18N::translate('Day'), route('calendar', [ 81*46295629SGreg Roach 'view' => 'day', 82*46295629SGreg Roach 'ged' => $tree->name(), 83*46295629SGreg Roach ]), 'menu-calendar-day', ['rel' => 'nofollow']); 84*46295629SGreg Roach } 85*46295629SGreg Roach 86*46295629SGreg Roach /** 87*46295629SGreg Roach * @param Tree $tree 88*46295629SGreg Roach * 89*46295629SGreg Roach * @return Menu 90*46295629SGreg Roach */ 91*46295629SGreg Roach protected function calendarMonthMenu(Tree $tree): Menu 92*46295629SGreg Roach { 93*46295629SGreg Roach return new Menu(I18N::translate('Month'), route('calendar', [ 94*46295629SGreg Roach 'view' => 'day', 95*46295629SGreg Roach 'ged' => $tree->name(), 96*46295629SGreg Roach ]), 'menu-calendar-month', ['rel' => 'nofollow']); 97*46295629SGreg Roach } 98*46295629SGreg Roach 99*46295629SGreg Roach /** 100*46295629SGreg Roach * @param Tree $tree 101*46295629SGreg Roach * 102*46295629SGreg Roach * @return Menu 103*46295629SGreg Roach */ 104*46295629SGreg Roach protected function calendarYearMenu(Tree $tree): Menu 105*46295629SGreg Roach { 106*46295629SGreg Roach return new Menu(I18N::translate('Year'), route('calendar', [ 107*46295629SGreg Roach 'view' => 'day', 108*46295629SGreg Roach 'ged' => $tree->name(), 109*46295629SGreg Roach ]), 'menu-calendar-year', ['rel' => 'nofollow']); 110*46295629SGreg Roach } 111*46295629SGreg Roach} 112