Completed
Push — 1.7 ( d3e363...adf9f9 )
by Greg
08:36
created
admin_trees_renumber.php 1 patch
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.
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 1 patch
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.
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 1 patch
Indentation   +256 added lines, -256 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.
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
 
154 154
 // We want to know about all PHP errors during development, and fewer in production.
155 155
 if (WT_DEBUG) {
156
-	error_reporting(E_ALL | E_STRICT | E_NOTICE | E_DEPRECATED);
156
+    error_reporting(E_ALL | E_STRICT | E_NOTICE | E_DEPRECATED);
157 157
 } else {
158
-	error_reporting(E_ALL);
158
+    error_reporting(E_ALL);
159 159
 }
160 160
 
161 161
 require WT_ROOT . 'vendor/autoload.php';
@@ -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
@@ -190,102 +190,102 @@  discard block
 block discarded – undo
190 190
 
191 191
 // Convert PHP errors into exceptions
192 192
 set_error_handler(function ($errno, $errstr, $errfile, $errline) {
193
-	throw new \ErrorException($errfile . ':' . $errline . ' ' . $errstr, $errno);
193
+    throw new \ErrorException($errfile . ':' . $errline . ' ' . $errstr, $errno);
194 194
 });
195 195
 
196 196
 set_exception_handler(function ($ex) {
197
-	$message = $ex->getFile() . ':' . $ex->getLine() . ' ' . $ex->getMessage() . PHP_EOL;
198
-
199
-	foreach ($ex->getTrace() as $level => $frame) {
200
-		$frame += array('args' => array(), 'file' => 'unknown', 'line' => 'unknown');
201
-		array_walk($frame['args'], function (&$arg) {
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;
226
-			}
227
-		});
228
-		$frame['file'] = str_replace(dirname(__DIR__), '', $frame['file']);
229
-		$message .= '#' . $level . ' ' . $frame['file'] . ':' . $frame['line'] . ' ';
230
-		if ($level) {
231
-			$message .= $frame['function'] . '(' . implode(', ', $frame['args']) . ')' . PHP_EOL;
232
-		} else {
233
-			$message .= get_class($ex) . '("' . $ex->getMessage() . '")' . PHP_EOL;
234
-		}
235
-	}
236
-
237
-	if (true || error_reporting() & $ex->getCode()) {
238
-		echo $message;
239
-	}
240
-
241
-	Log::addErrorLog($message);
197
+    $message = $ex->getFile() . ':' . $ex->getLine() . ' ' . $ex->getMessage() . PHP_EOL;
198
+
199
+    foreach ($ex->getTrace() as $level => $frame) {
200
+        $frame += array('args' => array(), 'file' => 'unknown', 'line' => 'unknown');
201
+        array_walk($frame['args'], function (&$arg) {
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;
226
+            }
227
+        });
228
+        $frame['file'] = str_replace(dirname(__DIR__), '', $frame['file']);
229
+        $message .= '#' . $level . ' ' . $frame['file'] . ':' . $frame['line'] . ' ';
230
+        if ($level) {
231
+            $message .= $frame['function'] . '(' . implode(', ', $frame['args']) . ')' . PHP_EOL;
232
+        } else {
233
+            $message .= get_class($ex) . '("' . $ex->getMessage() . '")' . PHP_EOL;
234
+        }
235
+    }
236
+
237
+    if (true || error_reporting() & $ex->getCode()) {
238
+        echo $message;
239
+    }
240
+
241
+    Log::addErrorLog($message);
242 242
 });
243 243
 
244 244
 // Load our configuration file, so we can connect to the database
245 245
 if (file_exists(WT_ROOT . 'data/config.ini.php')) {
246
-	$dbconfig = parse_ini_file(WT_ROOT . 'data/config.ini.php');
247
-	// Invalid/unreadable config file?
248
-	if (!is_array($dbconfig)) {
249
-		header('Location: ' . WT_BASE_URL . 'site-unavailable.php');
250
-		exit;
251
-	}
252
-	// Down for maintenance?
253
-	if (file_exists(WT_ROOT . 'data/offline.txt')) {
254
-		header('Location: ' . WT_BASE_URL . 'site-offline.php');
255
-		exit;
256
-	}
246
+    $dbconfig = parse_ini_file(WT_ROOT . 'data/config.ini.php');
247
+    // Invalid/unreadable config file?
248
+    if (!is_array($dbconfig)) {
249
+        header('Location: ' . WT_BASE_URL . 'site-unavailable.php');
250
+        exit;
251
+    }
252
+    // Down for maintenance?
253
+    if (file_exists(WT_ROOT . 'data/offline.txt')) {
254
+        header('Location: ' . WT_BASE_URL . 'site-offline.php');
255
+        exit;
256
+    }
257 257
 } else {
258
-	// No config file. Set one up.
259
-	header('Location: ' . WT_BASE_URL . 'setup.php');
260
-	exit;
258
+    // No config file. Set one up.
259
+    header('Location: ' . WT_BASE_URL . 'setup.php');
260
+    exit;
261 261
 }
262 262
 
263 263
 // What is the remote client's IP address
264 264
 if (Filter::server('HTTP_CLIENT_IP') !== null) {
265
-	define('WT_CLIENT_IP', Filter::server('HTTP_CLIENT_IP'));
265
+    define('WT_CLIENT_IP', Filter::server('HTTP_CLIENT_IP'));
266 266
 } elseif (Filter::server('HTTP_X_FORWARDED_FOR') !== null) {
267
-	define('WT_CLIENT_IP', Filter::server('HTTP_X_FORWARDED_FOR'));
267
+    define('WT_CLIENT_IP', Filter::server('HTTP_X_FORWARDED_FOR'));
268 268
 } else {
269
-	define('WT_CLIENT_IP', Filter::server('REMOTE_ADDR', WT_REGEX_IPV4, '127.0.0.1'));
269
+    define('WT_CLIENT_IP', Filter::server('REMOTE_ADDR', WT_REGEX_IPV4, '127.0.0.1'));
270 270
 }
271 271
 
272 272
 // Connect to the database
273 273
 try {
274
-	Database::createInstance($dbconfig['dbhost'], $dbconfig['dbport'], $dbconfig['dbname'], $dbconfig['dbuser'], $dbconfig['dbpass']);
275
-	define('WT_TBLPREFIX', $dbconfig['tblpfx']);
276
-	unset($dbconfig);
277
-	// Some of the FAMILY JOIN HUSBAND JOIN WIFE queries can excede the MAX_JOIN_SIZE setting
278
-	Database::exec("SET NAMES 'utf8' COLLATE 'utf8_unicode_ci', SQL_BIG_SELECTS=1");
279
-	// Update the database schema
280
-	$updated = Database::updateSchema('\Fisharebest\Webtrees\Schema', 'WT_SCHEMA_VERSION', WT_SCHEMA_VERSION);
281
-	if ($updated) {
282
-		// updateSchema() might load custom modules - which we cannot load again.
283
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''));
284
-		exit;
285
-	}
274
+    Database::createInstance($dbconfig['dbhost'], $dbconfig['dbport'], $dbconfig['dbname'], $dbconfig['dbuser'], $dbconfig['dbpass']);
275
+    define('WT_TBLPREFIX', $dbconfig['tblpfx']);
276
+    unset($dbconfig);
277
+    // Some of the FAMILY JOIN HUSBAND JOIN WIFE queries can excede the MAX_JOIN_SIZE setting
278
+    Database::exec("SET NAMES 'utf8' COLLATE 'utf8_unicode_ci', SQL_BIG_SELECTS=1");
279
+    // Update the database schema
280
+    $updated = Database::updateSchema('\Fisharebest\Webtrees\Schema', 'WT_SCHEMA_VERSION', WT_SCHEMA_VERSION);
281
+    if ($updated) {
282
+        // updateSchema() might load custom modules - which we cannot load again.
283
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''));
284
+        exit;
285
+    }
286 286
 } catch (PDOException $ex) {
287
-	header('Location: ' . WT_BASE_URL . 'site-unavailable.php?message=' . rawurlencode($ex->getMessage()));
288
-	exit;
287
+    header('Location: ' . WT_BASE_URL . 'site-unavailable.php?message=' . rawurlencode($ex->getMessage()));
288
+    exit;
289 289
 }
290 290
 
291 291
 // The config.ini.php file must always be in a fixed location.
@@ -295,120 +295,120 @@  discard block
 block discarded – undo
295 295
 // If we have a preferred URL (e.g. www.example.com instead of www.isp.com/~example), then redirect to it.
296 296
 $SERVER_URL = Site::getPreference('SERVER_URL');
297 297
 if ($SERVER_URL && $SERVER_URL != WT_BASE_URL) {
298
-	header('Location: ' . $SERVER_URL . WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''), true, 301);
299
-	exit;
298
+    header('Location: ' . $SERVER_URL . WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''), true, 301);
299
+    exit;
300 300
 }
301 301
 
302 302
 // Request more resources - if we can/want to
303 303
 if (!ini_get('safe_mode')) {
304
-	$memory_limit = Site::getPreference('MEMORY_LIMIT');
305
-	if ($memory_limit && strpos(ini_get('disable_functions'), 'ini_set') === false) {
306
-		ini_set('memory_limit', $memory_limit);
307
-	}
308
-	$max_execution_time = Site::getPreference('MAX_EXECUTION_TIME');
309
-	if ($max_execution_time && strpos(ini_get('disable_functions'), 'set_time_limit') === false) {
310
-		set_time_limit($max_execution_time);
311
-	}
304
+    $memory_limit = Site::getPreference('MEMORY_LIMIT');
305
+    if ($memory_limit && strpos(ini_get('disable_functions'), 'ini_set') === false) {
306
+        ini_set('memory_limit', $memory_limit);
307
+    }
308
+    $max_execution_time = Site::getPreference('MAX_EXECUTION_TIME');
309
+    if ($max_execution_time && strpos(ini_get('disable_functions'), 'set_time_limit') === false) {
310
+        set_time_limit($max_execution_time);
311
+    }
312 312
 }
313 313
 
314 314
 $rule = Database::prepare(
315
-	"SELECT rule FROM `##site_access_rule`" .
316
-	" WHERE IFNULL(INET_ATON(?), 0) BETWEEN ip_address_start AND ip_address_end" .
317
-	" AND ? LIKE user_agent_pattern" .
318
-	" ORDER BY ip_address_end LIMIT 1"
315
+    "SELECT rule FROM `##site_access_rule`" .
316
+    " WHERE IFNULL(INET_ATON(?), 0) BETWEEN ip_address_start AND ip_address_end" .
317
+    " AND ? LIKE user_agent_pattern" .
318
+    " ORDER BY ip_address_end LIMIT 1"
319 319
 )->execute(array(WT_CLIENT_IP, Filter::server('HTTP_USER_AGENT', null, '')))->fetchOne();
320 320
 
321 321
 switch ($rule) {
322 322
 case 'allow':
323
-	$SEARCH_SPIDER = false;
324
-	break;
323
+    $SEARCH_SPIDER = false;
324
+    break;
325 325
 case 'deny':
326
-	http_response_code(403);
327
-	exit;
326
+    http_response_code(403);
327
+    exit;
328 328
 case 'robot':
329 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;
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 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;
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.
344 344
 session_set_save_handler(
345
-	// open
346
-	function () {
347
-		return true;
348
-	},
349
-	// close
350
-	function () {
351
-		return true;
352
-	},
353
-	// read
354
-	function ($id) {
355
-		return (string) Database::prepare("SELECT session_data FROM `##session` WHERE session_id=?")->execute(array($id))->fetchOne();
356
-	},
357
-	// write
358
-	function ($id, $data) {
359
-		// Only update the session table once per minute, unless the session data has actually changed.
360
-		Database::prepare(
361
-			"INSERT INTO `##session` (session_id, user_id, ip_address, session_data, session_time)" .
362
-			" VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP - SECOND(CURRENT_TIMESTAMP))" .
363
-			" ON DUPLICATE KEY UPDATE" .
364
-			" user_id      = VALUES(user_id)," .
365
-			" ip_address   = VALUES(ip_address)," .
366
-			" session_data = VALUES(session_data)," .
367
-			" session_time = CURRENT_TIMESTAMP - SECOND(CURRENT_TIMESTAMP)"
368
-		)->execute(array($id, (int) Auth::id(), WT_CLIENT_IP, $data));
369
-
370
-		return true;
371
-	},
372
-	// destroy
373
-	function ($id) {
374
-		Database::prepare("DELETE FROM `##session` WHERE session_id=?")->execute(array($id));
375
-
376
-		return true;
377
-	},
378
-	// gc
379
-	function ($maxlifetime) {
380
-		Database::prepare("DELETE FROM `##session` WHERE session_time < DATE_SUB(NOW(), INTERVAL ? SECOND)")->execute(array($maxlifetime));
381
-
382
-		return true;
383
-	}
345
+    // open
346
+    function () {
347
+        return true;
348
+    },
349
+    // close
350
+    function () {
351
+        return true;
352
+    },
353
+    // read
354
+    function ($id) {
355
+        return (string) Database::prepare("SELECT session_data FROM `##session` WHERE session_id=?")->execute(array($id))->fetchOne();
356
+    },
357
+    // write
358
+    function ($id, $data) {
359
+        // Only update the session table once per minute, unless the session data has actually changed.
360
+        Database::prepare(
361
+            "INSERT INTO `##session` (session_id, user_id, ip_address, session_data, session_time)" .
362
+            " VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP - SECOND(CURRENT_TIMESTAMP))" .
363
+            " ON DUPLICATE KEY UPDATE" .
364
+            " user_id      = VALUES(user_id)," .
365
+            " ip_address   = VALUES(ip_address)," .
366
+            " session_data = VALUES(session_data)," .
367
+            " session_time = CURRENT_TIMESTAMP - SECOND(CURRENT_TIMESTAMP)"
368
+        )->execute(array($id, (int) Auth::id(), WT_CLIENT_IP, $data));
369
+
370
+        return true;
371
+    },
372
+    // destroy
373
+    function ($id) {
374
+        Database::prepare("DELETE FROM `##session` WHERE session_id=?")->execute(array($id));
375
+
376
+        return true;
377
+    },
378
+    // gc
379
+    function ($maxlifetime) {
380
+        Database::prepare("DELETE FROM `##session` WHERE session_time < DATE_SUB(NOW(), INTERVAL ? SECOND)")->execute(array($maxlifetime));
381
+
382
+        return true;
383
+    }
384 384
 );
385 385
 
386 386
 Session::start(array(
387
-	'gc_maxlifetime' => Site::getPreference('SESSION_TIME'),
388
-	'cookie_path'    => implode('/', array_map('rawurlencode', explode('/', parse_url(WT_BASE_URL, PHP_URL_PATH)))),
387
+    'gc_maxlifetime' => Site::getPreference('SESSION_TIME'),
388
+    'cookie_path'    => implode('/', array_map('rawurlencode', explode('/', parse_url(WT_BASE_URL, PHP_URL_PATH)))),
389 389
 ));
390 390
 
391 391
 if (!Auth::isSearchEngine() && !Session::get('initiated')) {
392
-	// A new session, so prevent session fixation attacks by choosing a new PHPSESSID.
393
-	Session::regenerate(true);
394
-	Session::put('initiated', true);
392
+    // A new session, so prevent session fixation attacks by choosing a new PHPSESSID.
393
+    Session::regenerate(true);
394
+    Session::put('initiated', true);
395 395
 } else {
396
-	// An existing session
396
+    // An existing session
397 397
 }
398 398
 
399 399
 // Set the tree for the page; (1) the request, (2) the session, (3) the site default, (4) any tree
400 400
 foreach (array(Filter::post('ged'), Filter::get('ged'), Session::get('GEDCOM'), Site::getPreference('DEFAULT_GEDCOM')) as $tree_name) {
401
-	$WT_TREE = Tree::findByName($tree_name);
402
-	if ($WT_TREE) {
403
-		Session::put('GEDCOM', $tree_name);
404
-		break;
405
-	}
401
+    $WT_TREE = Tree::findByName($tree_name);
402
+    if ($WT_TREE) {
403
+        Session::put('GEDCOM', $tree_name);
404
+        break;
405
+    }
406 406
 }
407 407
 // No chosen tree? Use any one.
408 408
 if (!$WT_TREE) {
409
-	foreach (Tree::getAll() as $WT_TREE) {
410
-		break;
411
-	}
409
+    foreach (Tree::getAll() as $WT_TREE) {
410
+        break;
411
+    }
412 412
 }
413 413
 
414 414
 // With no parameters, init() looks to the environment to choose a language
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 
421 421
 // Users get their own time-zone. Visitors get the site time-zone.
422 422
 if (Auth::check()) {
423
-	date_default_timezone_set(Auth::user()->getPreference('TIMEZONE', 'UTC'));
423
+    date_default_timezone_set(Auth::user()->getPreference('TIMEZONE', 'UTC'));
424 424
 } else {
425
-	date_default_timezone_set(Site::getPreference('TIMEZONE') ?: 'UTC');
425
+    date_default_timezone_set(Site::getPreference('TIMEZONE') ?: 'UTC');
426 426
 }
427 427
 define('WT_TIMESTAMP_OFFSET', date_offset_get(new \DateTime('now')));
428 428
 
@@ -430,79 +430,79 @@  discard block
 block discarded – undo
430 430
 
431 431
 // The login URL must be an absolute URL, and can be user-defined
432 432
 if (Site::getPreference('LOGIN_URL')) {
433
-	define('WT_LOGIN_URL', Site::getPreference('LOGIN_URL'));
433
+    define('WT_LOGIN_URL', Site::getPreference('LOGIN_URL'));
434 434
 } else {
435
-	define('WT_LOGIN_URL', WT_BASE_URL . 'login.php');
435
+    define('WT_LOGIN_URL', WT_BASE_URL . 'login.php');
436 436
 }
437 437
 
438 438
 // If there is no current tree and we need one, then redirect somewhere
439 439
 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') {
440
-	if (!$WT_TREE || !$WT_TREE->getPreference('imported')) {
441
-		if (Auth::isAdmin()) {
442
-			header('Location: ' . WT_BASE_URL . 'admin_trees_manage.php');
443
-		} else {
444
-			// We're not an administrator, so we can only log in if there is a tree.
445
-			if (Auth::id()) {
446
-				Auth::logout();
447
-				FlashMessages::addMessage(
448
-					I18N::translate('This user account does not have access to any tree.')
449
-				);
450
-			}
451
-			header('Location: ' . WT_LOGIN_URL . '?url=' . rawurlencode(WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')), true, 301);
452
-
453
-		}
454
-		exit;
455
-	}
440
+    if (!$WT_TREE || !$WT_TREE->getPreference('imported')) {
441
+        if (Auth::isAdmin()) {
442
+            header('Location: ' . WT_BASE_URL . 'admin_trees_manage.php');
443
+        } else {
444
+            // We're not an administrator, so we can only log in if there is a tree.
445
+            if (Auth::id()) {
446
+                Auth::logout();
447
+                FlashMessages::addMessage(
448
+                    I18N::translate('This user account does not have access to any tree.')
449
+                );
450
+            }
451
+            header('Location: ' . WT_LOGIN_URL . '?url=' . rawurlencode(WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')), true, 301);
452
+
453
+        }
454
+        exit;
455
+    }
456 456
 }
457 457
 
458 458
 // Update the last-login time no more than once a minute
459 459
 if (WT_TIMESTAMP - Session::get('activity_time') >= 60) {
460
-	if (Session::get('masquerade') === null) {
461
-		Auth::user()->setPreference('sessiontime', WT_TIMESTAMP);
462
-	}
463
-	Session::put('activity_time', WT_TIMESTAMP);
460
+    if (Session::get('masquerade') === null) {
461
+        Auth::user()->setPreference('sessiontime', WT_TIMESTAMP);
462
+    }
463
+    Session::put('activity_time', WT_TIMESTAMP);
464 464
 }
465 465
 
466 466
 // Set the theme
467 467
 if (substr(WT_SCRIPT_NAME, 0, 5) === 'admin' || WT_SCRIPT_NAME === 'module.php' && substr(Filter::get('mod_action'), 0, 5) === 'admin') {
468
-	// Administration scripts begin with “admin” and use a special administration theme
469
-	Theme::theme(new AdministrationTheme)->init($WT_TREE);
468
+    // Administration scripts begin with “admin” and use a special administration theme
469
+    Theme::theme(new AdministrationTheme)->init($WT_TREE);
470 470
 } else {
471
-	// Last theme used?
472
-	$theme_id = Session::get('theme_id');
473
-	// Default for tree
474
-	if (!array_key_exists($theme_id, Theme::themeNames()) && $WT_TREE) {
475
-		$theme_id = $WT_TREE->getPreference('THEME_DIR');
476
-	}
477
-	// Default for site
478
-	if (!array_key_exists($theme_id, Theme::themeNames())) {
479
-		$theme_id = Site::getPreference('THEME_DIR');
480
-	}
481
-	// Default
482
-	if (!array_key_exists($theme_id, Theme::themeNames())) {
483
-		$theme_id = 'webtrees';
484
-	}
485
-	foreach (Theme::installedThemes() as $theme) {
486
-		if ($theme->themeId() === $theme_id) {
487
-			Theme::theme($theme)->init($WT_TREE);
488
-			// Remember this setting
489
-			if (Site::getPreference('ALLOW_USER_THEMES')) {
490
-				Session::put('theme_id', $theme_id);
491
-			}
492
-			break;
493
-		}
494
-	}
471
+    // Last theme used?
472
+    $theme_id = Session::get('theme_id');
473
+    // Default for tree
474
+    if (!array_key_exists($theme_id, Theme::themeNames()) && $WT_TREE) {
475
+        $theme_id = $WT_TREE->getPreference('THEME_DIR');
476
+    }
477
+    // Default for site
478
+    if (!array_key_exists($theme_id, Theme::themeNames())) {
479
+        $theme_id = Site::getPreference('THEME_DIR');
480
+    }
481
+    // Default
482
+    if (!array_key_exists($theme_id, Theme::themeNames())) {
483
+        $theme_id = 'webtrees';
484
+    }
485
+    foreach (Theme::installedThemes() as $theme) {
486
+        if ($theme->themeId() === $theme_id) {
487
+            Theme::theme($theme)->init($WT_TREE);
488
+            // Remember this setting
489
+            if (Site::getPreference('ALLOW_USER_THEMES')) {
490
+                Session::put('theme_id', $theme_id);
491
+            }
492
+            break;
493
+        }
494
+    }
495 495
 }
496 496
 
497 497
 // Search engines are only allowed to see certain pages.
498 498
 if (Auth::isSearchEngine() && !in_array(WT_SCRIPT_NAME, array(
499
-	'index.php', 'indilist.php', 'module.php', 'mediafirewall.php',
500
-	'individual.php', 'family.php', 'mediaviewer.php', 'note.php', 'repo.php', 'source.php',
499
+    'index.php', 'indilist.php', 'module.php', 'mediafirewall.php',
500
+    'individual.php', 'family.php', 'mediaviewer.php', 'note.php', 'repo.php', 'source.php',
501 501
 ))) {
502
-	http_response_code(403);
503
-	$controller = new PageController;
504
-	$controller->setPageTitle(I18N::translate('Search engine'));
505
-	$controller->pageHeader();
506
-	echo '<p class="ui-state-error">', I18N::translate('You do not have permission to view this page.'), '</p>';
507
-	exit;
502
+    http_response_code(403);
503
+    $controller = new PageController;
504
+    $controller->setPageTitle(I18N::translate('Search engine'));
505
+    $controller->pageHeader();
506
+    echo '<p class="ui-state-error">', I18N::translate('You do not have permission to view this page.'), '</p>';
507
+    exit;
508 508
 }
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 1 patch
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.
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.