xref: /webtrees/app/Module/ModuleTabInterface.php (revision 52288ec72a577b9a3a455ccc0f26d11b0df31667)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2022 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
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Module;
21
22use Fisharebest\Webtrees\Individual;
23use Illuminate\Support\Collection;
24use Psr\Http\Message\ResponseInterface;
25use Psr\Http\Message\ServerRequestInterface;
26
27/**
28 * Interface ModuleTabInterface - Classes and libraries for module system
29 */
30interface ModuleTabInterface extends ModuleInterface
31{
32    /**
33     * The text that appears on the tab.
34     *
35     * @return string
36     */
37    public function tabTitle(): string;
38
39    /**
40     * Users change change the order of tabs using the control panel.
41     *
42     * @param int $tab_order
43     *
44     * @return void
45     */
46    public function setTabOrder(int $tab_order): void;
47
48    /**
49     * Users change change the order of tabs using the control panel.
50     *
51     * @return int
52     */
53    public function getTabOrder(): int;
54
55    /**
56     * The default position for this tab.  It can be changed in the control panel.
57     *
58     * @return int
59     */
60    public function defaultTabOrder(): int;
61
62    /**
63     * Generate the HTML content of this tab.
64     *
65     * @param Individual $individual
66     *
67     * @return string
68     */
69    public function getTabContent(Individual $individual): string;
70
71    /**
72     * Is this tab empty? If so, we don't always need to display it.
73     *
74     * @param Individual $individual
75     *
76     * @return bool
77     */
78    public function hasTabContent(Individual $individual): bool;
79
80    /**
81     * Can this tab load asynchronously?
82     *
83     * @return bool
84     */
85    public function canLoadAjax(): bool;
86
87    /**
88     * A greyed out tab has no actual content, but may perhaps have
89     * options to create content.
90     *
91     * @param Individual $individual
92     *
93     * @return bool
94     */
95    public function isGrayedOut(Individual $individual): bool;
96
97    /**
98     * This module handles the following facts - so don't show them on the "Facts and events" tab.
99     *
100     * @return Collection<int,string>
101     */
102    public function supportedFacts(): Collection;
103
104    /**
105     * Generate an AJAX response for a tab.
106     *
107     * @param ServerRequestInterface $request
108     *
109     * @return ResponseInterface
110     */
111    public function getTabAction(ServerRequestInterface $request): ResponseInterface;
112}
113