Passed
Push — 1.7 ( 4c1abf...23cbb7 )
by Greg
08:10
created
app/Module/ResearchTaskModule.php 1 patch
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -29,58 +29,58 @@  discard block
 block discarded – undo
29 29
  * Class ResearchTaskModule
30 30
  */
31 31
 class ResearchTaskModule extends AbstractModule implements ModuleBlockInterface {
32
-	const DEFAULT_SHOW_OTHER      = '1';
33
-	const DEFAULT_SHOW_UNASSIGNED = '1';
34
-	const DEFAULT_SHOW_FUTURE     = '1';
35
-	const DEFAULT_BLOCK           = '1';
36
-
37
-	/** {@inheritdoc} */
38
-	public function getTitle() {
39
-		return /* I18N: Name of a module. Tasks that need further research. */ I18N::translate('Research tasks');
40
-	}
41
-
42
-	/** {@inheritdoc} */
43
-	public function getDescription() {
44
-		return /* I18N: Description of “Research tasks” module */ I18N::translate('A list of tasks and activities that are linked to the family tree.');
45
-	}
46
-
47
-	/**
48
-	 * Generate the HTML content of this block.
49
-	 *
50
-	 * @param int      $block_id
51
-	 * @param bool     $template
52
-	 * @param string[] $cfg
53
-	 *
54
-	 * @return string
55
-	 */
56
-	public function getBlock($block_id, $template = true, $cfg = array()) {
57
-		global $ctype, $controller, $WT_TREE;
58
-
59
-		$show_other      = $this->getBlockSetting($block_id, 'show_other', self::DEFAULT_SHOW_OTHER);
60
-		$show_unassigned = $this->getBlockSetting($block_id, 'show_unassigned', self::DEFAULT_SHOW_UNASSIGNED);
61
-		$show_future     = $this->getBlockSetting($block_id, 'show_future', self::DEFAULT_SHOW_FUTURE);
62
-		$block           = $this->getBlockSetting($block_id, 'block', self::DEFAULT_BLOCK);
63
-
64
-		foreach (array('show_unassigned', 'show_other', 'show_future', 'block') as $name) {
65
-			if (array_key_exists($name, $cfg)) {
66
-				$$name = $cfg[$name];
67
-			}
68
-		}
69
-
70
-		$id    = $this->getName() . $block_id;
71
-		$class = $this->getName() . '_block';
72
-		if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
73
-			$title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
74
-		} else {
75
-			$title = '';
76
-		}
77
-		$title .= $this->getTitle();
78
-
79
-		$table_id = Uuid::uuid4(); // create a unique ID
80
-
81
-		$controller
82
-			->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
83
-			->addInlineJavascript('
32
+    const DEFAULT_SHOW_OTHER      = '1';
33
+    const DEFAULT_SHOW_UNASSIGNED = '1';
34
+    const DEFAULT_SHOW_FUTURE     = '1';
35
+    const DEFAULT_BLOCK           = '1';
36
+
37
+    /** {@inheritdoc} */
38
+    public function getTitle() {
39
+        return /* I18N: Name of a module. Tasks that need further research. */ I18N::translate('Research tasks');
40
+    }
41
+
42
+    /** {@inheritdoc} */
43
+    public function getDescription() {
44
+        return /* I18N: Description of “Research tasks” module */ I18N::translate('A list of tasks and activities that are linked to the family tree.');
45
+    }
46
+
47
+    /**
48
+     * Generate the HTML content of this block.
49
+     *
50
+     * @param int      $block_id
51
+     * @param bool     $template
52
+     * @param string[] $cfg
53
+     *
54
+     * @return string
55
+     */
56
+    public function getBlock($block_id, $template = true, $cfg = array()) {
57
+        global $ctype, $controller, $WT_TREE;
58
+
59
+        $show_other      = $this->getBlockSetting($block_id, 'show_other', self::DEFAULT_SHOW_OTHER);
60
+        $show_unassigned = $this->getBlockSetting($block_id, 'show_unassigned', self::DEFAULT_SHOW_UNASSIGNED);
61
+        $show_future     = $this->getBlockSetting($block_id, 'show_future', self::DEFAULT_SHOW_FUTURE);
62
+        $block           = $this->getBlockSetting($block_id, 'block', self::DEFAULT_BLOCK);
63
+
64
+        foreach (array('show_unassigned', 'show_other', 'show_future', 'block') as $name) {
65
+            if (array_key_exists($name, $cfg)) {
66
+                $$name = $cfg[$name];
67
+            }
68
+        }
69
+
70
+        $id    = $this->getName() . $block_id;
71
+        $class = $this->getName() . '_block';
72
+        if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
73
+            $title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
74
+        } else {
75
+            $title = '';
76
+        }
77
+        $title .= $this->getTitle();
78
+
79
+        $table_id = Uuid::uuid4(); // create a unique ID
80
+
81
+        $controller
82
+            ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
83
+            ->addInlineJavascript('
84 84
 			jQuery("#' . $table_id . '").dataTable({
85 85
 				dom: \'t\',
86 86
 				' . I18N::datatablesI18N() . ',
@@ -101,101 +101,101 @@  discard block
 block discarded – undo
101 101
 			jQuery(".loading-image").css("display", "none");
102 102
 		');
103 103
 
104
-		$content = '';
105
-		$content .= '<div class="loading-image">&nbsp;</div>';
106
-		$content .= '<table id="' . $table_id . '" style="visibility:hidden;">';
107
-		$content .= '<thead><tr>';
108
-		$content .= '<th>' . GedcomTag::getLabel('DATE') . '</th>';
109
-		$content .= '<th>' . I18N::translate('Record') . '</th>';
110
-		$content .= '<th>' . I18N::translate('Username') . '</th>';
111
-		$content .= '<th>' . GedcomTag::getLabel('TEXT') . '</th>';
112
-		$content .= '</tr></thead><tbody>';
113
-
114
-		$found  = false;
115
-		$end_jd = $show_future ? 99999999 : WT_CLIENT_JD;
116
-
117
-		$xrefs = Database::prepare(
118
-			"SELECT DISTINCT d_gid FROM `##dates`" .
119
-			" WHERE d_file = :tree_id AND d_fact = '_TODO' AND d_julianday1 < :jd"
120
-		)->execute(array(
121
-			'tree_id' => $WT_TREE->getTreeId(),
122
-			'jd'      => $end_jd,
123
-		))->fetchOneColumn();
124
-
125
-		$facts = array();
126
-		foreach ($xrefs as $xref) {
127
-			$record = GedcomRecord::getInstance($xref, $WT_TREE);
128
-			if ($record->canShow()) {
129
-				foreach ($record->getFacts('_TODO') as $fact) {
130
-					$facts[] = $fact;
131
-				}
132
-			}
133
-		}
134
-
135
-		foreach ($facts as $fact) {
136
-			$record    = $fact->getParent();
137
-			$user_name = $fact->getAttribute('_WT_USER');
138
-			if ($user_name === Auth::user()->getUserName() || !$user_name && $show_unassigned || $user_name && $show_other) {
139
-				$content .= '<tr>';
140
-				$content .= '<td data-sort="' . $fact->getDate()->julianDay() . '">' . $fact->getDate()->display() . '</td>';
141
-				$content .= '<td data-sort="' . Filter::escapeHtml($record->getSortName()) . '"><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></td>';
142
-				$content .= '<td>' . $user_name . '</td>';
143
-				$content .= '<td dir="auto">' . $fact->getValue() . '</td>';
144
-				$content .= '</tr>';
145
-				$found = true;
146
-			}
147
-		}
148
-
149
-		$content .= '</tbody></table>';
150
-		if (!$found) {
151
-			$content .= '<p>' . I18N::translate('There are no research tasks in this family tree.') . '</p>';
152
-		}
153
-
154
-		if ($template) {
155
-			if ($block) {
156
-				$class .= ' small_inner_block';
157
-			}
158
-
159
-			return Theme::theme()->formatBlock($id, $title, $class, $content);
160
-		} else {
161
-			return $content;
162
-		}
163
-	}
164
-
165
-	/** {@inheritdoc} */
166
-	public function loadAjax() {
167
-		return false;
168
-	}
169
-
170
-	/** {@inheritdoc} */
171
-	public function isUserBlock() {
172
-		return true;
173
-	}
174
-
175
-	/** {@inheritdoc} */
176
-	public function isGedcomBlock() {
177
-		return true;
178
-	}
179
-
180
-	/**
181
-	 * An HTML form to edit block settings
182
-	 *
183
-	 * @param int $block_id
184
-	 */
185
-	public function configureBlock($block_id) {
186
-		if (Filter::postBool('save') && Filter::checkCsrf()) {
187
-			$this->setBlockSetting($block_id, 'show_other', Filter::postBool('show_other'));
188
-			$this->setBlockSetting($block_id, 'show_unassigned', Filter::postBool('show_unassigned'));
189
-			$this->setBlockSetting($block_id, 'show_future', Filter::postBool('show_future'));
190
-			$this->setBlockSetting($block_id, 'block', Filter::postBool('block'));
191
-		}
192
-
193
-		$show_other      = $this->getBlockSetting($block_id, 'show_other', self::DEFAULT_SHOW_OTHER);
194
-		$show_unassigned = $this->getBlockSetting($block_id, 'show_unassigned', self::DEFAULT_SHOW_UNASSIGNED);
195
-		$show_future     = $this->getBlockSetting($block_id, 'show_future', self::DEFAULT_SHOW_FUTURE);
196
-		$block           = $this->getBlockSetting($block_id, 'block', self::DEFAULT_BLOCK);
197
-
198
-		?>
104
+        $content = '';
105
+        $content .= '<div class="loading-image">&nbsp;</div>';
106
+        $content .= '<table id="' . $table_id . '" style="visibility:hidden;">';
107
+        $content .= '<thead><tr>';
108
+        $content .= '<th>' . GedcomTag::getLabel('DATE') . '</th>';
109
+        $content .= '<th>' . I18N::translate('Record') . '</th>';
110
+        $content .= '<th>' . I18N::translate('Username') . '</th>';
111
+        $content .= '<th>' . GedcomTag::getLabel('TEXT') . '</th>';
112
+        $content .= '</tr></thead><tbody>';
113
+
114
+        $found  = false;
115
+        $end_jd = $show_future ? 99999999 : WT_CLIENT_JD;
116
+
117
+        $xrefs = Database::prepare(
118
+            "SELECT DISTINCT d_gid FROM `##dates`" .
119
+            " WHERE d_file = :tree_id AND d_fact = '_TODO' AND d_julianday1 < :jd"
120
+        )->execute(array(
121
+            'tree_id' => $WT_TREE->getTreeId(),
122
+            'jd'      => $end_jd,
123
+        ))->fetchOneColumn();
124
+
125
+        $facts = array();
126
+        foreach ($xrefs as $xref) {
127
+            $record = GedcomRecord::getInstance($xref, $WT_TREE);
128
+            if ($record->canShow()) {
129
+                foreach ($record->getFacts('_TODO') as $fact) {
130
+                    $facts[] = $fact;
131
+                }
132
+            }
133
+        }
134
+
135
+        foreach ($facts as $fact) {
136
+            $record    = $fact->getParent();
137
+            $user_name = $fact->getAttribute('_WT_USER');
138
+            if ($user_name === Auth::user()->getUserName() || !$user_name && $show_unassigned || $user_name && $show_other) {
139
+                $content .= '<tr>';
140
+                $content .= '<td data-sort="' . $fact->getDate()->julianDay() . '">' . $fact->getDate()->display() . '</td>';
141
+                $content .= '<td data-sort="' . Filter::escapeHtml($record->getSortName()) . '"><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></td>';
142
+                $content .= '<td>' . $user_name . '</td>';
143
+                $content .= '<td dir="auto">' . $fact->getValue() . '</td>';
144
+                $content .= '</tr>';
145
+                $found = true;
146
+            }
147
+        }
148
+
149
+        $content .= '</tbody></table>';
150
+        if (!$found) {
151
+            $content .= '<p>' . I18N::translate('There are no research tasks in this family tree.') . '</p>';
152
+        }
153
+
154
+        if ($template) {
155
+            if ($block) {
156
+                $class .= ' small_inner_block';
157
+            }
158
+
159
+            return Theme::theme()->formatBlock($id, $title, $class, $content);
160
+        } else {
161
+            return $content;
162
+        }
163
+    }
164
+
165
+    /** {@inheritdoc} */
166
+    public function loadAjax() {
167
+        return false;
168
+    }
169
+
170
+    /** {@inheritdoc} */
171
+    public function isUserBlock() {
172
+        return true;
173
+    }
174
+
175
+    /** {@inheritdoc} */
176
+    public function isGedcomBlock() {
177
+        return true;
178
+    }
179
+
180
+    /**
181
+     * An HTML form to edit block settings
182
+     *
183
+     * @param int $block_id
184
+     */
185
+    public function configureBlock($block_id) {
186
+        if (Filter::postBool('save') && Filter::checkCsrf()) {
187
+            $this->setBlockSetting($block_id, 'show_other', Filter::postBool('show_other'));
188
+            $this->setBlockSetting($block_id, 'show_unassigned', Filter::postBool('show_unassigned'));
189
+            $this->setBlockSetting($block_id, 'show_future', Filter::postBool('show_future'));
190
+            $this->setBlockSetting($block_id, 'block', Filter::postBool('block'));
191
+        }
192
+
193
+        $show_other      = $this->getBlockSetting($block_id, 'show_other', self::DEFAULT_SHOW_OTHER);
194
+        $show_unassigned = $this->getBlockSetting($block_id, 'show_unassigned', self::DEFAULT_SHOW_UNASSIGNED);
195
+        $show_future     = $this->getBlockSetting($block_id, 'show_future', self::DEFAULT_SHOW_FUTURE);
196
+        $block           = $this->getBlockSetting($block_id, 'block', self::DEFAULT_BLOCK);
197
+
198
+        ?>
199 199
 		<tr>
200 200
 			<td colspan="2">
201 201
 				<?php echo I18N::translate('Research tasks are special events, added to individuals in your family tree, which identify the need for further research. You can use them as a reminder to check facts against more reliable sources, to obtain documents or photographs, to resolve conflicting information, etc.'); ?>
@@ -205,28 +205,28 @@  discard block
 block discarded – undo
205 205
 		</tr>
206 206
 		<?php
207 207
 
208
-		echo '<tr><td class="descriptionbox wrap width33">';
209
-		echo I18N::translate('Show research tasks that are assigned to other users');
210
-		echo '</td><td class="optionbox">';
211
-		echo FunctionsEdit::editFieldYesNo('show_other', $show_other);
212
-		echo '</td></tr>';
213
-
214
-		echo '<tr><td class="descriptionbox wrap width33">';
215
-		echo I18N::translate('Show research tasks that are not assigned to any user');
216
-		echo '</td><td class="optionbox">';
217
-		echo FunctionsEdit::editFieldYesNo('show_unassigned', $show_unassigned);
218
-		echo '</td></tr>';
219
-
220
-		echo '<tr><td class="descriptionbox wrap width33">';
221
-		echo I18N::translate('Show research tasks that have a date in the future');
222
-		echo '</td><td class="optionbox">';
223
-		echo FunctionsEdit::editFieldYesNo('show_future', $show_future);
224
-		echo '</td></tr>';
225
-
226
-		echo '<tr><td class="descriptionbox wrap width33">';
227
-		echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow');
228
-		echo '</td><td class="optionbox">';
229
-		echo FunctionsEdit::editFieldYesNo('block', $block);
230
-		echo '</td></tr>';
231
-	}
208
+        echo '<tr><td class="descriptionbox wrap width33">';
209
+        echo I18N::translate('Show research tasks that are assigned to other users');
210
+        echo '</td><td class="optionbox">';
211
+        echo FunctionsEdit::editFieldYesNo('show_other', $show_other);
212
+        echo '</td></tr>';
213
+
214
+        echo '<tr><td class="descriptionbox wrap width33">';
215
+        echo I18N::translate('Show research tasks that are not assigned to any user');
216
+        echo '</td><td class="optionbox">';
217
+        echo FunctionsEdit::editFieldYesNo('show_unassigned', $show_unassigned);
218
+        echo '</td></tr>';
219
+
220
+        echo '<tr><td class="descriptionbox wrap width33">';
221
+        echo I18N::translate('Show research tasks that have a date in the future');
222
+        echo '</td><td class="optionbox">';
223
+        echo FunctionsEdit::editFieldYesNo('show_future', $show_future);
224
+        echo '</td></tr>';
225
+
226
+        echo '<tr><td class="descriptionbox wrap width33">';
227
+        echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow');
228
+        echo '</td><td class="optionbox">';
229
+        echo FunctionsEdit::editFieldYesNo('block', $block);
230
+        echo '</td></tr>';
231
+    }
232 232
 }
Please login to merge, or discard this patch.
app/Module/StatisticsChartModule.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -24,55 +24,55 @@
 block discarded – undo
24 24
  * Class StatisticsChartModule
25 25
  */
26 26
 class StatisticsChartModule extends AbstractModule implements ModuleChartInterface {
27
-	/**
28
-	 * How should this module be labelled on tabs, menus, etc.?
29
-	 *
30
-	 * @return string
31
-	 */
32
-	public function getTitle() {
33
-		return /* I18N: Name of a module/chart */ I18N::translate('Statistics');
34
-	}
27
+    /**
28
+     * How should this module be labelled on tabs, menus, etc.?
29
+     *
30
+     * @return string
31
+     */
32
+    public function getTitle() {
33
+        return /* I18N: Name of a module/chart */ I18N::translate('Statistics');
34
+    }
35 35
 
36
-	/**
37
-	 * A sentence describing what this module does.
38
-	 *
39
-	 * @return string
40
-	 */
41
-	public function getDescription() {
42
-		return /* I18N: Description of the “StatisticsChart” module */ I18N::translate('Various statistics charts.');
43
-	}
36
+    /**
37
+     * A sentence describing what this module does.
38
+     *
39
+     * @return string
40
+     */
41
+    public function getDescription() {
42
+        return /* I18N: Description of the “StatisticsChart” module */ I18N::translate('Various statistics charts.');
43
+    }
44 44
 
45
-	/**
46
-	 * What is the default access level for this module?
47
-	 *
48
-	 * Some modules are aimed at admins or managers, and are not generally shown to users.
49
-	 *
50
-	 * @return int
51
-	 */
52
-	public function defaultAccessLevel() {
53
-		return Auth::PRIV_PRIVATE;
54
-	}
45
+    /**
46
+     * What is the default access level for this module?
47
+     *
48
+     * Some modules are aimed at admins or managers, and are not generally shown to users.
49
+     *
50
+     * @return int
51
+     */
52
+    public function defaultAccessLevel() {
53
+        return Auth::PRIV_PRIVATE;
54
+    }
55 55
 
56
-	/**
57
-	 * Return a menu item for this chart.
58
-	 *
59
-	 * @return Menu|null
60
-	 */
61
-	public function getChartMenu(Individual $individual) {
62
-		return new Menu(
63
-			$this->getTitle(),
64
-			'statistics.php?ged=' . $individual->getTree()->getNameUrl(),
65
-			'menu-chart-statistics',
66
-			array('rel' => 'nofollow')
67
-		);
68
-	}
56
+    /**
57
+     * Return a menu item for this chart.
58
+     *
59
+     * @return Menu|null
60
+     */
61
+    public function getChartMenu(Individual $individual) {
62
+        return new Menu(
63
+            $this->getTitle(),
64
+            'statistics.php?ged=' . $individual->getTree()->getNameUrl(),
65
+            'menu-chart-statistics',
66
+            array('rel' => 'nofollow')
67
+        );
68
+    }
69 69
 
70
-	/**
71
-	 * Return a menu item for this chart - for use in individual boxes.
72
-	 *
73
-	 * @return Menu|null
74
-	 */
75
-	public function getBoxChartMenu(Individual $individual) {
76
-		return null;
77
-	}
70
+    /**
71
+     * Return a menu item for this chart - for use in individual boxes.
72
+     *
73
+     * @return Menu|null
74
+     */
75
+    public function getBoxChartMenu(Individual $individual) {
76
+        return null;
77
+    }
78 78
 }
Please login to merge, or discard this patch.
app/Module/IndividualFactsTabModule.php 1 patch
Indentation   +468 added lines, -468 removed lines patch added patch discarded remove patch
@@ -31,95 +31,95 @@  discard block
 block discarded – undo
31 31
  * Class IndividualFactsTabModule
32 32
  */
33 33
 class IndividualFactsTabModule extends AbstractModule implements ModuleTabInterface {
34
-	/** {@inheritdoc} */
35
-	public function getTitle() {
36
-		return /* I18N: Name of a module/tab on the individual page. */ I18N::translate('Facts and events');
37
-	}
38
-
39
-	/** {@inheritdoc} */
40
-	public function getDescription() {
41
-		return /* I18N: Description of the “Facts and events” module */ I18N::translate('A tab showing the facts and events of an individual.');
42
-	}
43
-
44
-	/** {@inheritdoc} */
45
-	public function defaultTabOrder() {
46
-		return 10;
47
-	}
48
-
49
-	/** {@inheritdoc} */
50
-	public function isGrayedOut() {
51
-		return false;
52
-	}
53
-
54
-	/** {@inheritdoc} */
55
-	public function getTabContent() {
56
-		global $controller;
57
-		$EXPAND_HISTO_EVENTS = false;
58
-
59
-		$indifacts = array();
60
-		// The individual’s own facts
61
-		foreach ($controller->record->getFacts() as $fact) {
62
-			switch ($fact->getTag()) {
63
-			case 'SEX':
64
-			case 'NAME':
65
-			case 'SOUR':
66
-			case 'OBJE':
67
-			case 'NOTE':
68
-			case 'FAMC':
69
-			case 'FAMS':
70
-				break;
71
-			default:
72
-				if (!array_key_exists('extra_info', Module::getActiveSidebars($controller->record->getTree())) || !ExtraInformationModule::showFact($fact)) {
73
-					$indifacts[] = $fact;
74
-				}
75
-				break;
76
-			}
77
-		}
78
-
79
-		// Add spouse-family facts
80
-		foreach ($controller->record->getSpouseFamilies() as $family) {
81
-			foreach ($family->getFacts() as $fact) {
82
-				switch ($fact->getTag()) {
83
-				case 'SOUR':
84
-				case 'NOTE':
85
-				case 'OBJE':
86
-				case 'CHAN':
87
-				case '_UID':
88
-				case 'RIN':
89
-				case 'HUSB':
90
-				case 'WIFE':
91
-				case 'CHIL':
92
-					break;
93
-				default:
94
-					$indifacts[] = $fact;
95
-					break;
96
-				}
97
-			}
98
-			$spouse = $family->getSpouse($controller->record);
99
-			if ($spouse) {
100
-				foreach (self::spouseFacts($controller->record, $spouse) as $fact) {
101
-					$indifacts[] = $fact;
102
-				}
103
-			}
104
-			foreach (self::childFacts($controller->record, $family, '_CHIL', '') as $fact) {
105
-				$indifacts[] = $fact;
106
-			}
107
-		}
108
-
109
-		foreach (self::parentFacts($controller->record, 1) as $fact) {
110
-			$indifacts[] = $fact;
111
-		}
112
-		foreach (self::historicalFacts($controller->record) as $fact) {
113
-			$indifacts[] = $fact;
114
-		}
115
-		foreach (self::associateFacts($controller->record) as $fact) {
116
-			$indifacts[] = $fact;
117
-		}
118
-
119
-		Functions::sortFacts($indifacts);
120
-
121
-		ob_start();
122
-		?>
34
+    /** {@inheritdoc} */
35
+    public function getTitle() {
36
+        return /* I18N: Name of a module/tab on the individual page. */ I18N::translate('Facts and events');
37
+    }
38
+
39
+    /** {@inheritdoc} */
40
+    public function getDescription() {
41
+        return /* I18N: Description of the “Facts and events” module */ I18N::translate('A tab showing the facts and events of an individual.');
42
+    }
43
+
44
+    /** {@inheritdoc} */
45
+    public function defaultTabOrder() {
46
+        return 10;
47
+    }
48
+
49
+    /** {@inheritdoc} */
50
+    public function isGrayedOut() {
51
+        return false;
52
+    }
53
+
54
+    /** {@inheritdoc} */
55
+    public function getTabContent() {
56
+        global $controller;
57
+        $EXPAND_HISTO_EVENTS = false;
58
+
59
+        $indifacts = array();
60
+        // The individual’s own facts
61
+        foreach ($controller->record->getFacts() as $fact) {
62
+            switch ($fact->getTag()) {
63
+            case 'SEX':
64
+            case 'NAME':
65
+            case 'SOUR':
66
+            case 'OBJE':
67
+            case 'NOTE':
68
+            case 'FAMC':
69
+            case 'FAMS':
70
+                break;
71
+            default:
72
+                if (!array_key_exists('extra_info', Module::getActiveSidebars($controller->record->getTree())) || !ExtraInformationModule::showFact($fact)) {
73
+                    $indifacts[] = $fact;
74
+                }
75
+                break;
76
+            }
77
+        }
78
+
79
+        // Add spouse-family facts
80
+        foreach ($controller->record->getSpouseFamilies() as $family) {
81
+            foreach ($family->getFacts() as $fact) {
82
+                switch ($fact->getTag()) {
83
+                case 'SOUR':
84
+                case 'NOTE':
85
+                case 'OBJE':
86
+                case 'CHAN':
87
+                case '_UID':
88
+                case 'RIN':
89
+                case 'HUSB':
90
+                case 'WIFE':
91
+                case 'CHIL':
92
+                    break;
93
+                default:
94
+                    $indifacts[] = $fact;
95
+                    break;
96
+                }
97
+            }
98
+            $spouse = $family->getSpouse($controller->record);
99
+            if ($spouse) {
100
+                foreach (self::spouseFacts($controller->record, $spouse) as $fact) {
101
+                    $indifacts[] = $fact;
102
+                }
103
+            }
104
+            foreach (self::childFacts($controller->record, $family, '_CHIL', '') as $fact) {
105
+                $indifacts[] = $fact;
106
+            }
107
+        }
108
+
109
+        foreach (self::parentFacts($controller->record, 1) as $fact) {
110
+            $indifacts[] = $fact;
111
+        }
112
+        foreach (self::historicalFacts($controller->record) as $fact) {
113
+            $indifacts[] = $fact;
114
+        }
115
+        foreach (self::associateFacts($controller->record) as $fact) {
116
+            $indifacts[] = $fact;
117
+        }
118
+
119
+        Functions::sortFacts($indifacts);
120
+
121
+        ob_start();
122
+        ?>
123 123
 		<table class="facts_table">
124 124
 			<colgroup>
125 125
 				<col class="width20">
@@ -144,20 +144,20 @@  discard block
 block discarded – undo
144 144
 				</tr>
145 145
 				<?php
146 146
 
147
-		if (!$indifacts) {
148
-			echo '<tr><td colspan="2" class="facts_value">', I18N::translate('There are no facts for this individual.'), '</td></tr>';
149
-		}
147
+        if (!$indifacts) {
148
+            echo '<tr><td colspan="2" class="facts_value">', I18N::translate('There are no facts for this individual.'), '</td></tr>';
149
+        }
150 150
 
151
-		foreach ($indifacts as $fact) {
152
-			FunctionsPrintFacts::printFact($fact, $controller->record);
153
-		}
151
+        foreach ($indifacts as $fact) {
152
+            FunctionsPrintFacts::printFact($fact, $controller->record);
153
+        }
154 154
 
155
-		//-- new fact link
156
-		if ($controller->record->canEdit()) {
157
-			FunctionsPrint::printAddNewFact($controller->record->getXref(), $indifacts, 'INDI');
158
-		}
155
+        //-- new fact link
156
+        if ($controller->record->canEdit()) {
157
+            FunctionsPrint::printAddNewFact($controller->record->getXref(), $indifacts, 'INDI');
158
+        }
159 159
 
160
-		?>
160
+        ?>
161 161
 			</tbody>
162 162
 		</table>
163 163
 		<script>
@@ -166,372 +166,372 @@  discard block
 block discarded – undo
166 166
 		</script>
167 167
 		<?php
168 168
 
169
-		return '<div id="' . $this->getName() . '_content">' . ob_get_clean() . '</div>';
170
-	}
171
-
172
-	/** {@inheritdoc} */
173
-	public function hasTabContent() {
174
-		return true;
175
-	}
176
-
177
-	/** {@inheritdoc} */
178
-	public function canLoadAjax() {
179
-		return !Auth::isSearchEngine(); // Search engines cannot use AJAX
180
-	}
181
-
182
-	/** {@inheritdoc} */
183
-	public function getPreLoadContent() {
184
-		return '';
185
-	}
186
-
187
-	/**
188
-	 * Spouse facts that are shown on an individual’s page.
189
-	 *
190
-	 * @param Individual $individual Show events that occured during the lifetime of this individual
191
-	 * @param Individual $spouse     Show events of this individual
192
-	 *
193
-	 * @return Fact[]
194
-	 */
195
-	private static function spouseFacts(Individual $individual, Individual $spouse) {
196
-		$SHOW_RELATIVES_EVENTS = $individual->getTree()->getPreference('SHOW_RELATIVES_EVENTS');
197
-
198
-		$facts = array();
199
-		if (strstr($SHOW_RELATIVES_EVENTS, '_DEAT_SPOU')) {
200
-			// Only include events between birth and death
201
-			$birt_date = $individual->getEstimatedBirthDate();
202
-			$deat_date = $individual->getEstimatedDeathDate();
203
-
204
-			foreach ($spouse->getFacts(WT_EVENTS_DEAT) as $fact) {
205
-
206
-				$fact_date = $fact->getDate();
207
-				if ($fact_date->isOK() && Date::compare($birt_date, $fact_date) <= 0 && Date::compare($fact_date, $deat_date) <= 0) {
208
-					// Convert the event to a close relatives event.
209
-					$rela_fact = clone($fact);
210
-					$rela_fact->setTag('_' . $fact->getTag() . '_SPOU');
211
-					$facts[] = $rela_fact;
212
-				}
213
-			}
214
-		}
215
-
216
-		return $facts;
217
-	}
218
-
219
-	/**
220
-	 * Get the events of children and grandchildren.
221
-	 *
222
-	 * @param Individual $person
223
-	 * @param Family     $family
224
-	 * @param string     $option
225
-	 * @param string     $relation
226
-	 *
227
-	 * @return Fact[]
228
-	 */
229
-	private static function childFacts(Individual $person, Family $family, $option, $relation) {
230
-		global $controller;
231
-
232
-		$SHOW_RELATIVES_EVENTS = $person->getTree()->getPreference('SHOW_RELATIVES_EVENTS');
233
-
234
-		$facts = array();
235
-
236
-		// Only include events between birth and death
237
-		$birt_date = $controller->record->getEstimatedBirthDate();
238
-		$deat_date = $controller->record->getEstimatedDeathDate();
239
-
240
-		// Deal with recursion.
241
-		switch ($option) {
242
-		case '_CHIL':
243
-			// Add grandchildren
244
-			foreach ($family->getChildren() as $child) {
245
-				foreach ($child->getSpouseFamilies() as $cfamily) {
246
-					switch ($child->getSex()) {
247
-					case 'M':
248
-						foreach (self::childFacts($person, $cfamily, '_GCHI', 'son') as $fact) {
249
-							$facts[] = $fact;
250
-						}
251
-						break;
252
-					case 'F':
253
-						foreach (self::childFacts($person, $cfamily, '_GCHI', 'dau') as $fact) {
254
-							$facts[] = $fact;
255
-						}
256
-						break;
257
-					default:
258
-						foreach (self::childFacts($person, $cfamily, '_GCHI', 'chi') as $fact) {
259
-							$facts[] = $fact;
260
-						}
261
-						break;
262
-					}
263
-				}
264
-			}
265
-			break;
266
-		}
267
-
268
-		// For each child in the family
269
-		foreach ($family->getChildren() as $child) {
270
-			if ($child->getXref() == $person->getXref()) {
271
-				// We are not our own sibling!
272
-				continue;
273
-			}
274
-			// add child’s birth
275
-			if (strpos($SHOW_RELATIVES_EVENTS, '_BIRT' . str_replace('_HSIB', '_SIBL', $option)) !== false) {
276
-				foreach ($child->getFacts(WT_EVENTS_BIRT) as $fact) {
277
-					$sgdate = $fact->getDate();
278
-					// Always show _BIRT_CHIL, even if the dates are not known
279
-					if ($option == '_CHIL' || $sgdate->isOK() && Date::compare($birt_date, $sgdate) <= 0 && Date::compare($sgdate, $deat_date) <= 0) {
280
-						if ($option == '_GCHI' && $relation == 'dau') {
281
-							// Convert the event to a close relatives event.
282
-							$rela_fact = clone($fact);
283
-							$rela_fact->setTag('_' . $fact->getTag() . '_GCH1');
284
-							$facts[] = $rela_fact;
285
-						} elseif ($option == '_GCHI' && $relation == 'son') {
286
-							// Convert the event to a close relatives event.
287
-							$rela_fact = clone($fact);
288
-							$rela_fact->setTag('_' . $fact->getTag() . '_GCH2');
289
-							$facts[] = $rela_fact;
290
-						} else {
291
-							// Convert the event to a close relatives event.
292
-							$rela_fact = clone($fact);
293
-							$rela_fact->setTag('_' . $fact->getTag() . $option);
294
-							$facts[] = $rela_fact;
295
-						}
296
-					}
297
-				}
298
-			}
299
-			// add child’s death
300
-			if (strpos($SHOW_RELATIVES_EVENTS, '_DEAT' . str_replace('_HSIB', '_SIBL', $option)) !== false) {
301
-				foreach ($child->getFacts(WT_EVENTS_DEAT) as $fact) {
302
-					$sgdate = $fact->getDate();
303
-					if ($sgdate->isOK() && Date::compare($birt_date, $sgdate) <= 0 && Date::compare($sgdate, $deat_date) <= 0) {
304
-						if ($option == '_GCHI' && $relation == 'dau') {
305
-							// Convert the event to a close relatives event.
306
-							$rela_fact = clone($fact);
307
-							$rela_fact->setTag('_' . $fact->getTag() . '_GCH1');
308
-							$facts[] = $rela_fact;
309
-						} elseif ($option == '_GCHI' && $relation == 'son') {
310
-							// Convert the event to a close relatives event.
311
-							$rela_fact = clone($fact);
312
-							$rela_fact->setTag('_' . $fact->getTag() . '_GCH2');
313
-							$facts[] = $rela_fact;
314
-						} else {
315
-							// Convert the event to a close relatives event.
316
-							$rela_fact = clone($fact);
317
-							$rela_fact->setTag('_' . $fact->getTag() . $option);
318
-							$facts[] = $rela_fact;
319
-						}
320
-					}
321
-				}
322
-			}
323
-			// add child’s marriage
324
-			if (strstr($SHOW_RELATIVES_EVENTS, '_MARR' . str_replace('_HSIB', '_SIBL', $option))) {
325
-				foreach ($child->getSpouseFamilies() as $sfamily) {
326
-					foreach ($sfamily->getFacts(WT_EVENTS_MARR) as $fact) {
327
-						$sgdate = $fact->getDate();
328
-						if ($sgdate->isOK() && Date::compare($birt_date, $sgdate) <= 0 && Date::compare($sgdate, $deat_date) <= 0) {
329
-							if ($option == '_GCHI' && $relation == 'dau') {
330
-								// Convert the event to a close relatives event.
331
-								$rela_fact = clone($fact);
332
-								$rela_fact->setTag('_' . $fact->getTag() . '_GCH1');
333
-								$facts[] = $rela_fact;
334
-							} elseif ($option == '_GCHI' && $relation == 'son') {
335
-								// Convert the event to a close relatives event.
336
-								$rela_fact = clone($fact);
337
-								$rela_fact->setTag('_' . $fact->getTag() . '_GCH2');
338
-								$facts[] = $rela_fact;
339
-							} else {
340
-								// Convert the event to a close relatives event.
341
-								$rela_fact = clone($fact);
342
-								$rela_fact->setTag('_' . $fact->getTag() . $option);
343
-								$facts[] = $rela_fact;
344
-							}
345
-						}
346
-					}
347
-				}
348
-			}
349
-		}
350
-
351
-		return $facts;
352
-	}
353
-
354
-	/**
355
-	 * Get the events of parents and grandparents.
356
-	 *
357
-	 * @param Individual $person
358
-	 * @param int        $sosa
359
-	 *
360
-	 * @return Fact[]
361
-	 */
362
-	private static function parentFacts(Individual $person, $sosa) {
363
-		global $controller;
364
-
365
-		$SHOW_RELATIVES_EVENTS = $person->getTree()->getPreference('SHOW_RELATIVES_EVENTS');
366
-
367
-		$facts = array();
368
-
369
-		// Only include events between birth and death
370
-		$birt_date = $controller->record->getEstimatedBirthDate();
371
-		$deat_date = $controller->record->getEstimatedDeathDate();
372
-
373
-		if ($sosa == 1) {
374
-			foreach ($person->getChildFamilies() as $family) {
375
-				// Add siblings
376
-				foreach (self::childFacts($person, $family, '_SIBL', '') as $fact) {
377
-					$facts[] = $fact;
378
-				}
379
-				foreach ($family->getSpouses() as $spouse) {
380
-					foreach ($spouse->getSpouseFamilies() as $sfamily) {
381
-						if ($family !== $sfamily) {
382
-							// Add half-siblings
383
-							foreach (self::childFacts($person, $sfamily, '_HSIB', '') as $fact) {
384
-								$facts[] = $fact;
385
-							}
386
-						}
387
-					}
388
-					// Add grandparents
389
-					foreach (self::parentFacts($spouse, $spouse->getSex() == 'F' ? 3 : 2) as $fact) {
390
-						$facts[] = $fact;
391
-					}
392
-				}
393
-			}
394
-
395
-			if (strstr($SHOW_RELATIVES_EVENTS, '_MARR_PARE')) {
396
-				// add father/mother marriages
397
-				foreach ($person->getChildFamilies() as $sfamily) {
398
-					foreach ($sfamily->getFacts(WT_EVENTS_MARR) as $fact) {
399
-						if ($fact->getDate()->isOK() && Date::compare($birt_date, $fact->getDate()) <= 0 && Date::compare($fact->getDate(), $deat_date) <= 0) {
400
-							// marriage of parents (to each other)
401
-							$rela_fact = clone($fact);
402
-							$rela_fact->setTag('_' . $fact->getTag() . '_FAMC');
403
-							$facts[] = $rela_fact;
404
-						}
405
-					}
406
-				}
407
-				foreach ($person->getChildStepFamilies() as $sfamily) {
408
-					foreach ($sfamily->getFacts(WT_EVENTS_MARR) as $fact) {
409
-						if ($fact->getDate()->isOK() && Date::compare($birt_date, $fact->getDate()) <= 0 && Date::compare($fact->getDate(), $deat_date) <= 0) {
410
-							// marriage of a parent (to another spouse)
411
-							// Convert the event to a close relatives event
412
-							$rela_fact = clone($fact);
413
-							$rela_fact->setTag('_' . $fact->getTag() . '_PARE');
414
-							$facts[] = $rela_fact;
415
-						}
416
-					}
417
-				}
418
-			}
419
-		}
420
-
421
-		foreach ($person->getChildFamilies() as $family) {
422
-			foreach ($family->getSpouses() as $parent) {
423
-				if (strstr($SHOW_RELATIVES_EVENTS, '_DEAT' . ($sosa == 1 ? '_PARE' : '_GPAR'))) {
424
-					foreach ($parent->getFacts(WT_EVENTS_DEAT) as $fact) {
425
-						if ($fact->getDate()->isOK() && Date::compare($birt_date, $fact->getDate()) <= 0 && Date::compare($fact->getDate(), $deat_date) <= 0) {
426
-							switch ($sosa) {
427
-							case 1:
428
-								// Convert the event to a close relatives event.
429
-								$rela_fact = clone($fact);
430
-								$rela_fact->setTag('_' . $fact->getTag() . '_PARE');
431
-								$facts[] = $rela_fact;
432
-								break;
433
-							case 2:
434
-								// Convert the event to a close relatives event
435
-								$rela_fact = clone($fact);
436
-								$rela_fact->setTag('_' . $fact->getTag() . '_GPA1');
437
-								$facts[] = $rela_fact;
438
-								break;
439
-							case 3:
440
-								// Convert the event to a close relatives event
441
-								$rela_fact = clone($fact);
442
-								$rela_fact->setTag('_' . $fact->getTag() . '_GPA2');
443
-								$facts[] = $rela_fact;
444
-								break;
445
-							}
446
-						}
447
-					}
448
-				}
449
-			}
450
-		}
451
-
452
-		return $facts;
453
-	}
454
-
455
-	/**
456
-	 * Get any historical events.
457
-	 *
458
-	 * @param Individual $person
459
-	 *
460
-	 * @return Fact[]
461
-	 */
462
-	private static function historicalFacts(Individual $person) {
463
-		$SHOW_RELATIVES_EVENTS = $person->getTree()->getPreference('SHOW_RELATIVES_EVENTS');
464
-
465
-		$facts = array();
466
-
467
-		if ($SHOW_RELATIVES_EVENTS) {
468
-			// Only include events between birth and death
469
-			$birt_date = $person->getEstimatedBirthDate();
470
-			$deat_date = $person->getEstimatedDeathDate();
471
-
472
-			if (file_exists(Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) {
473
-				$histo = array();
474
-				require Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php';
475
-				foreach ($histo as $hist) {
476
-					// Earlier versions of the WIKI encouraged people to use HTML entities,
477
-					// rather than UTF8 encoding.
478
-					$hist = html_entity_decode($hist, ENT_QUOTES, 'UTF-8');
479
-
480
-					$fact  = new Fact($hist, $person, 'histo');
481
-					$sdate = $fact->getDate();
482
-					if ($sdate->isOK() && Date::compare($birt_date, $sdate) <= 0 && Date::compare($sdate, $deat_date) <= 0) {
483
-						$facts[] = $fact;
484
-					}
485
-				}
486
-			}
487
-		}
488
-
489
-		return $facts;
490
-	}
491
-
492
-	/**
493
-	 * Get the events of associates.
494
-	 *
495
-	 * @param Individual $person
496
-	 *
497
-	 * @return Fact[]
498
-	 */
499
-	private static function associateFacts(Individual $person) {
500
-		$facts = array();
501
-
502
-		$associates = array_merge(
503
-			$person->linkedIndividuals('ASSO'),
504
-			$person->linkedIndividuals('_ASSO'),
505
-			$person->linkedFamilies('ASSO'),
506
-			$person->linkedFamilies('_ASSO')
507
-		);
508
-		foreach ($associates as $associate) {
509
-			foreach ($associate->getFacts() as $fact) {
510
-				$arec = $fact->getAttribute('_ASSO');
511
-				if (!$arec) {
512
-					$arec = $fact->getAttribute('ASSO');
513
-				}
514
-				if ($arec && trim($arec, '@') === $person->getXref()) {
515
-					// Extract the important details from the fact
516
-					$factrec = '1 ' . $fact->getTag();
517
-					if (preg_match('/\n2 DATE .*/', $fact->getGedcom(), $match)) {
518
-						$factrec .= $match[0];
519
-					}
520
-					if (preg_match('/\n2 PLAC .*/', $fact->getGedcom(), $match)) {
521
-						$factrec .= $match[0];
522
-					}
523
-					if ($associate instanceof Family) {
524
-						foreach ($associate->getSpouses() as $spouse) {
525
-							$factrec .= "\n2 _ASSO @" . $spouse->getXref() . '@';
526
-						}
527
-					} else {
528
-						$factrec .= "\n2 _ASSO @" . $associate->getXref() . '@';
529
-					}
530
-					$facts[] = new Fact($factrec, $associate, 'asso');
531
-				}
532
-			}
533
-		}
534
-
535
-		return $facts;
536
-	}
169
+        return '<div id="' . $this->getName() . '_content">' . ob_get_clean() . '</div>';
170
+    }
171
+
172
+    /** {@inheritdoc} */
173
+    public function hasTabContent() {
174
+        return true;
175
+    }
176
+
177
+    /** {@inheritdoc} */
178
+    public function canLoadAjax() {
179
+        return !Auth::isSearchEngine(); // Search engines cannot use AJAX
180
+    }
181
+
182
+    /** {@inheritdoc} */
183
+    public function getPreLoadContent() {
184
+        return '';
185
+    }
186
+
187
+    /**
188
+     * Spouse facts that are shown on an individual’s page.
189
+     *
190
+     * @param Individual $individual Show events that occured during the lifetime of this individual
191
+     * @param Individual $spouse     Show events of this individual
192
+     *
193
+     * @return Fact[]
194
+     */
195
+    private static function spouseFacts(Individual $individual, Individual $spouse) {
196
+        $SHOW_RELATIVES_EVENTS = $individual->getTree()->getPreference('SHOW_RELATIVES_EVENTS');
197
+
198
+        $facts = array();
199
+        if (strstr($SHOW_RELATIVES_EVENTS, '_DEAT_SPOU')) {
200
+            // Only include events between birth and death
201
+            $birt_date = $individual->getEstimatedBirthDate();
202
+            $deat_date = $individual->getEstimatedDeathDate();
203
+
204
+            foreach ($spouse->getFacts(WT_EVENTS_DEAT) as $fact) {
205
+
206
+                $fact_date = $fact->getDate();
207
+                if ($fact_date->isOK() && Date::compare($birt_date, $fact_date) <= 0 && Date::compare($fact_date, $deat_date) <= 0) {
208
+                    // Convert the event to a close relatives event.
209
+                    $rela_fact = clone($fact);
210
+                    $rela_fact->setTag('_' . $fact->getTag() . '_SPOU');
211
+                    $facts[] = $rela_fact;
212
+                }
213
+            }
214
+        }
215
+
216
+        return $facts;
217
+    }
218
+
219
+    /**
220
+     * Get the events of children and grandchildren.
221
+     *
222
+     * @param Individual $person
223
+     * @param Family     $family
224
+     * @param string     $option
225
+     * @param string     $relation
226
+     *
227
+     * @return Fact[]
228
+     */
229
+    private static function childFacts(Individual $person, Family $family, $option, $relation) {
230
+        global $controller;
231
+
232
+        $SHOW_RELATIVES_EVENTS = $person->getTree()->getPreference('SHOW_RELATIVES_EVENTS');
233
+
234
+        $facts = array();
235
+
236
+        // Only include events between birth and death
237
+        $birt_date = $controller->record->getEstimatedBirthDate();
238
+        $deat_date = $controller->record->getEstimatedDeathDate();
239
+
240
+        // Deal with recursion.
241
+        switch ($option) {
242
+        case '_CHIL':
243
+            // Add grandchildren
244
+            foreach ($family->getChildren() as $child) {
245
+                foreach ($child->getSpouseFamilies() as $cfamily) {
246
+                    switch ($child->getSex()) {
247
+                    case 'M':
248
+                        foreach (self::childFacts($person, $cfamily, '_GCHI', 'son') as $fact) {
249
+                            $facts[] = $fact;
250
+                        }
251
+                        break;
252
+                    case 'F':
253
+                        foreach (self::childFacts($person, $cfamily, '_GCHI', 'dau') as $fact) {
254
+                            $facts[] = $fact;
255
+                        }
256
+                        break;
257
+                    default:
258
+                        foreach (self::childFacts($person, $cfamily, '_GCHI', 'chi') as $fact) {
259
+                            $facts[] = $fact;
260
+                        }
261
+                        break;
262
+                    }
263
+                }
264
+            }
265
+            break;
266
+        }
267
+
268
+        // For each child in the family
269
+        foreach ($family->getChildren() as $child) {
270
+            if ($child->getXref() == $person->getXref()) {
271
+                // We are not our own sibling!
272
+                continue;
273
+            }
274
+            // add child’s birth
275
+            if (strpos($SHOW_RELATIVES_EVENTS, '_BIRT' . str_replace('_HSIB', '_SIBL', $option)) !== false) {
276
+                foreach ($child->getFacts(WT_EVENTS_BIRT) as $fact) {
277
+                    $sgdate = $fact->getDate();
278
+                    // Always show _BIRT_CHIL, even if the dates are not known
279
+                    if ($option == '_CHIL' || $sgdate->isOK() && Date::compare($birt_date, $sgdate) <= 0 && Date::compare($sgdate, $deat_date) <= 0) {
280
+                        if ($option == '_GCHI' && $relation == 'dau') {
281
+                            // Convert the event to a close relatives event.
282
+                            $rela_fact = clone($fact);
283
+                            $rela_fact->setTag('_' . $fact->getTag() . '_GCH1');
284
+                            $facts[] = $rela_fact;
285
+                        } elseif ($option == '_GCHI' && $relation == 'son') {
286
+                            // Convert the event to a close relatives event.
287
+                            $rela_fact = clone($fact);
288
+                            $rela_fact->setTag('_' . $fact->getTag() . '_GCH2');
289
+                            $facts[] = $rela_fact;
290
+                        } else {
291
+                            // Convert the event to a close relatives event.
292
+                            $rela_fact = clone($fact);
293
+                            $rela_fact->setTag('_' . $fact->getTag() . $option);
294
+                            $facts[] = $rela_fact;
295
+                        }
296
+                    }
297
+                }
298
+            }
299
+            // add child’s death
300
+            if (strpos($SHOW_RELATIVES_EVENTS, '_DEAT' . str_replace('_HSIB', '_SIBL', $option)) !== false) {
301
+                foreach ($child->getFacts(WT_EVENTS_DEAT) as $fact) {
302
+                    $sgdate = $fact->getDate();
303
+                    if ($sgdate->isOK() && Date::compare($birt_date, $sgdate) <= 0 && Date::compare($sgdate, $deat_date) <= 0) {
304
+                        if ($option == '_GCHI' && $relation == 'dau') {
305
+                            // Convert the event to a close relatives event.
306
+                            $rela_fact = clone($fact);
307
+                            $rela_fact->setTag('_' . $fact->getTag() . '_GCH1');
308
+                            $facts[] = $rela_fact;
309
+                        } elseif ($option == '_GCHI' && $relation == 'son') {
310
+                            // Convert the event to a close relatives event.
311
+                            $rela_fact = clone($fact);
312
+                            $rela_fact->setTag('_' . $fact->getTag() . '_GCH2');
313
+                            $facts[] = $rela_fact;
314
+                        } else {
315
+                            // Convert the event to a close relatives event.
316
+                            $rela_fact = clone($fact);
317
+                            $rela_fact->setTag('_' . $fact->getTag() . $option);
318
+                            $facts[] = $rela_fact;
319
+                        }
320
+                    }
321
+                }
322
+            }
323
+            // add child’s marriage
324
+            if (strstr($SHOW_RELATIVES_EVENTS, '_MARR' . str_replace('_HSIB', '_SIBL', $option))) {
325
+                foreach ($child->getSpouseFamilies() as $sfamily) {
326
+                    foreach ($sfamily->getFacts(WT_EVENTS_MARR) as $fact) {
327
+                        $sgdate = $fact->getDate();
328
+                        if ($sgdate->isOK() && Date::compare($birt_date, $sgdate) <= 0 && Date::compare($sgdate, $deat_date) <= 0) {
329
+                            if ($option == '_GCHI' && $relation == 'dau') {
330
+                                // Convert the event to a close relatives event.
331
+                                $rela_fact = clone($fact);
332
+                                $rela_fact->setTag('_' . $fact->getTag() . '_GCH1');
333
+                                $facts[] = $rela_fact;
334
+                            } elseif ($option == '_GCHI' && $relation == 'son') {
335
+                                // Convert the event to a close relatives event.
336
+                                $rela_fact = clone($fact);
337
+                                $rela_fact->setTag('_' . $fact->getTag() . '_GCH2');
338
+                                $facts[] = $rela_fact;
339
+                            } else {
340
+                                // Convert the event to a close relatives event.
341
+                                $rela_fact = clone($fact);
342
+                                $rela_fact->setTag('_' . $fact->getTag() . $option);
343
+                                $facts[] = $rela_fact;
344
+                            }
345
+                        }
346
+                    }
347
+                }
348
+            }
349
+        }
350
+
351
+        return $facts;
352
+    }
353
+
354
+    /**
355
+     * Get the events of parents and grandparents.
356
+     *
357
+     * @param Individual $person
358
+     * @param int        $sosa
359
+     *
360
+     * @return Fact[]
361
+     */
362
+    private static function parentFacts(Individual $person, $sosa) {
363
+        global $controller;
364
+
365
+        $SHOW_RELATIVES_EVENTS = $person->getTree()->getPreference('SHOW_RELATIVES_EVENTS');
366
+
367
+        $facts = array();
368
+
369
+        // Only include events between birth and death
370
+        $birt_date = $controller->record->getEstimatedBirthDate();
371
+        $deat_date = $controller->record->getEstimatedDeathDate();
372
+
373
+        if ($sosa == 1) {
374
+            foreach ($person->getChildFamilies() as $family) {
375
+                // Add siblings
376
+                foreach (self::childFacts($person, $family, '_SIBL', '') as $fact) {
377
+                    $facts[] = $fact;
378
+                }
379
+                foreach ($family->getSpouses() as $spouse) {
380
+                    foreach ($spouse->getSpouseFamilies() as $sfamily) {
381
+                        if ($family !== $sfamily) {
382
+                            // Add half-siblings
383
+                            foreach (self::childFacts($person, $sfamily, '_HSIB', '') as $fact) {
384
+                                $facts[] = $fact;
385
+                            }
386
+                        }
387
+                    }
388
+                    // Add grandparents
389
+                    foreach (self::parentFacts($spouse, $spouse->getSex() == 'F' ? 3 : 2) as $fact) {
390
+                        $facts[] = $fact;
391
+                    }
392
+                }
393
+            }
394
+
395
+            if (strstr($SHOW_RELATIVES_EVENTS, '_MARR_PARE')) {
396
+                // add father/mother marriages
397
+                foreach ($person->getChildFamilies() as $sfamily) {
398
+                    foreach ($sfamily->getFacts(WT_EVENTS_MARR) as $fact) {
399
+                        if ($fact->getDate()->isOK() && Date::compare($birt_date, $fact->getDate()) <= 0 && Date::compare($fact->getDate(), $deat_date) <= 0) {
400
+                            // marriage of parents (to each other)
401
+                            $rela_fact = clone($fact);
402
+                            $rela_fact->setTag('_' . $fact->getTag() . '_FAMC');
403
+                            $facts[] = $rela_fact;
404
+                        }
405
+                    }
406
+                }
407
+                foreach ($person->getChildStepFamilies() as $sfamily) {
408
+                    foreach ($sfamily->getFacts(WT_EVENTS_MARR) as $fact) {
409
+                        if ($fact->getDate()->isOK() && Date::compare($birt_date, $fact->getDate()) <= 0 && Date::compare($fact->getDate(), $deat_date) <= 0) {
410
+                            // marriage of a parent (to another spouse)
411
+                            // Convert the event to a close relatives event
412
+                            $rela_fact = clone($fact);
413
+                            $rela_fact->setTag('_' . $fact->getTag() . '_PARE');
414
+                            $facts[] = $rela_fact;
415
+                        }
416
+                    }
417
+                }
418
+            }
419
+        }
420
+
421
+        foreach ($person->getChildFamilies() as $family) {
422
+            foreach ($family->getSpouses() as $parent) {
423
+                if (strstr($SHOW_RELATIVES_EVENTS, '_DEAT' . ($sosa == 1 ? '_PARE' : '_GPAR'))) {
424
+                    foreach ($parent->getFacts(WT_EVENTS_DEAT) as $fact) {
425
+                        if ($fact->getDate()->isOK() && Date::compare($birt_date, $fact->getDate()) <= 0 && Date::compare($fact->getDate(), $deat_date) <= 0) {
426
+                            switch ($sosa) {
427
+                            case 1:
428
+                                // Convert the event to a close relatives event.
429
+                                $rela_fact = clone($fact);
430
+                                $rela_fact->setTag('_' . $fact->getTag() . '_PARE');
431
+                                $facts[] = $rela_fact;
432
+                                break;
433
+                            case 2:
434
+                                // Convert the event to a close relatives event
435
+                                $rela_fact = clone($fact);
436
+                                $rela_fact->setTag('_' . $fact->getTag() . '_GPA1');
437
+                                $facts[] = $rela_fact;
438
+                                break;
439
+                            case 3:
440
+                                // Convert the event to a close relatives event
441
+                                $rela_fact = clone($fact);
442
+                                $rela_fact->setTag('_' . $fact->getTag() . '_GPA2');
443
+                                $facts[] = $rela_fact;
444
+                                break;
445
+                            }
446
+                        }
447
+                    }
448
+                }
449
+            }
450
+        }
451
+
452
+        return $facts;
453
+    }
454
+
455
+    /**
456
+     * Get any historical events.
457
+     *
458
+     * @param Individual $person
459
+     *
460
+     * @return Fact[]
461
+     */
462
+    private static function historicalFacts(Individual $person) {
463
+        $SHOW_RELATIVES_EVENTS = $person->getTree()->getPreference('SHOW_RELATIVES_EVENTS');
464
+
465
+        $facts = array();
466
+
467
+        if ($SHOW_RELATIVES_EVENTS) {
468
+            // Only include events between birth and death
469
+            $birt_date = $person->getEstimatedBirthDate();
470
+            $deat_date = $person->getEstimatedDeathDate();
471
+
472
+            if (file_exists(Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) {
473
+                $histo = array();
474
+                require Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php';
475
+                foreach ($histo as $hist) {
476
+                    // Earlier versions of the WIKI encouraged people to use HTML entities,
477
+                    // rather than UTF8 encoding.
478
+                    $hist = html_entity_decode($hist, ENT_QUOTES, 'UTF-8');
479
+
480
+                    $fact  = new Fact($hist, $person, 'histo');
481
+                    $sdate = $fact->getDate();
482
+                    if ($sdate->isOK() && Date::compare($birt_date, $sdate) <= 0 && Date::compare($sdate, $deat_date) <= 0) {
483
+                        $facts[] = $fact;
484
+                    }
485
+                }
486
+            }
487
+        }
488
+
489
+        return $facts;
490
+    }
491
+
492
+    /**
493
+     * Get the events of associates.
494
+     *
495
+     * @param Individual $person
496
+     *
497
+     * @return Fact[]
498
+     */
499
+    private static function associateFacts(Individual $person) {
500
+        $facts = array();
501
+
502
+        $associates = array_merge(
503
+            $person->linkedIndividuals('ASSO'),
504
+            $person->linkedIndividuals('_ASSO'),
505
+            $person->linkedFamilies('ASSO'),
506
+            $person->linkedFamilies('_ASSO')
507
+        );
508
+        foreach ($associates as $associate) {
509
+            foreach ($associate->getFacts() as $fact) {
510
+                $arec = $fact->getAttribute('_ASSO');
511
+                if (!$arec) {
512
+                    $arec = $fact->getAttribute('ASSO');
513
+                }
514
+                if ($arec && trim($arec, '@') === $person->getXref()) {
515
+                    // Extract the important details from the fact
516
+                    $factrec = '1 ' . $fact->getTag();
517
+                    if (preg_match('/\n2 DATE .*/', $fact->getGedcom(), $match)) {
518
+                        $factrec .= $match[0];
519
+                    }
520
+                    if (preg_match('/\n2 PLAC .*/', $fact->getGedcom(), $match)) {
521
+                        $factrec .= $match[0];
522
+                    }
523
+                    if ($associate instanceof Family) {
524
+                        foreach ($associate->getSpouses() as $spouse) {
525
+                            $factrec .= "\n2 _ASSO @" . $spouse->getXref() . '@';
526
+                        }
527
+                    } else {
528
+                        $factrec .= "\n2 _ASSO @" . $associate->getXref() . '@';
529
+                    }
530
+                    $facts[] = new Fact($factrec, $associate, 'asso');
531
+                }
532
+            }
533
+        }
534
+
535
+        return $facts;
536
+    }
537 537
 }
Please login to merge, or discard this patch.
app/Module/ChartsBlockModule.php 1 patch
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -29,170 +29,170 @@  discard block
 block discarded – undo
29 29
  * Class ChartsBlockModule
30 30
  */
31 31
 class ChartsBlockModule extends AbstractModule implements ModuleBlockInterface {
32
-	/** {@inheritdoc} */
33
-	public function getTitle() {
34
-		return /* I18N: Name of a module/block */ I18N::translate('Charts');
35
-	}
36
-
37
-	/** {@inheritdoc} */
38
-	public function getDescription() {
39
-		return /* I18N: Description of the “Charts” module */ I18N::translate('An alternative way to display charts.');
40
-	}
41
-
42
-	/**
43
-	 * Generate the HTML content of this block.
44
-	 *
45
-	 * @param int      $block_id
46
-	 * @param bool     $template
47
-	 * @param string[] $cfg
48
-	 *
49
-	 * @return string
50
-	 */
51
-	public function getBlock($block_id, $template = true, $cfg = array()) {
52
-		global $WT_TREE, $ctype, $controller;
53
-
54
-		$PEDIGREE_ROOT_ID = $WT_TREE->getPreference('PEDIGREE_ROOT_ID');
55
-		$gedcomid         = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid');
56
-
57
-		$details = $this->getBlockSetting($block_id, 'details', '0');
58
-		$type    = $this->getBlockSetting($block_id, 'type', 'pedigree');
59
-		$pid     = $this->getBlockSetting($block_id, 'pid', Auth::check() ? ($gedcomid ? $gedcomid : $PEDIGREE_ROOT_ID) : $PEDIGREE_ROOT_ID);
60
-
61
-		foreach (array('details', 'type', 'pid', 'block') as $name) {
62
-			if (array_key_exists($name, $cfg)) {
63
-				$$name = $cfg[$name];
64
-			}
65
-		}
66
-
67
-		$person = Individual::getInstance($pid, $WT_TREE);
68
-		if (!$person) {
69
-			$pid = $PEDIGREE_ROOT_ID;
70
-			$this->setBlockSetting($block_id, 'pid', $pid);
71
-			$person = Individual::getInstance($pid, $WT_TREE);
72
-		}
73
-
74
-		$id    = $this->getName() . $block_id;
75
-		$class = $this->getName() . '_block';
76
-		if ($ctype == 'gedcom' && Auth::isManager($WT_TREE) || $ctype == 'user' && Auth::check()) {
77
-			$title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
78
-		} else {
79
-			$title = '';
80
-		}
81
-
82
-		if ($person) {
83
-			$content = '';
84
-			switch ($type) {
85
-			case 'pedigree':
86
-				$title .= I18N::translate('Pedigree of %s', $person->getFullName());
87
-				$chartController = new HourglassController($person->getXref(), $details, false);
88
-				$controller->addInlineJavascript($chartController->setupJavascript());
89
-				$content .= '<table cellspacing="0" cellpadding="0" border="0"><tr>';
90
-				$content .= '<td>';
91
-				ob_start();
92
-				FunctionsPrint::printPedigreePerson($person, $details);
93
-				$content .= ob_get_clean();
94
-				$content .= '</td>';
95
-				$content .= '<td>';
96
-				ob_start();
97
-				$chartController->printPersonPedigree($person, 1);
98
-				$content .= ob_get_clean();
99
-				$content .= '</td>';
100
-				$content .= '</tr></table>';
101
-				break;
102
-			case 'descendants':
103
-				$title .= I18N::translate('Descendants of %s', $person->getFullName());
104
-				$chartController = new HourglassController($person->getXref(), $details, false);
105
-				$controller->addInlineJavascript($chartController->setupJavascript());
106
-				ob_start();
107
-				$chartController->printDescendency($person, 1, false);
108
-				$content .= ob_get_clean();
109
-				break;
110
-			case 'hourglass':
111
-				$title .= I18N::translate('Hourglass chart of %s', $person->getFullName());
112
-				$chartController = new HourglassController($person->getXref(), $details, false);
113
-				$controller->addInlineJavascript($chartController->setupJavascript());
114
-				$content .= '<table cellspacing="0" cellpadding="0" border="0"><tr>';
115
-				$content .= '<td>';
116
-				ob_start();
117
-				$chartController->printDescendency($person, 1, false);
118
-				$content .= ob_get_clean();
119
-				$content .= '</td>';
120
-				$content .= '<td>';
121
-				ob_start();
122
-				$chartController->printPersonPedigree($person, 1);
123
-				$content .= ob_get_clean();
124
-				$content .= '</td>';
125
-				$content .= '</tr></table>';
126
-				break;
127
-			case 'treenav':
128
-				$title .= I18N::translate('Interactive tree of %s', $person->getFullName());
129
-				$mod = new InteractiveTreeModule(WT_MODULES_DIR . 'tree');
130
-				$tv  = new TreeView;
131
-				$content .= '<script>jQuery("head").append(\'<link rel="stylesheet" href="' . $mod->css() . '" type="text/css" />\');</script>';
132
-				$content .= '<script src="' . $mod->js() . '"></script>';
133
-				list($html, $js) = $tv->drawViewport($person, 2);
134
-				$content .= $html . '<script>' . $js . '</script>';
135
-				break;
136
-			}
137
-		} else {
138
-			$content = I18N::translate('You must select an individual and a chart type in the block preferences');
139
-		}
140
-
141
-		if ($template) {
142
-			return Theme::theme()->formatBlock($id, $title, $class, $content);
143
-		} else {
144
-			return $content;
145
-		}
146
-	}
147
-
148
-	/** {@inheritdoc} */
149
-	public function loadAjax() {
150
-		return true;
151
-	}
152
-
153
-	/** {@inheritdoc} */
154
-	public function isUserBlock() {
155
-		return true;
156
-	}
157
-
158
-	/** {@inheritdoc} */
159
-	public function isGedcomBlock() {
160
-		return true;
161
-	}
162
-
163
-	/**
164
-	 * An HTML form to edit block settings
165
-	 *
166
-	 * @param int $block_id
167
-	 */
168
-	public function configureBlock($block_id) {
169
-		global $WT_TREE, $controller;
170
-
171
-		$PEDIGREE_ROOT_ID = $WT_TREE->getPreference('PEDIGREE_ROOT_ID');
172
-		$gedcomid         = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid');
173
-
174
-		if (Filter::postBool('save') && Filter::checkCsrf()) {
175
-			$this->setBlockSetting($block_id, 'details', Filter::postBool('details'));
176
-			$this->setBlockSetting($block_id, 'type', Filter::post('type', 'pedigree|descendants|hourglass|treenav', 'pedigree'));
177
-			$this->setBlockSetting($block_id, 'pid', Filter::post('pid', WT_REGEX_XREF));
178
-		}
179
-
180
-		$details = $this->getBlockSetting($block_id, 'details', '0');
181
-		$type    = $this->getBlockSetting($block_id, 'type', 'pedigree');
182
-		$pid     = $this->getBlockSetting($block_id, 'pid', Auth::check() ? ($gedcomid ? $gedcomid : $PEDIGREE_ROOT_ID) : $PEDIGREE_ROOT_ID);
183
-
184
-		$charts = array(
185
-			'pedigree'    => I18N::translate('Pedigree'),
186
-			'descendants' => I18N::translate('Descendants'),
187
-			'hourglass'   => I18N::translate('Hourglass chart'),
188
-			'treenav'     => I18N::translate('Interactive tree'),
189
-		);
190
-		uasort($charts, 'Fisharebest\Webtrees\I18N::strcasecmp');
191
-
192
-		$controller
193
-			->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
194
-			->addInlineJavascript('autocomplete();');
195
-	?>
32
+    /** {@inheritdoc} */
33
+    public function getTitle() {
34
+        return /* I18N: Name of a module/block */ I18N::translate('Charts');
35
+    }
36
+
37
+    /** {@inheritdoc} */
38
+    public function getDescription() {
39
+        return /* I18N: Description of the “Charts” module */ I18N::translate('An alternative way to display charts.');
40
+    }
41
+
42
+    /**
43
+     * Generate the HTML content of this block.
44
+     *
45
+     * @param int      $block_id
46
+     * @param bool     $template
47
+     * @param string[] $cfg
48
+     *
49
+     * @return string
50
+     */
51
+    public function getBlock($block_id, $template = true, $cfg = array()) {
52
+        global $WT_TREE, $ctype, $controller;
53
+
54
+        $PEDIGREE_ROOT_ID = $WT_TREE->getPreference('PEDIGREE_ROOT_ID');
55
+        $gedcomid         = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid');
56
+
57
+        $details = $this->getBlockSetting($block_id, 'details', '0');
58
+        $type    = $this->getBlockSetting($block_id, 'type', 'pedigree');
59
+        $pid     = $this->getBlockSetting($block_id, 'pid', Auth::check() ? ($gedcomid ? $gedcomid : $PEDIGREE_ROOT_ID) : $PEDIGREE_ROOT_ID);
60
+
61
+        foreach (array('details', 'type', 'pid', 'block') as $name) {
62
+            if (array_key_exists($name, $cfg)) {
63
+                $$name = $cfg[$name];
64
+            }
65
+        }
66
+
67
+        $person = Individual::getInstance($pid, $WT_TREE);
68
+        if (!$person) {
69
+            $pid = $PEDIGREE_ROOT_ID;
70
+            $this->setBlockSetting($block_id, 'pid', $pid);
71
+            $person = Individual::getInstance($pid, $WT_TREE);
72
+        }
73
+
74
+        $id    = $this->getName() . $block_id;
75
+        $class = $this->getName() . '_block';
76
+        if ($ctype == 'gedcom' && Auth::isManager($WT_TREE) || $ctype == 'user' && Auth::check()) {
77
+            $title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
78
+        } else {
79
+            $title = '';
80
+        }
81
+
82
+        if ($person) {
83
+            $content = '';
84
+            switch ($type) {
85
+            case 'pedigree':
86
+                $title .= I18N::translate('Pedigree of %s', $person->getFullName());
87
+                $chartController = new HourglassController($person->getXref(), $details, false);
88
+                $controller->addInlineJavascript($chartController->setupJavascript());
89
+                $content .= '<table cellspacing="0" cellpadding="0" border="0"><tr>';
90
+                $content .= '<td>';
91
+                ob_start();
92
+                FunctionsPrint::printPedigreePerson($person, $details);
93
+                $content .= ob_get_clean();
94
+                $content .= '</td>';
95
+                $content .= '<td>';
96
+                ob_start();
97
+                $chartController->printPersonPedigree($person, 1);
98
+                $content .= ob_get_clean();
99
+                $content .= '</td>';
100
+                $content .= '</tr></table>';
101
+                break;
102
+            case 'descendants':
103
+                $title .= I18N::translate('Descendants of %s', $person->getFullName());
104
+                $chartController = new HourglassController($person->getXref(), $details, false);
105
+                $controller->addInlineJavascript($chartController->setupJavascript());
106
+                ob_start();
107
+                $chartController->printDescendency($person, 1, false);
108
+                $content .= ob_get_clean();
109
+                break;
110
+            case 'hourglass':
111
+                $title .= I18N::translate('Hourglass chart of %s', $person->getFullName());
112
+                $chartController = new HourglassController($person->getXref(), $details, false);
113
+                $controller->addInlineJavascript($chartController->setupJavascript());
114
+                $content .= '<table cellspacing="0" cellpadding="0" border="0"><tr>';
115
+                $content .= '<td>';
116
+                ob_start();
117
+                $chartController->printDescendency($person, 1, false);
118
+                $content .= ob_get_clean();
119
+                $content .= '</td>';
120
+                $content .= '<td>';
121
+                ob_start();
122
+                $chartController->printPersonPedigree($person, 1);
123
+                $content .= ob_get_clean();
124
+                $content .= '</td>';
125
+                $content .= '</tr></table>';
126
+                break;
127
+            case 'treenav':
128
+                $title .= I18N::translate('Interactive tree of %s', $person->getFullName());
129
+                $mod = new InteractiveTreeModule(WT_MODULES_DIR . 'tree');
130
+                $tv  = new TreeView;
131
+                $content .= '<script>jQuery("head").append(\'<link rel="stylesheet" href="' . $mod->css() . '" type="text/css" />\');</script>';
132
+                $content .= '<script src="' . $mod->js() . '"></script>';
133
+                list($html, $js) = $tv->drawViewport($person, 2);
134
+                $content .= $html . '<script>' . $js . '</script>';
135
+                break;
136
+            }
137
+        } else {
138
+            $content = I18N::translate('You must select an individual and a chart type in the block preferences');
139
+        }
140
+
141
+        if ($template) {
142
+            return Theme::theme()->formatBlock($id, $title, $class, $content);
143
+        } else {
144
+            return $content;
145
+        }
146
+    }
147
+
148
+    /** {@inheritdoc} */
149
+    public function loadAjax() {
150
+        return true;
151
+    }
152
+
153
+    /** {@inheritdoc} */
154
+    public function isUserBlock() {
155
+        return true;
156
+    }
157
+
158
+    /** {@inheritdoc} */
159
+    public function isGedcomBlock() {
160
+        return true;
161
+    }
162
+
163
+    /**
164
+     * An HTML form to edit block settings
165
+     *
166
+     * @param int $block_id
167
+     */
168
+    public function configureBlock($block_id) {
169
+        global $WT_TREE, $controller;
170
+
171
+        $PEDIGREE_ROOT_ID = $WT_TREE->getPreference('PEDIGREE_ROOT_ID');
172
+        $gedcomid         = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid');
173
+
174
+        if (Filter::postBool('save') && Filter::checkCsrf()) {
175
+            $this->setBlockSetting($block_id, 'details', Filter::postBool('details'));
176
+            $this->setBlockSetting($block_id, 'type', Filter::post('type', 'pedigree|descendants|hourglass|treenav', 'pedigree'));
177
+            $this->setBlockSetting($block_id, 'pid', Filter::post('pid', WT_REGEX_XREF));
178
+        }
179
+
180
+        $details = $this->getBlockSetting($block_id, 'details', '0');
181
+        $type    = $this->getBlockSetting($block_id, 'type', 'pedigree');
182
+        $pid     = $this->getBlockSetting($block_id, 'pid', Auth::check() ? ($gedcomid ? $gedcomid : $PEDIGREE_ROOT_ID) : $PEDIGREE_ROOT_ID);
183
+
184
+        $charts = array(
185
+            'pedigree'    => I18N::translate('Pedigree'),
186
+            'descendants' => I18N::translate('Descendants'),
187
+            'hourglass'   => I18N::translate('Hourglass chart'),
188
+            'treenav'     => I18N::translate('Interactive tree'),
189
+        );
190
+        uasort($charts, 'Fisharebest\Webtrees\I18N::strcasecmp');
191
+
192
+        $controller
193
+            ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
194
+            ->addInlineJavascript('autocomplete();');
195
+    ?>
196 196
 		<tr>
197 197
 			<td class="descriptionbox wrap width33">
198 198
 				<?php echo I18N::translate('Chart type'); ?>
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
 			<td class="optionbox">
219 219
 				<input data-autocomplete-type="INDI" type="text" name="pid" id="pid" value="<?php echo $pid; ?>" size="5">
220 220
 				<?php
221
-				echo FunctionsPrint::printFindIndividualLink('pid');
222
-				$root = Individual::getInstance($pid, $WT_TREE);
223
-				if ($root) {
224
-					echo ' <span class="list_item">', $root->getFullName(), $root->formatFirstMajorFact(WT_EVENTS_BIRT, 1), '</span>';
225
-				}
226
-				?>
221
+                echo FunctionsPrint::printFindIndividualLink('pid');
222
+                $root = Individual::getInstance($pid, $WT_TREE);
223
+                if ($root) {
224
+                    echo ' <span class="list_item">', $root->getFullName(), $root->formatFirstMajorFact(WT_EVENTS_BIRT, 1), '</span>';
225
+                }
226
+                ?>
227 227
 			</td>
228 228
 		</tr>
229 229
 		<?php
230
-	}
230
+    }
231 231
 }
Please login to merge, or discard this patch.
app/Module/AlbumModule.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -28,245 +28,245 @@
 block discarded – undo
28 28
  * Class AlbumModule
29 29
  */
30 30
 class AlbumModule extends AbstractModule implements ModuleTabInterface {
31
-	/** @var Media[] List of media objects. */
32
-	private $media_list;
31
+    /** @var Media[] List of media objects. */
32
+    private $media_list;
33 33
 
34
-	/**
35
-	 * How should this module be labelled on tabs, menus, etc.?
36
-	 *
37
-	 * @return string
38
-	 */
39
-	public function getTitle() {
40
-		return /* I18N: Name of a module */ I18N::translate('Album');
41
-	}
34
+    /**
35
+     * How should this module be labelled on tabs, menus, etc.?
36
+     *
37
+     * @return string
38
+     */
39
+    public function getTitle() {
40
+        return /* I18N: Name of a module */ I18N::translate('Album');
41
+    }
42 42
 
43
-	/**
44
-	 * A sentence describing what this module does.
45
-	 *
46
-	 * @return string
47
-	 */
48
-	public function getDescription() {
49
-		return /* I18N: Description of the “Album” module */ I18N::translate('An alternative to the “media” tab, and an enhanced image viewer.');
50
-	}
43
+    /**
44
+     * A sentence describing what this module does.
45
+     *
46
+     * @return string
47
+     */
48
+    public function getDescription() {
49
+        return /* I18N: Description of the “Album” module */ I18N::translate('An alternative to the “media” tab, and an enhanced image viewer.');
50
+    }
51 51
 
52
-	/**
53
-	 * The user can re-arrange the tab order, but until they do, this
54
-	 * is the order in which tabs are shown.
55
-	 *
56
-	 * @return int
57
-	 */
58
-	public function defaultTabOrder() {
59
-		return 60;
60
-	}
52
+    /**
53
+     * The user can re-arrange the tab order, but until they do, this
54
+     * is the order in which tabs are shown.
55
+     *
56
+     * @return int
57
+     */
58
+    public function defaultTabOrder() {
59
+        return 60;
60
+    }
61 61
 
62
-	/**
63
-	 * Is this tab empty? If so, we don't always need to display it.
64
-	 *
65
-	 * @return bool
66
-	 */
67
-	public function hasTabContent() {
68
-		global $WT_TREE;
62
+    /**
63
+     * Is this tab empty? If so, we don't always need to display it.
64
+     *
65
+     * @return bool
66
+     */
67
+    public function hasTabContent() {
68
+        global $WT_TREE;
69 69
 
70
-		return Auth::isEditor($WT_TREE) || $this->getMedia();
71
-	}
70
+        return Auth::isEditor($WT_TREE) || $this->getMedia();
71
+    }
72 72
 
73
-	/**
74
-	 * A greyed out tab has no actual content, but may perhaps have
75
-	 * options to create content.
76
-	 *
77
-	 * @return bool
78
-	 */
79
-	public function isGrayedOut() {
80
-		return !$this->getMedia();
81
-	}
73
+    /**
74
+     * A greyed out tab has no actual content, but may perhaps have
75
+     * options to create content.
76
+     *
77
+     * @return bool
78
+     */
79
+    public function isGrayedOut() {
80
+        return !$this->getMedia();
81
+    }
82 82
 
83
-	/**
84
-	 * Generate the HTML content of this tab.
85
-	 *
86
-	 * @return string
87
-	 */
88
-	public function getTabContent() {
89
-		global $WT_TREE, $controller;
83
+    /**
84
+     * Generate the HTML content of this tab.
85
+     *
86
+     * @return string
87
+     */
88
+    public function getTabContent() {
89
+        global $WT_TREE, $controller;
90 90
 
91
-		$html = '<div id="' . $this->getName() . '_content">';
92
-		//Show Lightbox-Album header Links
93
-		if (Auth::isEditor($WT_TREE)) {
94
-			$html .= '<table class="facts_table"><tr class="noprint"><td class="descriptionbox rela">';
95
-			// Add a media object
96
-			if ($WT_TREE->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($WT_TREE)) {
97
-				$html .= '<span><a href="#" onclick="window.open(\'addmedia.php?action=showmediaform&linktoid=' . $controller->record->getXref() . '\', \'_blank\', \'resizable=1,scrollbars=1,top=50,height=780,width=600\');return false;">';
98
-				$html .= '<img src="' . Theme::theme()->assetUrl() . 'images/image_add.png" id="head_icon" class="icon" title="' . I18N::translate('Add a media object') . '" alt="' . I18N::translate('Add a media object') . '">';
99
-				$html .= I18N::translate('Add a media object');
100
-				$html .= '</a></span>';
101
-				// Link to an existing item
102
-				$html .= '<span><a href="#" onclick="window.open(\'inverselink.php?linktoid=' . $controller->record->getXref() . '&linkto=person\', \'_blank\', \'resizable=1,scrollbars=1,top=50,height=300,width=450\');">';
103
-				$html .= '<img src="' . Theme::theme()->assetUrl() . 'images/image_link.png" id="head_icon" class="icon" title="' . I18N::translate('Link to an existing media object') . '" alt="' . I18N::translate('Link to an existing media object') . '">';
104
-				$html .= I18N::translate('Link to an existing media object');
105
-				$html .= '</a></span>';
106
-			}
107
-			if (Auth::isManager($WT_TREE) && $this->getMedia()) {
108
-				// Popup Reorder Media
109
-				$html .= '<span><a href="#" onclick="reorder_media(\'' . $controller->record->getXref() . '\')">';
110
-				$html .= '<img src="' . Theme::theme()->assetUrl() . 'images/images.png" id="head_icon" class="icon" title="' . I18N::translate('Re-order media') . '" alt="' . I18N::translate('Re-order media') . '">';
111
-				$html .= I18N::translate('Re-order media');
112
-				$html .= '</a></span>';
113
-			}
114
-			$html .= '</td></tr></table>';
115
-		}
91
+        $html = '<div id="' . $this->getName() . '_content">';
92
+        //Show Lightbox-Album header Links
93
+        if (Auth::isEditor($WT_TREE)) {
94
+            $html .= '<table class="facts_table"><tr class="noprint"><td class="descriptionbox rela">';
95
+            // Add a media object
96
+            if ($WT_TREE->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($WT_TREE)) {
97
+                $html .= '<span><a href="#" onclick="window.open(\'addmedia.php?action=showmediaform&linktoid=' . $controller->record->getXref() . '\', \'_blank\', \'resizable=1,scrollbars=1,top=50,height=780,width=600\');return false;">';
98
+                $html .= '<img src="' . Theme::theme()->assetUrl() . 'images/image_add.png" id="head_icon" class="icon" title="' . I18N::translate('Add a media object') . '" alt="' . I18N::translate('Add a media object') . '">';
99
+                $html .= I18N::translate('Add a media object');
100
+                $html .= '</a></span>';
101
+                // Link to an existing item
102
+                $html .= '<span><a href="#" onclick="window.open(\'inverselink.php?linktoid=' . $controller->record->getXref() . '&linkto=person\', \'_blank\', \'resizable=1,scrollbars=1,top=50,height=300,width=450\');">';
103
+                $html .= '<img src="' . Theme::theme()->assetUrl() . 'images/image_link.png" id="head_icon" class="icon" title="' . I18N::translate('Link to an existing media object') . '" alt="' . I18N::translate('Link to an existing media object') . '">';
104
+                $html .= I18N::translate('Link to an existing media object');
105
+                $html .= '</a></span>';
106
+            }
107
+            if (Auth::isManager($WT_TREE) && $this->getMedia()) {
108
+                // Popup Reorder Media
109
+                $html .= '<span><a href="#" onclick="reorder_media(\'' . $controller->record->getXref() . '\')">';
110
+                $html .= '<img src="' . Theme::theme()->assetUrl() . 'images/images.png" id="head_icon" class="icon" title="' . I18N::translate('Re-order media') . '" alt="' . I18N::translate('Re-order media') . '">';
111
+                $html .= I18N::translate('Re-order media');
112
+                $html .= '</a></span>';
113
+            }
114
+            $html .= '</td></tr></table>';
115
+        }
116 116
 
117
-		// Used when sorting media on album tab page
118
-		$html .= '<table class="facts_table"><tr><td class="facts_value">'; // one-cell table - for presentation only
119
-		$html .= '<ul class="album-list">';
120
-		foreach ($this->getMedia() as $media) {
121
-			//View Edit Menu ----------------------------------
117
+        // Used when sorting media on album tab page
118
+        $html .= '<table class="facts_table"><tr><td class="facts_value">'; // one-cell table - for presentation only
119
+        $html .= '<ul class="album-list">';
120
+        foreach ($this->getMedia() as $media) {
121
+            //View Edit Menu ----------------------------------
122 122
 
123
-			//Get media item Notes
124
-			$haystack = $media->getGedcom();
125
-			$needle   = '1 NOTE';
126
-			$before   = substr($haystack, 0, strpos($haystack, $needle));
127
-			$after    = substr(strstr($haystack, $needle), strlen($needle));
128
-			$notes    = FunctionsPrint::printFactNotes($before . $needle . $after, 1, true);
123
+            //Get media item Notes
124
+            $haystack = $media->getGedcom();
125
+            $needle   = '1 NOTE';
126
+            $before   = substr($haystack, 0, strpos($haystack, $needle));
127
+            $after    = substr(strstr($haystack, $needle), strlen($needle));
128
+            $notes    = FunctionsPrint::printFactNotes($before . $needle . $after, 1, true);
129 129
 
130
-			// Prepare Below Thumbnail  menu ----------------------------------------------------
131
-			$menu = new Menu('<div style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap">' . $media->getFullName() . '</div>');
132
-			$menu->addClass('', 'submenu');
130
+            // Prepare Below Thumbnail  menu ----------------------------------------------------
131
+            $menu = new Menu('<div style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap">' . $media->getFullName() . '</div>');
132
+            $menu->addClass('', 'submenu');
133 133
 
134
-			// View Notes
135
-			if (strpos($media->getGedcom(), "\n1 NOTE")) {
136
-				$submenu = new Menu(I18N::translate('View the notes'), '#', '', array(
137
-					'onclick' => 'modalNotes("' . Filter::escapeJs($notes) . '","' . I18N::translate('View the notes') . '"); return false;',
138
-				));
139
-				$submenu->addClass("submenuitem");
140
-				$menu->addSubmenu($submenu);
141
-			}
142
-			//View Details
143
-			$submenu = new Menu(I18N::translate('View the details'), $media->getHtmlUrl());
144
-			$submenu->addClass("submenuitem");
145
-			$menu->addSubmenu($submenu);
134
+            // View Notes
135
+            if (strpos($media->getGedcom(), "\n1 NOTE")) {
136
+                $submenu = new Menu(I18N::translate('View the notes'), '#', '', array(
137
+                    'onclick' => 'modalNotes("' . Filter::escapeJs($notes) . '","' . I18N::translate('View the notes') . '"); return false;',
138
+                ));
139
+                $submenu->addClass("submenuitem");
140
+                $menu->addSubmenu($submenu);
141
+            }
142
+            //View Details
143
+            $submenu = new Menu(I18N::translate('View the details'), $media->getHtmlUrl());
144
+            $submenu->addClass("submenuitem");
145
+            $menu->addSubmenu($submenu);
146 146
 
147
-			//View Sources
148
-			foreach ($media->getFacts('SOUR') as $source_fact) {
149
-				$source = $source_fact->getTarget();
150
-				if ($source && $source->canShow()) {
151
-					$submenu = new Menu(I18N::translate('Source') . ' – ' . $source->getFullName(), $source->getHtmlUrl());
152
-					$submenu->addClass('submenuitem');
153
-					$menu->addSubmenu($submenu);
154
-				}
155
-			}
147
+            //View Sources
148
+            foreach ($media->getFacts('SOUR') as $source_fact) {
149
+                $source = $source_fact->getTarget();
150
+                if ($source && $source->canShow()) {
151
+                    $submenu = new Menu(I18N::translate('Source') . ' – ' . $source->getFullName(), $source->getHtmlUrl());
152
+                    $submenu->addClass('submenuitem');
153
+                    $menu->addSubmenu($submenu);
154
+                }
155
+            }
156 156
 
157
-			if (Auth::isEditor($media->getTree())) {
158
-				// Edit Media
159
-				$submenu = new Menu(I18N::translate('Edit the media object'), '#', '', array(
160
-					'onclick' => 'return window.open("addmedia.php?action=editmedia&pid=' . $media->getXref() . '", "_blank", edit_window_specs);',
161
-				));
162
-				$submenu->addClass("submenuitem");
163
-				$menu->addSubmenu($submenu);
164
-				if (Auth::isAdmin()) {
165
-					if (Module::getModuleByName('GEDFact_assistant')) {
166
-						$submenu = new Menu(I18N::translate('Manage the links'), '#', '', array(
167
-							'onclick' => 'return window.open("inverselink.php?mediaid=' . $media->getXref() . '&linkto=manage", "_blank", find_window_specs);',
168
-						));
169
-						$submenu->addClass("submenuitem");
170
-						$menu->addSubmenu($submenu);
171
-					} else {
172
-						$submenu = new Menu(I18N::translate('Link this media object to an individual'), '#', 'menu-obje-link-indi', array(
173
-							'onclick' => 'return ilinkitem("' . $media->getXref() . '","person");',
174
-						));
175
-						$submenu->addClass('submenuitem');
176
-						$menu->addSubmenu($submenu);
157
+            if (Auth::isEditor($media->getTree())) {
158
+                // Edit Media
159
+                $submenu = new Menu(I18N::translate('Edit the media object'), '#', '', array(
160
+                    'onclick' => 'return window.open("addmedia.php?action=editmedia&pid=' . $media->getXref() . '", "_blank", edit_window_specs);',
161
+                ));
162
+                $submenu->addClass("submenuitem");
163
+                $menu->addSubmenu($submenu);
164
+                if (Auth::isAdmin()) {
165
+                    if (Module::getModuleByName('GEDFact_assistant')) {
166
+                        $submenu = new Menu(I18N::translate('Manage the links'), '#', '', array(
167
+                            'onclick' => 'return window.open("inverselink.php?mediaid=' . $media->getXref() . '&linkto=manage", "_blank", find_window_specs);',
168
+                        ));
169
+                        $submenu->addClass("submenuitem");
170
+                        $menu->addSubmenu($submenu);
171
+                    } else {
172
+                        $submenu = new Menu(I18N::translate('Link this media object to an individual'), '#', 'menu-obje-link-indi', array(
173
+                            'onclick' => 'return ilinkitem("' . $media->getXref() . '","person");',
174
+                        ));
175
+                        $submenu->addClass('submenuitem');
176
+                        $menu->addSubmenu($submenu);
177 177
 
178
-						$submenu = new Menu(I18N::translate('Link this media object to a family'), '#', 'menu-obje-link-fam', array(
179
-							'onclick' => 'return ilinkitem("' . $media->getXref() . '","family");',
180
-						));
181
-						$submenu->addClass('submenuitem');
182
-						$menu->addSubmenu($submenu);
178
+                        $submenu = new Menu(I18N::translate('Link this media object to a family'), '#', 'menu-obje-link-fam', array(
179
+                            'onclick' => 'return ilinkitem("' . $media->getXref() . '","family");',
180
+                        ));
181
+                        $submenu->addClass('submenuitem');
182
+                        $menu->addSubmenu($submenu);
183 183
 
184
-						$submenu = new Menu(I18N::translate('Link this media object to a source'), '#', 'menu-obje-link-sour', array(
185
-							'onclick' => 'return ilinkitem("' . $media->getXref() . '","source");',
186
-						));
187
-						$submenu->addClass('submenuitem');
188
-						$menu->addSubmenu($submenu);
189
-					}
190
-					$submenu = new Menu(I18N::translate('Unlink the media object'), '#', '', array(
191
-						'onclick' => 'return unlink_media("' . I18N::translate('Are you sure you want to remove links to this media object?') . '", "' . $controller->record->getXref() . '", "' . $media->getXref() . '");',
192
-					));
193
-					$submenu->addClass("submenuitem");
194
-					$menu->addSubmenu($submenu);
195
-				}
196
-			}
197
-			$html .= '<li class="album-list-item">';
198
-			$html .= '<div class="album-image">' . $media->displayImage() . '</div>';
199
-			$html .= '<div class="album-title">' . $menu->getMenu() . '</div>';
200
-			$html .= '</li>';
201
-		}
202
-		$html .= '</ul>';
203
-		$html .= '</td></tr></table>';
184
+                        $submenu = new Menu(I18N::translate('Link this media object to a source'), '#', 'menu-obje-link-sour', array(
185
+                            'onclick' => 'return ilinkitem("' . $media->getXref() . '","source");',
186
+                        ));
187
+                        $submenu->addClass('submenuitem');
188
+                        $menu->addSubmenu($submenu);
189
+                    }
190
+                    $submenu = new Menu(I18N::translate('Unlink the media object'), '#', '', array(
191
+                        'onclick' => 'return unlink_media("' . I18N::translate('Are you sure you want to remove links to this media object?') . '", "' . $controller->record->getXref() . '", "' . $media->getXref() . '");',
192
+                    ));
193
+                    $submenu->addClass("submenuitem");
194
+                    $menu->addSubmenu($submenu);
195
+                }
196
+            }
197
+            $html .= '<li class="album-list-item">';
198
+            $html .= '<div class="album-image">' . $media->displayImage() . '</div>';
199
+            $html .= '<div class="album-title">' . $menu->getMenu() . '</div>';
200
+            $html .= '</li>';
201
+        }
202
+        $html .= '</ul>';
203
+        $html .= '</td></tr></table>';
204 204
 
205
-		return $html;
206
-	}
205
+        return $html;
206
+    }
207 207
 
208
-	/**
209
-	 * Get all facts containing media links for this person and their spouse-family records
210
-	 *
211
-	 * @return Media[]
212
-	 */
213
-	private function getMedia() {
214
-		global $controller;
208
+    /**
209
+     * Get all facts containing media links for this person and their spouse-family records
210
+     *
211
+     * @return Media[]
212
+     */
213
+    private function getMedia() {
214
+        global $controller;
215 215
 
216
-		if ($this->media_list === null) {
217
-			// Use facts from this individual and all their spouses
218
-			$facts = $controller->record->getFacts();
219
-			foreach ($controller->record->getSpouseFamilies() as $family) {
220
-				foreach ($family->getFacts() as $fact) {
221
-					$facts[] = $fact;
222
-				}
223
-			}
224
-			// Use all media from each fact
225
-			$this->media_list = array();
226
-			foreach ($facts as $fact) {
227
-				// Don't show pending edits, as the user just sees duplicates
228
-				if (!$fact->isPendingDeletion()) {
229
-					preg_match_all('/(?:^1|\n\d) OBJE @(' . WT_REGEX_XREF . ')@/', $fact->getGedcom(), $matches);
230
-					foreach ($matches[1] as $match) {
231
-						$media = Media::getInstance($match, $controller->record->getTree());
232
-						if ($media && $media->canShow()) {
233
-							$this->media_list[] = $media;
234
-						}
235
-					}
236
-				}
237
-			}
238
-			// If a media object is linked twice, only show it once
239
-			$this->media_list = array_unique($this->media_list);
240
-			// Sort these using _WT_OBJE_SORT
241
-			$wt_obje_sort = array();
242
-			foreach ($controller->record->getFacts('_WT_OBJE_SORT') as $fact) {
243
-				$wt_obje_sort[] = trim($fact->getValue(), '@');
244
-			}
245
-			usort($this->media_list, function (Media $x, Media $y) use ($wt_obje_sort) {
246
-				return array_search($x->getXref(), $wt_obje_sort) - array_search($y->getXref(), $wt_obje_sort);
247
-			});
248
-		}
216
+        if ($this->media_list === null) {
217
+            // Use facts from this individual and all their spouses
218
+            $facts = $controller->record->getFacts();
219
+            foreach ($controller->record->getSpouseFamilies() as $family) {
220
+                foreach ($family->getFacts() as $fact) {
221
+                    $facts[] = $fact;
222
+                }
223
+            }
224
+            // Use all media from each fact
225
+            $this->media_list = array();
226
+            foreach ($facts as $fact) {
227
+                // Don't show pending edits, as the user just sees duplicates
228
+                if (!$fact->isPendingDeletion()) {
229
+                    preg_match_all('/(?:^1|\n\d) OBJE @(' . WT_REGEX_XREF . ')@/', $fact->getGedcom(), $matches);
230
+                    foreach ($matches[1] as $match) {
231
+                        $media = Media::getInstance($match, $controller->record->getTree());
232
+                        if ($media && $media->canShow()) {
233
+                            $this->media_list[] = $media;
234
+                        }
235
+                    }
236
+                }
237
+            }
238
+            // If a media object is linked twice, only show it once
239
+            $this->media_list = array_unique($this->media_list);
240
+            // Sort these using _WT_OBJE_SORT
241
+            $wt_obje_sort = array();
242
+            foreach ($controller->record->getFacts('_WT_OBJE_SORT') as $fact) {
243
+                $wt_obje_sort[] = trim($fact->getValue(), '@');
244
+            }
245
+            usort($this->media_list, function (Media $x, Media $y) use ($wt_obje_sort) {
246
+                return array_search($x->getXref(), $wt_obje_sort) - array_search($y->getXref(), $wt_obje_sort);
247
+            });
248
+        }
249 249
 
250
-		return $this->media_list;
251
-	}
250
+        return $this->media_list;
251
+    }
252 252
 
253
-	/**
254
-	 * Can this tab load asynchronously?
255
-	 *
256
-	 * @return bool
257
-	 */
258
-	public function canLoadAjax() {
259
-		return !Auth::isSearchEngine(); // Search engines cannot use AJAX
260
-	}
253
+    /**
254
+     * Can this tab load asynchronously?
255
+     *
256
+     * @return bool
257
+     */
258
+    public function canLoadAjax() {
259
+        return !Auth::isSearchEngine(); // Search engines cannot use AJAX
260
+    }
261 261
 
262
-	/**
263
-	 * Any content (e.g. Javascript) that needs to be rendered before the tabs.
264
-	 *
265
-	 * This function is probably not needed, as there are better ways to achieve this.
266
-	 *
267
-	 * @return string
268
-	 */
269
-	public function getPreLoadContent() {
270
-		return '';
271
-	}
262
+    /**
263
+     * Any content (e.g. Javascript) that needs to be rendered before the tabs.
264
+     *
265
+     * This function is probably not needed, as there are better ways to achieve this.
266
+     *
267
+     * @return string
268
+     */
269
+    public function getPreLoadContent() {
270
+        return '';
271
+    }
272 272
 }
Please login to merge, or discard this patch.
app/Module/FactSourcesReportModule.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -23,42 +23,42 @@
 block discarded – undo
23 23
  * Class FactSourcesReportModule
24 24
  */
25 25
 class FactSourcesReportModule extends AbstractModule implements ModuleReportInterface {
26
-	/** {@inheritdoc} */
27
-	public function getTitle() {
28
-		// This text also appears in the .XML file - update both together
29
-		return /* I18N: Name of a module/report */ I18N::translate('Source');
30
-	}
26
+    /** {@inheritdoc} */
27
+    public function getTitle() {
28
+        // This text also appears in the .XML file - update both together
29
+        return /* I18N: Name of a module/report */ I18N::translate('Source');
30
+    }
31 31
 
32
-	/** {@inheritdoc} */
33
-	public function getDescription() {
34
-		// This text also appears in the .XML file - update both together
35
-		return /* I18N: Description of the “Source” module */ I18N::translate('A report of the information provided by a source.');
36
-	}
32
+    /** {@inheritdoc} */
33
+    public function getDescription() {
34
+        // This text also appears in the .XML file - update both together
35
+        return /* I18N: Description of the “Source” module */ I18N::translate('A report of the information provided by a source.');
36
+    }
37 37
 
38
-	/**
39
-	 * What is the default access level for this module?
40
-	 *
41
-	 * Some modules are aimed at admins or managers, and are not generally shown to users.
42
-	 *
43
-	 * @return int
44
-	 */
45
-	public function defaultAccessLevel() {
46
-		return Auth::PRIV_USER;
47
-	}
38
+    /**
39
+     * What is the default access level for this module?
40
+     *
41
+     * Some modules are aimed at admins or managers, and are not generally shown to users.
42
+     *
43
+     * @return int
44
+     */
45
+    public function defaultAccessLevel() {
46
+        return Auth::PRIV_USER;
47
+    }
48 48
 
49
-	/**
50
-	 * Return a menu item for this report.
51
-	 *
52
-	 * @return Menu
53
-	 */
54
-	public function getReportMenu() {
55
-		global $WT_TREE;
49
+    /**
50
+     * Return a menu item for this report.
51
+     *
52
+     * @return Menu
53
+     */
54
+    public function getReportMenu() {
55
+        global $WT_TREE;
56 56
 
57
-		return new Menu(
58
-			$this->getTitle(),
59
-			'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
60
-			'menu-report-' . $this->getName(),
61
-			array('rel' => 'nofollow')
62
-		);
63
-	}
57
+        return new Menu(
58
+            $this->getTitle(),
59
+            'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
60
+            'menu-report-' . $this->getName(),
61
+            array('rel' => 'nofollow')
62
+        );
63
+    }
64 64
 }
Please login to merge, or discard this patch.
app/Module/TimelineChartModule.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -24,55 +24,55 @@
 block discarded – undo
24 24
  * Class TimelineChartModule
25 25
  */
26 26
 class TimelineChartModule extends AbstractModule implements ModuleChartInterface {
27
-	/**
28
-	 * How should this module be labelled on tabs, menus, etc.?
29
-	 *
30
-	 * @return string
31
-	 */
32
-	public function getTitle() {
33
-		return /* I18N: Name of a module/chart */ I18N::translate('Timeline');
34
-	}
27
+    /**
28
+     * How should this module be labelled on tabs, menus, etc.?
29
+     *
30
+     * @return string
31
+     */
32
+    public function getTitle() {
33
+        return /* I18N: Name of a module/chart */ I18N::translate('Timeline');
34
+    }
35 35
 
36
-	/**
37
-	 * A sentence describing what this module does.
38
-	 *
39
-	 * @return string
40
-	 */
41
-	public function getDescription() {
42
-		return /* I18N: Description of the “TimelineChart” module */ I18N::translate('A timeline displaying individual events.');
43
-	}
36
+    /**
37
+     * A sentence describing what this module does.
38
+     *
39
+     * @return string
40
+     */
41
+    public function getDescription() {
42
+        return /* I18N: Description of the “TimelineChart” module */ I18N::translate('A timeline displaying individual events.');
43
+    }
44 44
 
45
-	/**
46
-	 * What is the default access level for this module?
47
-	 *
48
-	 * Some modules are aimed at admins or managers, and are not generally shown to users.
49
-	 *
50
-	 * @return int
51
-	 */
52
-	public function defaultAccessLevel() {
53
-		return Auth::PRIV_PRIVATE;
54
-	}
45
+    /**
46
+     * What is the default access level for this module?
47
+     *
48
+     * Some modules are aimed at admins or managers, and are not generally shown to users.
49
+     *
50
+     * @return int
51
+     */
52
+    public function defaultAccessLevel() {
53
+        return Auth::PRIV_PRIVATE;
54
+    }
55 55
 
56
-	/**
57
-	 * Return a menu item for this chart.
58
-	 *
59
-	 * @return Menu|null
60
-	 */
61
-	public function getChartMenu(Individual $individual) {
62
-		return new Menu(
63
-			$this->getTitle(),
64
-			'timeline.php?pids%5B%5D=' . $individual->getXref() . '&amp;ged=' . $individual->getTree()->getNameUrl(),
65
-			'menu-chart-timeline',
66
-			array('rel' => 'nofollow')
67
-		);
68
-	}
56
+    /**
57
+     * Return a menu item for this chart.
58
+     *
59
+     * @return Menu|null
60
+     */
61
+    public function getChartMenu(Individual $individual) {
62
+        return new Menu(
63
+            $this->getTitle(),
64
+            'timeline.php?pids%5B%5D=' . $individual->getXref() . '&amp;ged=' . $individual->getTree()->getNameUrl(),
65
+            'menu-chart-timeline',
66
+            array('rel' => 'nofollow')
67
+        );
68
+    }
69 69
 
70
-	/**
71
-	 * Return a menu item for this chart - for use in individual boxes.
72
-	 *
73
-	 * @return Menu|null
74
-	 */
75
-	public function getBoxChartMenu(Individual $individual) {
76
-		return null;
77
-	}
70
+    /**
71
+     * Return a menu item for this chart - for use in individual boxes.
72
+     *
73
+     * @return Menu|null
74
+     */
75
+    public function getBoxChartMenu(Individual $individual) {
76
+        return null;
77
+    }
78 78
 }
Please login to merge, or discard this patch.
app/Module/FamilyTreeFavoritesModule.php 1 patch
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -35,327 +35,327 @@
 block discarded – undo
35 35
  * logic works for both.
36 36
  */
37 37
 class FamilyTreeFavoritesModule extends AbstractModule implements ModuleBlockInterface {
38
-	// How to update the database schema for this module
39
-	const SCHEMA_TARGET_VERSION   = 4;
40
-	const SCHEMA_SETTING_NAME     = 'FV_SCHEMA_VERSION';
41
-	const SCHEMA_MIGRATION_PREFIX = '\Fisharebest\Webtrees\Module\FamilyTreeFavorites\Schema';
38
+    // How to update the database schema for this module
39
+    const SCHEMA_TARGET_VERSION   = 4;
40
+    const SCHEMA_SETTING_NAME     = 'FV_SCHEMA_VERSION';
41
+    const SCHEMA_MIGRATION_PREFIX = '\Fisharebest\Webtrees\Module\FamilyTreeFavorites\Schema';
42 42
 
43
-	/**
44
-	 * Create a new module.
45
-	 *
46
-	 * @param string $directory Where is this module installed
47
-	 */
48
-	public function __construct($directory) {
49
-		parent::__construct($directory);
43
+    /**
44
+     * Create a new module.
45
+     *
46
+     * @param string $directory Where is this module installed
47
+     */
48
+    public function __construct($directory) {
49
+        parent::__construct($directory);
50 50
 
51
-		// Create/update the database tables.
52
-		// NOTE: if we want to set any module-settings, we'll need to move this.
53
-		Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
54
-	}
51
+        // Create/update the database tables.
52
+        // NOTE: if we want to set any module-settings, we'll need to move this.
53
+        Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
54
+    }
55 55
 
56
-	/**
57
-	 * How should this module be labelled on tabs, menus, etc.?
58
-	 *
59
-	 * @return string
60
-	 */
61
-	public function getTitle() {
62
-		return /* I18N: Name of a module */ I18N::translate('Favorites');
63
-	}
56
+    /**
57
+     * How should this module be labelled on tabs, menus, etc.?
58
+     *
59
+     * @return string
60
+     */
61
+    public function getTitle() {
62
+        return /* I18N: Name of a module */ I18N::translate('Favorites');
63
+    }
64 64
 
65
-	/**
66
-	 * A sentence describing what this module does.
67
-	 *
68
-	 * @return string
69
-	 */
70
-	public function getDescription() {
71
-		return /* I18N: Description of the “Favorites” module */ I18N::translate('Display and manage a family tree’s favorite pages.');
72
-	}
65
+    /**
66
+     * A sentence describing what this module does.
67
+     *
68
+     * @return string
69
+     */
70
+    public function getDescription() {
71
+        return /* I18N: Description of the “Favorites” module */ I18N::translate('Display and manage a family tree’s favorite pages.');
72
+    }
73 73
 
74
-	/**
75
-	 * Generate the HTML content of this block.
76
-	 *
77
-	 * @param int      $block_id
78
-	 * @param bool     $template
79
-	 * @param string[] $cfg
80
-	 *
81
-	 * @return string
82
-	 */
83
-	public function getBlock($block_id, $template = true, $cfg = array()) {
84
-		global $ctype, $controller, $WT_TREE;
74
+    /**
75
+     * Generate the HTML content of this block.
76
+     *
77
+     * @param int      $block_id
78
+     * @param bool     $template
79
+     * @param string[] $cfg
80
+     *
81
+     * @return string
82
+     */
83
+    public function getBlock($block_id, $template = true, $cfg = array()) {
84
+        global $ctype, $controller, $WT_TREE;
85 85
 
86
-		$action = Filter::get('action');
87
-		switch ($action) {
88
-		case 'deletefav':
89
-			$favorite_id = Filter::getInteger('favorite_id');
90
-			if ($favorite_id) {
91
-				self::deleteFavorite($favorite_id);
92
-			}
93
-			break;
94
-		case 'addfav':
95
-			$gid      = Filter::get('gid', WT_REGEX_XREF);
96
-			$favnote  = Filter::get('favnote');
97
-			$url      = Filter::getUrl('url');
98
-			$favtitle = Filter::get('favtitle');
86
+        $action = Filter::get('action');
87
+        switch ($action) {
88
+        case 'deletefav':
89
+            $favorite_id = Filter::getInteger('favorite_id');
90
+            if ($favorite_id) {
91
+                self::deleteFavorite($favorite_id);
92
+            }
93
+            break;
94
+        case 'addfav':
95
+            $gid      = Filter::get('gid', WT_REGEX_XREF);
96
+            $favnote  = Filter::get('favnote');
97
+            $url      = Filter::getUrl('url');
98
+            $favtitle = Filter::get('favtitle');
99 99
 
100
-			if ($gid) {
101
-				$record = GedcomRecord::getInstance($gid, $WT_TREE);
102
-				if ($record && $record->canShow()) {
103
-					self::addFavorite(array(
104
-						'user_id'   => $ctype === 'user' ? Auth::id() : null,
105
-						'gedcom_id' => $WT_TREE->getTreeId(),
106
-						'gid'       => $record->getXref(),
107
-						'type'      => $record::RECORD_TYPE,
108
-						'url'       => null,
109
-						'note'      => $favnote,
110
-						'title'     => $favtitle,
111
-					));
112
-				}
113
-			} elseif ($url) {
114
-				self::addFavorite(array(
115
-					'user_id'   => $ctype === 'user' ? Auth::id() : null,
116
-					'gedcom_id' => $WT_TREE->getTreeId(),
117
-					'gid'       => null,
118
-					'type'      => 'URL',
119
-					'url'       => $url,
120
-					'note'      => $favnote,
121
-					'title'     => $favtitle ? $favtitle : $url,
122
-				));
123
-			}
124
-			break;
125
-		}
100
+            if ($gid) {
101
+                $record = GedcomRecord::getInstance($gid, $WT_TREE);
102
+                if ($record && $record->canShow()) {
103
+                    self::addFavorite(array(
104
+                        'user_id'   => $ctype === 'user' ? Auth::id() : null,
105
+                        'gedcom_id' => $WT_TREE->getTreeId(),
106
+                        'gid'       => $record->getXref(),
107
+                        'type'      => $record::RECORD_TYPE,
108
+                        'url'       => null,
109
+                        'note'      => $favnote,
110
+                        'title'     => $favtitle,
111
+                    ));
112
+                }
113
+            } elseif ($url) {
114
+                self::addFavorite(array(
115
+                    'user_id'   => $ctype === 'user' ? Auth::id() : null,
116
+                    'gedcom_id' => $WT_TREE->getTreeId(),
117
+                    'gid'       => null,
118
+                    'type'      => 'URL',
119
+                    'url'       => $url,
120
+                    'note'      => $favnote,
121
+                    'title'     => $favtitle ? $favtitle : $url,
122
+                ));
123
+            }
124
+            break;
125
+        }
126 126
 
127
-		$block = $this->getBlockSetting($block_id, 'block', '0');
127
+        $block = $this->getBlockSetting($block_id, 'block', '0');
128 128
 
129
-		foreach (array('block') as $name) {
130
-			if (array_key_exists($name, $cfg)) {
131
-				$$name = $cfg[$name];
132
-			}
133
-		}
129
+        foreach (array('block') as $name) {
130
+            if (array_key_exists($name, $cfg)) {
131
+                $$name = $cfg[$name];
132
+            }
133
+        }
134 134
 
135
-		$userfavs = $this->getFavorites($ctype === 'user' ? Auth::id() : $WT_TREE->getTreeId());
136
-		if (!is_array($userfavs)) {
137
-			$userfavs = array();
138
-		}
135
+        $userfavs = $this->getFavorites($ctype === 'user' ? Auth::id() : $WT_TREE->getTreeId());
136
+        if (!is_array($userfavs)) {
137
+            $userfavs = array();
138
+        }
139 139
 
140
-		$id    = $this->getName() . $block_id;
141
-		$class = $this->getName() . '_block';
142
-		$title = $this->getTitle();
140
+        $id    = $this->getName() . $block_id;
141
+        $class = $this->getName() . '_block';
142
+        $title = $this->getTitle();
143 143
 
144
-		if (Auth::check()) {
145
-			$controller
146
-				->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
147
-				->addInlineJavascript('autocomplete();');
148
-		}
144
+        if (Auth::check()) {
145
+            $controller
146
+                ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
147
+                ->addInlineJavascript('autocomplete();');
148
+        }
149 149
 
150
-		$content = '';
151
-		if ($userfavs) {
152
-			foreach ($userfavs as $key => $favorite) {
153
-				if (isset($favorite['id'])) {
154
-					$key = $favorite['id'];
155
-				}
156
-				$removeFavourite = '<a class="font9" href="index.php?ctype=' . $ctype . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;action=deletefav&amp;favorite_id=' . $key . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to remove this item from your list of favorites?') . '\');">' . I18N::translate('Remove') . '</a> ';
157
-				if ($favorite['type'] == 'URL') {
158
-					$content .= '<div id="boxurl' . $key . '.0" class="person_box">';
159
-					if ($ctype == 'user' || Auth::isManager($WT_TREE)) {
160
-						$content .= $removeFavourite;
161
-					}
162
-					$content .= '<a href="' . $favorite['url'] . '"><b>' . $favorite['title'] . '</b></a>';
163
-					$content .= '<br>' . $favorite['note'];
164
-					$content .= '</div>';
165
-				} else {
166
-					$record = GedcomRecord::getInstance($favorite['gid'], $WT_TREE);
167
-					if ($record && $record->canShow()) {
168
-						if ($record instanceof Individual) {
169
-							$content .= '<div id="box' . $favorite["gid"] . '.0" class="person_box action_header';
170
-							switch ($record->getSex()) {
171
-							case 'M':
172
-								break;
173
-							case 'F':
174
-								$content .= 'F';
175
-								break;
176
-							default:
177
-								$content .= 'NN';
178
-								break;
179
-							}
180
-							$content .= '">';
181
-							if ($ctype == "user" || Auth::isManager($WT_TREE)) {
182
-								$content .= $removeFavourite;
183
-							}
184
-							$content .= Theme::theme()->individualBoxLarge($record);
185
-							$content .= $favorite['note'];
186
-							$content .= '</div>';
187
-						} else {
188
-							$content .= '<div id="box' . $favorite['gid'] . '.0" class="person_box">';
189
-							if ($ctype == 'user' || Auth::isManager($WT_TREE)) {
190
-								$content .= $removeFavourite;
191
-							}
192
-							$content .= $record->formatList('span');
193
-							$content .= '<br>' . $favorite['note'];
194
-							$content .= '</div>';
195
-						}
196
-					}
197
-				}
198
-			}
199
-		}
200
-		if ($ctype == 'user' || Auth::isManager($WT_TREE)) {
201
-			$uniqueID = Uuid::uuid4(); // This block can theoretically appear multiple times, so use a unique ID.
202
-			$content .= '<div class="add_fav_head">';
203
-			$content .= '<a href="#" onclick="return expand_layer(\'add_fav' . $uniqueID . '\');">' . I18N::translate('Add a favorite') . '<i id="add_fav' . $uniqueID . '_img" class="icon-plus"></i></a>';
204
-			$content .= '</div>';
205
-			$content .= '<div id="add_fav' . $uniqueID . '" style="display: none;">';
206
-			$content .= '<form name="addfavform" method="get" action="index.php">';
207
-			$content .= '<input type="hidden" name="action" value="addfav">';
208
-			$content .= '<input type="hidden" name="ctype" value="' . $ctype . '">';
209
-			$content .= '<input type="hidden" name="ged" value="' . $WT_TREE->getNameHtml() . '">';
210
-			$content .= '<div class="add_fav_ref">';
211
-			$content .= '<input type="radio" name="fav_category" value="record" checked onclick="jQuery(\'#gid' . $uniqueID . '\').removeAttr(\'disabled\'); jQuery(\'#url, #favtitle\').attr(\'disabled\',\'disabled\').val(\'\');">';
212
-			$content .= '<label for="gid' . $uniqueID . '">' . I18N::translate('Enter an individual, family, or source ID') . '</label>';
213
-			$content .= '<input class="pedigree_form" data-autocomplete-type="IFSRO" type="text" name="gid" id="gid' . $uniqueID . '" size="5" value="">';
214
-			$content .= ' ' . FunctionsPrint::printFindIndividualLink('gid' . $uniqueID);
215
-			$content .= ' ' . FunctionsPrint::printFindFamilyLink('gid' . $uniqueID);
216
-			$content .= ' ' . FunctionsPrint::printFindSourceLink('gid' . $uniqueID);
217
-			$content .= ' ' . FunctionsPrint::printFindRepositoryLink('gid' . $uniqueID);
218
-			$content .= ' ' . FunctionsPrint::printFindNoteLink('gid' . $uniqueID);
219
-			$content .= ' ' . FunctionsPrint::printFindMediaLink('gid' . $uniqueID);
220
-			$content .= '</div>';
221
-			$content .= '<div class="add_fav_url">';
222
-			$content .= '<input type="radio" name="fav_category" value="url" onclick="jQuery(\'#url, #favtitle\').removeAttr(\'disabled\'); jQuery(\'#gid' . $uniqueID . '\').attr(\'disabled\',\'disabled\').val(\'\');">';
223
-			$content .= '<input type="text" name="url" id="url" size="20" value="" placeholder="' . GedcomTag::getLabel('URL') . '" disabled> ';
224
-			$content .= '<input type="text" name="favtitle" id="favtitle" size="20" value="" placeholder="' . I18N::translate('Title') . '" disabled>';
225
-			$content .= '<p>' . I18N::translate('Enter an optional note about this favorite') . '</p>';
226
-			$content .= '<textarea name="favnote" rows="6" cols="50"></textarea>';
227
-			$content .= '</div>';
228
-			$content .= '<input type="submit" value="' . /* I18N: A button label. */ I18N::translate('add') . '">';
229
-			$content .= '</form></div>';
230
-		}
150
+        $content = '';
151
+        if ($userfavs) {
152
+            foreach ($userfavs as $key => $favorite) {
153
+                if (isset($favorite['id'])) {
154
+                    $key = $favorite['id'];
155
+                }
156
+                $removeFavourite = '<a class="font9" href="index.php?ctype=' . $ctype . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;action=deletefav&amp;favorite_id=' . $key . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to remove this item from your list of favorites?') . '\');">' . I18N::translate('Remove') . '</a> ';
157
+                if ($favorite['type'] == 'URL') {
158
+                    $content .= '<div id="boxurl' . $key . '.0" class="person_box">';
159
+                    if ($ctype == 'user' || Auth::isManager($WT_TREE)) {
160
+                        $content .= $removeFavourite;
161
+                    }
162
+                    $content .= '<a href="' . $favorite['url'] . '"><b>' . $favorite['title'] . '</b></a>';
163
+                    $content .= '<br>' . $favorite['note'];
164
+                    $content .= '</div>';
165
+                } else {
166
+                    $record = GedcomRecord::getInstance($favorite['gid'], $WT_TREE);
167
+                    if ($record && $record->canShow()) {
168
+                        if ($record instanceof Individual) {
169
+                            $content .= '<div id="box' . $favorite["gid"] . '.0" class="person_box action_header';
170
+                            switch ($record->getSex()) {
171
+                            case 'M':
172
+                                break;
173
+                            case 'F':
174
+                                $content .= 'F';
175
+                                break;
176
+                            default:
177
+                                $content .= 'NN';
178
+                                break;
179
+                            }
180
+                            $content .= '">';
181
+                            if ($ctype == "user" || Auth::isManager($WT_TREE)) {
182
+                                $content .= $removeFavourite;
183
+                            }
184
+                            $content .= Theme::theme()->individualBoxLarge($record);
185
+                            $content .= $favorite['note'];
186
+                            $content .= '</div>';
187
+                        } else {
188
+                            $content .= '<div id="box' . $favorite['gid'] . '.0" class="person_box">';
189
+                            if ($ctype == 'user' || Auth::isManager($WT_TREE)) {
190
+                                $content .= $removeFavourite;
191
+                            }
192
+                            $content .= $record->formatList('span');
193
+                            $content .= '<br>' . $favorite['note'];
194
+                            $content .= '</div>';
195
+                        }
196
+                    }
197
+                }
198
+            }
199
+        }
200
+        if ($ctype == 'user' || Auth::isManager($WT_TREE)) {
201
+            $uniqueID = Uuid::uuid4(); // This block can theoretically appear multiple times, so use a unique ID.
202
+            $content .= '<div class="add_fav_head">';
203
+            $content .= '<a href="#" onclick="return expand_layer(\'add_fav' . $uniqueID . '\');">' . I18N::translate('Add a favorite') . '<i id="add_fav' . $uniqueID . '_img" class="icon-plus"></i></a>';
204
+            $content .= '</div>';
205
+            $content .= '<div id="add_fav' . $uniqueID . '" style="display: none;">';
206
+            $content .= '<form name="addfavform" method="get" action="index.php">';
207
+            $content .= '<input type="hidden" name="action" value="addfav">';
208
+            $content .= '<input type="hidden" name="ctype" value="' . $ctype . '">';
209
+            $content .= '<input type="hidden" name="ged" value="' . $WT_TREE->getNameHtml() . '">';
210
+            $content .= '<div class="add_fav_ref">';
211
+            $content .= '<input type="radio" name="fav_category" value="record" checked onclick="jQuery(\'#gid' . $uniqueID . '\').removeAttr(\'disabled\'); jQuery(\'#url, #favtitle\').attr(\'disabled\',\'disabled\').val(\'\');">';
212
+            $content .= '<label for="gid' . $uniqueID . '">' . I18N::translate('Enter an individual, family, or source ID') . '</label>';
213
+            $content .= '<input class="pedigree_form" data-autocomplete-type="IFSRO" type="text" name="gid" id="gid' . $uniqueID . '" size="5" value="">';
214
+            $content .= ' ' . FunctionsPrint::printFindIndividualLink('gid' . $uniqueID);
215
+            $content .= ' ' . FunctionsPrint::printFindFamilyLink('gid' . $uniqueID);
216
+            $content .= ' ' . FunctionsPrint::printFindSourceLink('gid' . $uniqueID);
217
+            $content .= ' ' . FunctionsPrint::printFindRepositoryLink('gid' . $uniqueID);
218
+            $content .= ' ' . FunctionsPrint::printFindNoteLink('gid' . $uniqueID);
219
+            $content .= ' ' . FunctionsPrint::printFindMediaLink('gid' . $uniqueID);
220
+            $content .= '</div>';
221
+            $content .= '<div class="add_fav_url">';
222
+            $content .= '<input type="radio" name="fav_category" value="url" onclick="jQuery(\'#url, #favtitle\').removeAttr(\'disabled\'); jQuery(\'#gid' . $uniqueID . '\').attr(\'disabled\',\'disabled\').val(\'\');">';
223
+            $content .= '<input type="text" name="url" id="url" size="20" value="" placeholder="' . GedcomTag::getLabel('URL') . '" disabled> ';
224
+            $content .= '<input type="text" name="favtitle" id="favtitle" size="20" value="" placeholder="' . I18N::translate('Title') . '" disabled>';
225
+            $content .= '<p>' . I18N::translate('Enter an optional note about this favorite') . '</p>';
226
+            $content .= '<textarea name="favnote" rows="6" cols="50"></textarea>';
227
+            $content .= '</div>';
228
+            $content .= '<input type="submit" value="' . /* I18N: A button label. */ I18N::translate('add') . '">';
229
+            $content .= '</form></div>';
230
+        }
231 231
 
232
-		if ($template) {
233
-			if ($block) {
234
-				$class .= ' small_inner_block';
235
-			}
232
+        if ($template) {
233
+            if ($block) {
234
+                $class .= ' small_inner_block';
235
+            }
236 236
 
237
-			return Theme::theme()->formatBlock($id, $title, $class, $content);
238
-		} else {
239
-			return $content;
240
-		}
241
-	}
237
+            return Theme::theme()->formatBlock($id, $title, $class, $content);
238
+        } else {
239
+            return $content;
240
+        }
241
+    }
242 242
 
243
-	/**
244
-	 * Should this block load asynchronously using AJAX?
245
-	 *
246
-	 * Simple blocks are faster in-line, more comples ones
247
-	 * can be loaded later.
248
-	 *
249
-	 * @return bool
250
-	 */
251
-	public function loadAjax() {
252
-		return false;
253
-	}
243
+    /**
244
+     * Should this block load asynchronously using AJAX?
245
+     *
246
+     * Simple blocks are faster in-line, more comples ones
247
+     * can be loaded later.
248
+     *
249
+     * @return bool
250
+     */
251
+    public function loadAjax() {
252
+        return false;
253
+    }
254 254
 
255
-	/**
256
-	 * Can this block be shown on the user’s home page?
257
-	 *
258
-	 * @return bool
259
-	 */
260
-	public function isUserBlock() {
261
-		return false;
262
-	}
255
+    /**
256
+     * Can this block be shown on the user’s home page?
257
+     *
258
+     * @return bool
259
+     */
260
+    public function isUserBlock() {
261
+        return false;
262
+    }
263 263
 
264
-	/**
265
-	 * Can this block be shown on the tree’s home page?
266
-	 *
267
-	 * @return bool
268
-	 */
269
-	public function isGedcomBlock() {
270
-		return true;
271
-	}
264
+    /**
265
+     * Can this block be shown on the tree’s home page?
266
+     *
267
+     * @return bool
268
+     */
269
+    public function isGedcomBlock() {
270
+        return true;
271
+    }
272 272
 
273
-	/**
274
-	 * An HTML form to edit block settings
275
-	 *
276
-	 * @param int $block_id
277
-	 */
278
-	public function configureBlock($block_id) {
279
-		if (Filter::postBool('save') && Filter::checkCsrf()) {
280
-			$this->setBlockSetting($block_id, 'block', Filter::postBool('block'));
281
-		}
273
+    /**
274
+     * An HTML form to edit block settings
275
+     *
276
+     * @param int $block_id
277
+     */
278
+    public function configureBlock($block_id) {
279
+        if (Filter::postBool('save') && Filter::checkCsrf()) {
280
+            $this->setBlockSetting($block_id, 'block', Filter::postBool('block'));
281
+        }
282 282
 
283
-		$block = $this->getBlockSetting($block_id, 'block', '0');
283
+        $block = $this->getBlockSetting($block_id, 'block', '0');
284 284
 
285
-		echo '<tr><td class="descriptionbox wrap width33">';
286
-		echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow');
287
-		echo '</td><td class="optionbox">';
288
-		echo FunctionsEdit::editFieldYesNo('block', $block);
289
-		echo '</td></tr>';
290
-	}
285
+        echo '<tr><td class="descriptionbox wrap width33">';
286
+        echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow');
287
+        echo '</td><td class="optionbox">';
288
+        echo FunctionsEdit::editFieldYesNo('block', $block);
289
+        echo '</td></tr>';
290
+    }
291 291
 
292
-	/**
293
-	 * Delete a favorite from the database
294
-	 *
295
-	 * @param int $favorite_id
296
-	 *
297
-	 * @return bool
298
-	 */
299
-	public static function deleteFavorite($favorite_id) {
300
-		return (bool)
301
-			Database::prepare("DELETE FROM `##favorite` WHERE favorite_id=?")
302
-			->execute(array($favorite_id));
303
-	}
292
+    /**
293
+     * Delete a favorite from the database
294
+     *
295
+     * @param int $favorite_id
296
+     *
297
+     * @return bool
298
+     */
299
+    public static function deleteFavorite($favorite_id) {
300
+        return (bool)
301
+            Database::prepare("DELETE FROM `##favorite` WHERE favorite_id=?")
302
+            ->execute(array($favorite_id));
303
+    }
304 304
 
305
-	/**
306
-	 * Store a new favorite in the database
307
-	 *
308
-	 * @param $favorite
309
-	 *
310
-	 * @return bool
311
-	 */
312
-	public static function addFavorite($favorite) {
313
-		// -- make sure a favorite is added
314
-		if (empty($favorite['gid']) && empty($favorite['url'])) {
315
-			return false;
316
-		}
305
+    /**
306
+     * Store a new favorite in the database
307
+     *
308
+     * @param $favorite
309
+     *
310
+     * @return bool
311
+     */
312
+    public static function addFavorite($favorite) {
313
+        // -- make sure a favorite is added
314
+        if (empty($favorite['gid']) && empty($favorite['url'])) {
315
+            return false;
316
+        }
317 317
 
318
-		//-- make sure this is not a duplicate entry
319
-		$sql = "SELECT 1 FROM `##favorite` WHERE";
320
-		if (!empty($favorite['gid'])) {
321
-			$sql .= " xref=?";
322
-			$vars = array($favorite['gid']);
323
-		} else {
324
-			$sql .= " url=?";
325
-			$vars = array($favorite['url']);
326
-		}
327
-		$sql .= " AND gedcom_id=?";
328
-		$vars[] = $favorite['gedcom_id'];
329
-		if ($favorite['user_id']) {
330
-			$sql .= " AND user_id=?";
331
-			$vars[] = $favorite['user_id'];
332
-		} else {
333
-			$sql .= " AND user_id IS NULL";
334
-		}
318
+        //-- make sure this is not a duplicate entry
319
+        $sql = "SELECT 1 FROM `##favorite` WHERE";
320
+        if (!empty($favorite['gid'])) {
321
+            $sql .= " xref=?";
322
+            $vars = array($favorite['gid']);
323
+        } else {
324
+            $sql .= " url=?";
325
+            $vars = array($favorite['url']);
326
+        }
327
+        $sql .= " AND gedcom_id=?";
328
+        $vars[] = $favorite['gedcom_id'];
329
+        if ($favorite['user_id']) {
330
+            $sql .= " AND user_id=?";
331
+            $vars[] = $favorite['user_id'];
332
+        } else {
333
+            $sql .= " AND user_id IS NULL";
334
+        }
335 335
 
336
-		if (Database::prepare($sql)->execute($vars)->fetchOne()) {
337
-			return false;
338
-		}
336
+        if (Database::prepare($sql)->execute($vars)->fetchOne()) {
337
+            return false;
338
+        }
339 339
 
340
-		//-- add the favorite to the database
341
-		return (bool)
342
-			Database::prepare("INSERT INTO `##favorite` (user_id, gedcom_id, xref, favorite_type, url, title, note) VALUES (? ,? ,? ,? ,? ,? ,?)")
343
-				->execute(array($favorite['user_id'], $favorite['gedcom_id'], $favorite['gid'], $favorite['type'], $favorite['url'], $favorite['title'], $favorite['note']));
344
-	}
340
+        //-- add the favorite to the database
341
+        return (bool)
342
+            Database::prepare("INSERT INTO `##favorite` (user_id, gedcom_id, xref, favorite_type, url, title, note) VALUES (? ,? ,? ,? ,? ,? ,?)")
343
+                ->execute(array($favorite['user_id'], $favorite['gedcom_id'], $favorite['gid'], $favorite['type'], $favorite['url'], $favorite['title'], $favorite['note']));
344
+    }
345 345
 
346
-	/**
347
-	 * Get favorites for a user or family tree
348
-	 *
349
-	 * @param int $gedcom_id
350
-	 *
351
-	 * @return string[][]
352
-	 */
353
-	public static function getFavorites($gedcom_id) {
354
-		return
355
-			Database::prepare(
356
-				"SELECT favorite_id AS id, user_id, gedcom_id, xref AS gid, favorite_type AS type, title, note, url" .
357
-				" FROM `##favorite` WHERE gedcom_id=? AND user_id IS NULL")
358
-			->execute(array($gedcom_id))
359
-			->fetchAll(PDO::FETCH_ASSOC);
360
-	}
346
+    /**
347
+     * Get favorites for a user or family tree
348
+     *
349
+     * @param int $gedcom_id
350
+     *
351
+     * @return string[][]
352
+     */
353
+    public static function getFavorites($gedcom_id) {
354
+        return
355
+            Database::prepare(
356
+                "SELECT favorite_id AS id, user_id, gedcom_id, xref AS gid, favorite_type AS type, title, note, url" .
357
+                " FROM `##favorite` WHERE gedcom_id=? AND user_id IS NULL")
358
+            ->execute(array($gedcom_id))
359
+            ->fetchAll(PDO::FETCH_ASSOC);
360
+    }
361 361
 }
Please login to merge, or discard this patch.
app/Module/ClippingsCartModule.php 1 patch
Indentation   +391 added lines, -391 removed lines patch added patch discarded remove patch
@@ -32,80 +32,80 @@  discard block
 block discarded – undo
32 32
  * Class ClippingsCartModule
33 33
  */
34 34
 class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface, ModuleSidebarInterface {
35
-	/** {@inheritdoc} */
36
-	public function getTitle() {
37
-		return /* I18N: Name of a module */
38
-			I18N::translate('Clippings cart');
39
-	}
40
-
41
-	/** {@inheritdoc} */
42
-	public function getDescription() {
43
-		return /* I18N: Description of the “Clippings cart” module */
44
-			I18N::translate('Select records from your family tree and save them as a GEDCOM file.');
45
-	}
46
-
47
-	/**
48
-	 * What is the default access level for this module?
49
-	 *
50
-	 * Some modules are aimed at admins or managers, and are not generally shown to users.
51
-	 *
52
-	 * @return int
53
-	 */
54
-	public function defaultAccessLevel() {
55
-		return Auth::PRIV_USER;
56
-	}
57
-
58
-	/**
59
-	 * This is a general purpose hook, allowing modules to respond to routes
60
-	 * of the form module.php?mod=FOO&mod_action=BAR
61
-	 *
62
-	 * @param string $mod_action
63
-	 */
64
-	public function modAction($mod_action) {
65
-		global $WT_TREE;
66
-
67
-		// Only allow access if either the menu or sidebar is enabled.
68
-		if (
69
-			!array_key_exists($this->getName(), Module::getActiveSidebars($WT_TREE)) &&
70
-			!array_key_exists($this->getName(), Module::getActiveMenus($WT_TREE))
71
-		) {
72
-			http_response_code(404);
73
-
74
-			return;
75
-		}
76
-
77
-		switch ($mod_action) {
78
-		case 'ajax':
79
-			$html = $this->getSidebarAjaxContent();
80
-			header('Content-Type: text/html; charset=UTF-8');
81
-			echo $html;
82
-			break;
83
-		case 'index':
84
-			global $controller, $WT_TREE;
85
-
86
-			$MAX_PEDIGREE_GENERATIONS = $WT_TREE->getPreference('MAX_PEDIGREE_GENERATIONS');
87
-
88
-			$clip_ctrl = new ClippingsCartController;
89
-			$cart      = Session::get('cart');
90
-
91
-			$controller = new PageController;
92
-			$controller
93
-				->setPageTitle($this->getTitle())
94
-				->pageHeader()
95
-				->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
96
-				->addInlineJavascript('autocomplete();');
97
-
98
-			echo '<script>';
99
-			echo 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;}';
100
-			echo '</script>';
101
-
102
-			if (!$cart[$WT_TREE->getTreeId()]) {
103
-				echo '<h2>', I18N::translate('Family tree clippings cart'), '</h2>';
104
-			}
105
-
106
-			if ($clip_ctrl->action == 'add') {
107
-				$record = GedcomRecord::getInstance($clip_ctrl->id, $WT_TREE);
108
-				if ($clip_ctrl->type === 'FAM') { ?>
35
+    /** {@inheritdoc} */
36
+    public function getTitle() {
37
+        return /* I18N: Name of a module */
38
+            I18N::translate('Clippings cart');
39
+    }
40
+
41
+    /** {@inheritdoc} */
42
+    public function getDescription() {
43
+        return /* I18N: Description of the “Clippings cart” module */
44
+            I18N::translate('Select records from your family tree and save them as a GEDCOM file.');
45
+    }
46
+
47
+    /**
48
+     * What is the default access level for this module?
49
+     *
50
+     * Some modules are aimed at admins or managers, and are not generally shown to users.
51
+     *
52
+     * @return int
53
+     */
54
+    public function defaultAccessLevel() {
55
+        return Auth::PRIV_USER;
56
+    }
57
+
58
+    /**
59
+     * This is a general purpose hook, allowing modules to respond to routes
60
+     * of the form module.php?mod=FOO&mod_action=BAR
61
+     *
62
+     * @param string $mod_action
63
+     */
64
+    public function modAction($mod_action) {
65
+        global $WT_TREE;
66
+
67
+        // Only allow access if either the menu or sidebar is enabled.
68
+        if (
69
+            !array_key_exists($this->getName(), Module::getActiveSidebars($WT_TREE)) &&
70
+            !array_key_exists($this->getName(), Module::getActiveMenus($WT_TREE))
71
+        ) {
72
+            http_response_code(404);
73
+
74
+            return;
75
+        }
76
+
77
+        switch ($mod_action) {
78
+        case 'ajax':
79
+            $html = $this->getSidebarAjaxContent();
80
+            header('Content-Type: text/html; charset=UTF-8');
81
+            echo $html;
82
+            break;
83
+        case 'index':
84
+            global $controller, $WT_TREE;
85
+
86
+            $MAX_PEDIGREE_GENERATIONS = $WT_TREE->getPreference('MAX_PEDIGREE_GENERATIONS');
87
+
88
+            $clip_ctrl = new ClippingsCartController;
89
+            $cart      = Session::get('cart');
90
+
91
+            $controller = new PageController;
92
+            $controller
93
+                ->setPageTitle($this->getTitle())
94
+                ->pageHeader()
95
+                ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
96
+                ->addInlineJavascript('autocomplete();');
97
+
98
+            echo '<script>';
99
+            echo 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;}';
100
+            echo '</script>';
101
+
102
+            if (!$cart[$WT_TREE->getTreeId()]) {
103
+                echo '<h2>', I18N::translate('Family tree clippings cart'), '</h2>';
104
+            }
105
+
106
+            if ($clip_ctrl->action == 'add') {
107
+                $record = GedcomRecord::getInstance($clip_ctrl->id, $WT_TREE);
108
+                if ($clip_ctrl->type === 'FAM') { ?>
109 109
 					<form action="module.php" method="get">
110 110
 						<input type="hidden" name="mod" value="clippings">
111 111
 						<input type="hidden" name="mod_action" value="index">
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 									<td class="optionbox">
132 132
 										<input type="radio" name="others" value="members" checked>
133 133
 										<?php echo /* I18N: %s is a family (husband + wife) */
134
-										I18N::translate('%s and their children', $record->getFullName()); ?>
134
+                                        I18N::translate('%s and their children', $record->getFullName()); ?>
135 135
 									</td>
136 136
 								</tr>
137 137
 								<tr>
138 138
 									<td class="optionbox">
139 139
 										<input type="radio" name="others" value="descendants">
140 140
 										<?php echo /* I18N: %s is a family (husband + wife) */
141
-										I18N::translate('%s and their descendants', $record->getFullName()); ?>
141
+                                        I18N::translate('%s and their descendants', $record->getFullName()); ?>
142 142
 									</td>
143 143
 								</tr>
144 144
 							</tbody>
@@ -179,14 +179,14 @@  discard block
 block discarded – undo
179 179
 										<label>
180 180
 											<input type="radio" name="others" value="parents">
181 181
 											<?php
182
-											if ($record->getSex() === 'F') {
183
-												echo /* I18N: %s is a woman's name */
184
-												I18N::translate('%s, her parents and siblings', $record->getFullName());
185
-											} else {
186
-												echo /* I18N: %s is a man's name */
187
-												I18N::translate('%s, his parents and siblings', $record->getFullName());
188
-											}
189
-											?>
182
+                                            if ($record->getSex() === 'F') {
183
+                                                echo /* I18N: %s is a woman's name */
184
+                                                I18N::translate('%s, her parents and siblings', $record->getFullName());
185
+                                            } else {
186
+                                                echo /* I18N: %s is a man's name */
187
+                                                I18N::translate('%s, his parents and siblings', $record->getFullName());
188
+                                            }
189
+                                            ?>
190 190
 										</label>
191 191
 									</td>
192 192
 								</tr>
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
 										<label>
196 196
 											<input type="radio" name="others" value="members">
197 197
 											<?php
198
-											if ($record->getSex() === 'F') {
199
-												echo /* I18N: %s is a woman's name */
200
-												I18N::translate('%s, her spouses and children', $record->getFullName());
201
-											} else {
202
-												echo /* I18N: %s is a man's name */
203
-												I18N::translate('%s, his spouses and children', $record->getFullName());
204
-											}
205
-											?>
198
+                                            if ($record->getSex() === 'F') {
199
+                                                echo /* I18N: %s is a woman's name */
200
+                                                I18N::translate('%s, her spouses and children', $record->getFullName());
201
+                                            } else {
202
+                                                echo /* I18N: %s is a man's name */
203
+                                                I18N::translate('%s, his spouses and children', $record->getFullName());
204
+                                            }
205
+                                            ?>
206 206
 										</label>
207 207
 									</td>
208 208
 								</tr>
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
 										<label>
212 212
 											<input type="radio" name="others" value="ancestors" id="ancestors">
213 213
 											<?php
214
-											if ($record->getSex() === 'F') {
215
-												echo /* I18N: %s is a woman's name */
216
-												I18N::translate('%s and her ancestors', $record->getFullName());
217
-											} else {
218
-												echo /* I18N: %s is a man's name */
219
-												I18N::translate('%s and his ancestors', $record->getFullName());
220
-											}
221
-											?>
214
+                                            if ($record->getSex() === 'F') {
215
+                                                echo /* I18N: %s is a woman's name */
216
+                                                I18N::translate('%s and her ancestors', $record->getFullName());
217
+                                            } else {
218
+                                                echo /* I18N: %s is a man's name */
219
+                                                I18N::translate('%s and his ancestors', $record->getFullName());
220
+                                            }
221
+                                            ?>
222 222
 										</label>
223 223
 										<br>
224 224
 										<?php echo I18N::translate('Number of generations'); ?>
@@ -230,14 +230,14 @@  discard block
 block discarded – undo
230 230
 										<label>
231 231
 											<input type="radio" name="others" value="ancestorsfamilies" id="ancestorsfamilies">
232 232
 											<?php
233
-											if ($record->getSex() === 'F') {
234
-												echo /* I18N: %s is a woman's name */
235
-												I18N::translate('%s, her ancestors and their families', $record->getFullName());
236
-											} else {
237
-												echo /* I18N: %s is a man's name */
238
-												I18N::translate('%s, his ancestors and their families', $record->getFullName());
239
-											}
240
-											?>
233
+                                            if ($record->getSex() === 'F') {
234
+                                                echo /* I18N: %s is a woman's name */
235
+                                                I18N::translate('%s, her ancestors and their families', $record->getFullName());
236
+                                            } else {
237
+                                                echo /* I18N: %s is a man's name */
238
+                                                I18N::translate('%s, his ancestors and their families', $record->getFullName());
239
+                                            }
240
+                                            ?>
241 241
 										</label>
242 242
 										<br>
243 243
 										<?php echo I18N::translate('Number of generations'); ?>
@@ -249,14 +249,14 @@  discard block
 block discarded – undo
249 249
 										<label>
250 250
 											<input type="radio" name="others" value="descendants" id="descendants">
251 251
 											<?php
252
-											if ($record->getSex() === 'F') {
253
-												echo /* I18N: %s is a woman's name */
254
-												I18N::translate('%s, her spouses and descendants', $record->getFullName());
255
-											} else {
256
-												echo /* I18N: %s is a man's name */
257
-												I18N::translate('%s, his spouses and descendants', $record->getFullName());
258
-											}
259
-											?>
252
+                                            if ($record->getSex() === 'F') {
253
+                                                echo /* I18N: %s is a woman's name */
254
+                                                I18N::translate('%s, her spouses and descendants', $record->getFullName());
255
+                                            } else {
256
+                                                echo /* I18N: %s is a man's name */
257
+                                                I18N::translate('%s, his spouses and descendants', $record->getFullName());
258
+                                            }
259
+                                            ?>
260 260
 										</label>
261 261
 										<br>
262 262
 										<?php echo I18N::translate('Number of generations'); ?>
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 										<label>
303 303
 											<input type="radio" name="others" value="linked">
304 304
 											<?php echo /* I18N: %s is the name of a source */
305
-											I18N::translate('%s and the individuals that reference it.', $record->getFullName()); ?>
305
+                                            I18N::translate('%s and the individuals that reference it.', $record->getFullName()); ?>
306 306
 										</label>
307 307
 									</td>
308 308
 								</tr>
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
 						</table>
318 318
 					</form>
319 319
 				<?php }
320
-			}
320
+            }
321 321
 
322
-			if (!$cart[$WT_TREE->getTreeId()]) {
323
-				if ($clip_ctrl->action != 'add') {
324
-					echo I18N::translate('The clippings cart allows you to take extracts from this family tree and download them as a GEDCOM file.');
325
-					?>
322
+            if (!$cart[$WT_TREE->getTreeId()]) {
323
+                if ($clip_ctrl->action != 'add') {
324
+                    echo I18N::translate('The clippings cart allows you to take extracts from this family tree and download them as a GEDCOM file.');
325
+                    ?>
326 326
 					<form method="get" name="addin" action="module.php">
327 327
 						<input type="hidden" name="mod" value="clippings">
328 328
 						<input type="hidden" name="mod_action" value="index">
@@ -351,16 +351,16 @@  discard block
 block discarded – undo
351 351
 						</table>
352 352
 					</form>
353 353
 					<?php
354
-				}
354
+                }
355 355
 
356
-				// -- end new lines
357
-				echo I18N::translate('Your clippings cart is empty.');
358
-			} else {
359
-				// Keep track of the INDI from the parent page, otherwise it will
360
-				// get lost after ajax updates
361
-				$pid = Filter::get('pid', WT_REGEX_XREF);
356
+                // -- end new lines
357
+                echo I18N::translate('Your clippings cart is empty.');
358
+            } else {
359
+                // Keep track of the INDI from the parent page, otherwise it will
360
+                // get lost after ajax updates
361
+                $pid = Filter::get('pid', WT_REGEX_XREF);
362 362
 
363
-				if ($clip_ctrl->action !== 'download' && $clip_ctrl->action !== 'add') { ?>
363
+                if ($clip_ctrl->action !== 'download' && $clip_ctrl->action !== 'add') { ?>
364 364
 					<form method="get" action="module.php">
365 365
 						<input type="hidden" name="mod" value="clippings">
366 366
 						<input type="hidden" name="mod_action" value="index">
@@ -500,265 +500,265 @@  discard block
 block discarded – undo
500 500
 					</thead>
501 501
 					<tbody>
502 502
 						<?php
503
-						foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) {
504
-							$record = GedcomRecord::getInstance($xref, $WT_TREE);
505
-							if ($record) {
506
-								switch ($record::RECORD_TYPE) {
507
-								case 'INDI':
508
-									$icon = 'icon-indis';
509
-									break;
510
-								case 'FAM':
511
-									$icon = 'icon-sfamily';
512
-									break;
513
-								case 'SOUR':
514
-									$icon = 'icon-source';
515
-									break;
516
-								case 'REPO':
517
-									$icon = 'icon-repository';
518
-									break;
519
-								case 'NOTE':
520
-									$icon = 'icon-note';
521
-									break;
522
-								case 'OBJE':
523
-									$icon = 'icon-media';
524
-									break;
525
-								default:
526
-									$icon = 'icon-clippings';
527
-									break;
528
-								}
529
-								?>
503
+                        foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) {
504
+                            $record = GedcomRecord::getInstance($xref, $WT_TREE);
505
+                            if ($record) {
506
+                                switch ($record::RECORD_TYPE) {
507
+                                case 'INDI':
508
+                                    $icon = 'icon-indis';
509
+                                    break;
510
+                                case 'FAM':
511
+                                    $icon = 'icon-sfamily';
512
+                                    break;
513
+                                case 'SOUR':
514
+                                    $icon = 'icon-source';
515
+                                    break;
516
+                                case 'REPO':
517
+                                    $icon = 'icon-repository';
518
+                                    break;
519
+                                case 'NOTE':
520
+                                    $icon = 'icon-note';
521
+                                    break;
522
+                                case 'OBJE':
523
+                                    $icon = 'icon-media';
524
+                                    break;
525
+                                default:
526
+                                    $icon = 'icon-clippings';
527
+                                    break;
528
+                                }
529
+                                ?>
530 530
 								<tr>
531 531
 									<td class="list_value">
532 532
 										<i class="<?php echo $icon; ?>"></i>
533 533
 										<?php
534
-										echo '<a href="', $record->getHtmlUrl(), '">', $record->getFullName(), '</a>';
535
-										?>
534
+                                        echo '<a href="', $record->getHtmlUrl(), '">', $record->getFullName(), '</a>';
535
+                                        ?>
536 536
 									</td>
537 537
 									<td class="list_value center vmiddle"><a href="module.php?mod=clippings&amp;mod_action=index&amp;action=remove&amp;id=<?php echo $xref; ?>" class="icon-remove" title="<?php echo I18N::translate('Remove'); ?>"></a></td>
538 538
 								</tr>
539 539
 								<?php
540
-							}
541
-						}
542
-						?>
540
+                            }
541
+                        }
542
+                        ?>
543 543
 				</table>
544 544
 				<?php
545
-			}
546
-			break;
547
-		default:
548
-			http_response_code(404);
549
-			break;
550
-		}
551
-	}
552
-
553
-	/**
554
-	 * The user can re-order menus. Until they do, they are shown in this order.
555
-	 *
556
-	 * @return int
557
-	 */
558
-	public function defaultMenuOrder() {
559
-		return 20;
560
-	}
561
-
562
-	/**
563
-	 * A menu, to be added to the main application menu.
564
-	 *
565
-	 * @return Menu|null
566
-	 */
567
-	public function getMenu() {
568
-		global $controller, $WT_TREE;
569
-
570
-		$submenus = array();
571
-		if (isset($controller->record)) {
572
-			$submenus[] = new Menu($this->getTitle(), 'module.php?mod=clippings&amp;mod_action=index&amp;ged=' . $WT_TREE->getNameUrl(), 'menu-clippingscart', array('rel' => 'nofollow'));
573
-		}
574
-		if (!empty($controller->record) && $controller->record->canShow()) {
575
-			$submenus[] = new Menu(I18N::translate('Add to the clippings cart'), 'module.php?mod=clippings&amp;mod_action=index&amp;action=add&amp;id=' . $controller->record->getXref(), 'menu-clippingsadd', array('rel' => 'nofollow'));
576
-		}
577
-
578
-		if ($submenus) {
579
-			return new Menu($this->getTitle(), '#', 'menu-clippings', array('rel' => 'nofollow'), $submenus);
580
-		} else {
581
-			return new Menu($this->getTitle(), 'module.php?mod=clippings&amp;mod_action=index&amp;ged=' . $WT_TREE->getNameUrl(), 'menu-clippings', array('rel' => 'nofollow'));
582
-		}
583
-	}
584
-
585
-	/** {@inheritdoc} */
586
-	public function defaultSidebarOrder() {
587
-		return 60;
588
-	}
589
-
590
-	/** {@inheritdoc} */
591
-	public function hasSidebarContent() {
592
-		// Creating a controller has the side effect of initialising the cart
593
-		new ClippingsCartController;
594
-
595
-		return true;
596
-	}
597
-
598
-	/**
599
-	 * Load this sidebar synchronously.
600
-	 *
601
-	 * @return string
602
-	 */
603
-	public function getSidebarContent() {
604
-		global $controller;
605
-
606
-		$controller->addInlineJavascript('
545
+            }
546
+            break;
547
+        default:
548
+            http_response_code(404);
549
+            break;
550
+        }
551
+    }
552
+
553
+    /**
554
+     * The user can re-order menus. Until they do, they are shown in this order.
555
+     *
556
+     * @return int
557
+     */
558
+    public function defaultMenuOrder() {
559
+        return 20;
560
+    }
561
+
562
+    /**
563
+     * A menu, to be added to the main application menu.
564
+     *
565
+     * @return Menu|null
566
+     */
567
+    public function getMenu() {
568
+        global $controller, $WT_TREE;
569
+
570
+        $submenus = array();
571
+        if (isset($controller->record)) {
572
+            $submenus[] = new Menu($this->getTitle(), 'module.php?mod=clippings&amp;mod_action=index&amp;ged=' . $WT_TREE->getNameUrl(), 'menu-clippingscart', array('rel' => 'nofollow'));
573
+        }
574
+        if (!empty($controller->record) && $controller->record->canShow()) {
575
+            $submenus[] = new Menu(I18N::translate('Add to the clippings cart'), 'module.php?mod=clippings&amp;mod_action=index&amp;action=add&amp;id=' . $controller->record->getXref(), 'menu-clippingsadd', array('rel' => 'nofollow'));
576
+        }
577
+
578
+        if ($submenus) {
579
+            return new Menu($this->getTitle(), '#', 'menu-clippings', array('rel' => 'nofollow'), $submenus);
580
+        } else {
581
+            return new Menu($this->getTitle(), 'module.php?mod=clippings&amp;mod_action=index&amp;ged=' . $WT_TREE->getNameUrl(), 'menu-clippings', array('rel' => 'nofollow'));
582
+        }
583
+    }
584
+
585
+    /** {@inheritdoc} */
586
+    public function defaultSidebarOrder() {
587
+        return 60;
588
+    }
589
+
590
+    /** {@inheritdoc} */
591
+    public function hasSidebarContent() {
592
+        // Creating a controller has the side effect of initialising the cart
593
+        new ClippingsCartController;
594
+
595
+        return true;
596
+    }
597
+
598
+    /**
599
+     * Load this sidebar synchronously.
600
+     *
601
+     * @return string
602
+     */
603
+    public function getSidebarContent() {
604
+        global $controller;
605
+
606
+        $controller->addInlineJavascript('
607 607
 				jQuery("#sb_clippings_content").on("click", ".add_cart, .remove_cart", function() {
608 608
 					jQuery("#sb_clippings_content").load(this.href);
609 609
 					return false;
610 610
 				});
611 611
 			');
612 612
 
613
-		return '<div id="sb_clippings_content">' . $this->getCartList() . '</div>';
614
-	}
615
-
616
-	/** {@inheritdoc} */
617
-	public function getSidebarAjaxContent() {
618
-		global $WT_TREE;
619
-
620
-		$cart = Session::get('cart');
621
-
622
-		$clip_ctrl         = new ClippingsCartController;
623
-		$add               = Filter::get('add', WT_REGEX_XREF);
624
-		$add1              = Filter::get('add1', WT_REGEX_XREF);
625
-		$remove            = Filter::get('remove', WT_REGEX_XREF);
626
-		$others            = Filter::get('others');
627
-		$clip_ctrl->level1 = Filter::getInteger('level1');
628
-		$clip_ctrl->level2 = Filter::getInteger('level2');
629
-		$clip_ctrl->level3 = Filter::getInteger('level3');
630
-		if ($add) {
631
-			$record = GedcomRecord::getInstance($add, $WT_TREE);
632
-			if ($record) {
633
-				$clip_ctrl->id   = $record->getXref();
634
-				$clip_ctrl->type = $record::RECORD_TYPE;
635
-				$clip_ctrl->addClipping($record);
636
-			}
637
-		} elseif ($add1) {
638
-			$record = Individual::getInstance($add1, $WT_TREE);
639
-			if ($record) {
640
-				$clip_ctrl->id   = $record->getXref();
641
-				$clip_ctrl->type = $record::RECORD_TYPE;
642
-				if ($others == 'parents') {
643
-					foreach ($record->getChildFamilies() as $family) {
644
-						$clip_ctrl->addClipping($family);
645
-						$clip_ctrl->addFamilyMembers($family);
646
-					}
647
-				} elseif ($others == 'ancestors') {
648
-					$clip_ctrl->addAncestorsToCart($record, $clip_ctrl->level1);
649
-				} elseif ($others == 'ancestorsfamilies') {
650
-					$clip_ctrl->addAncestorsToCartFamilies($record, $clip_ctrl->level2);
651
-				} elseif ($others == 'members') {
652
-					foreach ($record->getSpouseFamilies() as $family) {
653
-						$clip_ctrl->addClipping($family);
654
-						$clip_ctrl->addFamilyMembers($family);
655
-					}
656
-				} elseif ($others == 'descendants') {
657
-					foreach ($record->getSpouseFamilies() as $family) {
658
-						$clip_ctrl->addClipping($family);
659
-						$clip_ctrl->addFamilyDescendancy($family, $clip_ctrl->level3);
660
-					}
661
-				}
662
-			}
663
-		} elseif ($remove) {
664
-			unset($cart[$WT_TREE->getTreeId()][$remove]);
665
-			Session::put('cart', $cart);
666
-		} elseif (isset($_REQUEST['empty'])) {
667
-			$cart[$WT_TREE->getTreeId()] = array();
668
-			Session::put('cart', $cart);
669
-		} elseif (isset($_REQUEST['download'])) {
670
-			return $this->downloadForm($clip_ctrl);
671
-		}
672
-
673
-		return $this->getCartList();
674
-	}
675
-
676
-	/**
677
-	 * A list for the side bar.
678
-	 *
679
-	 * @return string
680
-	 */
681
-	public function getCartList() {
682
-		global $WT_TREE;
683
-
684
-		$cart = Session::get('cart', array());
685
-		if (!array_key_exists($WT_TREE->getTreeId(), $cart)) {
686
-			$cart[$WT_TREE->getTreeId()] = array();
687
-		}
688
-		$pid = Filter::get('pid', WT_REGEX_XREF);
689
-
690
-		if (!$cart[$WT_TREE->getTreeId()]) {
691
-			$out = I18N::translate('Your clippings cart is empty.');
692
-		} else {
693
-			$out = '<ul>';
694
-			foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) {
695
-				$record = GedcomRecord::getInstance($xref, $WT_TREE);
696
-				if ($record instanceof Individual || $record instanceof Family) {
697
-					switch ($record::RECORD_TYPE) {
698
-					case 'INDI':
699
-						$icon = 'icon-indis';
700
-						break;
701
-					case 'FAM':
702
-						$icon = 'icon-sfamily';
703
-						break;
704
-					}
705
-					$out .= '<li>';
706
-					if (!empty($icon)) {
707
-						$out .= '<i class="' . $icon . '"></i>';
708
-					}
709
-					$out .= '<a href="' . $record->getHtmlUrl() . '">';
710
-					if ($record instanceof Individual) {
711
-						$out .= $record->getSexImage();
712
-					}
713
-					$out .= ' ' . $record->getFullName() . ' ';
714
-					if ($record instanceof Individual && $record->canShow()) {
715
-						$out .= ' (' . $record->getLifeSpan() . ')';
716
-					}
717
-					$out .= '</a>';
718
-					$out .= '<a class="icon-remove remove_cart" href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;remove=' . $xref . '&amp;pid=' . $pid . '" title="' . I18N::translate('Remove') . '"></a>';
719
-					$out .= '</li>';
720
-				}
721
-			}
722
-			$out .= '</ul>';
723
-		}
724
-
725
-		if ($cart[$WT_TREE->getTreeId()]) {
726
-			$out .=
727
-				'<br><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;empty=true&amp;pid=' . $pid . '" class="remove_cart">' .
728
-				I18N::translate('Empty the clippings cart') .
729
-				'</a>' .
730
-				'<br>' .
731
-				'<a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;download=true&amp;pid=' . $pid . '" class="add_cart">' .
732
-				I18N::translate('Download') .
733
-				'</a>';
734
-		}
735
-		$record = Individual::getInstance($pid, $WT_TREE);
736
-		if ($record && !array_key_exists($record->getXref(), $cart[$WT_TREE->getTreeId()])) {
737
-			$out .= '<br><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;action=add1&amp;type=INDI&amp;id=' . $pid . '&amp;pid=' . $pid . '" class="add_cart"><i class="icon-clippings"></i> ' . I18N::translate('Add %s to the clippings cart', $record->getFullName()) . '</a>';
738
-		}
739
-
740
-		return $out;
741
-	}
742
-
743
-	/**
744
-	 * A form to choose the download options.
745
-	 *
746
-	 * @param ClippingsCartController $clip_ctrl
747
-	 *
748
-	 * @return string
749
-	 */
750
-	public function downloadForm(ClippingsCartController $clip_ctrl) {
751
-		global $WT_TREE;
752
-
753
-		$pid = Filter::get('pid', WT_REGEX_XREF);
754
-
755
-		$out = '<script>';
756
-		$out .= 'function cancelDownload() {
613
+        return '<div id="sb_clippings_content">' . $this->getCartList() . '</div>';
614
+    }
615
+
616
+    /** {@inheritdoc} */
617
+    public function getSidebarAjaxContent() {
618
+        global $WT_TREE;
619
+
620
+        $cart = Session::get('cart');
621
+
622
+        $clip_ctrl         = new ClippingsCartController;
623
+        $add               = Filter::get('add', WT_REGEX_XREF);
624
+        $add1              = Filter::get('add1', WT_REGEX_XREF);
625
+        $remove            = Filter::get('remove', WT_REGEX_XREF);
626
+        $others            = Filter::get('others');
627
+        $clip_ctrl->level1 = Filter::getInteger('level1');
628
+        $clip_ctrl->level2 = Filter::getInteger('level2');
629
+        $clip_ctrl->level3 = Filter::getInteger('level3');
630
+        if ($add) {
631
+            $record = GedcomRecord::getInstance($add, $WT_TREE);
632
+            if ($record) {
633
+                $clip_ctrl->id   = $record->getXref();
634
+                $clip_ctrl->type = $record::RECORD_TYPE;
635
+                $clip_ctrl->addClipping($record);
636
+            }
637
+        } elseif ($add1) {
638
+            $record = Individual::getInstance($add1, $WT_TREE);
639
+            if ($record) {
640
+                $clip_ctrl->id   = $record->getXref();
641
+                $clip_ctrl->type = $record::RECORD_TYPE;
642
+                if ($others == 'parents') {
643
+                    foreach ($record->getChildFamilies() as $family) {
644
+                        $clip_ctrl->addClipping($family);
645
+                        $clip_ctrl->addFamilyMembers($family);
646
+                    }
647
+                } elseif ($others == 'ancestors') {
648
+                    $clip_ctrl->addAncestorsToCart($record, $clip_ctrl->level1);
649
+                } elseif ($others == 'ancestorsfamilies') {
650
+                    $clip_ctrl->addAncestorsToCartFamilies($record, $clip_ctrl->level2);
651
+                } elseif ($others == 'members') {
652
+                    foreach ($record->getSpouseFamilies() as $family) {
653
+                        $clip_ctrl->addClipping($family);
654
+                        $clip_ctrl->addFamilyMembers($family);
655
+                    }
656
+                } elseif ($others == 'descendants') {
657
+                    foreach ($record->getSpouseFamilies() as $family) {
658
+                        $clip_ctrl->addClipping($family);
659
+                        $clip_ctrl->addFamilyDescendancy($family, $clip_ctrl->level3);
660
+                    }
661
+                }
662
+            }
663
+        } elseif ($remove) {
664
+            unset($cart[$WT_TREE->getTreeId()][$remove]);
665
+            Session::put('cart', $cart);
666
+        } elseif (isset($_REQUEST['empty'])) {
667
+            $cart[$WT_TREE->getTreeId()] = array();
668
+            Session::put('cart', $cart);
669
+        } elseif (isset($_REQUEST['download'])) {
670
+            return $this->downloadForm($clip_ctrl);
671
+        }
672
+
673
+        return $this->getCartList();
674
+    }
675
+
676
+    /**
677
+     * A list for the side bar.
678
+     *
679
+     * @return string
680
+     */
681
+    public function getCartList() {
682
+        global $WT_TREE;
683
+
684
+        $cart = Session::get('cart', array());
685
+        if (!array_key_exists($WT_TREE->getTreeId(), $cart)) {
686
+            $cart[$WT_TREE->getTreeId()] = array();
687
+        }
688
+        $pid = Filter::get('pid', WT_REGEX_XREF);
689
+
690
+        if (!$cart[$WT_TREE->getTreeId()]) {
691
+            $out = I18N::translate('Your clippings cart is empty.');
692
+        } else {
693
+            $out = '<ul>';
694
+            foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) {
695
+                $record = GedcomRecord::getInstance($xref, $WT_TREE);
696
+                if ($record instanceof Individual || $record instanceof Family) {
697
+                    switch ($record::RECORD_TYPE) {
698
+                    case 'INDI':
699
+                        $icon = 'icon-indis';
700
+                        break;
701
+                    case 'FAM':
702
+                        $icon = 'icon-sfamily';
703
+                        break;
704
+                    }
705
+                    $out .= '<li>';
706
+                    if (!empty($icon)) {
707
+                        $out .= '<i class="' . $icon . '"></i>';
708
+                    }
709
+                    $out .= '<a href="' . $record->getHtmlUrl() . '">';
710
+                    if ($record instanceof Individual) {
711
+                        $out .= $record->getSexImage();
712
+                    }
713
+                    $out .= ' ' . $record->getFullName() . ' ';
714
+                    if ($record instanceof Individual && $record->canShow()) {
715
+                        $out .= ' (' . $record->getLifeSpan() . ')';
716
+                    }
717
+                    $out .= '</a>';
718
+                    $out .= '<a class="icon-remove remove_cart" href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;remove=' . $xref . '&amp;pid=' . $pid . '" title="' . I18N::translate('Remove') . '"></a>';
719
+                    $out .= '</li>';
720
+                }
721
+            }
722
+            $out .= '</ul>';
723
+        }
724
+
725
+        if ($cart[$WT_TREE->getTreeId()]) {
726
+            $out .=
727
+                '<br><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;empty=true&amp;pid=' . $pid . '" class="remove_cart">' .
728
+                I18N::translate('Empty the clippings cart') .
729
+                '</a>' .
730
+                '<br>' .
731
+                '<a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;download=true&amp;pid=' . $pid . '" class="add_cart">' .
732
+                I18N::translate('Download') .
733
+                '</a>';
734
+        }
735
+        $record = Individual::getInstance($pid, $WT_TREE);
736
+        if ($record && !array_key_exists($record->getXref(), $cart[$WT_TREE->getTreeId()])) {
737
+            $out .= '<br><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;action=add1&amp;type=INDI&amp;id=' . $pid . '&amp;pid=' . $pid . '" class="add_cart"><i class="icon-clippings"></i> ' . I18N::translate('Add %s to the clippings cart', $record->getFullName()) . '</a>';
738
+        }
739
+
740
+        return $out;
741
+    }
742
+
743
+    /**
744
+     * A form to choose the download options.
745
+     *
746
+     * @param ClippingsCartController $clip_ctrl
747
+     *
748
+     * @return string
749
+     */
750
+    public function downloadForm(ClippingsCartController $clip_ctrl) {
751
+        global $WT_TREE;
752
+
753
+        $pid = Filter::get('pid', WT_REGEX_XREF);
754
+
755
+        $out = '<script>';
756
+        $out .= 'function cancelDownload() {
757 757
 				var link = "module.php?mod=' . $this->getName() . '&mod_action=ajax&pid=' . $pid . '";
758 758
 				jQuery("#sb_clippings_content").load(link);
759 759
 			}';
760
-		$out .= '</script>';
761
-		$out .= '<form method="get" action="module.php">
760
+        $out .= '</script>';
761
+        $out .= '<form method="get" action="module.php">
762 762
 		<input type="hidden" name="mod" value="clippings">
763 763
 		<input type="hidden" name="mod_action" value="index">
764 764
 		<input type="hidden" name="pid" value="' . $pid . '">
@@ -772,25 +772,25 @@  discard block
 block discarded – undo
772 772
 		<td class="optionbox"><input type="checkbox" name="IncludeMedia" value="yes" checked></td></tr>
773 773
 		';
774 774
 
775
-		if (Auth::isManager($WT_TREE)) {
776
-			$out .=
777
-				'<tr><td class="descriptionbox width50 wrap">' . I18N::translate('Apply privacy settings') . '</td>' .
778
-				'<td class="optionbox">' .
779
-				'<input type="radio" name="privatize_export" value="none" checked> ' . I18N::translate('None') . '<br>' .
780
-				'<input type="radio" name="privatize_export" value="gedadmin"> ' . I18N::translate('Manager') . '<br>' .
781
-				'<input type="radio" name="privatize_export" value="user"> ' . I18N::translate('Member') . '<br>' .
782
-				'<input type="radio" name="privatize_export" value="visitor"> ' . I18N::translate('Visitor') .
783
-				'</td></tr>';
784
-		} elseif (Auth::isMember($WT_TREE)) {
785
-			$out .=
786
-				'<tr><td class="descriptionbox width50 wrap">' . I18N::translate('Apply privacy settings') . '</td>' .
787
-				'<td class="list_value">' .
788
-				'<input type="radio" name="privatize_export" value="user" checked> ' . I18N::translate('Member') . '<br>' .
789
-				'<input type="radio" name="privatize_export" value="visitor"> ' . I18N::translate('Visitor') .
790
-				'</td></tr>';
791
-		}
792
-
793
-		$out .= '
775
+        if (Auth::isManager($WT_TREE)) {
776
+            $out .=
777
+                '<tr><td class="descriptionbox width50 wrap">' . I18N::translate('Apply privacy settings') . '</td>' .
778
+                '<td class="optionbox">' .
779
+                '<input type="radio" name="privatize_export" value="none" checked> ' . I18N::translate('None') . '<br>' .
780
+                '<input type="radio" name="privatize_export" value="gedadmin"> ' . I18N::translate('Manager') . '<br>' .
781
+                '<input type="radio" name="privatize_export" value="user"> ' . I18N::translate('Member') . '<br>' .
782
+                '<input type="radio" name="privatize_export" value="visitor"> ' . I18N::translate('Visitor') .
783
+                '</td></tr>';
784
+        } elseif (Auth::isMember($WT_TREE)) {
785
+            $out .=
786
+                '<tr><td class="descriptionbox width50 wrap">' . I18N::translate('Apply privacy settings') . '</td>' .
787
+                '<td class="list_value">' .
788
+                '<input type="radio" name="privatize_export" value="user" checked> ' . I18N::translate('Member') . '<br>' .
789
+                '<input type="radio" name="privatize_export" value="visitor"> ' . I18N::translate('Visitor') .
790
+                '</td></tr>';
791
+        }
792
+
793
+        $out .= '
794 794
 		<tr><td class="descriptionbox width50 wrap">' . I18N::translate('Convert from UTF-8 to ISO-8859-1') . '</td>
795 795
 		<td class="optionbox"><input type="checkbox" name="convert" value="yes"></td></tr>
796 796
 
@@ -810,6 +810,6 @@  discard block
 block discarded – undo
810 810
 		<input type="submit" value="' . /* I18N: A button label. */ I18N::translate('download') . '">
811 811
 		</form>';
812 812
 
813
-		return $out;
814
-	}
813
+        return $out;
814
+    }
815 815
 }
Please login to merge, or discard this patch.