forked from fisharebest/webtrees
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inverselink.php
149 lines (135 loc) · 5.44 KB
/
inverselink.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/**
* webtrees: online genealogy
* Copyright (C) 2017 webtrees development team
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Fisharebest\Webtrees;
use Fisharebest\Webtrees\Controller\SimpleController;
/** @global Tree $WT_TREE */
global $WT_TREE;
require 'includes/session.php';
$controller = new SimpleController;
$controller
->restrictAccess(Auth::isEditor($WT_TREE))
->setPageTitle(I18N::translate('Link to an existing media object'))
->pageHeader();
//-- page parameters and checking
$linktoid = Filter::get('linktoid', WT_REGEX_XREF);
$mediaid = Filter::get('mediaid', WT_REGEX_XREF);
$linkto = Filter::get('linkto', 'person|source|family|manage|repository|note');
$action = Filter::get('action', 'choose|update', 'choose');
// If GedFAct_assistant/_MEDIA/ installed ======================
if ($linkto == 'manage' && Module::getModuleByName('GEDFact_assistant')) {
require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/_MEDIA/media_0_inverselink.php';
} else {
//-- check for admin
$paramok = true;
if (!empty($linktoid)) {
$paramok = GedcomRecord::getInstance($linktoid, $WT_TREE)->canShow();
}
if ($action == 'choose' && $paramok) {
echo '<form name="link" action="inverselink.php">';
echo '<input type="hidden" name="action" value="update">';
if (!empty($mediaid)) {
echo '<input type="hidden" name="mediaid" value="', $mediaid, '">';
}
if (!empty($linktoid)) {
echo '<input type="hidden" name="linktoid" value="', $linktoid, '">';
}
echo '<input type="hidden" name="linkto" value="', $linkto, '">';
echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">';
echo '<table class="table wt-facts-table">';
echo '<tr><td class="topbottombar" colspan="2">';
echo I18N::translate('Link to an existing media object');
echo '</td></tr><tr><th scope="row">', I18N::translate('Media'), '</th>';
echo '<td class="optionbox wrap">';
if (!empty($mediaid)) {
//-- Get the title of this existing Media item
$title =
Database::prepare("SELECT m_titl FROM `##media` where m_id=? AND m_file=?")
->execute([$mediaid, $WT_TREE->getTreeId()])
->fetchOne();
if ($title) {
echo '<b>', Html::escape($title), '</b>';
} else {
echo '<b>', $mediaid, '</b>';
}
} else {
echo '<input data-autocomplete-type="OBJE" type="text" name="mediaid" id="mediaid" size="5">';
echo '</td></tr>';
}
if (!isset($linktoid)) {
$linktoid = '';
}
echo '<tr><th scope="row">';
if ($linkto === 'person') {
echo I18N::translate('Individual'), '</th>';
echo '<td>';
if ($linktoid == '') {
echo '<input class="pedigree_form" type="text" name="linktoid" id="linktopid" size="3" value="', $linktoid, '"> ';
} else {
$record = Individual::getInstance($linktoid, $WT_TREE);
echo $record->formatList('span', false, $record->getFullName());
}
}
if ($linkto === 'family') {
echo I18N::translate('Family'), '</th>';
echo '<td>';
if ($linktoid == '') {
echo '<input class="pedigree_form" type="text" name="linktoid" id="linktofamid" size="3" value="', $linktoid, '"> ';
} else {
$record = Family::getInstance($linktoid, $WT_TREE);
echo $record->formatList('span', false, $record->getFullName());
}
}
if ($linkto === 'source') {
echo I18N::translate('Source'), '</th>';
echo '<td>';
if ($linktoid == '') {
echo '<input class="pedigree_form" type="text" name="linktoid" id="linktosid" size="3" value="', $linktoid, '"> ';
} else {
$record = Source::getInstance($linktoid, $WT_TREE);
echo $record->formatList('span', false, $record->getFullName());
}
}
if ($linkto === 'repository') {
echo I18N::translate('Repository'), '</th>';
echo '<td>';
if ($linktoid == '') {
echo '<input class="pedigree_form" type="text" name="linktoid" id="linktorid" size="3" value="', $linktoid, '">';
} else {
$record = Repository::getInstance($linktoid, $WT_TREE);
echo $record->formatList('span', false, $record->getFullName());
}
}
if ($linkto === 'note') {
echo I18N::translate('Shared note'), '</th>';
echo '<td>';
if ($linktoid == '') {
echo '<input class="pedigree_form" type="text" name="linktoid" id="linktonid" size="3" value="', $linktoid, '">';
} else {
$record = Note::getInstance($linktoid, $WT_TREE);
echo $record->formatList('span', false, $record->getFullName());
}
}
echo '</td></tr>';
echo '<tr><td class="topbottombar" colspan="2"><input type="submit" value="', /* I18N: A button label (a verb). */ I18N::translate('link'), '"></td></tr>';
echo '</table>';
echo '</form>';
} elseif ($action == 'update' && $paramok) {
$record = GedcomRecord::getInstance($linktoid, $WT_TREE);
$record->createFact('1 OBJE @' . $mediaid . '@', true);
$controller->addInlineJavascript('closePopupAndReloadParent();');
}
echo '<button onclick="closePopupAndReloadParent();">', I18N::translate('close'), '</button>';
}