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