Completed
Push — 1.7 ( ec97c0...420789 )
by
unknown
07:31
created
admin_trees_renumber.php 2 patches
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -29,259 +29,259 @@
 block discarded – undo
29 29
 
30 30
 $controller = new PageController;
31 31
 $controller
32
-	->restrictAccess(Auth::isManager($WT_TREE))
33
-	->setPageTitle(I18N::translate(/* I18N: Renumber the records in a family tree */ 'Renumber family tree') . ' — ' . $WT_TREE->getTitleHtml())
34
-	->pageHeader();
32
+    ->restrictAccess(Auth::isManager($WT_TREE))
33
+    ->setPageTitle(I18N::translate(/* I18N: Renumber the records in a family tree */ 'Renumber family tree') . ' — ' . $WT_TREE->getTitleHtml())
34
+    ->pageHeader();
35 35
 
36 36
 // Every XREF used by this tree and also used by some other tree
37 37
 $xrefs = Database::prepare(
38
-	"SELECT xref, type FROM (" .
39
-	" SELECT i_id AS xref, 'INDI' AS type FROM `##individuals` WHERE i_file = ?" .
40
-	"  UNION " .
41
-	" SELECT f_id AS xref, 'FAM' AS type FROM `##families` WHERE f_file = ?" .
42
-	"  UNION " .
43
-	" SELECT s_id AS xref, 'SOUR' AS type FROM `##sources` WHERE s_file = ?" .
44
-	"  UNION " .
45
-	" SELECT m_id AS xref, 'OBJE' AS type FROM `##media` WHERE m_file = ?" .
46
-	"  UNION " .
47
-	" SELECT o_id AS xref, o_type AS type FROM `##other` WHERE o_file = ? AND o_type NOT IN ('HEAD', 'TRLR')" .
48
-	") AS this_tree JOIN (" .
49
-	" SELECT xref FROM `##change` WHERE gedcom_id <> ?" .
50
-	"  UNION " .
51
-	" SELECT i_id AS xref FROM `##individuals` WHERE i_file <> ?" .
52
-	"  UNION " .
53
-	" SELECT f_id AS xref FROM `##families` WHERE f_file <> ?" .
54
-	"  UNION " .
55
-	" SELECT s_id AS xref FROM `##sources` WHERE s_file <> ?" .
56
-	"  UNION " .
57
-	" SELECT m_id AS xref FROM `##media` WHERE m_file <> ?" .
58
-	"  UNION " .
59
-	" SELECT o_id AS xref FROM `##other` WHERE o_file <> ? AND o_type NOT IN ('HEAD', 'TRLR')" .
60
-	") AS other_trees USING (xref)"
38
+    "SELECT xref, type FROM (" .
39
+    " SELECT i_id AS xref, 'INDI' AS type FROM `##individuals` WHERE i_file = ?" .
40
+    "  UNION " .
41
+    " SELECT f_id AS xref, 'FAM' AS type FROM `##families` WHERE f_file = ?" .
42
+    "  UNION " .
43
+    " SELECT s_id AS xref, 'SOUR' AS type FROM `##sources` WHERE s_file = ?" .
44
+    "  UNION " .
45
+    " SELECT m_id AS xref, 'OBJE' AS type FROM `##media` WHERE m_file = ?" .
46
+    "  UNION " .
47
+    " SELECT o_id AS xref, o_type AS type FROM `##other` WHERE o_file = ? AND o_type NOT IN ('HEAD', 'TRLR')" .
48
+    ") AS this_tree JOIN (" .
49
+    " SELECT xref FROM `##change` WHERE gedcom_id <> ?" .
50
+    "  UNION " .
51
+    " SELECT i_id AS xref FROM `##individuals` WHERE i_file <> ?" .
52
+    "  UNION " .
53
+    " SELECT f_id AS xref FROM `##families` WHERE f_file <> ?" .
54
+    "  UNION " .
55
+    " SELECT s_id AS xref FROM `##sources` WHERE s_file <> ?" .
56
+    "  UNION " .
57
+    " SELECT m_id AS xref FROM `##media` WHERE m_file <> ?" .
58
+    "  UNION " .
59
+    " SELECT o_id AS xref FROM `##other` WHERE o_file <> ? AND o_type NOT IN ('HEAD', 'TRLR')" .
60
+    ") AS other_trees USING (xref)"
61 61
 )->execute(array(
62
-	$WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(),
63
-	$WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(),
62
+    $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(),
63
+    $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(),
64 64
 ))->fetchAssoc();
65 65
 
66 66
 echo '<h1>', $controller->getPageTitle(), '</h1>';
67 67
 
68 68
 if (Filter::get('action') === 'renumber') {
69
-	foreach ($xrefs as $old_xref => $type) {
70
-		Database::beginTransaction();
71
-		Database::exec(
72
-			"LOCK TABLE `##individuals` WRITE," .
73
-			" `##families` WRITE," .
74
-			" `##sources` WRITE," .
75
-			" `##media` WRITE," .
76
-			" `##other` WRITE," .
77
-			" `##name` WRITE," .
78
-			" `##placelinks` WRITE," .
79
-			" `##change` WRITE," .
80
-			" `##next_id` WRITE," .
81
-			" `##dates` WRITE," .
82
-			" `##default_resn` WRITE," .
83
-			" `##hit_counter` WRITE," .
84
-			" `##link` WRITE," .
85
-			" `##user_gedcom_setting` WRITE"
86
-		);
87
-		$new_xref = $WT_TREE->getNewXref($type);
88
-		switch ($type) {
89
-		case 'INDI':
90
-			Database::prepare(
91
-				"UPDATE `##individuals` SET i_id = ?, i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_id = ? AND i_file = ?"
92
-			)->execute(array($new_xref, "0 @$old_xref@ INDI\n", "0 @$new_xref@ INDI\n", $old_xref, $WT_TREE->getTreeId()));
93
-			Database::prepare(
94
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'HUSB') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
95
-			)->execute(array($old_xref, " HUSB @$old_xref@", " HUSB @$new_xref@", $WT_TREE->getTreeId()));
96
-			Database::prepare(
97
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'WIFE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
98
-			)->execute(array($old_xref, " WIFE @$old_xref@", " WIFE @$new_xref@", $WT_TREE->getTreeId()));
99
-			Database::prepare(
100
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'CHIL') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
101
-			)->execute(array($old_xref, " CHIL @$old_xref@", " CHIL @$new_xref@", $WT_TREE->getTreeId()));
102
-			Database::prepare(
103
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'ASSO') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
104
-			)->execute(array($old_xref, " ASSO @$old_xref@", " ASSO @$new_xref@", $WT_TREE->getTreeId()));
105
-			Database::prepare(
106
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = '_ASSO') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
107
-			)->execute(array($old_xref, " _ASSO @$old_xref@", " _ASSO @$new_xref@", $WT_TREE->getTreeId()));
108
-			Database::prepare(
109
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'ASSO') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
110
-			)->execute(array($old_xref, " ASSO @$old_xref@", " ASSO @$new_xref@", $WT_TREE->getTreeId()));
111
-			Database::prepare(
112
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = '_ASSO') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
113
-			)->execute(array($old_xref, " _ASSO @$old_xref@", " _ASSO @$new_xref@", $WT_TREE->getTreeId()));
114
-			Database::prepare(
115
-				"UPDATE `##placelinks` SET pl_gid = ? WHERE pl_gid = ? AND pl_file = ?"
116
-			)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
117
-			Database::prepare(
118
-				"UPDATE `##dates` SET d_gid = ? WHERE d_gid = ? AND d_file = ?"
119
-			)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
120
-			Database::prepare(
121
-				"UPDATE `##user_gedcom_setting` SET setting_value = ? WHERE setting_value = ? AND gedcom_id = ? AND setting_name IN ('gedcomid', 'rootid')"
122
-			)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
123
-			break;
124
-		case 'FAM':
125
-			Database::prepare(
126
-				"UPDATE `##families` SET f_id = ?, f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_id = ? AND f_file = ?"
127
-			)->execute(array($new_xref, "0 @$old_xref@ FAM\n", "0 @$new_xref@ FAM\n", $old_xref, $WT_TREE->getTreeId()));
128
-			Database::prepare(
129
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'FAMC') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
130
-			)->execute(array($old_xref, " FAMC @$old_xref@", " FAMC @$new_xref@", $WT_TREE->getTreeId()));
131
-			Database::prepare(
132
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'FAMS') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
133
-			)->execute(array($old_xref, " FAMS @$old_xref@", " FAMS @$new_xref@", $WT_TREE->getTreeId()));
134
-			Database::prepare(
135
-				"UPDATE `##placelinks` SET pl_gid = ? WHERE pl_gid = ? AND pl_file = ?"
136
-			)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
137
-			Database::prepare(
138
-				"UPDATE `##dates` SET d_gid = ? WHERE d_gid = ? AND d_file = ?"
139
-			)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
140
-			break;
141
-		case 'SOUR':
142
-			Database::prepare(
143
-				"UPDATE `##sources` SET s_id = ?, s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_id = ? AND s_file = ?"
144
-			)->execute(array($new_xref, "0 @$old_xref@ SOUR\n", "0 @$new_xref@ SOUR\n", $old_xref, $WT_TREE->getTreeId()));
145
-			Database::prepare(
146
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'SOUR') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
147
-			)->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
148
-			Database::prepare(
149
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'SOUR') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
150
-			)->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
151
-			Database::prepare(
152
-				"UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ? AND l_type = 'SOUR') SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
153
-			)->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
154
-			Database::prepare(
155
-				"UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ? AND l_type = 'SOUR') SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
156
-			)->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
157
-			break;
158
-		case 'REPO':
159
-			Database::prepare(
160
-				"UPDATE `##other` SET o_id = ?, o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_id = ? AND o_file = ?"
161
-			)->execute(array($new_xref, "0 @$old_xref@ REPO\n", "0 @$new_xref@ REPO\n", $old_xref, $WT_TREE->getTreeId()));
162
-			Database::prepare(
163
-				"UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ? AND l_type = 'REPO') SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
164
-			)->execute(array($old_xref, " REPO @$old_xref@", " REPO @$new_xref@", $WT_TREE->getTreeId()));
165
-			break;
166
-		case 'NOTE':
167
-			Database::prepare(
168
-				"UPDATE `##other` SET o_id = ?, o_gedcom = REPLACE(REPLACE(o_gedcom, ?, ?), ?, ?) WHERE o_id = ? AND o_file = ?"
169
-			)->execute(array($new_xref, "0 @$old_xref@ NOTE\n", "0 @$new_xref@ NOTE\n", "0 @$old_xref@ NOTE ", "0 @$new_xref@ NOTE ", $old_xref, $WT_TREE->getTreeId()));
170
-			Database::prepare(
171
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'NOTE') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
172
-			)->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
173
-			Database::prepare(
174
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'NOTE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
175
-			)->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
176
-			Database::prepare(
177
-				"UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ? AND l_type = 'NOTE') SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
178
-			)->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
179
-			Database::prepare(
180
-				"UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ? AND l_type = 'NOTE') SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
181
-			)->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
182
-			Database::prepare(
183
-				"UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ? AND l_type = 'NOTE') SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
184
-			)->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
185
-			break;
186
-		case 'OBJE':
187
-			Database::prepare(
188
-				"UPDATE `##media` SET m_id = ?, m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_id = ? AND m_file = ?"
189
-			)->execute(array($new_xref, "0 @$old_xref@ OBJE\n", "0 @$new_xref@ OBJE\n", $old_xref, $WT_TREE->getTreeId()));
190
-			Database::prepare(
191
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'OBJE') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
192
-			)->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
193
-			Database::prepare(
194
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'OBJE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
195
-			)->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
196
-			Database::prepare(
197
-				"UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ? AND l_type = 'OBJE') SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
198
-			)->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
199
-			Database::prepare(
200
-				"UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ? AND l_type = 'OBJE') SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
201
-			)->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
202
-			Database::prepare(
203
-				"UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ? AND l_type = 'OBJE') SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
204
-			)->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
205
-			break;
206
-		default:
207
-			Database::prepare(
208
-				"UPDATE `##other` SET o_id = ?, o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_id = ? AND o_file = ?"
209
-			)->execute(array($new_xref, "0 @$old_xref@ $type\n", "0 @$new_xref@ $type\n", $old_xref, $WT_TREE->getTreeId()));
210
-			Database::prepare(
211
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ?) SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
212
-			)->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
213
-			Database::prepare(
214
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ?) SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
215
-			)->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
216
-			Database::prepare(
217
-				"UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ?) SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
218
-			)->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
219
-			Database::prepare(
220
-				"UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ?) SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
221
-			)->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
222
-			Database::prepare(
223
-				"UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ?) SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
224
-			)->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
225
-			break;
226
-		}
227
-		Database::prepare(
228
-			"UPDATE `##name` SET n_id = ? WHERE n_id = ? AND n_file = ?"
229
-		)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
230
-		Database::prepare(
231
-			"UPDATE `##default_resn` SET xref = ? WHERE xref = ? AND gedcom_id = ?"
232
-		)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
233
-		Database::prepare(
234
-			"UPDATE `##hit_counter` SET page_parameter = ? WHERE page_parameter = ? AND gedcom_id = ?"
235
-		)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
236
-		Database::prepare(
237
-			"UPDATE `##link` SET l_from = ? WHERE l_from = ? AND l_file = ?"
238
-		)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
239
-		Database::prepare(
240
-			"UPDATE `##link` SET l_to = ? WHERE l_to = ? AND l_file = ?"
241
-		)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
242
-		echo '<p>', I18N::translate('The record %1$s has been renamed to %2$s.', $old_xref, $new_xref), '</p>';
243
-		unset($xrefs[$old_xref]);
244
-		Database::exec("UNLOCK TABLES");
245
-		Database::commit();
69
+    foreach ($xrefs as $old_xref => $type) {
70
+        Database::beginTransaction();
71
+        Database::exec(
72
+            "LOCK TABLE `##individuals` WRITE," .
73
+            " `##families` WRITE," .
74
+            " `##sources` WRITE," .
75
+            " `##media` WRITE," .
76
+            " `##other` WRITE," .
77
+            " `##name` WRITE," .
78
+            " `##placelinks` WRITE," .
79
+            " `##change` WRITE," .
80
+            " `##next_id` WRITE," .
81
+            " `##dates` WRITE," .
82
+            " `##default_resn` WRITE," .
83
+            " `##hit_counter` WRITE," .
84
+            " `##link` WRITE," .
85
+            " `##user_gedcom_setting` WRITE"
86
+        );
87
+        $new_xref = $WT_TREE->getNewXref($type);
88
+        switch ($type) {
89
+        case 'INDI':
90
+            Database::prepare(
91
+                "UPDATE `##individuals` SET i_id = ?, i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_id = ? AND i_file = ?"
92
+            )->execute(array($new_xref, "0 @$old_xref@ INDI\n", "0 @$new_xref@ INDI\n", $old_xref, $WT_TREE->getTreeId()));
93
+            Database::prepare(
94
+                "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'HUSB') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
95
+            )->execute(array($old_xref, " HUSB @$old_xref@", " HUSB @$new_xref@", $WT_TREE->getTreeId()));
96
+            Database::prepare(
97
+                "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'WIFE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
98
+            )->execute(array($old_xref, " WIFE @$old_xref@", " WIFE @$new_xref@", $WT_TREE->getTreeId()));
99
+            Database::prepare(
100
+                "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'CHIL') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
101
+            )->execute(array($old_xref, " CHIL @$old_xref@", " CHIL @$new_xref@", $WT_TREE->getTreeId()));
102
+            Database::prepare(
103
+                "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'ASSO') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
104
+            )->execute(array($old_xref, " ASSO @$old_xref@", " ASSO @$new_xref@", $WT_TREE->getTreeId()));
105
+            Database::prepare(
106
+                "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = '_ASSO') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
107
+            )->execute(array($old_xref, " _ASSO @$old_xref@", " _ASSO @$new_xref@", $WT_TREE->getTreeId()));
108
+            Database::prepare(
109
+                "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'ASSO') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
110
+            )->execute(array($old_xref, " ASSO @$old_xref@", " ASSO @$new_xref@", $WT_TREE->getTreeId()));
111
+            Database::prepare(
112
+                "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = '_ASSO') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
113
+            )->execute(array($old_xref, " _ASSO @$old_xref@", " _ASSO @$new_xref@", $WT_TREE->getTreeId()));
114
+            Database::prepare(
115
+                "UPDATE `##placelinks` SET pl_gid = ? WHERE pl_gid = ? AND pl_file = ?"
116
+            )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
117
+            Database::prepare(
118
+                "UPDATE `##dates` SET d_gid = ? WHERE d_gid = ? AND d_file = ?"
119
+            )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
120
+            Database::prepare(
121
+                "UPDATE `##user_gedcom_setting` SET setting_value = ? WHERE setting_value = ? AND gedcom_id = ? AND setting_name IN ('gedcomid', 'rootid')"
122
+            )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
123
+            break;
124
+        case 'FAM':
125
+            Database::prepare(
126
+                "UPDATE `##families` SET f_id = ?, f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_id = ? AND f_file = ?"
127
+            )->execute(array($new_xref, "0 @$old_xref@ FAM\n", "0 @$new_xref@ FAM\n", $old_xref, $WT_TREE->getTreeId()));
128
+            Database::prepare(
129
+                "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'FAMC') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
130
+            )->execute(array($old_xref, " FAMC @$old_xref@", " FAMC @$new_xref@", $WT_TREE->getTreeId()));
131
+            Database::prepare(
132
+                "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'FAMS') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
133
+            )->execute(array($old_xref, " FAMS @$old_xref@", " FAMS @$new_xref@", $WT_TREE->getTreeId()));
134
+            Database::prepare(
135
+                "UPDATE `##placelinks` SET pl_gid = ? WHERE pl_gid = ? AND pl_file = ?"
136
+            )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
137
+            Database::prepare(
138
+                "UPDATE `##dates` SET d_gid = ? WHERE d_gid = ? AND d_file = ?"
139
+            )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
140
+            break;
141
+        case 'SOUR':
142
+            Database::prepare(
143
+                "UPDATE `##sources` SET s_id = ?, s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_id = ? AND s_file = ?"
144
+            )->execute(array($new_xref, "0 @$old_xref@ SOUR\n", "0 @$new_xref@ SOUR\n", $old_xref, $WT_TREE->getTreeId()));
145
+            Database::prepare(
146
+                "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'SOUR') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
147
+            )->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
148
+            Database::prepare(
149
+                "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'SOUR') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
150
+            )->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
151
+            Database::prepare(
152
+                "UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ? AND l_type = 'SOUR') SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
153
+            )->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
154
+            Database::prepare(
155
+                "UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ? AND l_type = 'SOUR') SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
156
+            )->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
157
+            break;
158
+        case 'REPO':
159
+            Database::prepare(
160
+                "UPDATE `##other` SET o_id = ?, o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_id = ? AND o_file = ?"
161
+            )->execute(array($new_xref, "0 @$old_xref@ REPO\n", "0 @$new_xref@ REPO\n", $old_xref, $WT_TREE->getTreeId()));
162
+            Database::prepare(
163
+                "UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ? AND l_type = 'REPO') SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
164
+            )->execute(array($old_xref, " REPO @$old_xref@", " REPO @$new_xref@", $WT_TREE->getTreeId()));
165
+            break;
166
+        case 'NOTE':
167
+            Database::prepare(
168
+                "UPDATE `##other` SET o_id = ?, o_gedcom = REPLACE(REPLACE(o_gedcom, ?, ?), ?, ?) WHERE o_id = ? AND o_file = ?"
169
+            )->execute(array($new_xref, "0 @$old_xref@ NOTE\n", "0 @$new_xref@ NOTE\n", "0 @$old_xref@ NOTE ", "0 @$new_xref@ NOTE ", $old_xref, $WT_TREE->getTreeId()));
170
+            Database::prepare(
171
+                "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'NOTE') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
172
+            )->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
173
+            Database::prepare(
174
+                "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'NOTE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
175
+            )->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
176
+            Database::prepare(
177
+                "UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ? AND l_type = 'NOTE') SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
178
+            )->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
179
+            Database::prepare(
180
+                "UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ? AND l_type = 'NOTE') SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
181
+            )->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
182
+            Database::prepare(
183
+                "UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ? AND l_type = 'NOTE') SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
184
+            )->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
185
+            break;
186
+        case 'OBJE':
187
+            Database::prepare(
188
+                "UPDATE `##media` SET m_id = ?, m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_id = ? AND m_file = ?"
189
+            )->execute(array($new_xref, "0 @$old_xref@ OBJE\n", "0 @$new_xref@ OBJE\n", $old_xref, $WT_TREE->getTreeId()));
190
+            Database::prepare(
191
+                "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'OBJE') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
192
+            )->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
193
+            Database::prepare(
194
+                "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'OBJE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
195
+            )->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
196
+            Database::prepare(
197
+                "UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ? AND l_type = 'OBJE') SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
198
+            )->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
199
+            Database::prepare(
200
+                "UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ? AND l_type = 'OBJE') SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
201
+            )->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
202
+            Database::prepare(
203
+                "UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ? AND l_type = 'OBJE') SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
204
+            )->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
205
+            break;
206
+        default:
207
+            Database::prepare(
208
+                "UPDATE `##other` SET o_id = ?, o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_id = ? AND o_file = ?"
209
+            )->execute(array($new_xref, "0 @$old_xref@ $type\n", "0 @$new_xref@ $type\n", $old_xref, $WT_TREE->getTreeId()));
210
+            Database::prepare(
211
+                "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ?) SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
212
+            )->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
213
+            Database::prepare(
214
+                "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ?) SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
215
+            )->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
216
+            Database::prepare(
217
+                "UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ?) SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
218
+            )->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
219
+            Database::prepare(
220
+                "UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ?) SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
221
+            )->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
222
+            Database::prepare(
223
+                "UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ?) SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
224
+            )->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
225
+            break;
226
+        }
227
+        Database::prepare(
228
+            "UPDATE `##name` SET n_id = ? WHERE n_id = ? AND n_file = ?"
229
+        )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
230
+        Database::prepare(
231
+            "UPDATE `##default_resn` SET xref = ? WHERE xref = ? AND gedcom_id = ?"
232
+        )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
233
+        Database::prepare(
234
+            "UPDATE `##hit_counter` SET page_parameter = ? WHERE page_parameter = ? AND gedcom_id = ?"
235
+        )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
236
+        Database::prepare(
237
+            "UPDATE `##link` SET l_from = ? WHERE l_from = ? AND l_file = ?"
238
+        )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
239
+        Database::prepare(
240
+            "UPDATE `##link` SET l_to = ? WHERE l_to = ? AND l_file = ?"
241
+        )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
242
+        echo '<p>', I18N::translate('The record %1$s has been renamed to %2$s.', $old_xref, $new_xref), '</p>';
243
+        unset($xrefs[$old_xref]);
244
+        Database::exec("UNLOCK TABLES");
245
+        Database::commit();
246 246
 
247
-		try {
248
-			Database::prepare(
249
-				"UPDATE `##favorite` SET xref = ? WHERE xref = ? AND gedcom_id = ?"
250
-			)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
251
-		} catch (\Exception $ex) {
252
-			// Perhaps the favorites module was not installed?
253
-		}
247
+        try {
248
+            Database::prepare(
249
+                "UPDATE `##favorite` SET xref = ? WHERE xref = ? AND gedcom_id = ?"
250
+            )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
251
+        } catch (\Exception $ex) {
252
+            // Perhaps the favorites module was not installed?
253
+        }
254 254
 
255
-		// How much time do we have left?
256
-		if (microtime(true) - WT_START_TIME > ini_get('max_execution_time') - 2) {
257
-			echo '<p>', I18N::translate('The server’s time limit has been reached.'), '</p>';
258
-			break;
259
-		}
260
-	}
261
-	if ($xrefs) {
255
+        // How much time do we have left?
256
+        if (microtime(true) - WT_START_TIME > ini_get('max_execution_time') - 2) {
257
+            echo '<p>', I18N::translate('The server’s time limit has been reached.'), '</p>';
258
+            break;
259
+        }
260
+    }
261
+    if ($xrefs) {
262 262
 
263
-	}
263
+    }
264 264
 } else {
265
-	echo '<p>', I18N::translate('In a family tree, each record has an internal reference number (called an “XREF”) such as “F123” or “R14”.'), '</p>';
266
-	echo '<p>', I18N::translate('You can renumber the records in a family tree, so that these internal reference numbers are not duplicated in any other family tree.'), '</p>';
265
+    echo '<p>', I18N::translate('In a family tree, each record has an internal reference number (called an “XREF”) such as “F123” or “R14”.'), '</p>';
266
+    echo '<p>', I18N::translate('You can renumber the records in a family tree, so that these internal reference numbers are not duplicated in any other family tree.'), '</p>';
267 267
 }
268 268
 
269 269
 echo '<p>', I18N::plural(
270
-	'This family tree has %s record which uses the same “XREF” as another family tree.',
271
-	'This family tree has %s records which use the same “XREF” as another family tree.',
272
-	count($xrefs), count($xrefs)
270
+    'This family tree has %s record which uses the same “XREF” as another family tree.',
271
+    'This family tree has %s records which use the same “XREF” as another family tree.',
272
+    count($xrefs), count($xrefs)
273 273
 ), '</p>';
274 274
 
275 275
 if ($xrefs) {
276
-	// We use GET (not POST) for this update operation - because we want the user to
277
-	// be able to press F5 to continue after a timeout.
278
-	echo '<form>';
279
-	echo '<p>', I18N::translate('You can renumber this family tree.'), '</p>';
280
-	echo '<button type="submit" class="btn btn-primary">';
281
-	echo '<i class="fa fa-check"></i> ', /* I18N: A button label. */ I18N::translate('continue');
282
-	echo '</button>';
283
-	echo '<input type="hidden" name="action" value="renumber">';
284
-	echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">';
285
-	echo '</form>';
286
-	echo '<p>', I18N::translate('Caution! This may take a long time. Be patient.'), '</p>';
276
+    // We use GET (not POST) for this update operation - because we want the user to
277
+    // be able to press F5 to continue after a timeout.
278
+    echo '<form>';
279
+    echo '<p>', I18N::translate('You can renumber this family tree.'), '</p>';
280
+    echo '<button type="submit" class="btn btn-primary">';
281
+    echo '<i class="fa fa-check"></i> ', /* I18N: A button label. */ I18N::translate('continue');
282
+    echo '</button>';
283
+    echo '<input type="hidden" name="action" value="renumber">';
284
+    echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">';
285
+    echo '</form>';
286
+    echo '<p>', I18N::translate('Caution! This may take a long time. Be patient.'), '</p>';
287 287
 }
Please login to merge, or discard this patch.
Switch Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -86,143 +86,143 @@
 block discarded – undo
86 86
 		);
87 87
 		$new_xref = $WT_TREE->getNewXref($type);
88 88
 		switch ($type) {
89
-		case 'INDI':
90
-			Database::prepare(
91
-				"UPDATE `##individuals` SET i_id = ?, i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_id = ? AND i_file = ?"
92
-			)->execute(array($new_xref, "0 @$old_xref@ INDI\n", "0 @$new_xref@ INDI\n", $old_xref, $WT_TREE->getTreeId()));
93
-			Database::prepare(
94
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'HUSB') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
95
-			)->execute(array($old_xref, " HUSB @$old_xref@", " HUSB @$new_xref@", $WT_TREE->getTreeId()));
96
-			Database::prepare(
97
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'WIFE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
98
-			)->execute(array($old_xref, " WIFE @$old_xref@", " WIFE @$new_xref@", $WT_TREE->getTreeId()));
99
-			Database::prepare(
100
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'CHIL') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
101
-			)->execute(array($old_xref, " CHIL @$old_xref@", " CHIL @$new_xref@", $WT_TREE->getTreeId()));
102
-			Database::prepare(
103
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'ASSO') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
104
-			)->execute(array($old_xref, " ASSO @$old_xref@", " ASSO @$new_xref@", $WT_TREE->getTreeId()));
105
-			Database::prepare(
106
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = '_ASSO') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
107
-			)->execute(array($old_xref, " _ASSO @$old_xref@", " _ASSO @$new_xref@", $WT_TREE->getTreeId()));
108
-			Database::prepare(
109
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'ASSO') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
110
-			)->execute(array($old_xref, " ASSO @$old_xref@", " ASSO @$new_xref@", $WT_TREE->getTreeId()));
111
-			Database::prepare(
112
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = '_ASSO') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
113
-			)->execute(array($old_xref, " _ASSO @$old_xref@", " _ASSO @$new_xref@", $WT_TREE->getTreeId()));
114
-			Database::prepare(
115
-				"UPDATE `##placelinks` SET pl_gid = ? WHERE pl_gid = ? AND pl_file = ?"
116
-			)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
117
-			Database::prepare(
118
-				"UPDATE `##dates` SET d_gid = ? WHERE d_gid = ? AND d_file = ?"
119
-			)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
120
-			Database::prepare(
121
-				"UPDATE `##user_gedcom_setting` SET setting_value = ? WHERE setting_value = ? AND gedcom_id = ? AND setting_name IN ('gedcomid', 'rootid')"
122
-			)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
123
-			break;
124
-		case 'FAM':
125
-			Database::prepare(
126
-				"UPDATE `##families` SET f_id = ?, f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_id = ? AND f_file = ?"
127
-			)->execute(array($new_xref, "0 @$old_xref@ FAM\n", "0 @$new_xref@ FAM\n", $old_xref, $WT_TREE->getTreeId()));
128
-			Database::prepare(
129
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'FAMC') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
130
-			)->execute(array($old_xref, " FAMC @$old_xref@", " FAMC @$new_xref@", $WT_TREE->getTreeId()));
131
-			Database::prepare(
132
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'FAMS') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
133
-			)->execute(array($old_xref, " FAMS @$old_xref@", " FAMS @$new_xref@", $WT_TREE->getTreeId()));
134
-			Database::prepare(
135
-				"UPDATE `##placelinks` SET pl_gid = ? WHERE pl_gid = ? AND pl_file = ?"
136
-			)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
137
-			Database::prepare(
138
-				"UPDATE `##dates` SET d_gid = ? WHERE d_gid = ? AND d_file = ?"
139
-			)->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
140
-			break;
141
-		case 'SOUR':
142
-			Database::prepare(
143
-				"UPDATE `##sources` SET s_id = ?, s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_id = ? AND s_file = ?"
144
-			)->execute(array($new_xref, "0 @$old_xref@ SOUR\n", "0 @$new_xref@ SOUR\n", $old_xref, $WT_TREE->getTreeId()));
145
-			Database::prepare(
146
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'SOUR') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
147
-			)->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
148
-			Database::prepare(
149
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'SOUR') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
150
-			)->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
151
-			Database::prepare(
152
-				"UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ? AND l_type = 'SOUR') SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
153
-			)->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
154
-			Database::prepare(
155
-				"UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ? AND l_type = 'SOUR') SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
156
-			)->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
157
-			break;
158
-		case 'REPO':
159
-			Database::prepare(
160
-				"UPDATE `##other` SET o_id = ?, o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_id = ? AND o_file = ?"
161
-			)->execute(array($new_xref, "0 @$old_xref@ REPO\n", "0 @$new_xref@ REPO\n", $old_xref, $WT_TREE->getTreeId()));
162
-			Database::prepare(
163
-				"UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ? AND l_type = 'REPO') SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
164
-			)->execute(array($old_xref, " REPO @$old_xref@", " REPO @$new_xref@", $WT_TREE->getTreeId()));
165
-			break;
166
-		case 'NOTE':
167
-			Database::prepare(
168
-				"UPDATE `##other` SET o_id = ?, o_gedcom = REPLACE(REPLACE(o_gedcom, ?, ?), ?, ?) WHERE o_id = ? AND o_file = ?"
169
-			)->execute(array($new_xref, "0 @$old_xref@ NOTE\n", "0 @$new_xref@ NOTE\n", "0 @$old_xref@ NOTE ", "0 @$new_xref@ NOTE ", $old_xref, $WT_TREE->getTreeId()));
170
-			Database::prepare(
171
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'NOTE') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
172
-			)->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
173
-			Database::prepare(
174
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'NOTE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
175
-			)->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
176
-			Database::prepare(
177
-				"UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ? AND l_type = 'NOTE') SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
178
-			)->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
179
-			Database::prepare(
180
-				"UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ? AND l_type = 'NOTE') SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
181
-			)->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
182
-			Database::prepare(
183
-				"UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ? AND l_type = 'NOTE') SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
184
-			)->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
185
-			break;
186
-		case 'OBJE':
187
-			Database::prepare(
188
-				"UPDATE `##media` SET m_id = ?, m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_id = ? AND m_file = ?"
189
-			)->execute(array($new_xref, "0 @$old_xref@ OBJE\n", "0 @$new_xref@ OBJE\n", $old_xref, $WT_TREE->getTreeId()));
190
-			Database::prepare(
191
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'OBJE') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
192
-			)->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
193
-			Database::prepare(
194
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'OBJE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
195
-			)->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
196
-			Database::prepare(
197
-				"UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ? AND l_type = 'OBJE') SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
198
-			)->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
199
-			Database::prepare(
200
-				"UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ? AND l_type = 'OBJE') SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
201
-			)->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
202
-			Database::prepare(
203
-				"UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ? AND l_type = 'OBJE') SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
204
-			)->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
205
-			break;
206
-		default:
207
-			Database::prepare(
208
-				"UPDATE `##other` SET o_id = ?, o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_id = ? AND o_file = ?"
209
-			)->execute(array($new_xref, "0 @$old_xref@ $type\n", "0 @$new_xref@ $type\n", $old_xref, $WT_TREE->getTreeId()));
210
-			Database::prepare(
211
-				"UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ?) SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
212
-			)->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
213
-			Database::prepare(
214
-				"UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ?) SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
215
-			)->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
216
-			Database::prepare(
217
-				"UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ?) SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
218
-			)->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
219
-			Database::prepare(
220
-				"UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ?) SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
221
-			)->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
222
-			Database::prepare(
223
-				"UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ?) SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
224
-			)->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
225
-			break;
89
+		    case 'INDI':
90
+			    Database::prepare(
91
+				    "UPDATE `##individuals` SET i_id = ?, i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_id = ? AND i_file = ?"
92
+			    )->execute(array($new_xref, "0 @$old_xref@ INDI\n", "0 @$new_xref@ INDI\n", $old_xref, $WT_TREE->getTreeId()));
93
+			    Database::prepare(
94
+				    "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'HUSB') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
95
+			    )->execute(array($old_xref, " HUSB @$old_xref@", " HUSB @$new_xref@", $WT_TREE->getTreeId()));
96
+			    Database::prepare(
97
+				    "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'WIFE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
98
+			    )->execute(array($old_xref, " WIFE @$old_xref@", " WIFE @$new_xref@", $WT_TREE->getTreeId()));
99
+			    Database::prepare(
100
+				    "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'CHIL') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
101
+			    )->execute(array($old_xref, " CHIL @$old_xref@", " CHIL @$new_xref@", $WT_TREE->getTreeId()));
102
+			    Database::prepare(
103
+				    "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'ASSO') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
104
+			    )->execute(array($old_xref, " ASSO @$old_xref@", " ASSO @$new_xref@", $WT_TREE->getTreeId()));
105
+			    Database::prepare(
106
+				    "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = '_ASSO') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
107
+			    )->execute(array($old_xref, " _ASSO @$old_xref@", " _ASSO @$new_xref@", $WT_TREE->getTreeId()));
108
+			    Database::prepare(
109
+				    "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'ASSO') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
110
+			    )->execute(array($old_xref, " ASSO @$old_xref@", " ASSO @$new_xref@", $WT_TREE->getTreeId()));
111
+			    Database::prepare(
112
+				    "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = '_ASSO') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
113
+			    )->execute(array($old_xref, " _ASSO @$old_xref@", " _ASSO @$new_xref@", $WT_TREE->getTreeId()));
114
+			    Database::prepare(
115
+				    "UPDATE `##placelinks` SET pl_gid = ? WHERE pl_gid = ? AND pl_file = ?"
116
+			    )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
117
+			    Database::prepare(
118
+				    "UPDATE `##dates` SET d_gid = ? WHERE d_gid = ? AND d_file = ?"
119
+			    )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
120
+			    Database::prepare(
121
+				    "UPDATE `##user_gedcom_setting` SET setting_value = ? WHERE setting_value = ? AND gedcom_id = ? AND setting_name IN ('gedcomid', 'rootid')"
122
+			    )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
123
+			    break;
124
+		    case 'FAM':
125
+			    Database::prepare(
126
+				    "UPDATE `##families` SET f_id = ?, f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_id = ? AND f_file = ?"
127
+			    )->execute(array($new_xref, "0 @$old_xref@ FAM\n", "0 @$new_xref@ FAM\n", $old_xref, $WT_TREE->getTreeId()));
128
+			    Database::prepare(
129
+				    "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'FAMC') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
130
+			    )->execute(array($old_xref, " FAMC @$old_xref@", " FAMC @$new_xref@", $WT_TREE->getTreeId()));
131
+			    Database::prepare(
132
+				    "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'FAMS') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
133
+			    )->execute(array($old_xref, " FAMS @$old_xref@", " FAMS @$new_xref@", $WT_TREE->getTreeId()));
134
+			    Database::prepare(
135
+				    "UPDATE `##placelinks` SET pl_gid = ? WHERE pl_gid = ? AND pl_file = ?"
136
+			    )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
137
+			    Database::prepare(
138
+				    "UPDATE `##dates` SET d_gid = ? WHERE d_gid = ? AND d_file = ?"
139
+			    )->execute(array($new_xref, $old_xref, $WT_TREE->getTreeId()));
140
+			    break;
141
+		    case 'SOUR':
142
+			    Database::prepare(
143
+				    "UPDATE `##sources` SET s_id = ?, s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_id = ? AND s_file = ?"
144
+			    )->execute(array($new_xref, "0 @$old_xref@ SOUR\n", "0 @$new_xref@ SOUR\n", $old_xref, $WT_TREE->getTreeId()));
145
+			    Database::prepare(
146
+				    "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'SOUR') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
147
+			    )->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
148
+			    Database::prepare(
149
+				    "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'SOUR') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
150
+			    )->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
151
+			    Database::prepare(
152
+				    "UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ? AND l_type = 'SOUR') SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
153
+			    )->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
154
+			    Database::prepare(
155
+				    "UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ? AND l_type = 'SOUR') SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
156
+			    )->execute(array($old_xref, " SOUR @$old_xref@", " SOUR @$new_xref@", $WT_TREE->getTreeId()));
157
+			    break;
158
+		    case 'REPO':
159
+			    Database::prepare(
160
+				    "UPDATE `##other` SET o_id = ?, o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_id = ? AND o_file = ?"
161
+			    )->execute(array($new_xref, "0 @$old_xref@ REPO\n", "0 @$new_xref@ REPO\n", $old_xref, $WT_TREE->getTreeId()));
162
+			    Database::prepare(
163
+				    "UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ? AND l_type = 'REPO') SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
164
+			    )->execute(array($old_xref, " REPO @$old_xref@", " REPO @$new_xref@", $WT_TREE->getTreeId()));
165
+			    break;
166
+		    case 'NOTE':
167
+			    Database::prepare(
168
+				    "UPDATE `##other` SET o_id = ?, o_gedcom = REPLACE(REPLACE(o_gedcom, ?, ?), ?, ?) WHERE o_id = ? AND o_file = ?"
169
+			    )->execute(array($new_xref, "0 @$old_xref@ NOTE\n", "0 @$new_xref@ NOTE\n", "0 @$old_xref@ NOTE ", "0 @$new_xref@ NOTE ", $old_xref, $WT_TREE->getTreeId()));
170
+			    Database::prepare(
171
+				    "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'NOTE') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
172
+			    )->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
173
+			    Database::prepare(
174
+				    "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'NOTE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
175
+			    )->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
176
+			    Database::prepare(
177
+				    "UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ? AND l_type = 'NOTE') SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
178
+			    )->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
179
+			    Database::prepare(
180
+				    "UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ? AND l_type = 'NOTE') SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
181
+			    )->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
182
+			    Database::prepare(
183
+				    "UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ? AND l_type = 'NOTE') SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
184
+			    )->execute(array($old_xref, " NOTE @$old_xref@", " NOTE @$new_xref@", $WT_TREE->getTreeId()));
185
+			    break;
186
+		    case 'OBJE':
187
+			    Database::prepare(
188
+				    "UPDATE `##media` SET m_id = ?, m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_id = ? AND m_file = ?"
189
+			    )->execute(array($new_xref, "0 @$old_xref@ OBJE\n", "0 @$new_xref@ OBJE\n", $old_xref, $WT_TREE->getTreeId()));
190
+			    Database::prepare(
191
+				    "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ? AND l_type = 'OBJE') SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
192
+			    )->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
193
+			    Database::prepare(
194
+				    "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'OBJE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
195
+			    )->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
196
+			    Database::prepare(
197
+				    "UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ? AND l_type = 'OBJE') SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
198
+			    )->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
199
+			    Database::prepare(
200
+				    "UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ? AND l_type = 'OBJE') SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
201
+			    )->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
202
+			    Database::prepare(
203
+				    "UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ? AND l_type = 'OBJE') SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
204
+			    )->execute(array($old_xref, " OBJE @$old_xref@", " OBJE @$new_xref@", $WT_TREE->getTreeId()));
205
+			    break;
206
+		    default:
207
+			    Database::prepare(
208
+				    "UPDATE `##other` SET o_id = ?, o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_id = ? AND o_file = ?"
209
+			    )->execute(array($new_xref, "0 @$old_xref@ $type\n", "0 @$new_xref@ $type\n", $old_xref, $WT_TREE->getTreeId()));
210
+			    Database::prepare(
211
+				    "UPDATE `##individuals` JOIN `##link` ON (l_file = i_file AND l_to = ?) SET i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_file = ?"
212
+			    )->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
213
+			    Database::prepare(
214
+				    "UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ?) SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?"
215
+			    )->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
216
+			    Database::prepare(
217
+				    "UPDATE `##media` JOIN `##link` ON (l_file = m_file AND l_to = ?) SET m_gedcom = REPLACE(m_gedcom, ?, ?) WHERE m_file = ?"
218
+			    )->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
219
+			    Database::prepare(
220
+				    "UPDATE `##sources` JOIN `##link` ON (l_file = s_file AND l_to = ?) SET s_gedcom = REPLACE(s_gedcom, ?, ?) WHERE s_file = ?"
221
+			    )->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
222
+			    Database::prepare(
223
+				    "UPDATE `##other` JOIN `##link` ON (l_file = o_file AND l_to = ?) SET o_gedcom = REPLACE(o_gedcom, ?, ?) WHERE o_file = ?"
224
+			    )->execute(array($old_xref, " @$old_xref@", " @$new_xref@", $WT_TREE->getTreeId()));
225
+			    break;
226 226
 		}
227 227
 		Database::prepare(
228 228
 			"UPDATE `##name` SET n_id = ? WHERE n_id = ? AND n_file = ?"
Please login to merge, or discard this patch.
admin_module_reports.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -24,29 +24,29 @@
 block discarded – undo
24 24
 
25 25
 $controller = new PageController;
26 26
 $controller
27
-	->restrictAccess(Auth::isAdmin())
28
-	->setPageTitle(I18N::translate('Reports'));
27
+    ->restrictAccess(Auth::isAdmin())
28
+    ->setPageTitle(I18N::translate('Reports'));
29 29
 
30 30
 $action  = Filter::post('action');
31 31
 $modules = Module::getAllModulesByComponent('report');
32 32
 
33 33
 if ($action === 'update_mods' && Filter::checkCsrf()) {
34
-	foreach ($modules as $module) {
35
-		foreach (Tree::getAll() as $tree) {
36
-			$access_level = Filter::post('access-' . $module->getName() . '-' . $tree->getTreeId(), WT_REGEX_INTEGER, $module->defaultAccessLevel());
37
-			Database::prepare(
38
-				"REPLACE INTO `##module_privacy` (module_name, gedcom_id, component, access_level) VALUES (?, ?, 'report', ?)"
39
-			)->execute(array($module->getName(), $tree->getTreeId(), $access_level));
40
-		}
41
-	}
34
+    foreach ($modules as $module) {
35
+        foreach (Tree::getAll() as $tree) {
36
+            $access_level = Filter::post('access-' . $module->getName() . '-' . $tree->getTreeId(), WT_REGEX_INTEGER, $module->defaultAccessLevel());
37
+            Database::prepare(
38
+                "REPLACE INTO `##module_privacy` (module_name, gedcom_id, component, access_level) VALUES (?, ?, 'report', ?)"
39
+            )->execute(array($module->getName(), $tree->getTreeId(), $access_level));
40
+        }
41
+    }
42 42
 
43
-	header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
43
+    header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
44 44
 
45
-	return;
45
+    return;
46 46
 }
47 47
 
48 48
 $controller
49
-	->pageHeader();
49
+    ->pageHeader();
50 50
 
51 51
 ?>
52 52
 <ol class="breadcrumb small">
Please login to merge, or discard this patch.
editnews.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 
32 32
 $controller = new SimpleController;
33 33
 $controller
34
-	->setPageTitle(I18N::translate('Add/edit a journal/news entry'))
35
-	->restrictAccess(Auth::isMember($WT_TREE))
36
-	->pageHeader();
34
+    ->setPageTitle(I18N::translate('Add/edit a journal/news entry'))
35
+    ->restrictAccess(Auth::isMember($WT_TREE))
36
+    ->pageHeader();
37 37
 
38 38
 $action    = Filter::get('action', 'compose|save', 'compose');
39 39
 $news_id   = Filter::getInteger('news_id');
@@ -45,43 +45,43 @@  discard block
 block discarded – undo
45 45
 
46 46
 switch ($action) {
47 47
 case 'compose':
48
-	if (Module::getModuleByName('ckeditor')) {
49
-		CkeditorModule::enableEditor($controller);
50
-	}
48
+    if (Module::getModuleByName('ckeditor')) {
49
+        CkeditorModule::enableEditor($controller);
50
+    }
51 51
 
52
-	echo '<h3>' . I18N::translate('Add/edit a journal/news entry') . '</h3>';
53
-	echo '<form style="overflow: hidden;" name="messageform" method="post" action="editnews.php?action=save&news_id=' . $news_id . '">';
54
-	if ($news_id) {
55
-		$news = Database::prepare("SELECT news_id AS id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS date, subject, body FROM `##news` WHERE news_id=?")->execute(array($news_id))->fetchOneRow(PDO::FETCH_ASSOC);
56
-	} else {
57
-		$news              = array();
58
-		$news['user_id']   = $user_id;
59
-		$news['gedcom_id'] = $gedcom_id;
60
-		$news['date']      = WT_TIMESTAMP;
61
-		$news['subject']   = '';
62
-		$news['body']      = '';
63
-	}
64
-	echo '<input type="hidden" name="user_id" value="' . $news['user_id'] . '">';
65
-	echo '<input type="hidden" name="gedcom_id" value="' . $news['gedcom_id'] . '">';
66
-	echo '<input type="hidden" name="date" value="' . $news['date'] . '">';
67
-	echo '<table>';
68
-	echo '<tr><th style="text-align:start;">' . I18N::translate('Title') . '</th><tr>';
69
-	echo '<tr><td><input type="text" name="title" size="50" dir="auto" autofocus value="' . $news['subject'] . '"></td></tr>';
70
-	echo '<tr><th style="text-align:start;">' . I18N::translate('Content') . '</th></tr>';
71
-	echo '<tr><td>';
72
-	echo '<textarea name="text" class="html-edit" cols="80" rows="10" dir="auto">' . Filter::escapeHtml($news['body']) . '</textarea>';
73
-	echo '</td></tr>';
74
-	echo '<tr><td><input type="submit" value="' . I18N::translate('save') . '"></td></tr>';
75
-	echo '</table>';
76
-	echo '</form>';
77
-	break;
52
+    echo '<h3>' . I18N::translate('Add/edit a journal/news entry') . '</h3>';
53
+    echo '<form style="overflow: hidden;" name="messageform" method="post" action="editnews.php?action=save&news_id=' . $news_id . '">';
54
+    if ($news_id) {
55
+        $news = Database::prepare("SELECT news_id AS id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS date, subject, body FROM `##news` WHERE news_id=?")->execute(array($news_id))->fetchOneRow(PDO::FETCH_ASSOC);
56
+    } else {
57
+        $news              = array();
58
+        $news['user_id']   = $user_id;
59
+        $news['gedcom_id'] = $gedcom_id;
60
+        $news['date']      = WT_TIMESTAMP;
61
+        $news['subject']   = '';
62
+        $news['body']      = '';
63
+    }
64
+    echo '<input type="hidden" name="user_id" value="' . $news['user_id'] . '">';
65
+    echo '<input type="hidden" name="gedcom_id" value="' . $news['gedcom_id'] . '">';
66
+    echo '<input type="hidden" name="date" value="' . $news['date'] . '">';
67
+    echo '<table>';
68
+    echo '<tr><th style="text-align:start;">' . I18N::translate('Title') . '</th><tr>';
69
+    echo '<tr><td><input type="text" name="title" size="50" dir="auto" autofocus value="' . $news['subject'] . '"></td></tr>';
70
+    echo '<tr><th style="text-align:start;">' . I18N::translate('Content') . '</th></tr>';
71
+    echo '<tr><td>';
72
+    echo '<textarea name="text" class="html-edit" cols="80" rows="10" dir="auto">' . Filter::escapeHtml($news['body']) . '</textarea>';
73
+    echo '</td></tr>';
74
+    echo '<tr><td><input type="submit" value="' . I18N::translate('save') . '"></td></tr>';
75
+    echo '</table>';
76
+    echo '</form>';
77
+    break;
78 78
 case 'save':
79
-	if ($news_id) {
80
-		Database::prepare("UPDATE `##news` SET subject=?, body=?, updated=FROM_UNIXTIME(?) WHERE news_id=?")->execute(array($title, $text, $date, $news_id));
81
-	} else {
82
-		Database::prepare("INSERT INTO `##news` (user_id, gedcom_id, subject, body, updated) VALUES (NULLIF(?, ''), NULLIF(?, '') ,? ,?, CURRENT_TIMESTAMP)")->execute(array($user_id, $gedcom_id, $title, $text));
83
-	}
79
+    if ($news_id) {
80
+        Database::prepare("UPDATE `##news` SET subject=?, body=?, updated=FROM_UNIXTIME(?) WHERE news_id=?")->execute(array($title, $text, $date, $news_id));
81
+    } else {
82
+        Database::prepare("INSERT INTO `##news` (user_id, gedcom_id, subject, body, updated) VALUES (NULLIF(?, ''), NULLIF(?, '') ,? ,?, CURRENT_TIMESTAMP)")->execute(array($user_id, $gedcom_id, $title, $text));
83
+    }
84 84
 
85
-	$controller->addInlineJavascript('window.opener.location.reload();window.close();');
86
-	break;
85
+    $controller->addInlineJavascript('window.opener.location.reload();window.close();');
86
+    break;
87 87
 }
Please login to merge, or discard this patch.
Switch Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -44,44 +44,44 @@
 block discarded – undo
44 44
 $text      = Filter::post('text');
45 45
 
46 46
 switch ($action) {
47
-case 'compose':
48
-	if (Module::getModuleByName('ckeditor')) {
49
-		CkeditorModule::enableEditor($controller);
50
-	}
47
+    case 'compose':
48
+	    if (Module::getModuleByName('ckeditor')) {
49
+		    CkeditorModule::enableEditor($controller);
50
+	    }
51 51
 
52
-	echo '<h3>' . I18N::translate('Add/edit a journal/news entry') . '</h3>';
53
-	echo '<form style="overflow: hidden;" name="messageform" method="post" action="editnews.php?action=save&news_id=' . $news_id . '">';
54
-	if ($news_id) {
55
-		$news = Database::prepare("SELECT news_id AS id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS date, subject, body FROM `##news` WHERE news_id=?")->execute(array($news_id))->fetchOneRow(PDO::FETCH_ASSOC);
56
-	} else {
57
-		$news              = array();
58
-		$news['user_id']   = $user_id;
59
-		$news['gedcom_id'] = $gedcom_id;
60
-		$news['date']      = WT_TIMESTAMP;
61
-		$news['subject']   = '';
62
-		$news['body']      = '';
63
-	}
64
-	echo '<input type="hidden" name="user_id" value="' . $news['user_id'] . '">';
65
-	echo '<input type="hidden" name="gedcom_id" value="' . $news['gedcom_id'] . '">';
66
-	echo '<input type="hidden" name="date" value="' . $news['date'] . '">';
67
-	echo '<table>';
68
-	echo '<tr><th style="text-align:start;">' . I18N::translate('Title') . '</th><tr>';
69
-	echo '<tr><td><input type="text" name="title" size="50" dir="auto" autofocus value="' . $news['subject'] . '"></td></tr>';
70
-	echo '<tr><th style="text-align:start;">' . I18N::translate('Content') . '</th></tr>';
71
-	echo '<tr><td>';
72
-	echo '<textarea name="text" class="html-edit" cols="80" rows="10" dir="auto">' . Filter::escapeHtml($news['body']) . '</textarea>';
73
-	echo '</td></tr>';
74
-	echo '<tr><td><input type="submit" value="' . I18N::translate('save') . '"></td></tr>';
75
-	echo '</table>';
76
-	echo '</form>';
77
-	break;
78
-case 'save':
79
-	if ($news_id) {
80
-		Database::prepare("UPDATE `##news` SET subject=?, body=?, updated=FROM_UNIXTIME(?) WHERE news_id=?")->execute(array($title, $text, $date, $news_id));
81
-	} else {
82
-		Database::prepare("INSERT INTO `##news` (user_id, gedcom_id, subject, body, updated) VALUES (NULLIF(?, ''), NULLIF(?, '') ,? ,?, CURRENT_TIMESTAMP)")->execute(array($user_id, $gedcom_id, $title, $text));
83
-	}
52
+	    echo '<h3>' . I18N::translate('Add/edit a journal/news entry') . '</h3>';
53
+	    echo '<form style="overflow: hidden;" name="messageform" method="post" action="editnews.php?action=save&news_id=' . $news_id . '">';
54
+	    if ($news_id) {
55
+		    $news = Database::prepare("SELECT news_id AS id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS date, subject, body FROM `##news` WHERE news_id=?")->execute(array($news_id))->fetchOneRow(PDO::FETCH_ASSOC);
56
+	    } else {
57
+		    $news              = array();
58
+		    $news['user_id']   = $user_id;
59
+		    $news['gedcom_id'] = $gedcom_id;
60
+		    $news['date']      = WT_TIMESTAMP;
61
+		    $news['subject']   = '';
62
+		    $news['body']      = '';
63
+	    }
64
+	    echo '<input type="hidden" name="user_id" value="' . $news['user_id'] . '">';
65
+	    echo '<input type="hidden" name="gedcom_id" value="' . $news['gedcom_id'] . '">';
66
+	    echo '<input type="hidden" name="date" value="' . $news['date'] . '">';
67
+	    echo '<table>';
68
+	    echo '<tr><th style="text-align:start;">' . I18N::translate('Title') . '</th><tr>';
69
+	    echo '<tr><td><input type="text" name="title" size="50" dir="auto" autofocus value="' . $news['subject'] . '"></td></tr>';
70
+	    echo '<tr><th style="text-align:start;">' . I18N::translate('Content') . '</th></tr>';
71
+	    echo '<tr><td>';
72
+	    echo '<textarea name="text" class="html-edit" cols="80" rows="10" dir="auto">' . Filter::escapeHtml($news['body']) . '</textarea>';
73
+	    echo '</td></tr>';
74
+	    echo '<tr><td><input type="submit" value="' . I18N::translate('save') . '"></td></tr>';
75
+	    echo '</table>';
76
+	    echo '</form>';
77
+	    break;
78
+    case 'save':
79
+	    if ($news_id) {
80
+		    Database::prepare("UPDATE `##news` SET subject=?, body=?, updated=FROM_UNIXTIME(?) WHERE news_id=?")->execute(array($title, $text, $date, $news_id));
81
+	    } else {
82
+		    Database::prepare("INSERT INTO `##news` (user_id, gedcom_id, subject, body, updated) VALUES (NULLIF(?, ''), NULLIF(?, '') ,? ,?, CURRENT_TIMESTAMP)")->execute(array($user_id, $gedcom_id, $title, $text));
83
+	    }
84 84
 
85
-	$controller->addInlineJavascript('window.opener.location.reload();window.close();');
86
-	break;
85
+	    $controller->addInlineJavascript('window.opener.location.reload();window.close();');
86
+	    break;
87 87
 }
Please login to merge, or discard this patch.
themes/_custom/theme.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -32,61 +32,61 @@
 block discarded – undo
32 32
  * The rest are just examples, and should be removed in actual themes.
33 33
  */
34 34
 class MyTheme extends WebtreesTheme {
35
-	/**
36
-	 * Give your theme a unique identifier. Themes beginning with an underscore
37
-	 * are reserved for internal use.
38
-	 *
39
-	 * {@inheritdoc}
40
-	 */
41
-	public function themeId() {
42
-		return '_custom';
43
-	}
35
+    /**
36
+     * Give your theme a unique identifier. Themes beginning with an underscore
37
+     * are reserved for internal use.
38
+     *
39
+     * {@inheritdoc}
40
+     */
41
+    public function themeId() {
42
+        return '_custom';
43
+    }
44 44
 
45
-	/**
46
-	 * Give your theme a name. This is shown to the users.
47
-	 * Use HTML entities where appropriate. e.g. “Black &amp; white”.
48
-	 *
49
-	 * You could use switch($this->locale) {} to provide a translated versions
50
-	 * of the theme name.
51
-	 *
52
-	 * {@inheritdoc}
53
-	 */
54
-	public function themeName() {
55
-		return 'Custom theme';
56
-	}
45
+    /**
46
+     * Give your theme a name. This is shown to the users.
47
+     * Use HTML entities where appropriate. e.g. “Black &amp; white”.
48
+     *
49
+     * You could use switch($this->locale) {} to provide a translated versions
50
+     * of the theme name.
51
+     *
52
+     * {@inheritdoc}
53
+     */
54
+    public function themeName() {
55
+        return 'Custom theme';
56
+    }
57 57
 
58
-	/**
59
-	 * This is an example function which shows how to add an additional CSS file to the theme.
60
-	 *
61
-	 * {@inheritdoc}
62
-	 */
63
-	public function stylesheets() {
64
-		$css_files   = parent::stylesheets();
65
-		// Put a version number in the URL, to prevent browsers from caching old versions.
66
-		$css_files[] = WT_BASE_URL . 'themes/_custom/custom-v1.0.css';
58
+    /**
59
+     * This is an example function which shows how to add an additional CSS file to the theme.
60
+     *
61
+     * {@inheritdoc}
62
+     */
63
+    public function stylesheets() {
64
+        $css_files   = parent::stylesheets();
65
+        // Put a version number in the URL, to prevent browsers from caching old versions.
66
+        $css_files[] = WT_BASE_URL . 'themes/_custom/custom-v1.0.css';
67 67
 
68
-		return $css_files;
69
-	}
68
+        return $css_files;
69
+    }
70 70
 
71
-	/**
72
-	 * This is an example function which shows one way to remove an entry from a menu.
73
-	 *
74
-	 * @param string $surname The significant surname for the page.
75
-	 *
76
-	 * {@inheritdoc}
77
-	 */
78
-	public function menuLists($surname) {
79
-		// Start with the default "Lists" menu.
80
-		$menu = parent::menuLists($surname);
81
-		// Remove the "notes" sub-menu.
82
-		$submenus = array_filter($menu->getSubmenus(), function (Menu $menu) {
83
-			return $menu->getClass() !== 'menu-list-note';
84
-		});
85
-		// Replace the sub-menus
86
-		$menu->setSubmenus($submenus);
71
+    /**
72
+     * This is an example function which shows one way to remove an entry from a menu.
73
+     *
74
+     * @param string $surname The significant surname for the page.
75
+     *
76
+     * {@inheritdoc}
77
+     */
78
+    public function menuLists($surname) {
79
+        // Start with the default "Lists" menu.
80
+        $menu = parent::menuLists($surname);
81
+        // Remove the "notes" sub-menu.
82
+        $submenus = array_filter($menu->getSubmenus(), function (Menu $menu) {
83
+            return $menu->getClass() !== 'menu-list-note';
84
+        });
85
+        // Replace the sub-menus
86
+        $menu->setSubmenus($submenus);
87 87
 
88
-		return $menu;
89
-	}
88
+        return $menu;
89
+    }
90 90
 }
91 91
 
92 92
 return new MyTheme; // This script must return a theme object.
Please login to merge, or discard this patch.
lifespan.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 
26 26
 $controller = new LifespanController;
27 27
 $controller
28
-	->restrictAccess(Module::isActiveChart($WT_TREE, 'lifespans_chart'))
29
-	->pageHeader()
30
-	->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL);
28
+    ->restrictAccess(Module::isActiveChart($WT_TREE, 'lifespans_chart'))
29
+    ->pageHeader()
30
+    ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL);
31 31
 
32 32
 ?>
33 33
 <div id="lifespan-page">
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 </div>
127 127
 <?php
128 128
 $controller
129
-	->addInlineJavascript("
129
+    ->addInlineJavascript("
130 130
 		autocomplete();
131 131
 		var scale = jQuery('#lifespan-scale'),
132 132
 			barHeight = jQuery('#lifespan-people').children().first().outerHeight();
Please login to merge, or discard this patch.
includes/session.php 2 patches
Switch Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -200,29 +200,29 @@  discard block
 block discarded – undo
200 200
 		$frame += array('args' => array(), 'file' => 'unknown', 'line' => 'unknown');
201 201
 		array_walk($frame['args'], function (&$arg) {
202 202
 			switch (gettype($arg)) {
203
-			case 'boolean':
204
-			case 'integer':
205
-			case 'double':
206
-			case 'null':
207
-				$arg = var_export($arg, true);
208
-				break;
209
-			case 'string':
210
-				if (mb_strlen($arg) > 30) {
211
-					$arg = substr($arg, 0, 30) . '…';
212
-				}
213
-				$arg = var_export($arg, true);
214
-				break;
215
-			case 'object':
216
-				$reflection = new \ReflectionClass($arg);
217
-				if (is_object($arg) && method_exists($arg, '__toString')) {
218
-					$arg = '[' . $reflection->getShortName() . ' ' . (string) $arg . ']';
219
-				} else {
220
-					$arg = '[' . $reflection->getShortName() . ']';
221
-				}
222
-				break;
223
-			default:
224
-				$arg = '[' . gettype($arg) . ']';
225
-				break;
203
+			    case 'boolean':
204
+			    case 'integer':
205
+			    case 'double':
206
+			    case 'null':
207
+				    $arg = var_export($arg, true);
208
+				    break;
209
+			    case 'string':
210
+				    if (mb_strlen($arg) > 30) {
211
+					    $arg = substr($arg, 0, 30) . '…';
212
+				    }
213
+				    $arg = var_export($arg, true);
214
+				    break;
215
+			    case 'object':
216
+				    $reflection = new \ReflectionClass($arg);
217
+				    if (is_object($arg) && method_exists($arg, '__toString')) {
218
+					    $arg = '[' . $reflection->getShortName() . ' ' . (string) $arg . ']';
219
+				    } else {
220
+					    $arg = '[' . $reflection->getShortName() . ']';
221
+				    }
222
+				    break;
223
+			    default:
224
+				    $arg = '[' . gettype($arg) . ']';
225
+				    break;
226 226
 			}
227 227
 		});
228 228
 		$frame['file'] = str_replace(dirname(__DIR__), '', $frame['file']);
@@ -319,25 +319,25 @@  discard block
 block discarded – undo
319 319
 )->execute(array(WT_CLIENT_IP, Filter::server('HTTP_USER_AGENT', null, '')))->fetchOne();
320 320
 
321 321
 switch ($rule) {
322
-case 'allow':
323
-	$SEARCH_SPIDER = false;
324
-	break;
325
-case 'deny':
326
-	http_response_code(403);
327
-	exit;
328
-case 'robot':
329
-case 'unknown':
330
-	// Search engines don’t send cookies, and so create a new session with every visit.
331
-	// Make sure they always use the same one
332
-	Session::setId('search-engine-' . str_replace('.', '-', WT_CLIENT_IP));
333
-	$SEARCH_SPIDER = true;
334
-	break;
335
-case '':
336
-	Database::prepare(
337
-		"INSERT INTO `##site_access_rule` (ip_address_start, ip_address_end, user_agent_pattern, comment) VALUES (IFNULL(INET_ATON(?), 0), IFNULL(INET_ATON(?), 4294967295), ?, '')"
338
-	)->execute(array(WT_CLIENT_IP, WT_CLIENT_IP, Filter::server('HTTP_USER_AGENT', null, '')));
339
-	$SEARCH_SPIDER = true;
340
-	break;
322
+    case 'allow':
323
+	    $SEARCH_SPIDER = false;
324
+	    break;
325
+    case 'deny':
326
+	    http_response_code(403);
327
+	    exit;
328
+    case 'robot':
329
+    case 'unknown':
330
+	    // Search engines don’t send cookies, and so create a new session with every visit.
331
+	    // Make sure they always use the same one
332
+	    Session::setId('search-engine-' . str_replace('.', '-', WT_CLIENT_IP));
333
+	    $SEARCH_SPIDER = true;
334
+	    break;
335
+    case '':
336
+	    Database::prepare(
337
+		    "INSERT INTO `##site_access_rule` (ip_address_start, ip_address_end, user_agent_pattern, comment) VALUES (IFNULL(INET_ATON(?), 0), IFNULL(INET_ATON(?), 4294967295), ?, '')"
338
+	    )->execute(array(WT_CLIENT_IP, WT_CLIENT_IP, Filter::server('HTTP_USER_AGENT', null, '')));
339
+	    $SEARCH_SPIDER = true;
340
+	    break;
341 341
 }
342 342
 
343 343
 // Store our session data in the database.
Please login to merge, or discard this patch.
Indentation   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 
26 26
 // WT_SCRIPT_NAME is defined in each script that the user is permitted to load.
27 27
 if (!defined('WT_SCRIPT_NAME')) {
28
-	http_response_code(403);
28
+    http_response_code(403);
29 29
 
30
-	return;
30
+    return;
31 31
 }
32 32
 
33 33
 /**
@@ -50,41 +50,41 @@  discard block
 block discarded – undo
50 50
 define('WT_STATIC_URL', getenv('STATIC_URL')); // We could set this to load our own static resources from a cookie-free domain.
51 51
 
52 52
 if (getenv('USE_CDN')) {
53
-	// Caution, using a CDN will break support for responsive features in IE8, as respond.js
54
-	// needs to be on the same domain as all the CSS files.
55
-	define('WT_BOOTSTRAP_CSS_URL', '//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css');
56
-	define('WT_BOOTSTRAP_DATETIMEPICKER_CSS_URL', '//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css');
57
-	define('WT_BOOTSTRAP_DATETIMEPICKER_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js');
58
-	define('WT_BOOTSTRAP_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js');
59
-	define('WT_BOOTSTRAP_RTL_CSS_URL', '//cdnjs.cloudflare.com/ajax/libs/bootstrap-rtl/3.2.0-rc2/css/bootstrap-rtl.min.css'); // Cloudflare is out of date
60
-	//define('WT_DATATABLES_BOOTSTRAP_CSS_URL', '//cdn.datatables.net/plug-ins/1.10.7/integration/bootstrap/3/dataTables.bootstrap.css');
61
-	define('WT_DATATABLES_BOOTSTRAP_JS_URL', '//cdn.datatables.net/plug-ins/1.10.7/integration/bootstrap/3/dataTables.bootstrap.js');
62
-	define('WT_FONT_AWESOME_CSS_URL', '//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css');
63
-	define('WT_JQUERYUI_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js');
64
-	define('WT_JQUERYUI_TOUCH_PUNCH_URL', '//cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js');
65
-	define('WT_JQUERY_DATATABLES_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.7/js/jquery.dataTables.min.js');
66
-	define('WT_JQUERY_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js');
67
-	define('WT_JQUERY2_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js');
68
-	define('WT_MODERNIZR_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js');
69
-	define('WT_MOMENT_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment-with-locales.min.js');
70
-	define('WT_RESPOND_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js');
53
+    // Caution, using a CDN will break support for responsive features in IE8, as respond.js
54
+    // needs to be on the same domain as all the CSS files.
55
+    define('WT_BOOTSTRAP_CSS_URL', '//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css');
56
+    define('WT_BOOTSTRAP_DATETIMEPICKER_CSS_URL', '//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css');
57
+    define('WT_BOOTSTRAP_DATETIMEPICKER_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js');
58
+    define('WT_BOOTSTRAP_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js');
59
+    define('WT_BOOTSTRAP_RTL_CSS_URL', '//cdnjs.cloudflare.com/ajax/libs/bootstrap-rtl/3.2.0-rc2/css/bootstrap-rtl.min.css'); // Cloudflare is out of date
60
+    //define('WT_DATATABLES_BOOTSTRAP_CSS_URL', '//cdn.datatables.net/plug-ins/1.10.7/integration/bootstrap/3/dataTables.bootstrap.css');
61
+    define('WT_DATATABLES_BOOTSTRAP_JS_URL', '//cdn.datatables.net/plug-ins/1.10.7/integration/bootstrap/3/dataTables.bootstrap.js');
62
+    define('WT_FONT_AWESOME_CSS_URL', '//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css');
63
+    define('WT_JQUERYUI_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js');
64
+    define('WT_JQUERYUI_TOUCH_PUNCH_URL', '//cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js');
65
+    define('WT_JQUERY_DATATABLES_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.7/js/jquery.dataTables.min.js');
66
+    define('WT_JQUERY_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js');
67
+    define('WT_JQUERY2_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js');
68
+    define('WT_MODERNIZR_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js');
69
+    define('WT_MOMENT_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment-with-locales.min.js');
70
+    define('WT_RESPOND_JS_URL', '//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js');
71 71
 } else {
72
-	define('WT_BOOTSTRAP_CSS_URL', WT_STATIC_URL . 'packages/bootstrap-3.3.6/css/bootstrap.min.css');
73
-	define('WT_BOOTSTRAP_DATETIMEPICKER_CSS_URL', WT_STATIC_URL . 'packages/bootstrap-datetimepicker-4.17.37/css/bootstrap-datetimepicker.min.css');
74
-	define('WT_BOOTSTRAP_DATETIMEPICKER_JS_URL', WT_STATIC_URL . 'packages/bootstrap-datetimepicker-4.17.37/js/bootstrap-datetimepicker.min.js');
75
-	define('WT_BOOTSTRAP_JS_URL', WT_STATIC_URL . 'packages/bootstrap-3.3.6/js/bootstrap.min.js');
76
-	define('WT_BOOTSTRAP_RTL_CSS_URL', WT_STATIC_URL . 'packages/bootstrap-rtl-3.3.4/css/bootstrap-rtl.min.css');
77
-	//define('WT_DATATABLES_BOOTSTRAP_CSS_URL', WT_STATIC_URL . 'packages/datatables-1.10.7/plugins/dataTables.bootstrap.css');
78
-	define('WT_DATATABLES_BOOTSTRAP_JS_URL', WT_STATIC_URL . 'packages/datatables-1.10.7/plugins/dataTables.bootstrap.js');
79
-	define('WT_FONT_AWESOME_CSS_URL', WT_STATIC_URL . 'packages/font-awesome-4.4.0/css/font-awesome.min.css');
80
-	define('WT_JQUERYUI_JS_URL', WT_STATIC_URL . 'packages/jquery-ui-1.11.4/js/jquery-ui.min.js');
81
-	define('WT_JQUERYUI_TOUCH_PUNCH_URL', WT_STATIC_URL . 'packages/jqueryui-touch-punch-0.2.3/jquery.ui.touch-punch.min.js');
82
-	define('WT_JQUERY_DATATABLES_JS_URL', WT_STATIC_URL . 'packages/datatables-1.10.7/js/jquery.dataTables.min.js');
83
-	define('WT_JQUERY_JS_URL', WT_STATIC_URL . 'packages/jquery-1.12.1/jquery.min.js');
84
-	define('WT_JQUERY2_JS_URL', WT_STATIC_URL . 'packages/jquery-2.2.1/jquery.min.js');
85
-	define('WT_MODERNIZR_JS_URL', WT_STATIC_URL . 'packages/modernizr-2.8.3/modernizr.min.js');
86
-	define('WT_MOMENT_JS_URL', WT_STATIC_URL . 'packages/moment-2.11.2/moment-with-locales.min.js');
87
-	define('WT_RESPOND_JS_URL', WT_STATIC_URL . 'packages/respond-1.4.2/respond.min.js');
72
+    define('WT_BOOTSTRAP_CSS_URL', WT_STATIC_URL . 'packages/bootstrap-3.3.6/css/bootstrap.min.css');
73
+    define('WT_BOOTSTRAP_DATETIMEPICKER_CSS_URL', WT_STATIC_URL . 'packages/bootstrap-datetimepicker-4.17.37/css/bootstrap-datetimepicker.min.css');
74
+    define('WT_BOOTSTRAP_DATETIMEPICKER_JS_URL', WT_STATIC_URL . 'packages/bootstrap-datetimepicker-4.17.37/js/bootstrap-datetimepicker.min.js');
75
+    define('WT_BOOTSTRAP_JS_URL', WT_STATIC_URL . 'packages/bootstrap-3.3.6/js/bootstrap.min.js');
76
+    define('WT_BOOTSTRAP_RTL_CSS_URL', WT_STATIC_URL . 'packages/bootstrap-rtl-3.3.4/css/bootstrap-rtl.min.css');
77
+    //define('WT_DATATABLES_BOOTSTRAP_CSS_URL', WT_STATIC_URL . 'packages/datatables-1.10.7/plugins/dataTables.bootstrap.css');
78
+    define('WT_DATATABLES_BOOTSTRAP_JS_URL', WT_STATIC_URL . 'packages/datatables-1.10.7/plugins/dataTables.bootstrap.js');
79
+    define('WT_FONT_AWESOME_CSS_URL', WT_STATIC_URL . 'packages/font-awesome-4.4.0/css/font-awesome.min.css');
80
+    define('WT_JQUERYUI_JS_URL', WT_STATIC_URL . 'packages/jquery-ui-1.11.4/js/jquery-ui.min.js');
81
+    define('WT_JQUERYUI_TOUCH_PUNCH_URL', WT_STATIC_URL . 'packages/jqueryui-touch-punch-0.2.3/jquery.ui.touch-punch.min.js');
82
+    define('WT_JQUERY_DATATABLES_JS_URL', WT_STATIC_URL . 'packages/datatables-1.10.7/js/jquery.dataTables.min.js');
83
+    define('WT_JQUERY_JS_URL', WT_STATIC_URL . 'packages/jquery-1.12.1/jquery.min.js');
84
+    define('WT_JQUERY2_JS_URL', WT_STATIC_URL . 'packages/jquery-2.2.1/jquery.min.js');
85
+    define('WT_MODERNIZR_JS_URL', WT_STATIC_URL . 'packages/modernizr-2.8.3/modernizr.min.js');
86
+    define('WT_MOMENT_JS_URL', WT_STATIC_URL . 'packages/moment-2.11.2/moment-with-locales.min.js');
87
+    define('WT_RESPOND_JS_URL', WT_STATIC_URL . 'packages/respond-1.4.2/respond.min.js');
88 88
 }
89 89
 
90 90
 // We can't load these from a CDN, as these have been patched.
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 
177 177
 // Ignore the default port.
178 178
 if ($protocol === 'http' && $port === '80' || $protocol === 'https' && $port === '443') {
179
-	$port = '';
179
+    $port = '';
180 180
 } else {
181
-	$port = ':' . $port;
181
+    $port = ':' . $port;
182 182
 }
183 183
 
184 184
 // REDIRECT_URL should be set when Apache is following a RedirectRule
@@ -197,98 +197,98 @@  discard block
 block discarded – undo
197 197
 });
198 198
 
199 199
 set_exception_handler(function ($ex) {
200
-	$message = $ex->getFile() . ':' . $ex->getLine() . ' ' . $ex->getMessage() . PHP_EOL;
201
-
202
-	foreach ($ex->getTrace() as $level => $frame) {
203
-		$frame += array('args' => array(), 'file' => 'unknown', 'line' => 'unknown');
204
-		array_walk($frame['args'], function (&$arg) {
205
-			switch (gettype($arg)) {
206
-			case 'boolean':
207
-			case 'integer':
208
-			case 'double':
209
-			case 'null':
210
-				$arg = var_export($arg, true);
211
-				break;
212
-			case 'string':
213
-				if (mb_strlen($arg) > 30) {
214
-					$arg = substr($arg, 0, 30) . '…';
215
-				}
216
-				$arg = var_export($arg, true);
217
-				break;
218
-			case 'object':
219
-				$reflection = new \ReflectionClass($arg);
220
-				if (is_object($arg) && method_exists($arg, '__toString')) {
221
-					$arg = '[' . $reflection->getShortName() . ' ' . (string) $arg . ']';
222
-				} else {
223
-					$arg = '[' . $reflection->getShortName() . ']';
224
-				}
225
-				break;
226
-			default:
227
-				$arg = '[' . gettype($arg) . ']';
228
-				break;
229
-			}
230
-		});
231
-		$frame['file'] = str_replace(dirname(__DIR__), '', $frame['file']);
232
-		$message .= '#' . $level . ' ' . $frame['file'] . ':' . $frame['line'] . ' ';
233
-		if ($level) {
234
-			$message .= $frame['function'] . '(' . implode(', ', $frame['args']) . ')' . PHP_EOL;
235
-		} else {
236
-			$message .= get_class($ex) . '("' . $ex->getMessage() . '")' . PHP_EOL;
237
-		}
238
-	}
239
-
240
-	if (error_reporting() & $ex->getCode()) {
241
-		echo $message;
242
-	}
243
-
244
-	Log::addErrorLog($message);
200
+    $message = $ex->getFile() . ':' . $ex->getLine() . ' ' . $ex->getMessage() . PHP_EOL;
201
+
202
+    foreach ($ex->getTrace() as $level => $frame) {
203
+        $frame += array('args' => array(), 'file' => 'unknown', 'line' => 'unknown');
204
+        array_walk($frame['args'], function (&$arg) {
205
+            switch (gettype($arg)) {
206
+            case 'boolean':
207
+            case 'integer':
208
+            case 'double':
209
+            case 'null':
210
+                $arg = var_export($arg, true);
211
+                break;
212
+            case 'string':
213
+                if (mb_strlen($arg) > 30) {
214
+                    $arg = substr($arg, 0, 30) . '…';
215
+                }
216
+                $arg = var_export($arg, true);
217
+                break;
218
+            case 'object':
219
+                $reflection = new \ReflectionClass($arg);
220
+                if (is_object($arg) && method_exists($arg, '__toString')) {
221
+                    $arg = '[' . $reflection->getShortName() . ' ' . (string) $arg . ']';
222
+                } else {
223
+                    $arg = '[' . $reflection->getShortName() . ']';
224
+                }
225
+                break;
226
+            default:
227
+                $arg = '[' . gettype($arg) . ']';
228
+                break;
229
+            }
230
+        });
231
+        $frame['file'] = str_replace(dirname(__DIR__), '', $frame['file']);
232
+        $message .= '#' . $level . ' ' . $frame['file'] . ':' . $frame['line'] . ' ';
233
+        if ($level) {
234
+            $message .= $frame['function'] . '(' . implode(', ', $frame['args']) . ')' . PHP_EOL;
235
+        } else {
236
+            $message .= get_class($ex) . '("' . $ex->getMessage() . '")' . PHP_EOL;
237
+        }
238
+    }
239
+
240
+    if (error_reporting() & $ex->getCode()) {
241
+        echo $message;
242
+    }
243
+
244
+    Log::addErrorLog($message);
245 245
 });
246 246
 
247 247
 // Load our configuration file, so we can connect to the database
248 248
 if (file_exists(WT_ROOT . 'data/config.ini.php')) {
249
-	$dbconfig = parse_ini_file(WT_ROOT . 'data/config.ini.php');
250
-	// Invalid/unreadable config file?
251
-	if (!is_array($dbconfig)) {
252
-		header('Location: ' . WT_BASE_URL . 'site-unavailable.php');
253
-		exit;
254
-	}
255
-	// Down for maintenance?
256
-	if (file_exists(WT_ROOT . 'data/offline.txt')) {
257
-		header('Location: ' . WT_BASE_URL . 'site-offline.php');
258
-		exit;
259
-	}
249
+    $dbconfig = parse_ini_file(WT_ROOT . 'data/config.ini.php');
250
+    // Invalid/unreadable config file?
251
+    if (!is_array($dbconfig)) {
252
+        header('Location: ' . WT_BASE_URL . 'site-unavailable.php');
253
+        exit;
254
+    }
255
+    // Down for maintenance?
256
+    if (file_exists(WT_ROOT . 'data/offline.txt')) {
257
+        header('Location: ' . WT_BASE_URL . 'site-offline.php');
258
+        exit;
259
+    }
260 260
 } else {
261
-	// No config file. Set one up.
262
-	header('Location: ' . WT_BASE_URL . 'setup.php');
263
-	exit;
261
+    // No config file. Set one up.
262
+    header('Location: ' . WT_BASE_URL . 'setup.php');
263
+    exit;
264 264
 }
265 265
 
266 266
 // What is the remote client's IP address
267 267
 if (Filter::server('HTTP_CLIENT_IP') !== null) {
268
-	define('WT_CLIENT_IP', Filter::server('HTTP_CLIENT_IP'));
268
+    define('WT_CLIENT_IP', Filter::server('HTTP_CLIENT_IP'));
269 269
 } elseif (Filter::server('HTTP_X_FORWARDED_FOR') !== null) {
270
-	define('WT_CLIENT_IP', Filter::server('HTTP_X_FORWARDED_FOR'));
270
+    define('WT_CLIENT_IP', Filter::server('HTTP_X_FORWARDED_FOR'));
271 271
 } else {
272
-	define('WT_CLIENT_IP', Filter::server('REMOTE_ADDR', WT_REGEX_IPV4, '127.0.0.1'));
272
+    define('WT_CLIENT_IP', Filter::server('REMOTE_ADDR', WT_REGEX_IPV4, '127.0.0.1'));
273 273
 }
274 274
 
275 275
 // Connect to the database
276 276
 try {
277
-	Database::createInstance($dbconfig['dbhost'], $dbconfig['dbport'], $dbconfig['dbname'], $dbconfig['dbuser'], $dbconfig['dbpass']);
278
-	define('WT_TBLPREFIX', $dbconfig['tblpfx']);
279
-	unset($dbconfig);
280
-	// Some of the FAMILY JOIN HUSBAND JOIN WIFE queries can excede the MAX_JOIN_SIZE setting
281
-	Database::exec("SET NAMES 'utf8' COLLATE 'utf8_unicode_ci', SQL_BIG_SELECTS=1");
282
-	// Update the database schema
283
-	$updated = Database::updateSchema('\Fisharebest\Webtrees\Schema', 'WT_SCHEMA_VERSION', WT_SCHEMA_VERSION);
284
-	if ($updated) {
285
-		// updateSchema() might load custom modules - which we cannot load again.
286
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''));
287
-		exit;
288
-	}
277
+    Database::createInstance($dbconfig['dbhost'], $dbconfig['dbport'], $dbconfig['dbname'], $dbconfig['dbuser'], $dbconfig['dbpass']);
278
+    define('WT_TBLPREFIX', $dbconfig['tblpfx']);
279
+    unset($dbconfig);
280
+    // Some of the FAMILY JOIN HUSBAND JOIN WIFE queries can excede the MAX_JOIN_SIZE setting
281
+    Database::exec("SET NAMES 'utf8' COLLATE 'utf8_unicode_ci', SQL_BIG_SELECTS=1");
282
+    // Update the database schema
283
+    $updated = Database::updateSchema('\Fisharebest\Webtrees\Schema', 'WT_SCHEMA_VERSION', WT_SCHEMA_VERSION);
284
+    if ($updated) {
285
+        // updateSchema() might load custom modules - which we cannot load again.
286
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''));
287
+        exit;
288
+    }
289 289
 } catch (PDOException $ex) {
290
-	header('Location: ' . WT_BASE_URL . 'site-unavailable.php?message=' . rawurlencode($ex->getMessage()));
291
-	exit;
290
+    header('Location: ' . WT_BASE_URL . 'site-unavailable.php?message=' . rawurlencode($ex->getMessage()));
291
+    exit;
292 292
 }
293 293
 
294 294
 // The config.ini.php file must always be in a fixed location.
@@ -298,120 +298,120 @@  discard block
 block discarded – undo
298 298
 // If we have a preferred URL (e.g. www.example.com instead of www.isp.com/~example), then redirect to it.
299 299
 $SERVER_URL = Site::getPreference('SERVER_URL');
300 300
 if ($SERVER_URL && $SERVER_URL != WT_BASE_URL) {
301
-	header('Location: ' . $SERVER_URL . WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''), true, 301);
302
-	exit;
301
+    header('Location: ' . $SERVER_URL . WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''), true, 301);
302
+    exit;
303 303
 }
304 304
 
305 305
 // Request more resources - if we can/want to
306 306
 if (!ini_get('safe_mode')) {
307
-	$memory_limit = Site::getPreference('MEMORY_LIMIT');
308
-	if ($memory_limit && strpos(ini_get('disable_functions'), 'ini_set') === false) {
309
-		ini_set('memory_limit', $memory_limit);
310
-	}
311
-	$max_execution_time = Site::getPreference('MAX_EXECUTION_TIME');
312
-	if ($max_execution_time && strpos(ini_get('disable_functions'), 'set_time_limit') === false) {
313
-		set_time_limit($max_execution_time);
314
-	}
307
+    $memory_limit = Site::getPreference('MEMORY_LIMIT');
308
+    if ($memory_limit && strpos(ini_get('disable_functions'), 'ini_set') === false) {
309
+        ini_set('memory_limit', $memory_limit);
310
+    }
311
+    $max_execution_time = Site::getPreference('MAX_EXECUTION_TIME');
312
+    if ($max_execution_time && strpos(ini_get('disable_functions'), 'set_time_limit') === false) {
313
+        set_time_limit($max_execution_time);
314
+    }
315 315
 }
316 316
 
317 317
 $rule = Database::prepare(
318
-	"SELECT rule FROM `##site_access_rule`" .
319
-	" WHERE IFNULL(INET_ATON(?), 0) BETWEEN ip_address_start AND ip_address_end" .
320
-	" AND ? LIKE user_agent_pattern" .
321
-	" ORDER BY ip_address_end LIMIT 1"
318
+    "SELECT rule FROM `##site_access_rule`" .
319
+    " WHERE IFNULL(INET_ATON(?), 0) BETWEEN ip_address_start AND ip_address_end" .
320
+    " AND ? LIKE user_agent_pattern" .
321
+    " ORDER BY ip_address_end LIMIT 1"
322 322
 )->execute(array(WT_CLIENT_IP, Filter::server('HTTP_USER_AGENT', null, '')))->fetchOne();
323 323
 
324 324
 switch ($rule) {
325 325
 case 'allow':
326
-	$SEARCH_SPIDER = false;
327
-	break;
326
+    $SEARCH_SPIDER = false;
327
+    break;
328 328
 case 'deny':
329
-	http_response_code(403);
330
-	exit;
329
+    http_response_code(403);
330
+    exit;
331 331
 case 'robot':
332 332
 case 'unknown':
333
-	// Search engines don’t send cookies, and so create a new session with every visit.
334
-	// Make sure they always use the same one
335
-	Session::setId('search-engine-' . str_replace('.', '-', WT_CLIENT_IP));
336
-	$SEARCH_SPIDER = true;
337
-	break;
333
+    // Search engines don’t send cookies, and so create a new session with every visit.
334
+    // Make sure they always use the same one
335
+    Session::setId('search-engine-' . str_replace('.', '-', WT_CLIENT_IP));
336
+    $SEARCH_SPIDER = true;
337
+    break;
338 338
 case '':
339
-	Database::prepare(
340
-		"INSERT INTO `##site_access_rule` (ip_address_start, ip_address_end, user_agent_pattern, comment) VALUES (IFNULL(INET_ATON(?), 0), IFNULL(INET_ATON(?), 4294967295), ?, '')"
341
-	)->execute(array(WT_CLIENT_IP, WT_CLIENT_IP, Filter::server('HTTP_USER_AGENT', null, '')));
342
-	$SEARCH_SPIDER = true;
343
-	break;
339
+    Database::prepare(
340
+        "INSERT INTO `##site_access_rule` (ip_address_start, ip_address_end, user_agent_pattern, comment) VALUES (IFNULL(INET_ATON(?), 0), IFNULL(INET_ATON(?), 4294967295), ?, '')"
341
+    )->execute(array(WT_CLIENT_IP, WT_CLIENT_IP, Filter::server('HTTP_USER_AGENT', null, '')));
342
+    $SEARCH_SPIDER = true;
343
+    break;
344 344
 }
345 345
 
346 346
 // Store our session data in the database.
347 347
 session_set_save_handler(
348
-	// open
349
-	function () {
350
-		return true;
351
-	},
352
-	// close
353
-	function () {
354
-		return true;
355
-	},
356
-	// read
357
-	function ($id) {
358
-		return (string) Database::prepare("SELECT session_data FROM `##session` WHERE session_id=?")->execute(array($id))->fetchOne();
359
-	},
360
-	// write
361
-	function ($id, $data) {
362
-		// Only update the session table once per minute, unless the session data has actually changed.
363
-		Database::prepare(
364
-			"INSERT INTO `##session` (session_id, user_id, ip_address, session_data, session_time)" .
365
-			" VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP - SECOND(CURRENT_TIMESTAMP))" .
366
-			" ON DUPLICATE KEY UPDATE" .
367
-			" user_id      = VALUES(user_id)," .
368
-			" ip_address   = VALUES(ip_address)," .
369
-			" session_data = VALUES(session_data)," .
370
-			" session_time = CURRENT_TIMESTAMP - SECOND(CURRENT_TIMESTAMP)"
371
-		)->execute(array($id, (int) Auth::id(), WT_CLIENT_IP, $data));
372
-
373
-		return true;
374
-	},
375
-	// destroy
376
-	function ($id) {
377
-		Database::prepare("DELETE FROM `##session` WHERE session_id=?")->execute(array($id));
378
-
379
-		return true;
380
-	},
381
-	// gc
382
-	function ($maxlifetime) {
383
-		Database::prepare("DELETE FROM `##session` WHERE session_time < DATE_SUB(NOW(), INTERVAL ? SECOND)")->execute(array($maxlifetime));
384
-
385
-		return true;
386
-	}
348
+    // open
349
+    function () {
350
+        return true;
351
+    },
352
+    // close
353
+    function () {
354
+        return true;
355
+    },
356
+    // read
357
+    function ($id) {
358
+        return (string) Database::prepare("SELECT session_data FROM `##session` WHERE session_id=?")->execute(array($id))->fetchOne();
359
+    },
360
+    // write
361
+    function ($id, $data) {
362
+        // Only update the session table once per minute, unless the session data has actually changed.
363
+        Database::prepare(
364
+            "INSERT INTO `##session` (session_id, user_id, ip_address, session_data, session_time)" .
365
+            " VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP - SECOND(CURRENT_TIMESTAMP))" .
366
+            " ON DUPLICATE KEY UPDATE" .
367
+            " user_id      = VALUES(user_id)," .
368
+            " ip_address   = VALUES(ip_address)," .
369
+            " session_data = VALUES(session_data)," .
370
+            " session_time = CURRENT_TIMESTAMP - SECOND(CURRENT_TIMESTAMP)"
371
+        )->execute(array($id, (int) Auth::id(), WT_CLIENT_IP, $data));
372
+
373
+        return true;
374
+    },
375
+    // destroy
376
+    function ($id) {
377
+        Database::prepare("DELETE FROM `##session` WHERE session_id=?")->execute(array($id));
378
+
379
+        return true;
380
+    },
381
+    // gc
382
+    function ($maxlifetime) {
383
+        Database::prepare("DELETE FROM `##session` WHERE session_time < DATE_SUB(NOW(), INTERVAL ? SECOND)")->execute(array($maxlifetime));
384
+
385
+        return true;
386
+    }
387 387
 );
388 388
 
389 389
 Session::start(array(
390
-	'gc_maxlifetime' => Site::getPreference('SESSION_TIME'),
391
-	'cookie_path'    => implode('/', array_map('rawurlencode', explode('/', parse_url(WT_BASE_URL, PHP_URL_PATH)))),
390
+    'gc_maxlifetime' => Site::getPreference('SESSION_TIME'),
391
+    'cookie_path'    => implode('/', array_map('rawurlencode', explode('/', parse_url(WT_BASE_URL, PHP_URL_PATH)))),
392 392
 ));
393 393
 
394 394
 if (!Auth::isSearchEngine() && !Session::get('initiated')) {
395
-	// A new session, so prevent session fixation attacks by choosing a new PHPSESSID.
396
-	Session::regenerate(true);
397
-	Session::put('initiated', true);
395
+    // A new session, so prevent session fixation attacks by choosing a new PHPSESSID.
396
+    Session::regenerate(true);
397
+    Session::put('initiated', true);
398 398
 } else {
399
-	// An existing session
399
+    // An existing session
400 400
 }
401 401
 
402 402
 // Set the tree for the page; (1) the request, (2) the session, (3) the site default, (4) any tree
403 403
 foreach (array(Filter::post('ged'), Filter::get('ged'), Session::get('GEDCOM'), Site::getPreference('DEFAULT_GEDCOM')) as $tree_name) {
404
-	$WT_TREE = Tree::findByName($tree_name);
405
-	if ($WT_TREE) {
406
-		Session::put('GEDCOM', $tree_name);
407
-		break;
408
-	}
404
+    $WT_TREE = Tree::findByName($tree_name);
405
+    if ($WT_TREE) {
406
+        Session::put('GEDCOM', $tree_name);
407
+        break;
408
+    }
409 409
 }
410 410
 // No chosen tree? Use any one.
411 411
 if (!$WT_TREE) {
412
-	foreach (Tree::getAll() as $WT_TREE) {
413
-		break;
414
-	}
412
+    foreach (Tree::getAll() as $WT_TREE) {
413
+        break;
414
+    }
415 415
 }
416 416
 
417 417
 // With no parameters, init() looks to the environment to choose a language
@@ -423,9 +423,9 @@  discard block
 block discarded – undo
423 423
 
424 424
 // Users get their own time-zone. Visitors get the site time-zone.
425 425
 if (Auth::check()) {
426
-	date_default_timezone_set(Auth::user()->getPreference('TIMEZONE', 'UTC'));
426
+    date_default_timezone_set(Auth::user()->getPreference('TIMEZONE', 'UTC'));
427 427
 } else {
428
-	date_default_timezone_set(Site::getPreference('TIMEZONE') ?: 'UTC');
428
+    date_default_timezone_set(Site::getPreference('TIMEZONE') ?: 'UTC');
429 429
 }
430 430
 define('WT_TIMESTAMP_OFFSET', date_offset_get(new \DateTime('now')));
431 431
 
@@ -433,79 +433,79 @@  discard block
 block discarded – undo
433 433
 
434 434
 // The login URL must be an absolute URL, and can be user-defined
435 435
 if (Site::getPreference('LOGIN_URL')) {
436
-	define('WT_LOGIN_URL', Site::getPreference('LOGIN_URL'));
436
+    define('WT_LOGIN_URL', Site::getPreference('LOGIN_URL'));
437 437
 } else {
438
-	define('WT_LOGIN_URL', WT_BASE_URL . 'login.php');
438
+    define('WT_LOGIN_URL', WT_BASE_URL . 'login.php');
439 439
 }
440 440
 
441 441
 // If there is no current tree and we need one, then redirect somewhere
442 442
 if (WT_SCRIPT_NAME != 'admin_trees_manage.php' && WT_SCRIPT_NAME != 'admin_pgv_to_wt.php' && WT_SCRIPT_NAME != 'login.php' && WT_SCRIPT_NAME != 'logout.php' && WT_SCRIPT_NAME != 'import.php' && WT_SCRIPT_NAME != 'help_text.php' && WT_SCRIPT_NAME != 'message.php' && WT_SCRIPT_NAME != 'action.php') {
443
-	if (!$WT_TREE || !$WT_TREE->getPreference('imported')) {
444
-		if (Auth::isAdmin()) {
445
-			header('Location: ' . WT_BASE_URL . 'admin_trees_manage.php');
446
-		} else {
447
-			// We're not an administrator, so we can only log in if there is a tree.
448
-			if (Auth::id()) {
449
-				Auth::logout();
450
-				FlashMessages::addMessage(
451
-					I18N::translate('This user account does not have access to any tree.')
452
-				);
453
-			}
454
-			header('Location: ' . WT_LOGIN_URL . '?url=' . rawurlencode(WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')), true, 301);
455
-
456
-		}
457
-		exit;
458
-	}
443
+    if (!$WT_TREE || !$WT_TREE->getPreference('imported')) {
444
+        if (Auth::isAdmin()) {
445
+            header('Location: ' . WT_BASE_URL . 'admin_trees_manage.php');
446
+        } else {
447
+            // We're not an administrator, so we can only log in if there is a tree.
448
+            if (Auth::id()) {
449
+                Auth::logout();
450
+                FlashMessages::addMessage(
451
+                    I18N::translate('This user account does not have access to any tree.')
452
+                );
453
+            }
454
+            header('Location: ' . WT_LOGIN_URL . '?url=' . rawurlencode(WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')), true, 301);
455
+
456
+        }
457
+        exit;
458
+    }
459 459
 }
460 460
 
461 461
 // Update the last-login time no more than once a minute
462 462
 if (WT_TIMESTAMP - Session::get('activity_time') >= 60) {
463
-	if (Session::get('masquerade') === null) {
464
-		Auth::user()->setPreference('sessiontime', WT_TIMESTAMP);
465
-	}
466
-	Session::put('activity_time', WT_TIMESTAMP);
463
+    if (Session::get('masquerade') === null) {
464
+        Auth::user()->setPreference('sessiontime', WT_TIMESTAMP);
465
+    }
466
+    Session::put('activity_time', WT_TIMESTAMP);
467 467
 }
468 468
 
469 469
 // Set the theme
470 470
 if (substr(WT_SCRIPT_NAME, 0, 5) === 'admin' || WT_SCRIPT_NAME === 'module.php' && substr(Filter::get('mod_action'), 0, 5) === 'admin') {
471
-	// Administration scripts begin with “admin” and use a special administration theme
472
-	Theme::theme(new AdministrationTheme)->init($WT_TREE);
471
+    // Administration scripts begin with “admin” and use a special administration theme
472
+    Theme::theme(new AdministrationTheme)->init($WT_TREE);
473 473
 } else {
474
-	// Last theme used?
475
-	$theme_id = Session::get('theme_id');
476
-	// Default for tree
477
-	if (!array_key_exists($theme_id, Theme::themeNames()) && $WT_TREE) {
478
-		$theme_id = $WT_TREE->getPreference('THEME_DIR');
479
-	}
480
-	// Default for site
481
-	if (!array_key_exists($theme_id, Theme::themeNames())) {
482
-		$theme_id = Site::getPreference('THEME_DIR');
483
-	}
484
-	// Default
485
-	if (!array_key_exists($theme_id, Theme::themeNames())) {
486
-		$theme_id = 'webtrees';
487
-	}
488
-	foreach (Theme::installedThemes() as $theme) {
489
-		if ($theme->themeId() === $theme_id) {
490
-			Theme::theme($theme)->init($WT_TREE);
491
-			// Remember this setting
492
-			if (Site::getPreference('ALLOW_USER_THEMES')) {
493
-				Session::put('theme_id', $theme_id);
494
-			}
495
-			break;
496
-		}
497
-	}
474
+    // Last theme used?
475
+    $theme_id = Session::get('theme_id');
476
+    // Default for tree
477
+    if (!array_key_exists($theme_id, Theme::themeNames()) && $WT_TREE) {
478
+        $theme_id = $WT_TREE->getPreference('THEME_DIR');
479
+    }
480
+    // Default for site
481
+    if (!array_key_exists($theme_id, Theme::themeNames())) {
482
+        $theme_id = Site::getPreference('THEME_DIR');
483
+    }
484
+    // Default
485
+    if (!array_key_exists($theme_id, Theme::themeNames())) {
486
+        $theme_id = 'webtrees';
487
+    }
488
+    foreach (Theme::installedThemes() as $theme) {
489
+        if ($theme->themeId() === $theme_id) {
490
+            Theme::theme($theme)->init($WT_TREE);
491
+            // Remember this setting
492
+            if (Site::getPreference('ALLOW_USER_THEMES')) {
493
+                Session::put('theme_id', $theme_id);
494
+            }
495
+            break;
496
+        }
497
+    }
498 498
 }
499 499
 
500 500
 // Search engines are only allowed to see certain pages.
501 501
 if (Auth::isSearchEngine() && !in_array(WT_SCRIPT_NAME, array(
502
-	'index.php', 'indilist.php', 'module.php', 'mediafirewall.php',
503
-	'individual.php', 'family.php', 'mediaviewer.php', 'note.php', 'repo.php', 'source.php',
502
+    'index.php', 'indilist.php', 'module.php', 'mediafirewall.php',
503
+    'individual.php', 'family.php', 'mediaviewer.php', 'note.php', 'repo.php', 'source.php',
504 504
 ))) {
505
-	http_response_code(403);
506
-	$controller = new PageController;
507
-	$controller->setPageTitle(I18N::translate('Search engine'));
508
-	$controller->pageHeader();
509
-	echo '<p class="ui-state-error">', I18N::translate('You do not have permission to view this page.'), '</p>';
510
-	exit;
505
+    http_response_code(403);
506
+    $controller = new PageController;
507
+    $controller->setPageTitle(I18N::translate('Search engine'));
508
+    $controller->pageHeader();
509
+    echo '<p class="ui-state-error">', I18N::translate('You do not have permission to view this page.'), '</p>';
510
+    exit;
511 511
 }
Please login to merge, or discard this patch.
admin_module_charts.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -24,29 +24,29 @@
 block discarded – undo
24 24
 
25 25
 $controller = new PageController;
26 26
 $controller
27
-	->restrictAccess(Auth::isAdmin())
28
-	->setPageTitle(I18N::translate('Charts'));
27
+    ->restrictAccess(Auth::isAdmin())
28
+    ->setPageTitle(I18N::translate('Charts'));
29 29
 
30 30
 $action  = Filter::post('action');
31 31
 $modules = Module::getAllModulesByComponent('chart');
32 32
 
33 33
 if ($action === 'update_mods' && Filter::checkCsrf()) {
34
-	foreach ($modules as $module) {
35
-		foreach (Tree::getAll() as $tree) {
36
-			$access_level = Filter::post('access-' . $module->getName() . '-' . $tree->getTreeId(), WT_REGEX_INTEGER, $module->defaultAccessLevel());
37
-			Database::prepare(
38
-				"REPLACE INTO `##module_privacy` (module_name, gedcom_id, component, access_level) VALUES (?, ?, 'chart', ?)"
39
-			)->execute(array($module->getName(), $tree->getTreeId(), $access_level));
40
-		}
41
-	}
34
+    foreach ($modules as $module) {
35
+        foreach (Tree::getAll() as $tree) {
36
+            $access_level = Filter::post('access-' . $module->getName() . '-' . $tree->getTreeId(), WT_REGEX_INTEGER, $module->defaultAccessLevel());
37
+            Database::prepare(
38
+                "REPLACE INTO `##module_privacy` (module_name, gedcom_id, component, access_level) VALUES (?, ?, 'chart', ?)"
39
+            )->execute(array($module->getName(), $tree->getTreeId(), $access_level));
40
+        }
41
+    }
42 42
 
43
-	header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
43
+    header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
44 44
 
45
-	return;
45
+    return;
46 46
 }
47 47
 
48 48
 $controller
49
-	->pageHeader();
49
+    ->pageHeader();
50 50
 
51 51
 ?>
52 52
 <ol class="breadcrumb small">
Please login to merge, or discard this patch.
find.php 2 patches
Indentation   +376 added lines, -376 removed lines patch added patch discarded remove patch
@@ -41,66 +41,66 @@  discard block
 block discarded – undo
41 41
 $qs        = Filter::get('tags');
42 42
 
43 43
 if ($subclick === 'all') {
44
-	$all = true;
44
+    $all = true;
45 45
 }
46 46
 
47 47
 $embed = substr($choose, 0, 1) === '1';
48 48
 
49 49
 switch ($type) {
50 50
 case 'indi':
51
-	$controller->setPageTitle(I18N::translate('Find an individual'));
52
-	break;
51
+    $controller->setPageTitle(I18N::translate('Find an individual'));
52
+    break;
53 53
 case 'fam':
54
-	$controller->setPageTitle(I18N::translate('Find a family'));
55
-	break;
54
+    $controller->setPageTitle(I18N::translate('Find a family'));
55
+    break;
56 56
 case 'media':
57
-	$controller->setPageTitle(I18N::translate('Find a media object'));
58
-	break;
57
+    $controller->setPageTitle(I18N::translate('Find a media object'));
58
+    break;
59 59
 case 'place':
60
-	$controller->setPageTitle(I18N::translate('Find a place'));
61
-	break;
60
+    $controller->setPageTitle(I18N::translate('Find a place'));
61
+    break;
62 62
 case 'repo':
63
-	$controller->setPageTitle(I18N::translate('Find a repository'));
64
-	break;
63
+    $controller->setPageTitle(I18N::translate('Find a repository'));
64
+    break;
65 65
 case 'note':
66
-	$controller->setPageTitle(I18N::translate('Find a shared note'));
67
-	break;
66
+    $controller->setPageTitle(I18N::translate('Find a shared note'));
67
+    break;
68 68
 case 'source':
69
-	$controller->setPageTitle(I18N::translate('Find a source'));
70
-	break;
69
+    $controller->setPageTitle(I18N::translate('Find a source'));
70
+    break;
71 71
 case 'specialchar':
72
-	$controller->setPageTitle(I18N::translate('Find a special character'));
73
-	break;
72
+    $controller->setPageTitle(I18N::translate('Find a special character'));
73
+    break;
74 74
 case 'factINDI':
75
-	$controller
76
-		->setPageTitle(I18N::translate('Find a fact or event'))
77
-		->addInlineJavascript('initPickFact("INDI");');
78
-	break;
75
+    $controller
76
+        ->setPageTitle(I18N::translate('Find a fact or event'))
77
+        ->addInlineJavascript('initPickFact("INDI");');
78
+    break;
79 79
 case 'factFAM':
80
-	$controller
81
-		->setPageTitle(I18N::translate('Find a fact or event'))
82
-		->addInlineJavascript('initPickFact("FAM");');
83
-	break;
80
+    $controller
81
+        ->setPageTitle(I18N::translate('Find a fact or event'))
82
+        ->addInlineJavascript('initPickFact("FAM");');
83
+    break;
84 84
 case 'factSOUR':
85
-	$controller
86
-		->setPageTitle(I18N::translate('Find a fact or event'))
87
-		->addInlineJavascript('initPickFact("SOUR");');
88
-	break;
85
+    $controller
86
+        ->setPageTitle(I18N::translate('Find a fact or event'))
87
+        ->addInlineJavascript('initPickFact("SOUR");');
88
+    break;
89 89
 case 'factREPO':
90
-	$controller
91
-		->setPageTitle(I18N::translate('Find a fact or event'))
92
-		->addInlineJavascript('initPickFact("REPO");');
93
-	break;
90
+    $controller
91
+        ->setPageTitle(I18N::translate('Find a fact or event'))
92
+        ->addInlineJavascript('initPickFact("REPO");');
93
+    break;
94 94
 case 'factNAME':
95
-	$controller
96
-		->setPageTitle(I18N::translate('Find a fact or event'))
97
-		->addInlineJavascript('initPickFact("NAME");');
98
-	break;
95
+    $controller
96
+        ->setPageTitle(I18N::translate('Find a fact or event'))
97
+        ->addInlineJavascript('initPickFact("NAME");');
98
+    break;
99 99
 case 'factPLAC':
100
-	$controller
101
-		->setPageTitle(I18N::translate('Find a fact or event'))
102
-		->addInlineJavascript('initPickFact("PLAC");');
103
-	break;
100
+    $controller
101
+        ->setPageTitle(I18N::translate('Find a fact or event'))
102
+        ->addInlineJavascript('initPickFact("PLAC");');
103
+    break;
104 104
 }
105 105
 $controller->pageHeader();
106 106
 
@@ -140,41 +140,41 @@  discard block
 block discarded – undo
140 140
 
141 141
 // Show indi and hide the rest
142 142
 if ($type == "indi") {
143
-	echo '<div id="find-header">
143
+    echo '<div id="find-header">
144 144
 	<form name="filterindi" method="get" onsubmit="return checknames(this);" action="find.php">
145 145
 	<input type="hidden" name="callback" value="' . $callback . '">
146 146
 	<input type="hidden" name="action" value="filter">
147 147
 	<input type="hidden" name="type" value="indi">
148 148
 	<span>', /* I18N: Label for search field */ I18N::translate('Name contains'), '</span>
149 149
 	<input type="text" name="filter" value="';
150
-	if ($filter) {
151
-		echo $filter;
152
-	}
153
-	echo '" autofocus>
150
+    if ($filter) {
151
+        echo $filter;
152
+    }
153
+    echo '" autofocus>
154 154
 	<input type="submit" value="', I18N::translate('search'), '">
155 155
 	</form></div>';
156 156
 }
157 157
 
158 158
 // Show fam and hide the rest
159 159
 if ($type == "fam") {
160
-	echo '<div id="find-header">
160
+    echo '<div id="find-header">
161 161
 	<form name="filterfam" method="get" onsubmit="return checknames(this);" action="find.php">
162 162
 	<input type="hidden" name="callback" value="' . $callback . '">
163 163
 	<input type="hidden" name="action" value="filter">
164 164
 	<input type="hidden" name="type" value="fam">
165 165
 	<span>', I18N::translate('Name contains'), '</span>
166 166
 	<input type="text" name="filter" value="';
167
-	if ($filter) {
168
-		echo $filter;
169
-	}
170
-	echo '" autofocus>
167
+    if ($filter) {
168
+        echo $filter;
169
+    }
170
+    echo '" autofocus>
171 171
 	<input type="submit" value="', I18N::translate('search'), '">
172 172
 	</form></div>';
173 173
 }
174 174
 
175 175
 // Show media and hide the rest
176 176
 if ($type == 'media') {
177
-	echo '<div id="find-header">
177
+    echo '<div id="find-header">
178 178
 	<form name="filtermedia" method="get" action="find.php">
179 179
 	<input type="hidden" name="choose" value="', $choose, '">
180 180
 	<input type="hidden" name="action" value="filter">
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 	<input type="hidden" name="subclick">
184 184
 	<span>', /* I18N: Label for search field */ I18N::translate('Media contains'), '</span>
185 185
 	<input type="text" name="filter" value="';
186
-	if ($filter) {
187
-		echo $filter;
188
-	}
189
-	echo '" autofocus>',
190
-	'<p><input type="submit" name="search" value="', I18N::translate('search'), '" onclick="this.form.subclick.value=this.name">
186
+    if ($filter) {
187
+        echo $filter;
188
+    }
189
+    echo '" autofocus>',
190
+    '<p><input type="submit" name="search" value="', I18N::translate('search'), '" onclick="this.form.subclick.value=this.name">
191 191
 	</p></form></div>';
192 192
 }
193 193
 
194 194
 // Show place and hide the rest
195 195
 if ($type == "place") {
196
-	echo '<div id="find-header">
196
+    echo '<div id="find-header">
197 197
 	<form name="filterplace" method="get" action="find.php">
198 198
 	<input type="hidden" name="action" value="filter">
199 199
 	<input type="hidden" name="type" value="place">
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
 	<input type="hidden" name="subclick">
202 202
 	<span>', /* I18N: Label for search field */ I18N::translate('Place contains'), '</span>
203 203
 	<input type="text" name="filter" value="';
204
-	if ($filter) {
205
-		echo $filter;
206
-	}
207
-	echo '" autofocus>
204
+    if ($filter) {
205
+        echo $filter;
206
+    }
207
+    echo '" autofocus>
208 208
 	<p><input type="submit" name="search" value="', I18N::translate('search'), '" onclick="this.form.subclick.value=this.name">
209 209
 	</p></form></div>';
210 210
 }
211 211
 
212 212
 // Show repo and hide the rest
213 213
 if ($type == "repo") {
214
-	echo '<div id="find-header">
214
+    echo '<div id="find-header">
215 215
 	<form name="filterrepo" method="get" action="find.php">
216 216
 	<input type="hidden" name="action" value="filter">
217 217
 	<input type="hidden" name="type" value="repo">
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
 	<input type="hidden" name="subclick">
220 220
 	<span>', /* I18N: Label for search field */ I18N::translate('Repository contains'), '</span>
221 221
 	<input type="text" name="filter" value="';
222
-	if ($filter) {
223
-		echo $filter;
224
-	}
225
-	echo '" autofocus>
222
+    if ($filter) {
223
+        echo $filter;
224
+    }
225
+    echo '" autofocus>
226 226
 	<p><input type="submit" name="search" value="', I18N::translate('search'), '" onclick="this.form.subclick.value=this.name">
227 227
 	</td></tr></table>
228 228
 	</p></form></div>';
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
 // Show Shared Notes and hide the rest
232 232
 if ($type == "note") {
233
-	echo '<div id="find-header">
233
+    echo '<div id="find-header">
234 234
 	<form name="filternote" method="get" action="find.php">
235 235
 	<input type="hidden" name="action" value="filter">
236 236
 	<input type="hidden" name="type" value="note">
@@ -238,17 +238,17 @@  discard block
 block discarded – undo
238 238
 	<input type="hidden" name="subclick">
239 239
 	<span>', /* I18N: Label for search field */ I18N::translate('Shared note contains'), '</span>
240 240
 	<input type="text" name="filter" value="';
241
-	if ($filter) {
242
-		echo $filter;
243
-	}
244
-	echo '" autofocus>
241
+    if ($filter) {
242
+        echo $filter;
243
+    }
244
+    echo '" autofocus>
245 245
 	<p><input type="submit" name="search" value="', I18N::translate('search'), '" onclick="this.form.subclick.value=this.name">
246 246
 	</p></form></div>';
247 247
 }
248 248
 
249 249
 // Show source and hide the rest
250 250
 if ($type == "source") {
251
-	echo '<div id="find-header">
251
+    echo '<div id="find-header">
252 252
 	<form name="filtersource" method="get" action="find.php">
253 253
 	<input type="hidden" name="action" value="filter">
254 254
 	<input type="hidden" name="type" value="source">
@@ -256,43 +256,43 @@  discard block
 block discarded – undo
256 256
 	<input type="hidden" name="subclick">
257 257
 	<span>', /* I18N: Label for search field */ I18N::translate('Source contains'), '</span>
258 258
 	<input type="text" name="filter" value="';
259
-	if ($filter) {
260
-		echo $filter;
261
-	}
262
-	echo '" autofocus>
259
+    if ($filter) {
260
+        echo $filter;
261
+    }
262
+    echo '" autofocus>
263 263
 	<p><input type="submit" name="search" value="', I18N::translate('search'), '" onclick="this.form.subclick.value=this.name">
264 264
 	</p></form></div>';
265 265
 }
266 266
 
267 267
 // Show specialchar and hide the rest
268 268
 if ($type == 'specialchar') {
269
-	$language_filter       = Filter::get('language_filter', null, Auth::user()->getPreference('default_language_filter'));
270
-	$specialchar_languages = SpecialChars::allLanguages();
271
-	if (!array_key_exists($language_filter, $specialchar_languages)) {
272
-		$language_filter = 'en';
273
-	}
274
-	Auth::user()->setPreference('default_language_filter', $language_filter);
275
-	$action = 'filter';
276
-	echo '<div id="find-header">
269
+    $language_filter       = Filter::get('language_filter', null, Auth::user()->getPreference('default_language_filter'));
270
+    $specialchar_languages = SpecialChars::allLanguages();
271
+    if (!array_key_exists($language_filter, $specialchar_languages)) {
272
+        $language_filter = 'en';
273
+    }
274
+    Auth::user()->setPreference('default_language_filter', $language_filter);
275
+    $action = 'filter';
276
+    echo '<div id="find-header">
277 277
 	<form name="filterspecialchar" method="get" action="find.php">
278 278
 	<input type="hidden" name="action" value="filter">
279 279
 	<input type="hidden" name="type" value="specialchar">
280 280
 	<input type="hidden" name="callback" value="' . $callback . '">
281 281
 	<p><select id="language_filter" name="language_filter" onchange="submit();">';
282
-	foreach (SpecialChars::allLanguages() as $lanuguage_tag => $language_name) {
283
-		echo '<option value="' . $lanuguage_tag . '" ';
284
-		if ($lanuguage_tag === $language_filter) {
285
-			echo 'selected';
286
-		}
287
-		echo '>', $language_name, '</option>';
288
-	}
289
-	echo '</select>
282
+    foreach (SpecialChars::allLanguages() as $lanuguage_tag => $language_name) {
283
+        echo '<option value="' . $lanuguage_tag . '" ';
284
+        if ($lanuguage_tag === $language_filter) {
285
+            echo 'selected';
286
+        }
287
+        echo '>', $language_name, '</option>';
288
+    }
289
+    echo '</select>
290 290
 	</p></form></div>';
291 291
 }
292 292
 
293 293
 // Show facts
294 294
 if ($type == "factINDI" || $type == "factFAM" || $type == "factSOUR" || $type == "factREPO" || $type == "factNAME" || $type == "factPLAC") {
295
-	echo '<div id="find-facts-header">
295
+    echo '<div id="find-facts-header">
296 296
 	<form name="filterfacts" method="get" action="find.php"
297 297
 	input type="hidden" name="type" value="facts">
298 298
 	<input type="hidden" name="tags" value="', $qs, '">
@@ -300,18 +300,18 @@  discard block
 block discarded – undo
300 300
 	<table class="list_table width100" border="0">
301 301
 	<tr><td class="list_label" style="padding: 5px; font-weight: normal; white-space: normal;">';
302 302
 
303
-	$all           = strlen($qs) ? explode(',', strtoupper($qs)) : array();
304
-	$preselDefault = array();
305
-	$preselCustom  = array();
306
-	foreach ($all as $one) {
307
-		if (GedcomTag::isTag($one)) {
308
-			$preselDefault[] = $one;
309
-		} else {
310
-			$preselCustom[] = $one;
311
-		}
312
-	}
313
-
314
-	echo '<script>'; ?>
303
+    $all           = strlen($qs) ? explode(',', strtoupper($qs)) : array();
304
+    $preselDefault = array();
305
+    $preselCustom  = array();
306
+    foreach ($all as $one) {
307
+        if (GedcomTag::isTag($one)) {
308
+            $preselDefault[] = $one;
309
+        } else {
310
+            $preselCustom[] = $one;
311
+        }
312
+    }
313
+
314
+    echo '<script>'; ?>
315 315
 	// A class representing a default tag
316 316
 	function DefaultTag(id, name, selected) {
317 317
 		this.Id=id;
@@ -402,81 +402,81 @@  discard block
 block discarded – undo
402 402
 		switch (factType) {
403 403
 			case "INDI":
404 404
 				DefaultTags=[<?php
405
-				$firstFact = true;
406
-				foreach (GedcomTag::getPicklistFacts('INDI') as $factId => $factName) {
407
-					if ($firstFact) {
408
-						$firstFact = false;
409
-					} else {
410
-						echo ',';
411
-					}
412
-					echo 'new DefaultTag("' . addslashes($factId) . '","' . addslashes($factName) . '",preselectedDefaultTags.indexOf("\\x01' . addslashes($factId) . '\\x01")>=0)';
413
-				}
414
-				?>];
405
+                $firstFact = true;
406
+                foreach (GedcomTag::getPicklistFacts('INDI') as $factId => $factName) {
407
+                    if ($firstFact) {
408
+                        $firstFact = false;
409
+                    } else {
410
+                        echo ',';
411
+                    }
412
+                    echo 'new DefaultTag("' . addslashes($factId) . '","' . addslashes($factName) . '",preselectedDefaultTags.indexOf("\\x01' . addslashes($factId) . '\\x01")>=0)';
413
+                }
414
+                ?>];
415 415
 				break;
416 416
 			case "FAM":
417 417
 				DefaultTags=[<?php
418
-				$firstFact = true;
419
-				foreach (GedcomTag::getPicklistFacts('FAM') as $factId => $factName) {
420
-					if ($firstFact) {
421
-						$firstFact = false;
422
-					} else {
423
-						echo ',';
424
-					}
425
-					echo 'new DefaultTag("' . addslashes($factId) . '","' . addslashes($factName) . '",preselectedDefaultTags.indexOf("\\x01' . addslashes($factId) . '\\x01")>=0)';
426
-				}
427
-				?>];
418
+                $firstFact = true;
419
+                foreach (GedcomTag::getPicklistFacts('FAM') as $factId => $factName) {
420
+                    if ($firstFact) {
421
+                        $firstFact = false;
422
+                    } else {
423
+                        echo ',';
424
+                    }
425
+                    echo 'new DefaultTag("' . addslashes($factId) . '","' . addslashes($factName) . '",preselectedDefaultTags.indexOf("\\x01' . addslashes($factId) . '\\x01")>=0)';
426
+                }
427
+                ?>];
428 428
 				break;
429 429
 			case "SOUR":
430 430
 				DefaultTags=[<?php
431
-				$firstFact = true;
432
-				foreach (GedcomTag::getPicklistFacts('SOUR') as $factId => $factName) {
433
-					if ($firstFact) {
434
-						$firstFact = false;
435
-					} else {
436
-						echo ',';
437
-					}
438
-					echo 'new DefaultTag("' . addslashes($factId) . '","' . addslashes($factName) . '",preselectedDefaultTags.indexOf("\\x01' . addslashes($factId) . '\\x01")>=0)';
439
-				}
440
-				?>];
431
+                $firstFact = true;
432
+                foreach (GedcomTag::getPicklistFacts('SOUR') as $factId => $factName) {
433
+                    if ($firstFact) {
434
+                        $firstFact = false;
435
+                    } else {
436
+                        echo ',';
437
+                    }
438
+                    echo 'new DefaultTag("' . addslashes($factId) . '","' . addslashes($factName) . '",preselectedDefaultTags.indexOf("\\x01' . addslashes($factId) . '\\x01")>=0)';
439
+                }
440
+                ?>];
441 441
 				break;
442 442
 			case "REPO":
443 443
 				DefaultTags=[<?php
444
-				$firstFact = true;
445
-				foreach (GedcomTag::getPicklistFacts('REPO') as $factId => $factName) {
446
-					if ($firstFact) {
447
-						$firstFact = false;
448
-					} else {
449
-						echo ',';
450
-					}
451
-					echo 'new DefaultTag("' . addslashes($factId) . '","' . addslashes($factName) . '",preselectedDefaultTags.indexOf("\\x01' . addslashes($factId) . '\\x01")>=0)';
452
-				}
453
-				?>];
444
+                $firstFact = true;
445
+                foreach (GedcomTag::getPicklistFacts('REPO') as $factId => $factName) {
446
+                    if ($firstFact) {
447
+                        $firstFact = false;
448
+                    } else {
449
+                        echo ',';
450
+                    }
451
+                    echo 'new DefaultTag("' . addslashes($factId) . '","' . addslashes($factName) . '",preselectedDefaultTags.indexOf("\\x01' . addslashes($factId) . '\\x01")>=0)';
452
+                }
453
+                ?>];
454 454
 				break;
455 455
 			case "PLAC":
456 456
 				DefaultTags=[<?php
457
-				$firstFact = true;
458
-				foreach (GedcomTag::getPicklistFacts('PLAC') as $factId => $factName) {
459
-					if ($firstFact) {
460
-						$firstFact = false;
461
-					} else {
462
-						echo ',';
463
-					}
464
-					echo 'new DefaultTag("' . addslashes($factId) . '","' . addslashes($factName) . '",preselectedDefaultTags.indexOf("\\x01' . addslashes($factId) . '\\x01")>=0)';
465
-				}
466
-				?>];
457
+                $firstFact = true;
458
+                foreach (GedcomTag::getPicklistFacts('PLAC') as $factId => $factName) {
459
+                    if ($firstFact) {
460
+                        $firstFact = false;
461
+                    } else {
462
+                        echo ',';
463
+                    }
464
+                    echo 'new DefaultTag("' . addslashes($factId) . '","' . addslashes($factName) . '",preselectedDefaultTags.indexOf("\\x01' . addslashes($factId) . '\\x01")>=0)';
465
+                }
466
+                ?>];
467 467
 				break;
468 468
 			case "NAME":
469 469
 				DefaultTags=[<?php
470
-				$firstFact = true;
471
-				foreach (GedcomTag::getPicklistFacts('NAME') as $factId => $factName) {
472
-					if ($firstFact) {
473
-						$firstFact = false;
474
-					} else {
475
-						echo ',';
476
-					}
477
-					echo 'new DefaultTag("' . addslashes($factId) . '","' . addslashes($factName) . '",preselectedDefaultTags.indexOf("\\x01' . addslashes($factId) . '\\x01")>=0)';
478
-				}
479
-				?>];
470
+                $firstFact = true;
471
+                foreach (GedcomTag::getPicklistFacts('NAME') as $factId => $factName) {
472
+                    if ($firstFact) {
473
+                        $firstFact = false;
474
+                    } else {
475
+                        echo ',';
476
+                    }
477
+                    echo 'new DefaultTag("' . addslashes($factId) . '","' . addslashes($factName) . '",preselectedDefaultTags.indexOf("\\x01' . addslashes($factId) . '\\x01")>=0)';
478
+                }
479
+                ?>];
480 480
 				break;
481 481
 			default:
482 482
 				DefaultTags=[];
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 		return false;
514 514
 	}
515 515
 	<?php echo '</script>';
516
-	echo '<div id="layDefinedTags"><table id="tabDefinedTags">
516
+    echo '<div id="layDefinedTags"><table id="tabDefinedTags">
517 517
 		<thead><tr>
518 518
 			<th></th>
519 519
 			<th>', I18N::translate('Tag'), '</th>
@@ -541,221 +541,221 @@  discard block
 block discarded – undo
541 541
 }
542 542
 
543 543
 if ($action === 'filter') {
544
-	$filter       = trim($filter);
545
-	$filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter));
546
-
547
-	// Output Individual
548
-	if ($type === 'indi') {
549
-		echo '<div id="find-output">';
550
-		$myindilist = FunctionsDb::searchIndividualNames($filter_array, array($WT_TREE));
551
-		if ($myindilist) {
552
-			echo '<ul>';
553
-			usort($myindilist, '\Fisharebest\Webtrees\GedcomRecord::compare');
554
-			foreach ($myindilist as $indi) {
555
-				echo $indi->formatList('li', true);
556
-			}
557
-			echo '</ul>
544
+    $filter       = trim($filter);
545
+    $filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter));
546
+
547
+    // Output Individual
548
+    if ($type === 'indi') {
549
+        echo '<div id="find-output">';
550
+        $myindilist = FunctionsDb::searchIndividualNames($filter_array, array($WT_TREE));
551
+        if ($myindilist) {
552
+            echo '<ul>';
553
+            usort($myindilist, '\Fisharebest\Webtrees\GedcomRecord::compare');
554
+            foreach ($myindilist as $indi) {
555
+                echo $indi->formatList('li', true);
556
+            }
557
+            echo '</ul>
558 558
 			<p>', I18N::translate('Total individuals: %s', count($myindilist)), '</p>';
559
-		} else {
560
-			echo '<p>', I18N::translate('No results found.'), '</p>';
561
-		}
562
-		echo '</div>';
563
-	}
564
-
565
-	// Output Family
566
-	if ($type == "fam") {
567
-		echo '<div id="find-output">';
568
-		// Get the famrecs with hits on names from the family table
569
-		// Get the famrecs with hits in the gedcom record from the family table
570
-		$myfamlist = array_unique(array_merge(
571
-			FunctionsDb::searchFamilyNames($filter_array, array($WT_TREE)),
572
-			FunctionsDb::searchFamilies($filter_array, array($WT_TREE))
573
-		));
574
-
575
-		if ($myfamlist) {
576
-			echo '<ul>';
577
-			usort($myfamlist, '\Fisharebest\Webtrees\GedcomRecord::compare');
578
-			foreach ($myfamlist as $family) {
579
-				echo $family->formatList('li', true);
580
-			}
581
-			echo '</ul>
559
+        } else {
560
+            echo '<p>', I18N::translate('No results found.'), '</p>';
561
+        }
562
+        echo '</div>';
563
+    }
564
+
565
+    // Output Family
566
+    if ($type == "fam") {
567
+        echo '<div id="find-output">';
568
+        // Get the famrecs with hits on names from the family table
569
+        // Get the famrecs with hits in the gedcom record from the family table
570
+        $myfamlist = array_unique(array_merge(
571
+            FunctionsDb::searchFamilyNames($filter_array, array($WT_TREE)),
572
+            FunctionsDb::searchFamilies($filter_array, array($WT_TREE))
573
+        ));
574
+
575
+        if ($myfamlist) {
576
+            echo '<ul>';
577
+            usort($myfamlist, '\Fisharebest\Webtrees\GedcomRecord::compare');
578
+            foreach ($myfamlist as $family) {
579
+                echo $family->formatList('li', true);
580
+            }
581
+            echo '</ul>
582 582
 			<p>', I18N::translate('Total families: %s', count($myfamlist)), '</p>';
583
-		} else {
584
-			echo '<p>', I18N::translate('No results found.'), '</p>';
585
-		}
586
-		echo '</div>';
587
-	}
588
-
589
-	// Output Media
590
-	if ($type === 'media') {
591
-		$medialist = QueryMedia::mediaList('', 'include', 'title', $filter, '');
592
-
593
-		echo '<div id="find-output">';
594
-
595
-		if ($medialist) {
596
-			foreach ($medialist as $media) {
597
-				echo '<div class="find-media-media">';
598
-				echo '<div class="find-media-thumb">', $media->displayImage(), '</div>';
599
-				echo '<div class="find-media-details">', $media->getFullName(), '</div>';
600
-				if (!$embed) {
601
-					echo '<p><a href="#" dir="auto" onclick="pasteid(\'', $media->getXref(), '\');">', $media->getFilename(), '</a></p>';
602
-				} else {
603
-					echo '<p><a href="#" dir="auto" onclick="pasteid(\'', $media->getXref(), '\', \'', '\', \'', Filter::escapeJs($media->getFilename()), '\');">', Filter::escapeHtml($media->getFilename()), '</a></p> ';
604
-				}
605
-				if ($media->fileExists()) {
606
-					$imgsize = $media->getImageAttributes();
607
-					echo GedcomTag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']);
608
-				}
609
-				echo '<ul>';
610
-				$found = false;
611
-				foreach ($media->linkedIndividuals('OBJE') as $indindividual) {
612
-					echo '<li>', $indindividual->getFullName(), '</li>';
613
-					$found = true;
614
-				}
615
-				foreach ($media->linkedFamilies('OBJE') as $family) {
616
-					echo '<li>', $family->getFullName(), '</li>';
617
-					$found = true;
618
-				}
619
-				foreach ($media->linkedSources('OBJE') as $source) {
620
-					echo '<li>', $source->getFullName(), '</li>';
621
-					$found = true;
622
-				}
623
-				foreach ($media->linkedNotes('OBJE') as $note) {
624
-					// Invalid GEDCOM - you cannot link a NOTE to an OBJE
625
-					echo '<li>', $note->getFullName(), '</li>';
626
-					$found = true;
627
-				}
628
-				foreach ($media->linkedRepositories('OBJE') as $repository) {
629
-					// Invalid GEDCOM - you cannot link a REPO to an OBJE
630
-					echo '<li>', $repository->getFullName(), '</li>';
631
-					$found = true;
632
-				}
633
-				if (!$found) {
634
-					echo '<li>', I18N::translate('This media object is not linked to any other record.'), '</li>';
635
-				}
636
-				echo '</ul>';
637
-				echo '</div>'; // close div="find-media-media"
638
-			}
639
-		} else {
640
-			echo '<p>', I18N::translate('No results found.'), '</p>';
641
-		}
642
-		echo '</div>';
643
-	}
644
-
645
-	// Output Places
646
-	if ($type == "place") {
647
-		echo '<div id="find-output">';
648
-		if (!$filter || $all) {
649
-			$places = Place::allPlaces($WT_TREE);
650
-		} else {
651
-			$places = Place::findPlaces($filter, $WT_TREE);
652
-		}
653
-		if ($places) {
654
-			echo '<ul>';
655
-			foreach ($places as $place) {
656
-				echo '<li><a href="#" onclick="pasteid(\'', Filter::escapeJs($place->getGedcomName()), '\');">';
657
-				if (!$filter || $all) {
658
-					echo $place->getReverseName(); // When displaying all names, sort/display by the country, then region, etc.
659
-				} else {
660
-					echo $place->getFullName(); // When we’ve searched for a place, sort by this place
661
-				}
662
-				echo '</a></li>';
663
-			}
664
-			echo '</ul>
583
+        } else {
584
+            echo '<p>', I18N::translate('No results found.'), '</p>';
585
+        }
586
+        echo '</div>';
587
+    }
588
+
589
+    // Output Media
590
+    if ($type === 'media') {
591
+        $medialist = QueryMedia::mediaList('', 'include', 'title', $filter, '');
592
+
593
+        echo '<div id="find-output">';
594
+
595
+        if ($medialist) {
596
+            foreach ($medialist as $media) {
597
+                echo '<div class="find-media-media">';
598
+                echo '<div class="find-media-thumb">', $media->displayImage(), '</div>';
599
+                echo '<div class="find-media-details">', $media->getFullName(), '</div>';
600
+                if (!$embed) {
601
+                    echo '<p><a href="#" dir="auto" onclick="pasteid(\'', $media->getXref(), '\');">', $media->getFilename(), '</a></p>';
602
+                } else {
603
+                    echo '<p><a href="#" dir="auto" onclick="pasteid(\'', $media->getXref(), '\', \'', '\', \'', Filter::escapeJs($media->getFilename()), '\');">', Filter::escapeHtml($media->getFilename()), '</a></p> ';
604
+                }
605
+                if ($media->fileExists()) {
606
+                    $imgsize = $media->getImageAttributes();
607
+                    echo GedcomTag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']);
608
+                }
609
+                echo '<ul>';
610
+                $found = false;
611
+                foreach ($media->linkedIndividuals('OBJE') as $indindividual) {
612
+                    echo '<li>', $indindividual->getFullName(), '</li>';
613
+                    $found = true;
614
+                }
615
+                foreach ($media->linkedFamilies('OBJE') as $family) {
616
+                    echo '<li>', $family->getFullName(), '</li>';
617
+                    $found = true;
618
+                }
619
+                foreach ($media->linkedSources('OBJE') as $source) {
620
+                    echo '<li>', $source->getFullName(), '</li>';
621
+                    $found = true;
622
+                }
623
+                foreach ($media->linkedNotes('OBJE') as $note) {
624
+                    // Invalid GEDCOM - you cannot link a NOTE to an OBJE
625
+                    echo '<li>', $note->getFullName(), '</li>';
626
+                    $found = true;
627
+                }
628
+                foreach ($media->linkedRepositories('OBJE') as $repository) {
629
+                    // Invalid GEDCOM - you cannot link a REPO to an OBJE
630
+                    echo '<li>', $repository->getFullName(), '</li>';
631
+                    $found = true;
632
+                }
633
+                if (!$found) {
634
+                    echo '<li>', I18N::translate('This media object is not linked to any other record.'), '</li>';
635
+                }
636
+                echo '</ul>';
637
+                echo '</div>'; // close div="find-media-media"
638
+            }
639
+        } else {
640
+            echo '<p>', I18N::translate('No results found.'), '</p>';
641
+        }
642
+        echo '</div>';
643
+    }
644
+
645
+    // Output Places
646
+    if ($type == "place") {
647
+        echo '<div id="find-output">';
648
+        if (!$filter || $all) {
649
+            $places = Place::allPlaces($WT_TREE);
650
+        } else {
651
+            $places = Place::findPlaces($filter, $WT_TREE);
652
+        }
653
+        if ($places) {
654
+            echo '<ul>';
655
+            foreach ($places as $place) {
656
+                echo '<li><a href="#" onclick="pasteid(\'', Filter::escapeJs($place->getGedcomName()), '\');">';
657
+                if (!$filter || $all) {
658
+                    echo $place->getReverseName(); // When displaying all names, sort/display by the country, then region, etc.
659
+                } else {
660
+                    echo $place->getFullName(); // When we’ve searched for a place, sort by this place
661
+                }
662
+                echo '</a></li>';
663
+            }
664
+            echo '</ul>
665 665
 			<p>', I18N::translate('Places found'), ' ', count($places), '</p>';
666
-		} else {
667
-			echo '<p>', I18N::translate('No results found.'), '</p>';
668
-		}
669
-		echo '</div>';
670
-	}
671
-
672
-	// Output Repositories
673
-	if ($type == "repo") {
674
-		echo '<div id="find-output">';
675
-		if ($filter) {
676
-			$repo_list = FunctionsDb::searchRepositories($filter_array, array($WT_TREE));
677
-		} else {
678
-			$repo_list = FunctionsDb::getRepositoryList($WT_TREE);
679
-		}
680
-		if ($repo_list) {
681
-			usort($repo_list, '\Fisharebest\Webtrees\GedcomRecord::compare');
682
-			echo '<ul>';
683
-			foreach ($repo_list as $repo) {
684
-				echo '<li><a href="', $repo->getHtmlUrl(), '" onclick="pasteid(\'', $repo->getXref(), '\');"><span class="list_item">', $repo->getFullName(), '</span></a></li>';
685
-			}
686
-			echo '</ul>
666
+        } else {
667
+            echo '<p>', I18N::translate('No results found.'), '</p>';
668
+        }
669
+        echo '</div>';
670
+    }
671
+
672
+    // Output Repositories
673
+    if ($type == "repo") {
674
+        echo '<div id="find-output">';
675
+        if ($filter) {
676
+            $repo_list = FunctionsDb::searchRepositories($filter_array, array($WT_TREE));
677
+        } else {
678
+            $repo_list = FunctionsDb::getRepositoryList($WT_TREE);
679
+        }
680
+        if ($repo_list) {
681
+            usort($repo_list, '\Fisharebest\Webtrees\GedcomRecord::compare');
682
+            echo '<ul>';
683
+            foreach ($repo_list as $repo) {
684
+                echo '<li><a href="', $repo->getHtmlUrl(), '" onclick="pasteid(\'', $repo->getXref(), '\');"><span class="list_item">', $repo->getFullName(), '</span></a></li>';
685
+            }
686
+            echo '</ul>
687 687
 			<p>', I18N::translate('Repositories found'), " ", count($repo_list), '</p>';
688
-		} else {
689
-			echo '<p>', I18N::translate('No results found.'), '</p>';
690
-		}
691
-		echo '</div>';
692
-	}
693
-
694
-	// Output Shared Notes
695
-	if ($type == "note") {
696
-		echo '<div id="find-output">';
697
-		if ($filter) {
698
-			$mynotelist = FunctionsDb::searchNotes($filter_array, array($WT_TREE));
699
-		} else {
700
-			$mynotelist = FunctionsDb::getNoteList($WT_TREE);
701
-		}
702
-		if ($mynotelist) {
703
-			usort($mynotelist, '\Fisharebest\Webtrees\GedcomRecord::compare');
704
-			echo '<ul>';
705
-			foreach ($mynotelist as $note) {
706
-				echo '<li><a href="', $note->getHtmlUrl(), '" onclick="pasteid(\'', $note->getXref(), '\');"><span class="list_item">', $note->getFullName(), '</span></a></li>';
707
-			}
708
-			echo '</ul>
688
+        } else {
689
+            echo '<p>', I18N::translate('No results found.'), '</p>';
690
+        }
691
+        echo '</div>';
692
+    }
693
+
694
+    // Output Shared Notes
695
+    if ($type == "note") {
696
+        echo '<div id="find-output">';
697
+        if ($filter) {
698
+            $mynotelist = FunctionsDb::searchNotes($filter_array, array($WT_TREE));
699
+        } else {
700
+            $mynotelist = FunctionsDb::getNoteList($WT_TREE);
701
+        }
702
+        if ($mynotelist) {
703
+            usort($mynotelist, '\Fisharebest\Webtrees\GedcomRecord::compare');
704
+            echo '<ul>';
705
+            foreach ($mynotelist as $note) {
706
+                echo '<li><a href="', $note->getHtmlUrl(), '" onclick="pasteid(\'', $note->getXref(), '\');"><span class="list_item">', $note->getFullName(), '</span></a></li>';
707
+            }
708
+            echo '</ul>
709 709
 			<p>', I18N::translate('Shared notes found'), ' ', count($mynotelist), '</p>';
710
-		} else {
711
-			echo '<p>', I18N::translate('No results found.'), '</p>';
712
-		}
713
-		echo '</div>';
714
-	}
715
-
716
-	// Output Sources
717
-	if ($type == "source") {
718
-		echo '<div id="find-output">';
719
-		if ($filter) {
720
-			$mysourcelist = FunctionsDb::searchSources($filter_array, array($WT_TREE));
721
-		} else {
722
-			$mysourcelist = FunctionsDb::getSourceList($WT_TREE);
723
-		}
724
-		if ($mysourcelist) {
725
-			usort($mysourcelist, '\Fisharebest\Webtrees\GedcomRecord::compare');
726
-			echo '<ul>';
727
-			foreach ($mysourcelist as $source) {
728
-				echo '<li><a href="', $source->getHtmlUrl(), '" onclick="pasteid(\'', $source->getXref(), '\', \'',
729
-					Filter::escapeJs($source->getFullName()), '\');"><span class="list_item">',
730
-					$source->getFullName(), '</span></a></li>';
731
-			}
732
-			echo '</ul>
710
+        } else {
711
+            echo '<p>', I18N::translate('No results found.'), '</p>';
712
+        }
713
+        echo '</div>';
714
+    }
715
+
716
+    // Output Sources
717
+    if ($type == "source") {
718
+        echo '<div id="find-output">';
719
+        if ($filter) {
720
+            $mysourcelist = FunctionsDb::searchSources($filter_array, array($WT_TREE));
721
+        } else {
722
+            $mysourcelist = FunctionsDb::getSourceList($WT_TREE);
723
+        }
724
+        if ($mysourcelist) {
725
+            usort($mysourcelist, '\Fisharebest\Webtrees\GedcomRecord::compare');
726
+            echo '<ul>';
727
+            foreach ($mysourcelist as $source) {
728
+                echo '<li><a href="', $source->getHtmlUrl(), '" onclick="pasteid(\'', $source->getXref(), '\', \'',
729
+                    Filter::escapeJs($source->getFullName()), '\');"><span class="list_item">',
730
+                    $source->getFullName(), '</span></a></li>';
731
+            }
732
+            echo '</ul>
733 733
 			<p>', I18N::translate('Total sources: %s', count($mysourcelist)), '</p>';
734
-		} else {
735
-			echo '<p>', I18N::translate('No results found.'), '</p>';
736
-		}
737
-		echo '</div>';
738
-	}
739
-
740
-	// Output Special Characters
741
-	if ($type == "specialchar") {
742
-		echo '<div id="find-output-special"><p>';
743
-		// lower case special characters
744
-		foreach (SpecialChars::create($language_filter)->upper() as $special_character) {
745
-			echo '<a class="largechars" href="#" onclick="return window.opener.paste_char(\'', $special_character, '\');">', $special_character, '</a> ';
746
-		}
747
-		echo '</p><p>';
748
-		//upper case special characters
749
-		foreach (SpecialChars::create($language_filter)->lower() as $special_character) {
750
-			echo '<a class="largechars" href="#" onclick="return window.opener.paste_char(\'', $special_character, '\');">', $special_character, '</a> ';
751
-		}
752
-		echo '</p><p>';
753
-		// other special characters (not letters)
754
-		foreach (SpecialChars::create($language_filter)->other() as $special_character) {
755
-			echo '<a class="largechars" href="#" onclick="return window.opener.paste_char(\'', $special_character, '\');">', $special_character, '</a> ';
756
-		}
757
-		echo '</p></div>';
758
-	}
734
+        } else {
735
+            echo '<p>', I18N::translate('No results found.'), '</p>';
736
+        }
737
+        echo '</div>';
738
+    }
739
+
740
+    // Output Special Characters
741
+    if ($type == "specialchar") {
742
+        echo '<div id="find-output-special"><p>';
743
+        // lower case special characters
744
+        foreach (SpecialChars::create($language_filter)->upper() as $special_character) {
745
+            echo '<a class="largechars" href="#" onclick="return window.opener.paste_char(\'', $special_character, '\');">', $special_character, '</a> ';
746
+        }
747
+        echo '</p><p>';
748
+        //upper case special characters
749
+        foreach (SpecialChars::create($language_filter)->lower() as $special_character) {
750
+            echo '<a class="largechars" href="#" onclick="return window.opener.paste_char(\'', $special_character, '\');">', $special_character, '</a> ';
751
+        }
752
+        echo '</p><p>';
753
+        // other special characters (not letters)
754
+        foreach (SpecialChars::create($language_filter)->other() as $special_character) {
755
+            echo '<a class="largechars" href="#" onclick="return window.opener.paste_char(\'', $special_character, '\');">', $special_character, '</a> ';
756
+        }
757
+        echo '</p></div>';
758
+    }
759 759
 }
760 760
 echo '<button onclick="window.close();">', I18N::translate('close'), '</button>';
761 761
 echo "</div>";
Please login to merge, or discard this patch.
Switch Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -47,60 +47,60 @@
 block discarded – undo
47 47
 $embed = substr($choose, 0, 1) === '1';
48 48
 
49 49
 switch ($type) {
50
-case 'indi':
51
-	$controller->setPageTitle(I18N::translate('Find an individual'));
52
-	break;
53
-case 'fam':
54
-	$controller->setPageTitle(I18N::translate('Find a family'));
55
-	break;
56
-case 'media':
57
-	$controller->setPageTitle(I18N::translate('Find a media object'));
58
-	break;
59
-case 'place':
60
-	$controller->setPageTitle(I18N::translate('Find a place'));
61
-	break;
62
-case 'repo':
63
-	$controller->setPageTitle(I18N::translate('Find a repository'));
64
-	break;
65
-case 'note':
66
-	$controller->setPageTitle(I18N::translate('Find a shared note'));
67
-	break;
68
-case 'source':
69
-	$controller->setPageTitle(I18N::translate('Find a source'));
70
-	break;
71
-case 'specialchar':
72
-	$controller->setPageTitle(I18N::translate('Find a special character'));
73
-	break;
74
-case 'factINDI':
75
-	$controller
76
-		->setPageTitle(I18N::translate('Find a fact or event'))
77
-		->addInlineJavascript('initPickFact("INDI");');
78
-	break;
79
-case 'factFAM':
80
-	$controller
81
-		->setPageTitle(I18N::translate('Find a fact or event'))
82
-		->addInlineJavascript('initPickFact("FAM");');
83
-	break;
84
-case 'factSOUR':
85
-	$controller
86
-		->setPageTitle(I18N::translate('Find a fact or event'))
87
-		->addInlineJavascript('initPickFact("SOUR");');
88
-	break;
89
-case 'factREPO':
90
-	$controller
91
-		->setPageTitle(I18N::translate('Find a fact or event'))
92
-		->addInlineJavascript('initPickFact("REPO");');
93
-	break;
94
-case 'factNAME':
95
-	$controller
96
-		->setPageTitle(I18N::translate('Find a fact or event'))
97
-		->addInlineJavascript('initPickFact("NAME");');
98
-	break;
99
-case 'factPLAC':
100
-	$controller
101
-		->setPageTitle(I18N::translate('Find a fact or event'))
102
-		->addInlineJavascript('initPickFact("PLAC");');
103
-	break;
50
+    case 'indi':
51
+	    $controller->setPageTitle(I18N::translate('Find an individual'));
52
+	    break;
53
+    case 'fam':
54
+	    $controller->setPageTitle(I18N::translate('Find a family'));
55
+	    break;
56
+    case 'media':
57
+	    $controller->setPageTitle(I18N::translate('Find a media object'));
58
+	    break;
59
+    case 'place':
60
+	    $controller->setPageTitle(I18N::translate('Find a place'));
61
+	    break;
62
+    case 'repo':
63
+	    $controller->setPageTitle(I18N::translate('Find a repository'));
64
+	    break;
65
+    case 'note':
66
+	    $controller->setPageTitle(I18N::translate('Find a shared note'));
67
+	    break;
68
+    case 'source':
69
+	    $controller->setPageTitle(I18N::translate('Find a source'));
70
+	    break;
71
+    case 'specialchar':
72
+	    $controller->setPageTitle(I18N::translate('Find a special character'));
73
+	    break;
74
+    case 'factINDI':
75
+	    $controller
76
+		    ->setPageTitle(I18N::translate('Find a fact or event'))
77
+		    ->addInlineJavascript('initPickFact("INDI");');
78
+	    break;
79
+    case 'factFAM':
80
+	    $controller
81
+		    ->setPageTitle(I18N::translate('Find a fact or event'))
82
+		    ->addInlineJavascript('initPickFact("FAM");');
83
+	    break;
84
+    case 'factSOUR':
85
+	    $controller
86
+		    ->setPageTitle(I18N::translate('Find a fact or event'))
87
+		    ->addInlineJavascript('initPickFact("SOUR");');
88
+	    break;
89
+    case 'factREPO':
90
+	    $controller
91
+		    ->setPageTitle(I18N::translate('Find a fact or event'))
92
+		    ->addInlineJavascript('initPickFact("REPO");');
93
+	    break;
94
+    case 'factNAME':
95
+	    $controller
96
+		    ->setPageTitle(I18N::translate('Find a fact or event'))
97
+		    ->addInlineJavascript('initPickFact("NAME");');
98
+	    break;
99
+    case 'factPLAC':
100
+	    $controller
101
+		    ->setPageTitle(I18N::translate('Find a fact or event'))
102
+		    ->addInlineJavascript('initPickFact("PLAC");');
103
+	    break;
104 104
 }
105 105
 $controller->pageHeader();
106 106
 
Please login to merge, or discard this patch.
search.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@
 block discarded – undo
23 23
 
24 24
 $controller = new SearchController;
25 25
 $controller
26
-	->pageHeader()
27
-	->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
28
-	->addInlineJavascript('autocomplete();');
26
+    ->pageHeader()
27
+    ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
28
+    ->addInlineJavascript('autocomplete();');
29 29
 
30 30
 ?>
31 31
 <script>
Please login to merge, or discard this patch.