xref: /webtrees/app/Module/ModuleTabInterface.php (revision d11be7027e34e3121be11cc025421873364403f9)
1a25f0a04SGreg Roach<?php
23976b470SGreg Roach
3a25f0a04SGreg Roach/**
4a25f0a04SGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6a25f0a04SGreg Roach * This program is free software: you can redistribute it and/or modify
7a25f0a04SGreg Roach * it under the terms of the GNU General Public License as published by
8a25f0a04SGreg Roach * the Free Software Foundation, either version 3 of the License, or
9a25f0a04SGreg Roach * (at your option) any later version.
10a25f0a04SGreg Roach * This program is distributed in the hope that it will be useful,
11a25f0a04SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12a25f0a04SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13a25f0a04SGreg Roach * GNU General Public License for more details.
14a25f0a04SGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
16a25f0a04SGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
2076692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module;
21c1010edaSGreg Roach
22225e381fSGreg Roachuse Fisharebest\Webtrees\Individual;
238eaf8709SGreg Roachuse Illuminate\Support\Collection;
24852ede8cSGreg Roachuse Psr\Http\Message\ResponseInterface;
25852ede8cSGreg Roachuse Psr\Http\Message\ServerRequestInterface;
26a25f0a04SGreg Roach
27a25f0a04SGreg Roach/**
28a25f0a04SGreg Roach * Interface ModuleTabInterface - Classes and libraries for module system
29a25f0a04SGreg Roach */
3037eb8894SGreg Roachinterface ModuleTabInterface extends ModuleInterface
31c1010edaSGreg Roach{
3239402588SGreg Roach    /**
3339402588SGreg Roach     * The text that appears on the tab.
3439402588SGreg Roach     *
3539402588SGreg Roach     * @return string
3639402588SGreg Roach     */
37defb8071SRichard Cissée    public function tabTitle(): string;
38defb8071SRichard Cissée
39a25f0a04SGreg Roach    /**
4049a243cbSGreg Roach     * Users change change the order of tabs using the control panel.
4149a243cbSGreg Roach     *
4249a243cbSGreg Roach     * @param int $tab_order
4349a243cbSGreg Roach     *
4449a243cbSGreg Roach     * @return void
4549a243cbSGreg Roach     */
4649a243cbSGreg Roach    public function setTabOrder(int $tab_order): void;
4749a243cbSGreg Roach
4849a243cbSGreg Roach    /**
4949a243cbSGreg Roach     * Users change change the order of tabs using the control panel.
50a25f0a04SGreg Roach     *
51cbc1590aSGreg Roach     * @return int
52a25f0a04SGreg Roach     */
5349a243cbSGreg Roach    public function getTabOrder(): int;
5449a243cbSGreg Roach
5549a243cbSGreg Roach    /**
5649a243cbSGreg Roach     * The default position for this tab.  It can be changed in the control panel.
5749a243cbSGreg Roach     *
5849a243cbSGreg Roach     * @return int
5949a243cbSGreg Roach     */
60c1afbf58SGreg Roach    public function defaultTabOrder(): int;
61a25f0a04SGreg Roach
62a25f0a04SGreg Roach    /**
63a25f0a04SGreg Roach     * Generate the HTML content of this tab.
64a25f0a04SGreg Roach     *
65225e381fSGreg Roach     * @param Individual $individual
66225e381fSGreg Roach     *
67a25f0a04SGreg Roach     * @return string
68a25f0a04SGreg Roach     */
698f53f488SRico Sonntag    public function getTabContent(Individual $individual): string;
70a25f0a04SGreg Roach
71a25f0a04SGreg Roach    /**
72a25f0a04SGreg Roach     * Is this tab empty? If so, we don't always need to display it.
73cbc1590aSGreg Roach     *
74225e381fSGreg Roach     * @param Individual $individual
75225e381fSGreg Roach     *
76cbc1590aSGreg Roach     * @return bool
77a25f0a04SGreg Roach     */
788f53f488SRico Sonntag    public function hasTabContent(Individual $individual): bool;
79a25f0a04SGreg Roach
80a25f0a04SGreg Roach    /**
81a25f0a04SGreg Roach     * Can this tab load asynchronously?
82a25f0a04SGreg Roach     *
83cbc1590aSGreg Roach     * @return bool
84a25f0a04SGreg Roach     */
858f53f488SRico Sonntag    public function canLoadAjax(): bool;
86a25f0a04SGreg Roach
87a25f0a04SGreg Roach    /**
88a25f0a04SGreg Roach     * A greyed out tab has no actual content, but may perhaps have
89a25f0a04SGreg Roach     * options to create content.
90a25f0a04SGreg Roach     *
91225e381fSGreg Roach     * @param Individual $individual
92225e381fSGreg Roach     *
93cbc1590aSGreg Roach     * @return bool
94a25f0a04SGreg Roach     */
958f53f488SRico Sonntag    public function isGrayedOut(Individual $individual): bool;
968eaf8709SGreg Roach
978eaf8709SGreg Roach    /**
988eaf8709SGreg Roach     * This module handles the following facts - so don't show them on the "Facts and events" tab.
998eaf8709SGreg Roach     *
10036779af1SGreg Roach     * @return Collection<int,string>
1018eaf8709SGreg Roach     */
1028eaf8709SGreg Roach    public function supportedFacts(): Collection;
103852ede8cSGreg Roach
104852ede8cSGreg Roach    /**
105852ede8cSGreg Roach     * Generate an AJAX response for a tab.
106852ede8cSGreg Roach     *
107852ede8cSGreg Roach     * @param ServerRequestInterface $request
108852ede8cSGreg Roach     *
109852ede8cSGreg Roach     * @return ResponseInterface
110852ede8cSGreg Roach     */
111852ede8cSGreg Roach    public function getTabAction(ServerRequestInterface $request): ResponseInterface;
112a25f0a04SGreg Roach}
113