xref: /webtrees/app/Elements/WhereWithinSource.php (revision d5d34b5baea2eb070f63374a3564d16830d894a0)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2021 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\Elements;
21
22use Fisharebest\Webtrees\Http\RequestHandlers\AutoCompleteCitation;
23use Fisharebest\Webtrees\Registry;
24use Fisharebest\Webtrees\Tree;
25
26use function e;
27use function route;
28
29/**
30 * WHERE_WITHIN_SOURCE := {Size=1:248}
31 * Specific location with in the information referenced. For a published work, this could include
32 * the volume of a multi-volume work and the page number(s). For a periodical, it could include
33 * volume, issue, and page numbers. For a newspaper, it could include a column number and page
34 * number. For an unpublished source or microfilmed works, this could be a film or sheet number,
35 * page number, frame number, etc. A census record might have an enumerating district, page number,
36 * line number, dwelling number, and family number. The data in this field should be in the form of
37 * a label and value pair, such as Label1: value, Label2: value, with each pair being separated by
38 * a comma. For example, Film: 1234567, Frame: 344, Line: 28.
39 */
40class WhereWithinSource extends AbstractElement
41{
42    /**
43     * An edit control for this data.
44     *
45     * @param string $id
46     * @param string $name
47     * @param string $value
48     * @param Tree   $tree
49     *
50     * @return string
51     */
52    public function edit(string $id, string $name, string $value, Tree $tree): string
53    {
54        return '<input data-autocomplete-url="' . e(route(AutoCompleteCitation::class, ['tree' => $tree->name()])) . '" data-autocomplete-extra="SOUR" autocomplete="off" class="form-control" type="text" id="' . e($id) . '" name="' . e($name) . '" value="' . e($value) . '" />';
55    }
56
57    /**
58     * Display the value of this type of element.
59     *
60     * @param string $value
61     * @param Tree   $tree
62     *
63     * @return string
64     */
65    public function value(string $value, Tree $tree): string
66    {
67        return $this->valueAutoLink($value);
68    }
69}
70