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