xref: /webtrees/app/Report/ReportBaseFootnote.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\Report;
21a25f0a04SGreg Roach
22dec352c1SGreg Roachuse function str_contains;
23b6f35a76SGreg Roach
24a25f0a04SGreg Roach/**
25a25f0a04SGreg Roach * Class ReportBaseFootnote
26a25f0a04SGreg Roach */
27c1010edaSGreg Roachclass ReportBaseFootnote extends ReportBaseElement
28c1010edaSGreg Roach{
2977bab461SGreg Roach    // The name of the style for this element
3077bab461SGreg Roach    public string $styleName = '';
3177bab461SGreg Roach
3277bab461SGreg Roach    // Numbers for the links
3377bab461SGreg Roach    public int $num;
3477bab461SGreg Roach
3577bab461SGreg Roach    // The text that will be printed with the number
3677bab461SGreg Roach    public string $numText = '';
3777bab461SGreg Roach
3877bab461SGreg Roach    // Remaining width of a cell
3977bab461SGreg Roach    public float $wrapWidthRemaining;
4077bab461SGreg Roach
4177bab461SGreg Roach    // Original width of a cell (points)
4277bab461SGreg Roach    public float $wrapWidthCell;
4377bab461SGreg Roach
4477bab461SGreg Roach    // A link
4577bab461SGreg Roach    public string $addlink;
46a25f0a04SGreg Roach
47a25f0a04SGreg Roach    /**
4877bab461SGreg Roach     * Create an element.
4976692c8bSGreg Roach     *
50a25f0a04SGreg Roach     * @param string $style
51a25f0a04SGreg Roach     */
5277bab461SGreg Roach    public function __construct(string $style = '')
53c1010edaSGreg Roach    {
547a6ee1acSGreg Roach        $this->text = '';
5577bab461SGreg Roach        if ($style !== '') {
56a25f0a04SGreg Roach            $this->styleName = $style;
57a25f0a04SGreg Roach        } else {
587a6ee1acSGreg Roach            $this->styleName = 'footnote';
59a25f0a04SGreg Roach        }
60a25f0a04SGreg Roach    }
61a25f0a04SGreg Roach
62a25f0a04SGreg Roach    /**
6376692c8bSGreg Roach     * Set the width to wrap text.
6476692c8bSGreg Roach     *
65c21bdddcSGreg Roach     * @param float $wrapwidth
66c21bdddcSGreg Roach     * @param float $cellwidth
67a25f0a04SGreg Roach     *
68589feda3SGreg Roach     * @return float
69a25f0a04SGreg Roach     */
70c21bdddcSGreg Roach    public function setWrapWidth(float $wrapwidth, float $cellwidth): float
71c1010edaSGreg Roach    {
72a25f0a04SGreg Roach        $this->wrapWidthCell = $cellwidth;
73dec352c1SGreg Roach        if (str_contains($this->numText, "\n")) {
74a25f0a04SGreg Roach            $this->wrapWidthRemaining = $cellwidth;
75a25f0a04SGreg Roach        } else {
76a25f0a04SGreg Roach            $this->wrapWidthRemaining = $wrapwidth;
77a25f0a04SGreg Roach        }
78a25f0a04SGreg Roach
79a25f0a04SGreg Roach        return $this->wrapWidthRemaining;
80a25f0a04SGreg Roach    }
81a25f0a04SGreg Roach
82a25f0a04SGreg Roach    /**
8376692c8bSGreg Roach     * Set the number.
8476692c8bSGreg Roach     *
85c21bdddcSGreg Roach     * @param int $n
86a25f0a04SGreg Roach     *
87589feda3SGreg Roach     * @return void
88a25f0a04SGreg Roach     */
89e364afe4SGreg Roach    public function setNum(int $n): void
90c1010edaSGreg Roach    {
91a25f0a04SGreg Roach        $this->num     = $n;
92e364afe4SGreg Roach        $this->numText = $n . ' ';
93a25f0a04SGreg Roach    }
94a25f0a04SGreg Roach
95a25f0a04SGreg Roach    /**
9676692c8bSGreg Roach     * Add a link.
9776692c8bSGreg Roach     *
98c21bdddcSGreg Roach     * @param string $a
99a25f0a04SGreg Roach     *
100589feda3SGreg Roach     * @return void
101a25f0a04SGreg Roach     */
10277bab461SGreg Roach    public function setAddlink(string $a): void
103c1010edaSGreg Roach    {
104a25f0a04SGreg Roach        $this->addlink = $a;
105a25f0a04SGreg Roach    }
106a25f0a04SGreg Roach}
107