Passed
Push — 1.7 ( 23cbb7...8df8a8 )
by Greg
08:15
created
app/Module/YahrzeitModule.php 3 patches
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -32,111 +32,111 @@  discard block
 block discarded – undo
32 32
  * Class YahrzeitModule
33 33
  */
34 34
 class YahrzeitModule extends AbstractModule implements ModuleBlockInterface {
35
-	/** {@inheritdoc} */
36
-	public function getTitle() {
37
-		return /* I18N: Name of a module. Yahrzeiten (the plural of Yahrzeit) are special anniversaries of deaths in the Hebrew faith/calendar. */ I18N::translate('Yahrzeiten');
38
-	}
35
+    /** {@inheritdoc} */
36
+    public function getTitle() {
37
+        return /* I18N: Name of a module. Yahrzeiten (the plural of Yahrzeit) are special anniversaries of deaths in the Hebrew faith/calendar. */ I18N::translate('Yahrzeiten');
38
+    }
39 39
 
40
-	/** {@inheritdoc} */
41
-	public function getDescription() {
42
-		return /* I18N: Description of the “Yahrzeiten” module. A “Hebrew death” is a death where the date is recorded in the Hebrew calendar. */ I18N::translate('A list of the Hebrew death anniversaries that will occur in the near future.');
43
-	}
40
+    /** {@inheritdoc} */
41
+    public function getDescription() {
42
+        return /* I18N: Description of the “Yahrzeiten” module. A “Hebrew death” is a death where the date is recorded in the Hebrew calendar. */ I18N::translate('A list of the Hebrew death anniversaries that will occur in the near future.');
43
+    }
44 44
 
45
-	/**
46
-	 * Generate the HTML content of this block.
47
-	 *
48
-	 * @param int      $block_id
49
-	 * @param bool     $template
50
-	 * @param string[] $cfg
51
-	 *
52
-	 * @return string
53
-	 */
54
-	public function getBlock($block_id, $template = true, $cfg = array()) {
55
-		global $ctype, $controller, $WT_TREE;
45
+    /**
46
+     * Generate the HTML content of this block.
47
+     *
48
+     * @param int      $block_id
49
+     * @param bool     $template
50
+     * @param string[] $cfg
51
+     *
52
+     * @return string
53
+     */
54
+    public function getBlock($block_id, $template = true, $cfg = array()) {
55
+        global $ctype, $controller, $WT_TREE;
56 56
 
57
-		$days      = $this->getBlockSetting($block_id, 'days', '7');
58
-		$infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table');
59
-		$calendar  = $this->getBlockSetting($block_id, 'calendar', 'jewish');
60
-		$block     = $this->getBlockSetting($block_id, 'block', '1');
57
+        $days      = $this->getBlockSetting($block_id, 'days', '7');
58
+        $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table');
59
+        $calendar  = $this->getBlockSetting($block_id, 'calendar', 'jewish');
60
+        $block     = $this->getBlockSetting($block_id, 'block', '1');
61 61
 
62
-		foreach (array('days', 'infoStyle', 'block') as $name) {
63
-			if (array_key_exists($name, $cfg)) {
64
-				$$name = $cfg[$name];
65
-			}
66
-		}
62
+        foreach (array('days', 'infoStyle', 'block') as $name) {
63
+            if (array_key_exists($name, $cfg)) {
64
+                $$name = $cfg[$name];
65
+            }
66
+        }
67 67
 
68
-		$startjd = WT_CLIENT_JD;
69
-		$endjd   = WT_CLIENT_JD + $days - 1;
68
+        $startjd = WT_CLIENT_JD;
69
+        $endjd   = WT_CLIENT_JD + $days - 1;
70 70
 
71
-		$id    = $this->getName() . $block_id;
72
-		$class = $this->getName() . '_block';
73
-		if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
74
-			$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>';
75
-		} else {
76
-			$title = '';
77
-		}
78
-		$title .= $this->getTitle();
71
+        $id    = $this->getName() . $block_id;
72
+        $class = $this->getName() . '_block';
73
+        if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
74
+            $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>';
75
+        } else {
76
+            $title = '';
77
+        }
78
+        $title .= $this->getTitle();
79 79
 
80
-		$content = '';
81
-		// The standard anniversary rules cover most of the Yahrzeit rules, we just
82
-		// need to handle a few special cases.
83
-		// Fetch normal anniversaries...
84
-		$yahrzeits = array();
85
-		for ($jd = $startjd - 1; $jd <= $endjd + $days; ++$jd) {
86
-			foreach (FunctionsDb::getAnniversaryEvents($jd, 'DEAT _YART', $WT_TREE) as $fact) {
87
-				// Exact hebrew dates only
88
-				$date = $fact->getDate();
89
-				if ($date->minimumDate() instanceof JewishDate && $date->minimumJulianDay() === $date->maximumJulianDay()) {
90
-					$fact->jd    = $jd;
91
-					$yahrzeits[] = $fact;
92
-				}
93
-			}
94
-		}
80
+        $content = '';
81
+        // The standard anniversary rules cover most of the Yahrzeit rules, we just
82
+        // need to handle a few special cases.
83
+        // Fetch normal anniversaries...
84
+        $yahrzeits = array();
85
+        for ($jd = $startjd - 1; $jd <= $endjd + $days; ++$jd) {
86
+            foreach (FunctionsDb::getAnniversaryEvents($jd, 'DEAT _YART', $WT_TREE) as $fact) {
87
+                // Exact hebrew dates only
88
+                $date = $fact->getDate();
89
+                if ($date->minimumDate() instanceof JewishDate && $date->minimumJulianDay() === $date->maximumJulianDay()) {
90
+                    $fact->jd    = $jd;
91
+                    $yahrzeits[] = $fact;
92
+                }
93
+            }
94
+        }
95 95
 
96
-		// ...then adjust dates
97
-		$jewish_calendar = new JewishCalendar;
96
+        // ...then adjust dates
97
+        $jewish_calendar = new JewishCalendar;
98 98
 
99
-		foreach ($yahrzeits as $yahrzeit) {
100
-			if ($yahrzeit->getTag() === 'DEAT') {
101
-				$today = new JewishDate($yahrzeit->jd);
102
-				$hd    = $yahrzeit->getDate()->minimumDate();
103
-				$hd1   = new JewishDate($hd);
104
-				$hd1->y += 1;
105
-				$hd1->setJdFromYmd();
106
-				// Special rules. See http://www.hebcal.com/help/anniv.html
107
-				// Everything else is taken care of by our standard anniversary rules.
108
-				if ($hd->d == 30 && $hd->m == 2 && $hd->y != 0 && $hd1->daysInMonth() < 30) {
109
-					// 30 CSH - Last day in CSH
110
-					$yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 3, 1) - 1;
111
-				} elseif ($hd->d == 30 && $hd->m == 3 && $hd->y != 0 && $hd1->daysInMonth() < 30) {
112
-					// 30 KSL - Last day in KSL
113
-					$yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 4, 1) - 1;
114
-				} elseif ($hd->d == 30 && $hd->m == 6 && $hd->y != 0 && $today->daysInMonth() < 30 && !$today->isLeapYear()) {
115
-					// 30 ADR - Last day in SHV
116
-					$yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 6, 1) - 1;
117
-				}
118
-			}
119
-		}
99
+        foreach ($yahrzeits as $yahrzeit) {
100
+            if ($yahrzeit->getTag() === 'DEAT') {
101
+                $today = new JewishDate($yahrzeit->jd);
102
+                $hd    = $yahrzeit->getDate()->minimumDate();
103
+                $hd1   = new JewishDate($hd);
104
+                $hd1->y += 1;
105
+                $hd1->setJdFromYmd();
106
+                // Special rules. See http://www.hebcal.com/help/anniv.html
107
+                // Everything else is taken care of by our standard anniversary rules.
108
+                if ($hd->d == 30 && $hd->m == 2 && $hd->y != 0 && $hd1->daysInMonth() < 30) {
109
+                    // 30 CSH - Last day in CSH
110
+                    $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 3, 1) - 1;
111
+                } elseif ($hd->d == 30 && $hd->m == 3 && $hd->y != 0 && $hd1->daysInMonth() < 30) {
112
+                    // 30 KSL - Last day in KSL
113
+                    $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 4, 1) - 1;
114
+                } elseif ($hd->d == 30 && $hd->m == 6 && $hd->y != 0 && $today->daysInMonth() < 30 && !$today->isLeapYear()) {
115
+                    // 30 ADR - Last day in SHV
116
+                    $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 6, 1) - 1;
117
+                }
118
+            }
119
+        }
120 120
 
121
-		switch ($infoStyle) {
122
-		case 'list':
123
-			foreach ($yahrzeits as $yahrzeit) {
124
-				if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) {
125
-					$ind = $yahrzeit->getParent();
126
-					$content .= "<a href=\"" . $ind->getHtmlUrl() . "\" class=\"list_item name2\">" . $ind->getFullName() . "</a>" . $ind->getSexImage();
127
-					$content .= "<div class=\"indent\">";
128
-					$content .= $yahrzeit->getDate()->display(true);
129
-					$content .= ', ' . I18N::translate('%s year anniversary', $yahrzeit->anniv);
130
-					$content .= "</div>";
131
-				}
132
-			}
133
-			break;
134
-		case 'table':
135
-		default:
136
-			$table_id = Uuid::uuid4(); // table requires a unique ID
137
-			$controller
138
-				->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
139
-				->addInlineJavascript('
121
+        switch ($infoStyle) {
122
+        case 'list':
123
+            foreach ($yahrzeits as $yahrzeit) {
124
+                if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) {
125
+                    $ind = $yahrzeit->getParent();
126
+                    $content .= "<a href=\"" . $ind->getHtmlUrl() . "\" class=\"list_item name2\">" . $ind->getFullName() . "</a>" . $ind->getSexImage();
127
+                    $content .= "<div class=\"indent\">";
128
+                    $content .= $yahrzeit->getDate()->display(true);
129
+                    $content .= ', ' . I18N::translate('%s year anniversary', $yahrzeit->anniv);
130
+                    $content .= "</div>";
131
+                }
132
+            }
133
+            break;
134
+        case 'table':
135
+        default:
136
+            $table_id = Uuid::uuid4(); // table requires a unique ID
137
+            $controller
138
+                ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
139
+                ->addInlineJavascript('
140 140
 					jQuery("#' . $table_id . '").dataTable({
141 141
 						dom: \'t\',
142 142
 						' . I18N::datatablesI18N() . ',
@@ -160,135 +160,135 @@  discard block
 block discarded – undo
160 160
 					jQuery("#' . $table_id . '").css("visibility", "visible");
161 161
 					jQuery(".loading-image").css("display", "none");
162 162
 				');
163
-			$content = '';
164
-			$content .= '<div class="loading-image">&nbsp;</div>';
165
-			$content .= '<table id="' . $table_id . '" class="width100" style="visibility:hidden;">';
166
-			$content .= '<thead><tr>';
167
-			$content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>';
168
-			$content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>';
169
-			$content .= '<th>' . GedcomTag::getLabel('DEAT') . '</th>';
170
-			$content .= '<th>DEAT</th>';
171
-			$content .= '<th><i class="icon-reminder" title="' . I18N::translate('Anniversary') . '"></i></th>';
172
-			$content .= '<th>' . GedcomTag::getLabel('_YART') . '</th>';
173
-			$content .= '<th>_YART</th>';
174
-			$content .= '</tr></thead><tbody>';
163
+            $content = '';
164
+            $content .= '<div class="loading-image">&nbsp;</div>';
165
+            $content .= '<table id="' . $table_id . '" class="width100" style="visibility:hidden;">';
166
+            $content .= '<thead><tr>';
167
+            $content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>';
168
+            $content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>';
169
+            $content .= '<th>' . GedcomTag::getLabel('DEAT') . '</th>';
170
+            $content .= '<th>DEAT</th>';
171
+            $content .= '<th><i class="icon-reminder" title="' . I18N::translate('Anniversary') . '"></i></th>';
172
+            $content .= '<th>' . GedcomTag::getLabel('_YART') . '</th>';
173
+            $content .= '<th>_YART</th>';
174
+            $content .= '</tr></thead><tbody>';
175 175
 
176
-			foreach ($yahrzeits as $yahrzeit) {
177
-				if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) {
178
-					$content .= '<tr>';
179
-					$ind = $yahrzeit->getParent();
180
-					// Individual name(s)
181
-					$name = $ind->getFullName();
182
-					$url  = $ind->getHtmlUrl();
183
-					$content .= '<td>';
184
-					$content .= '<a href="' . $url . '">' . $name . '</a>';
185
-					$content .= $ind->getSexImage();
186
-					$addname = $ind->getAddName();
187
-					if ($addname) {
188
-						$content .= '<br><a href="' . $url . '">' . $addname . '</a>';
189
-					}
190
-					$content .= '</td>';
191
-					$content .= '<td>' . $ind->getSortName() . '</td>';
176
+            foreach ($yahrzeits as $yahrzeit) {
177
+                if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) {
178
+                    $content .= '<tr>';
179
+                    $ind = $yahrzeit->getParent();
180
+                    // Individual name(s)
181
+                    $name = $ind->getFullName();
182
+                    $url  = $ind->getHtmlUrl();
183
+                    $content .= '<td>';
184
+                    $content .= '<a href="' . $url . '">' . $name . '</a>';
185
+                    $content .= $ind->getSexImage();
186
+                    $addname = $ind->getAddName();
187
+                    if ($addname) {
188
+                        $content .= '<br><a href="' . $url . '">' . $addname . '</a>';
189
+                    }
190
+                    $content .= '</td>';
191
+                    $content .= '<td>' . $ind->getSortName() . '</td>';
192 192
 
193
-					// death/yahrzeit event date
194
-					$content .= '<td>' . $yahrzeit->getDate()->display() . '</td>';
195
-					$content .= '<td>' . $yahrzeit->getDate()->julianDay() . '</td>'; // sortable date
193
+                    // death/yahrzeit event date
194
+                    $content .= '<td>' . $yahrzeit->getDate()->display() . '</td>';
195
+                    $content .= '<td>' . $yahrzeit->getDate()->julianDay() . '</td>'; // sortable date
196 196
 
197
-					// Anniversary
198
-					$content .= '<td>' . $yahrzeit->anniv . '</td>';
197
+                    // Anniversary
198
+                    $content .= '<td>' . $yahrzeit->anniv . '</td>';
199 199
 
200
-					// upcomming yahrzeit dates
201
-					switch ($calendar) {
202
-					case 'gregorian':
203
-						$today = new GregorianDate($yahrzeit->jd);
204
-						break;
205
-					case 'jewish':
206
-					default:
207
-						$today = new JewishDate($yahrzeit->jd);
208
-						break;
209
-					}
210
-					$td = new Date($today->format('%@ %A %O %E'));
211
-					$content .= '<td>' . $td->display() . '</td>';
212
-					$content .= '<td>' . $td->julianDay() . '</td>'; // sortable date
200
+                    // upcomming yahrzeit dates
201
+                    switch ($calendar) {
202
+                    case 'gregorian':
203
+                        $today = new GregorianDate($yahrzeit->jd);
204
+                        break;
205
+                    case 'jewish':
206
+                    default:
207
+                        $today = new JewishDate($yahrzeit->jd);
208
+                        break;
209
+                    }
210
+                    $td = new Date($today->format('%@ %A %O %E'));
211
+                    $content .= '<td>' . $td->display() . '</td>';
212
+                    $content .= '<td>' . $td->julianDay() . '</td>'; // sortable date
213 213
 
214
-					$content .= '</tr>';
215
-				}
216
-			}
217
-			$content .= '</tbody></table>';
214
+                    $content .= '</tr>';
215
+                }
216
+            }
217
+            $content .= '</tbody></table>';
218 218
 
219
-			break;
220
-		}
219
+            break;
220
+        }
221 221
 
222
-		if ($template) {
223
-			if ($block) {
224
-				$class .= ' small_inner_block';
225
-			}
222
+        if ($template) {
223
+            if ($block) {
224
+                $class .= ' small_inner_block';
225
+            }
226 226
 
227
-			return Theme::theme()->formatBlock($id, $title, $class, $content);
228
-		} else {
229
-			return $content;
230
-		}
231
-	}
227
+            return Theme::theme()->formatBlock($id, $title, $class, $content);
228
+        } else {
229
+            return $content;
230
+        }
231
+    }
232 232
 
233
-	/** {@inheritdoc} */
234
-	public function loadAjax() {
235
-		return true;
236
-	}
233
+    /** {@inheritdoc} */
234
+    public function loadAjax() {
235
+        return true;
236
+    }
237 237
 
238
-	/** {@inheritdoc} */
239
-	public function isUserBlock() {
240
-		return true;
241
-	}
238
+    /** {@inheritdoc} */
239
+    public function isUserBlock() {
240
+        return true;
241
+    }
242 242
 
243
-	/** {@inheritdoc} */
244
-	public function isGedcomBlock() {
245
-		return true;
246
-	}
243
+    /** {@inheritdoc} */
244
+    public function isGedcomBlock() {
245
+        return true;
246
+    }
247 247
 
248
-	/**
249
-	 * An HTML form to edit block settings
250
-	 *
251
-	 * @param int $block_id
252
-	 */
253
-	public function configureBlock($block_id) {
254
-		if (Filter::postBool('save') && Filter::checkCsrf()) {
255
-			$this->setBlockSetting($block_id, 'days', Filter::postInteger('days', 1, 30, 7));
256
-			$this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table', 'table'));
257
-			$this->setBlockSetting($block_id, 'calendar', Filter::post('calendar', 'jewish|gregorian', 'jewish'));
258
-			$this->setBlockSetting($block_id, 'block', Filter::postBool('block'));
259
-		}
248
+    /**
249
+     * An HTML form to edit block settings
250
+     *
251
+     * @param int $block_id
252
+     */
253
+    public function configureBlock($block_id) {
254
+        if (Filter::postBool('save') && Filter::checkCsrf()) {
255
+            $this->setBlockSetting($block_id, 'days', Filter::postInteger('days', 1, 30, 7));
256
+            $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table', 'table'));
257
+            $this->setBlockSetting($block_id, 'calendar', Filter::post('calendar', 'jewish|gregorian', 'jewish'));
258
+            $this->setBlockSetting($block_id, 'block', Filter::postBool('block'));
259
+        }
260 260
 
261
-		$days      = $this->getBlockSetting($block_id, 'days', '7');
262
-		$infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table');
263
-		$calendar  = $this->getBlockSetting($block_id, 'calendar', 'jewish');
264
-		$block     = $this->getBlockSetting($block_id, 'block', '1');
261
+        $days      = $this->getBlockSetting($block_id, 'days', '7');
262
+        $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table');
263
+        $calendar  = $this->getBlockSetting($block_id, 'calendar', 'jewish');
264
+        $block     = $this->getBlockSetting($block_id, 'block', '1');
265 265
 
266
-		echo '<tr><td class="descriptionbox wrap width33">';
267
-		echo I18N::translate('Number of days to show');
268
-		echo '</td><td class="optionbox">';
269
-		echo '<input type="text" name="days" size="2" value="' . $days . '">';
270
-		echo ' <em>', I18N::plural('maximum %s day', 'maximum %s days', 30, I18N::number(30)), '</em>';
271
-		echo '</td></tr>';
266
+        echo '<tr><td class="descriptionbox wrap width33">';
267
+        echo I18N::translate('Number of days to show');
268
+        echo '</td><td class="optionbox">';
269
+        echo '<input type="text" name="days" size="2" value="' . $days . '">';
270
+        echo ' <em>', I18N::plural('maximum %s day', 'maximum %s days', 30, I18N::number(30)), '</em>';
271
+        echo '</td></tr>';
272 272
 
273
-		echo '<tr><td class="descriptionbox wrap width33">';
274
-		echo I18N::translate('Presentation style');
275
-		echo '</td><td class="optionbox">';
276
-		echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('list'), 'table' => I18N::translate('table')), null, $infoStyle, '');
277
-		echo '</td></tr>';
273
+        echo '<tr><td class="descriptionbox wrap width33">';
274
+        echo I18N::translate('Presentation style');
275
+        echo '</td><td class="optionbox">';
276
+        echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('list'), 'table' => I18N::translate('table')), null, $infoStyle, '');
277
+        echo '</td></tr>';
278 278
 
279
-		echo '<tr><td class="descriptionbox wrap width33">';
280
-		echo I18N::translate('Calendar');
281
-		echo '</td><td class="optionbox">';
282
-		echo FunctionsEdit::selectEditControl('calendar', array(
283
-			'jewish'    => /* I18N: The Hebrew/Jewish calendar */ I18N::translate('Jewish'),
284
-			'gregorian' => /* I18N: The gregorian calendar */ I18N::translate('Gregorian'),
285
-		), null, $calendar, '');
286
-		echo '</td></tr>';
279
+        echo '<tr><td class="descriptionbox wrap width33">';
280
+        echo I18N::translate('Calendar');
281
+        echo '</td><td class="optionbox">';
282
+        echo FunctionsEdit::selectEditControl('calendar', array(
283
+            'jewish'    => /* I18N: The Hebrew/Jewish calendar */ I18N::translate('Jewish'),
284
+            'gregorian' => /* I18N: The gregorian calendar */ I18N::translate('Gregorian'),
285
+        ), null, $calendar, '');
286
+        echo '</td></tr>';
287 287
 
288
-		echo '<tr><td class="descriptionbox wrap width33">';
289
-		echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow');
290
-		echo '</td><td class="optionbox">';
291
-		echo FunctionsEdit::editFieldYesNo('block', $block);
292
-		echo '</td></tr>';
293
-	}
288
+        echo '<tr><td class="descriptionbox wrap width33">';
289
+        echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow');
290
+        echo '</td><td class="optionbox">';
291
+        echo FunctionsEdit::editFieldYesNo('block', $block);
292
+        echo '</td></tr>';
293
+    }
294 294
 }
Please login to merge, or discard this patch.
Switch Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -119,24 +119,24 @@  discard block
 block discarded – undo
119 119
 		}
120 120
 
121 121
 		switch ($infoStyle) {
122
-		case 'list':
123
-			foreach ($yahrzeits as $yahrzeit) {
124
-				if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) {
125
-					$ind = $yahrzeit->getParent();
126
-					$content .= "<a href=\"" . $ind->getHtmlUrl() . "\" class=\"list_item name2\">" . $ind->getFullName() . "</a>" . $ind->getSexImage();
127
-					$content .= "<div class=\"indent\">";
128
-					$content .= $yahrzeit->getDate()->display(true);
129
-					$content .= ', ' . I18N::translate('%s year anniversary', $yahrzeit->anniv);
130
-					$content .= "</div>";
131
-				}
132
-			}
133
-			break;
134
-		case 'table':
135
-		default:
136
-			$table_id = Uuid::uuid4(); // table requires a unique ID
137
-			$controller
138
-				->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
139
-				->addInlineJavascript('
122
+		    case 'list':
123
+			    foreach ($yahrzeits as $yahrzeit) {
124
+				    if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) {
125
+					    $ind = $yahrzeit->getParent();
126
+					    $content .= "<a href=\"" . $ind->getHtmlUrl() . "\" class=\"list_item name2\">" . $ind->getFullName() . "</a>" . $ind->getSexImage();
127
+					    $content .= "<div class=\"indent\">";
128
+					    $content .= $yahrzeit->getDate()->display(true);
129
+					    $content .= ', ' . I18N::translate('%s year anniversary', $yahrzeit->anniv);
130
+					    $content .= "</div>";
131
+				    }
132
+			    }
133
+			    break;
134
+		    case 'table':
135
+		    default:
136
+			    $table_id = Uuid::uuid4(); // table requires a unique ID
137
+			    $controller
138
+				    ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
139
+				    ->addInlineJavascript('
140 140
 					jQuery("#' . $table_id . '").dataTable({
141 141
 						dom: \'t\',
142 142
 						' . I18N::datatablesI18N() . ',
@@ -160,53 +160,53 @@  discard block
 block discarded – undo
160 160
 					jQuery("#' . $table_id . '").css("visibility", "visible");
161 161
 					jQuery(".loading-image").css("display", "none");
162 162
 				');
163
-			$content = '';
164
-			$content .= '<div class="loading-image">&nbsp;</div>';
165
-			$content .= '<table id="' . $table_id . '" class="width100" style="visibility:hidden;">';
166
-			$content .= '<thead><tr>';
167
-			$content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>';
168
-			$content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>';
169
-			$content .= '<th>' . GedcomTag::getLabel('DEAT') . '</th>';
170
-			$content .= '<th>DEAT</th>';
171
-			$content .= '<th><i class="icon-reminder" title="' . I18N::translate('Anniversary') . '"></i></th>';
172
-			$content .= '<th>' . GedcomTag::getLabel('_YART') . '</th>';
173
-			$content .= '<th>_YART</th>';
174
-			$content .= '</tr></thead><tbody>';
163
+			    $content = '';
164
+			    $content .= '<div class="loading-image">&nbsp;</div>';
165
+			    $content .= '<table id="' . $table_id . '" class="width100" style="visibility:hidden;">';
166
+			    $content .= '<thead><tr>';
167
+			    $content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>';
168
+			    $content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>';
169
+			    $content .= '<th>' . GedcomTag::getLabel('DEAT') . '</th>';
170
+			    $content .= '<th>DEAT</th>';
171
+			    $content .= '<th><i class="icon-reminder" title="' . I18N::translate('Anniversary') . '"></i></th>';
172
+			    $content .= '<th>' . GedcomTag::getLabel('_YART') . '</th>';
173
+			    $content .= '<th>_YART</th>';
174
+			    $content .= '</tr></thead><tbody>';
175 175
 
176
-			foreach ($yahrzeits as $yahrzeit) {
177
-				if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) {
178
-					$content .= '<tr>';
179
-					$ind = $yahrzeit->getParent();
180
-					// Individual name(s)
181
-					$name = $ind->getFullName();
182
-					$url  = $ind->getHtmlUrl();
183
-					$content .= '<td>';
184
-					$content .= '<a href="' . $url . '">' . $name . '</a>';
185
-					$content .= $ind->getSexImage();
186
-					$addname = $ind->getAddName();
187
-					if ($addname) {
188
-						$content .= '<br><a href="' . $url . '">' . $addname . '</a>';
189
-					}
190
-					$content .= '</td>';
191
-					$content .= '<td>' . $ind->getSortName() . '</td>';
176
+			    foreach ($yahrzeits as $yahrzeit) {
177
+				    if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) {
178
+					    $content .= '<tr>';
179
+					    $ind = $yahrzeit->getParent();
180
+					    // Individual name(s)
181
+					    $name = $ind->getFullName();
182
+					    $url  = $ind->getHtmlUrl();
183
+					    $content .= '<td>';
184
+					    $content .= '<a href="' . $url . '">' . $name . '</a>';
185
+					    $content .= $ind->getSexImage();
186
+					    $addname = $ind->getAddName();
187
+					    if ($addname) {
188
+						    $content .= '<br><a href="' . $url . '">' . $addname . '</a>';
189
+					    }
190
+					    $content .= '</td>';
191
+					    $content .= '<td>' . $ind->getSortName() . '</td>';
192 192
 
193
-					// death/yahrzeit event date
194
-					$content .= '<td>' . $yahrzeit->getDate()->display() . '</td>';
195
-					$content .= '<td>' . $yahrzeit->getDate()->julianDay() . '</td>'; // sortable date
193
+					    // death/yahrzeit event date
194
+					    $content .= '<td>' . $yahrzeit->getDate()->display() . '</td>';
195
+					    $content .= '<td>' . $yahrzeit->getDate()->julianDay() . '</td>'; // sortable date
196 196
 
197
-					// Anniversary
198
-					$content .= '<td>' . $yahrzeit->anniv . '</td>';
197
+					    // Anniversary
198
+					    $content .= '<td>' . $yahrzeit->anniv . '</td>';
199 199
 
200
-					// upcomming yahrzeit dates
201
-					switch ($calendar) {
202
-					case 'gregorian':
203
-						$today = new GregorianDate($yahrzeit->jd);
204
-						break;
205
-					case 'jewish':
206
-					default:
207
-						$today = new JewishDate($yahrzeit->jd);
208
-						break;
209
-					}
200
+					    // upcomming yahrzeit dates
201
+					    switch ($calendar) {
202
+					        case 'gregorian':
203
+						        $today = new GregorianDate($yahrzeit->jd);
204
+						        break;
205
+					        case 'jewish':
206
+					        default:
207
+						        $today = new JewishDate($yahrzeit->jd);
208
+						        break;
209
+					    }
210 210
 					$td = new Date($today->format('%@ %A %O %E'));
211 211
 					$content .= '<td>' . $td->display() . '</td>';
212 212
 					$content .= '<td>' . $td->julianDay() . '</td>'; // sortable date
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,14 +31,17 @@  discard block
 block discarded – undo
31 31
 /**
32 32
  * Class YahrzeitModule
33 33
  */
34
-class YahrzeitModule extends AbstractModule implements ModuleBlockInterface {
34
+class YahrzeitModule extends AbstractModule implements ModuleBlockInterface
35
+{
35 36
 	/** {@inheritdoc} */
36
-	public function getTitle() {
37
+	public function getTitle()
38
+	{
37 39
 		return /* I18N: Name of a module. Yahrzeiten (the plural of Yahrzeit) are special anniversaries of deaths in the Hebrew faith/calendar. */ I18N::translate('Yahrzeiten');
38 40
 	}
39 41
 
40 42
 	/** {@inheritdoc} */
41
-	public function getDescription() {
43
+	public function getDescription()
44
+	{
42 45
 		return /* I18N: Description of the “Yahrzeiten” module. A “Hebrew death” is a death where the date is recorded in the Hebrew calendar. */ I18N::translate('A list of the Hebrew death anniversaries that will occur in the near future.');
43 46
 	}
44 47
 
@@ -51,7 +54,8 @@  discard block
 block discarded – undo
51 54
 	 *
52 55
 	 * @return string
53 56
 	 */
54
-	public function getBlock($block_id, $template = true, $cfg = array()) {
57
+	public function getBlock($block_id, $template = true, $cfg = array())
58
+	{
55 59
 		global $ctype, $controller, $WT_TREE;
56 60
 
57 61
 		$days      = $this->getBlockSetting($block_id, 'days', '7');
@@ -231,17 +235,20 @@  discard block
 block discarded – undo
231 235
 	}
232 236
 
233 237
 	/** {@inheritdoc} */
234
-	public function loadAjax() {
238
+	public function loadAjax()
239
+	{
235 240
 		return true;
236 241
 	}
237 242
 
238 243
 	/** {@inheritdoc} */
239
-	public function isUserBlock() {
244
+	public function isUserBlock()
245
+	{
240 246
 		return true;
241 247
 	}
242 248
 
243 249
 	/** {@inheritdoc} */
244
-	public function isGedcomBlock() {
250
+	public function isGedcomBlock()
251
+	{
245 252
 		return true;
246 253
 	}
247 254
 
@@ -250,7 +257,8 @@  discard block
 block discarded – undo
250 257
 	 *
251 258
 	 * @param int $block_id
252 259
 	 */
253
-	public function configureBlock($block_id) {
260
+	public function configureBlock($block_id)
261
+	{
254 262
 		if (Filter::postBool('save') && Filter::checkCsrf()) {
255 263
 			$this->setBlockSetting($block_id, 'days', Filter::postInteger('days', 1, 30, 7));
256 264
 			$this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table', 'table'));
Please login to merge, or discard this patch.
app/Module/UserFavoritesModule.php 3 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -29,73 +29,73 @@
 block discarded – undo
29 29
  * The "user favorites" module is almost identical to the "family tree favorites" module
30 30
  */
31 31
 class UserFavoritesModule extends FamilyTreeFavoritesModule {
32
-	/** {@inheritdoc} */
33
-	public function getDescription() {
34
-		return /* I18N: Description of the “Favorites” module */ I18N::translate('Display and manage a user’s favorite pages.');
35
-	}
32
+    /** {@inheritdoc} */
33
+    public function getDescription() {
34
+        return /* I18N: Description of the “Favorites” module */ I18N::translate('Display and manage a user’s favorite pages.');
35
+    }
36 36
 
37
-	/**
38
-	 * Can this block be shown on the user’s home page?
39
-	 *
40
-	 * @return bool
41
-	 */
42
-	public function isUserBlock() {
43
-		return true;
44
-	}
37
+    /**
38
+     * Can this block be shown on the user’s home page?
39
+     *
40
+     * @return bool
41
+     */
42
+    public function isUserBlock() {
43
+        return true;
44
+    }
45 45
 
46
-	/**
47
-	 * Can this block be shown on the tree’s home page?
48
-	 *
49
-	 * @return bool
50
-	 */
51
-	public function isGedcomBlock() {
52
-		return false;
53
-	}
46
+    /**
47
+     * Can this block be shown on the tree’s home page?
48
+     *
49
+     * @return bool
50
+     */
51
+    public function isGedcomBlock() {
52
+        return false;
53
+    }
54 54
 
55
-	/**
56
-	 * Get the favorites for a user (for the current family tree)
57
-	 *
58
-	 * @param int $user_id
59
-	 *
60
-	 * @return string[][]
61
-	 */
62
-	public static function getFavorites($user_id) {
63
-		global $WT_TREE;
55
+    /**
56
+     * Get the favorites for a user (for the current family tree)
57
+     *
58
+     * @param int $user_id
59
+     *
60
+     * @return string[][]
61
+     */
62
+    public static function getFavorites($user_id) {
63
+        global $WT_TREE;
64 64
 
65
-		return
66
-			Database::prepare(
67
-				"SELECT favorite_id AS id, user_id, gedcom_id, xref AS gid, favorite_type AS type, title AS title, note AS note, url AS url" .
68
-				" FROM `##favorite` WHERE user_id=? AND gedcom_id=?")
69
-			->execute(array($user_id, $WT_TREE->getTreeId()))
70
-			->fetchAll(PDO::FETCH_ASSOC);
71
-	}
65
+        return
66
+            Database::prepare(
67
+                "SELECT favorite_id AS id, user_id, gedcom_id, xref AS gid, favorite_type AS type, title AS title, note AS note, url AS url" .
68
+                " FROM `##favorite` WHERE user_id=? AND gedcom_id=?")
69
+            ->execute(array($user_id, $WT_TREE->getTreeId()))
70
+            ->fetchAll(PDO::FETCH_ASSOC);
71
+    }
72 72
 
73
-	/**
74
-	 * This is a general purpose hook, allowing modules to respond to routes
75
-	 * of the form module.php?mod=FOO&mod_action=BAR
76
-	 *
77
-	 * @param string $mod_action
78
-	 */
79
-	public function modAction($mod_action) {
80
-		global $WT_TREE;
73
+    /**
74
+     * This is a general purpose hook, allowing modules to respond to routes
75
+     * of the form module.php?mod=FOO&mod_action=BAR
76
+     *
77
+     * @param string $mod_action
78
+     */
79
+    public function modAction($mod_action) {
80
+        global $WT_TREE;
81 81
 
82
-		switch ($mod_action) {
83
-		case 'menu-add-favorite':
84
-			// Process the "add to user favorites" menu item on indi/fam/etc. pages
85
-			$record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
86
-			if (Auth::check() && $record->canShowName()) {
87
-				self::addFavorite(array(
88
-					'user_id'   => Auth::id(),
89
-					'gedcom_id' => $record->getTree()->getTreeId(),
90
-					'gid'       => $record->getXref(),
91
-					'type'      => $record::RECORD_TYPE,
92
-					'url'       => null,
93
-					'note'      => null,
94
-					'title'     => null,
95
-				));
96
-				FlashMessages::addMessage(/* I18N: %s is the name of an individual, source or other record */ I18N::translate('“%s” has been added to your favorites.', $record->getFullName()));
97
-			}
98
-			break;
99
-		}
100
-	}
82
+        switch ($mod_action) {
83
+        case 'menu-add-favorite':
84
+            // Process the "add to user favorites" menu item on indi/fam/etc. pages
85
+            $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
86
+            if (Auth::check() && $record->canShowName()) {
87
+                self::addFavorite(array(
88
+                    'user_id'   => Auth::id(),
89
+                    'gedcom_id' => $record->getTree()->getTreeId(),
90
+                    'gid'       => $record->getXref(),
91
+                    'type'      => $record::RECORD_TYPE,
92
+                    'url'       => null,
93
+                    'note'      => null,
94
+                    'title'     => null,
95
+                ));
96
+                FlashMessages::addMessage(/* I18N: %s is the name of an individual, source or other record */ I18N::translate('“%s” has been added to your favorites.', $record->getFullName()));
97
+            }
98
+            break;
99
+        }
100
+    }
101 101
 }
Please login to merge, or discard this patch.
Switch Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -80,22 +80,22 @@
 block discarded – undo
80 80
 		global $WT_TREE;
81 81
 
82 82
 		switch ($mod_action) {
83
-		case 'menu-add-favorite':
84
-			// Process the "add to user favorites" menu item on indi/fam/etc. pages
85
-			$record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
86
-			if (Auth::check() && $record->canShowName()) {
87
-				self::addFavorite(array(
88
-					'user_id'   => Auth::id(),
89
-					'gedcom_id' => $record->getTree()->getTreeId(),
90
-					'gid'       => $record->getXref(),
91
-					'type'      => $record::RECORD_TYPE,
92
-					'url'       => null,
93
-					'note'      => null,
94
-					'title'     => null,
95
-				));
96
-				FlashMessages::addMessage(/* I18N: %s is the name of an individual, source or other record */ I18N::translate('“%s” has been added to your favorites.', $record->getFullName()));
97
-			}
98
-			break;
83
+		    case 'menu-add-favorite':
84
+			    // Process the "add to user favorites" menu item on indi/fam/etc. pages
85
+			    $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
86
+			    if (Auth::check() && $record->canShowName()) {
87
+				    self::addFavorite(array(
88
+					    'user_id'   => Auth::id(),
89
+					    'gedcom_id' => $record->getTree()->getTreeId(),
90
+					    'gid'       => $record->getXref(),
91
+					    'type'      => $record::RECORD_TYPE,
92
+					    'url'       => null,
93
+					    'note'      => null,
94
+					    'title'     => null,
95
+				    ));
96
+				    FlashMessages::addMessage(/* I18N: %s is the name of an individual, source or other record */ I18N::translate('“%s” has been added to your favorites.', $record->getFullName()));
97
+			    }
98
+			    break;
99 99
 		}
100 100
 	}
101 101
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,9 +28,11 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * The "user favorites" module is almost identical to the "family tree favorites" module
30 30
  */
31
-class UserFavoritesModule extends FamilyTreeFavoritesModule {
31
+class UserFavoritesModule extends FamilyTreeFavoritesModule
32
+{
32 33
 	/** {@inheritdoc} */
33
-	public function getDescription() {
34
+	public function getDescription()
35
+	{
34 36
 		return /* I18N: Description of the “Favorites” module */ I18N::translate('Display and manage a user’s favorite pages.');
35 37
 	}
36 38
 
@@ -39,7 +41,8 @@  discard block
 block discarded – undo
39 41
 	 *
40 42
 	 * @return bool
41 43
 	 */
42
-	public function isUserBlock() {
44
+	public function isUserBlock()
45
+	{
43 46
 		return true;
44 47
 	}
45 48
 
@@ -48,7 +51,8 @@  discard block
 block discarded – undo
48 51
 	 *
49 52
 	 * @return bool
50 53
 	 */
51
-	public function isGedcomBlock() {
54
+	public function isGedcomBlock()
55
+	{
52 56
 		return false;
53 57
 	}
54 58
 
@@ -59,7 +63,8 @@  discard block
 block discarded – undo
59 63
 	 *
60 64
 	 * @return string[][]
61 65
 	 */
62
-	public static function getFavorites($user_id) {
66
+	public static function getFavorites($user_id)
67
+	{
63 68
 		global $WT_TREE;
64 69
 
65 70
 		return
@@ -76,7 +81,8 @@  discard block
 block discarded – undo
76 81
 	 *
77 82
 	 * @param string $mod_action
78 83
 	 */
79
-	public function modAction($mod_action) {
84
+	public function modAction($mod_action)
85
+	{
80 86
 		global $WT_TREE;
81 87
 
82 88
 		switch ($mod_action) {
Please login to merge, or discard this patch.
app/Module/UserWelcomeModule.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -24,71 +24,71 @@
 block discarded – undo
24 24
  * Class UserWelcomeModule
25 25
  */
26 26
 class UserWelcomeModule extends AbstractModule implements ModuleBlockInterface {
27
-	/** {@inheritdoc} */
28
-	public function getTitle() {
29
-		return /* I18N: Name of a module */ I18N::translate('My page');
30
-	}
27
+    /** {@inheritdoc} */
28
+    public function getTitle() {
29
+        return /* I18N: Name of a module */ I18N::translate('My page');
30
+    }
31 31
 
32
-	/** {@inheritdoc} */
33
-	public function getDescription() {
34
-		return /* I18N: Description of the “My page” module */ I18N::translate('A greeting message and useful links for a user.');
35
-	}
32
+    /** {@inheritdoc} */
33
+    public function getDescription() {
34
+        return /* I18N: Description of the “My page” module */ I18N::translate('A greeting message and useful links for a user.');
35
+    }
36 36
 
37
-	/**
38
-	 * Generate the HTML content of this block.
39
-	 *
40
-	 * @param int      $block_id
41
-	 * @param bool     $template
42
-	 * @param string[] $cfg
43
-	 *
44
-	 * @return string
45
-	 */
46
-	public function getBlock($block_id, $template = true, $cfg = array()) {
47
-		global $WT_TREE;
37
+    /**
38
+     * Generate the HTML content of this block.
39
+     *
40
+     * @param int      $block_id
41
+     * @param bool     $template
42
+     * @param string[] $cfg
43
+     *
44
+     * @return string
45
+     */
46
+    public function getBlock($block_id, $template = true, $cfg = array()) {
47
+        global $WT_TREE;
48 48
 
49
-		$id      = $this->getName() . $block_id;
50
-		$class   = $this->getName() . '_block';
51
-		$title   = '<span dir="auto">' . /* I18N: A greeting; %s is the user’s name */ I18N::translate('Welcome %s', Auth::user()->getRealNameHtml()) . '</span>';
52
-		$content = '<table><tr>';
53
-		$content .= '<td><a href="edituser.php"><i class="icon-mypage"></i><br>' . I18N::translate('My account') . '</a></td>';
49
+        $id      = $this->getName() . $block_id;
50
+        $class   = $this->getName() . '_block';
51
+        $title   = '<span dir="auto">' . /* I18N: A greeting; %s is the user’s name */ I18N::translate('Welcome %s', Auth::user()->getRealNameHtml()) . '</span>';
52
+        $content = '<table><tr>';
53
+        $content .= '<td><a href="edituser.php"><i class="icon-mypage"></i><br>' . I18N::translate('My account') . '</a></td>';
54 54
 
55
-		$gedcomid = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid');
55
+        $gedcomid = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid');
56 56
 
57
-		if ($gedcomid) {
58
-			if (Module::isActiveChart($WT_TREE, 'pedigree_chart')) {
59
-				$content .= '<td><a href="pedigree.php?rootid=' . $gedcomid . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-pedigree"></i><br>' . I18N::translate('My pedigree') . '</a></td>';
60
-			}
61
-			$content .= '<td><a href="individual.php?pid=' . $gedcomid . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-indis"></i><br>' . I18N::translate('My individual record') . '</a></td>';
62
-		}
63
-		$content .= '</tr></table>';
57
+        if ($gedcomid) {
58
+            if (Module::isActiveChart($WT_TREE, 'pedigree_chart')) {
59
+                $content .= '<td><a href="pedigree.php?rootid=' . $gedcomid . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-pedigree"></i><br>' . I18N::translate('My pedigree') . '</a></td>';
60
+            }
61
+            $content .= '<td><a href="individual.php?pid=' . $gedcomid . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-indis"></i><br>' . I18N::translate('My individual record') . '</a></td>';
62
+        }
63
+        $content .= '</tr></table>';
64 64
 
65
-		if ($template) {
66
-			return Theme::theme()->formatBlock($id, $title, $class, $content);
67
-		} else {
68
-			return $content;
69
-		}
70
-	}
65
+        if ($template) {
66
+            return Theme::theme()->formatBlock($id, $title, $class, $content);
67
+        } else {
68
+            return $content;
69
+        }
70
+    }
71 71
 
72
-	/** {@inheritdoc} */
73
-	public function loadAjax() {
74
-		return false;
75
-	}
72
+    /** {@inheritdoc} */
73
+    public function loadAjax() {
74
+        return false;
75
+    }
76 76
 
77
-	/** {@inheritdoc} */
78
-	public function isUserBlock() {
79
-		return true;
80
-	}
77
+    /** {@inheritdoc} */
78
+    public function isUserBlock() {
79
+        return true;
80
+    }
81 81
 
82
-	/** {@inheritdoc} */
83
-	public function isGedcomBlock() {
84
-		return false;
85
-	}
82
+    /** {@inheritdoc} */
83
+    public function isGedcomBlock() {
84
+        return false;
85
+    }
86 86
 
87
-	/**
88
-	 * An HTML form to edit block settings
89
-	 *
90
-	 * @param int $block_id
91
-	 */
92
-	public function configureBlock($block_id) {
93
-	}
87
+    /**
88
+     * An HTML form to edit block settings
89
+     *
90
+     * @param int $block_id
91
+     */
92
+    public function configureBlock($block_id) {
93
+    }
94 94
 }
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,14 +23,17 @@  discard block
 block discarded – undo
23 23
 /**
24 24
  * Class UserWelcomeModule
25 25
  */
26
-class UserWelcomeModule extends AbstractModule implements ModuleBlockInterface {
26
+class UserWelcomeModule extends AbstractModule implements ModuleBlockInterface
27
+{
27 28
 	/** {@inheritdoc} */
28
-	public function getTitle() {
29
+	public function getTitle()
30
+	{
29 31
 		return /* I18N: Name of a module */ I18N::translate('My page');
30 32
 	}
31 33
 
32 34
 	/** {@inheritdoc} */
33
-	public function getDescription() {
35
+	public function getDescription()
36
+	{
34 37
 		return /* I18N: Description of the “My page” module */ I18N::translate('A greeting message and useful links for a user.');
35 38
 	}
36 39
 
@@ -43,7 +46,8 @@  discard block
 block discarded – undo
43 46
 	 *
44 47
 	 * @return string
45 48
 	 */
46
-	public function getBlock($block_id, $template = true, $cfg = array()) {
49
+	public function getBlock($block_id, $template = true, $cfg = array())
50
+	{
47 51
 		global $WT_TREE;
48 52
 
49 53
 		$id      = $this->getName() . $block_id;
@@ -70,17 +74,20 @@  discard block
 block discarded – undo
70 74
 	}
71 75
 
72 76
 	/** {@inheritdoc} */
73
-	public function loadAjax() {
77
+	public function loadAjax()
78
+	{
74 79
 		return false;
75 80
 	}
76 81
 
77 82
 	/** {@inheritdoc} */
78
-	public function isUserBlock() {
83
+	public function isUserBlock()
84
+	{
79 85
 		return true;
80 86
 	}
81 87
 
82 88
 	/** {@inheritdoc} */
83
-	public function isGedcomBlock() {
89
+	public function isGedcomBlock()
90
+	{
84 91
 		return false;
85 92
 	}
86 93
 
@@ -89,6 +96,7 @@  discard block
 block discarded – undo
89 96
 	 *
90 97
 	 * @param int $block_id
91 98
 	 */
92
-	public function configureBlock($block_id) {
99
+	public function configureBlock($block_id)
100
+	{
93 101
 	}
94 102
 }
Please login to merge, or discard this patch.
app/Module/UserMessagesModule.php 3 patches
Indentation   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -28,162 +28,162 @@
 block discarded – undo
28 28
  * Class UserMessagesModule
29 29
  */
30 30
 class UserMessagesModule extends AbstractModule implements ModuleBlockInterface {
31
-	/** {@inheritdoc} */
32
-	public function getTitle() {
33
-		return /* I18N: Name of a module */ I18N::translate('Messages');
34
-	}
35
-
36
-	/** {@inheritdoc} */
37
-	public function getDescription() {
38
-		return /* I18N: Description of the “Messages” module */ I18N::translate('Communicate directly with other users, using private messages.');
39
-	}
40
-
41
-	/**
42
-	 * This is a general purpose hook, allowing modules to respond to routes
43
-	 * of the form module.php?mod=FOO&mod_action=BAR
44
-	 *
45
-	 * @param string $mod_action
46
-	 */
47
-	public function modAction($mod_action) {
48
-		switch ($mod_action) {
49
-		case 'delete':
50
-			$stmt = Database::prepare("DELETE FROM `##message` WHERE user_id = :user_id AND message_id = :message_id");
51
-
52
-			foreach (Filter::postArray('message_id') as $id) {
53
-				$stmt->execute(array(
54
-					'message_id' => $id,
55
-					'user_id'    => Auth::id(),
56
-				));
57
-			}
58
-		}
59
-
60
-		$ged   = Filter::post('ged');
61
-		$ctype = Filter::post('ctype', 'user|gedcom', 'user');
62
-
63
-		header('Location: ' . WT_BASE_URL . 'index.php?ged=' . Filter::escapeUrl($ged) . '&ctype=' . $ctype);
64
-	}
65
-
66
-	/**
67
-	 * Generate the HTML content of this block.
68
-	 *
69
-	 * @param int      $block_id
70
-	 * @param bool     $template
71
-	 * @param string[] $cfg
72
-	 *
73
-	 * @return string
74
-	 */
75
-	public function getBlock($block_id, $template = true, $cfg = array()) {
76
-		global $ctype, $WT_TREE;
77
-
78
-		$block = $this->getBlockSetting($block_id, 'block', '1');
79
-		foreach (array('block') as $name) {
80
-			if (array_key_exists($name, $cfg)) {
81
-				$$name = $cfg[$name];
82
-			}
83
-		}
84
-		$messages = Database::prepare("SELECT message_id, sender, subject, body, UNIX_TIMESTAMP(created) AS created FROM `##message` WHERE user_id=? ORDER BY message_id DESC")
85
-			->execute(array(Auth::id()))
86
-			->fetchAll();
87
-
88
-		$count = count($messages);
89
-		$id    = $this->getName() . $block_id;
90
-		$class = $this->getName() . '_block';
91
-		$title = I18N::plural('%s message', '%s messages', $count, I18N::number($count));
92
-		$users = array_filter(User::all(), function (User $user) {
93
-			return $user->getUserId() !== Auth::id() && $user->getPreference('verified_by_admin') && $user->getPreference('contactmethod') !== 'none';
94
-		});
95
-
96
-		$content = '<form id="messageform" name="messageform" method="post" action="module.php?mod=user_messages&mod_action=delete" onsubmit="return confirm(\'' . I18N::translate('Are you sure you want to delete this message? It cannot be retrieved later.') . '\');">';
97
-		$content .= '<input type="hidden" name="ged" value="' . $ctype . '">';
98
-		$content .= '<input type="hidden" name="ctype" value="' . $WT_TREE->getNameHtml() . '">';
99
-		if ($users) {
100
-			$content .= '<label for="touser">' . I18N::translate('Send a message') . '</label>';
101
-			$content .= '<select id="touser" name="touser">';
102
-			$content .= '<option value="">' . I18N::translate('&lt;select&gt;') . '</option>';
103
-			foreach ($users as $user) {
104
-				$content .= sprintf('<option value="%1$s">%2$s - %1$s</option>', Filter::escapeHtml($user->getUserName()), Filter::escapeHtml($user->getRealName()));
105
-			}
106
-			$content .= '</select>';
107
-			$content .= '<input type="button" value="' . I18N::translate('Send') . '" onclick="return message(document.messageform.touser.options[document.messageform.touser.selectedIndex].value, \'messaging2\', \'\');"><br><br>';
108
-		}
109
-		if ($messages) {
110
-			$content .= '<table class="list_table"><tr>';
111
-			$content .= '<th class="list_label">' . I18N::translate('Delete') . '<br><a href="#" onclick="jQuery(\'#' . $this->getName() . $block_id . ' :checkbox\').prop(\'checked\', true); return false;">' . I18N::translate('All') . '</a></th>';
112
-			$content .= '<th class="list_label">' . I18N::translate('Subject') . '</th>';
113
-			$content .= '<th class="list_label">' . I18N::translate('Date sent') . '</th>';
114
-			$content .= '<th class="list_label">' . I18N::translate('Email address') . '</th>';
115
-			$content .= '</tr>';
116
-			foreach ($messages as $message) {
117
-				$content .= '<tr>';
118
-				$content .= '<td class="list_value_wrap"><input type="checkbox" name="message_id[]" value="' . $message->message_id . '" id="cb_message' . $message->message_id . '"></td>';
119
-				$content .= '<td class="list_value_wrap"><a href="#" onclick="return expand_layer(\'message' . $message->message_id . '\');"><i id="message' . $message->message_id . '_img" class="icon-plus"></i> <b dir="auto">' . Filter::escapeHtml($message->subject) . '</b></a></td>';
120
-				$content .= '<td class="list_value_wrap">' . FunctionsDate::formatTimestamp($message->created + WT_TIMESTAMP_OFFSET) . '</td>';
121
-				$content .= '<td class="list_value_wrap">';
122
-				$user = User::findByIdentifier($message->sender);
123
-				if ($user) {
124
-					$content .= $user->getRealNameHtml();
125
-					$content .= '  - <span dir="auto">' . $user->getEmail() . '</span>';
126
-				} else {
127
-					$content .= '<a href="mailto:' . Filter::escapeHtml($message->sender) . '">' . Filter::escapeHtml($message->sender) . '</a>';
128
-				}
129
-				$content .= '</td>';
130
-				$content .= '</tr>';
131
-				$content .= '<tr><td class="list_value_wrap" colspan="4"><div id="message' . $message->message_id . '" style="display:none;">';
132
-				$content .= '<div dir="auto" style="white-space: pre-wrap;">' . Filter::expandUrls($message->body) . '</div><br>';
133
-				if (strpos($message->subject, /* I18N: When replying to an email, the subject becomes “RE: <subject>” */ I18N::translate('RE: ')) !== 0) {
134
-					$message->subject = I18N::translate('RE: ') . $message->subject;
135
-				}
136
-				if ($user) {
137
-					$content .= '<button type="button" onclick="reply(\'' . Filter::escapeJs($message->sender) . '\', \'' . Filter::escapeJs($message->subject) . '\'); return false;">' . I18N::translate('Reply') . '</button> ';
138
-				}
139
-				$content .= '<button type="button" onclick="if (confirm(\'' . I18N::translate('Are you sure you want to delete this message? It cannot be retrieved later.') . '\')) {jQuery(\'#messageform :checkbox\').prop(\'checked\', false); jQuery(\'#cb_message' . $message->message_id . '\').prop(\'checked\', true); document.messageform.submit();}">' . I18N::translate('Delete') . '</button></div></td></tr>';
140
-			}
141
-			$content .= '</table>';
142
-			$content .= '<p><button type="submit">' . I18N::translate('Delete selected messages') . '</button></p>';
143
-		}
144
-		$content .= '</form>';
145
-
146
-		if ($template) {
147
-			if ($block) {
148
-				$class .= ' small_inner_block';
149
-			}
150
-
151
-			return Theme::theme()->formatBlock($id, $title, $class, $content);
152
-		} else {
153
-			return $content;
154
-		}
155
-	}
156
-
157
-	/** {@inheritdoc} */
158
-	public function loadAjax() {
159
-		return false;
160
-	}
161
-
162
-	/** {@inheritdoc} */
163
-	public function isUserBlock() {
164
-		return true;
165
-	}
166
-
167
-	/** {@inheritdoc} */
168
-	public function isGedcomBlock() {
169
-		return false;
170
-	}
171
-
172
-	/**
173
-	 * An HTML form to edit block settings
174
-	 *
175
-	 * @param int $block_id
176
-	 */
177
-	public function configureBlock($block_id) {
178
-		if (Filter::postBool('save') && Filter::checkCsrf()) {
179
-			$this->setBlockSetting($block_id, 'block', Filter::postBool('block'));
180
-		}
181
-
182
-		$block = $this->getBlockSetting($block_id, 'block', '1');
183
-		echo '<tr><td class="descriptionbox wrap width33">';
184
-		echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow');
185
-		echo '</td><td class="optionbox">';
186
-		echo FunctionsEdit::editFieldYesNo('block', $block);
187
-		echo '</td></tr>';
188
-	}
31
+    /** {@inheritdoc} */
32
+    public function getTitle() {
33
+        return /* I18N: Name of a module */ I18N::translate('Messages');
34
+    }
35
+
36
+    /** {@inheritdoc} */
37
+    public function getDescription() {
38
+        return /* I18N: Description of the “Messages” module */ I18N::translate('Communicate directly with other users, using private messages.');
39
+    }
40
+
41
+    /**
42
+     * This is a general purpose hook, allowing modules to respond to routes
43
+     * of the form module.php?mod=FOO&mod_action=BAR
44
+     *
45
+     * @param string $mod_action
46
+     */
47
+    public function modAction($mod_action) {
48
+        switch ($mod_action) {
49
+        case 'delete':
50
+            $stmt = Database::prepare("DELETE FROM `##message` WHERE user_id = :user_id AND message_id = :message_id");
51
+
52
+            foreach (Filter::postArray('message_id') as $id) {
53
+                $stmt->execute(array(
54
+                    'message_id' => $id,
55
+                    'user_id'    => Auth::id(),
56
+                ));
57
+            }
58
+        }
59
+
60
+        $ged   = Filter::post('ged');
61
+        $ctype = Filter::post('ctype', 'user|gedcom', 'user');
62
+
63
+        header('Location: ' . WT_BASE_URL . 'index.php?ged=' . Filter::escapeUrl($ged) . '&ctype=' . $ctype);
64
+    }
65
+
66
+    /**
67
+     * Generate the HTML content of this block.
68
+     *
69
+     * @param int      $block_id
70
+     * @param bool     $template
71
+     * @param string[] $cfg
72
+     *
73
+     * @return string
74
+     */
75
+    public function getBlock($block_id, $template = true, $cfg = array()) {
76
+        global $ctype, $WT_TREE;
77
+
78
+        $block = $this->getBlockSetting($block_id, 'block', '1');
79
+        foreach (array('block') as $name) {
80
+            if (array_key_exists($name, $cfg)) {
81
+                $$name = $cfg[$name];
82
+            }
83
+        }
84
+        $messages = Database::prepare("SELECT message_id, sender, subject, body, UNIX_TIMESTAMP(created) AS created FROM `##message` WHERE user_id=? ORDER BY message_id DESC")
85
+            ->execute(array(Auth::id()))
86
+            ->fetchAll();
87
+
88
+        $count = count($messages);
89
+        $id    = $this->getName() . $block_id;
90
+        $class = $this->getName() . '_block';
91
+        $title = I18N::plural('%s message', '%s messages', $count, I18N::number($count));
92
+        $users = array_filter(User::all(), function (User $user) {
93
+            return $user->getUserId() !== Auth::id() && $user->getPreference('verified_by_admin') && $user->getPreference('contactmethod') !== 'none';
94
+        });
95
+
96
+        $content = '<form id="messageform" name="messageform" method="post" action="module.php?mod=user_messages&mod_action=delete" onsubmit="return confirm(\'' . I18N::translate('Are you sure you want to delete this message? It cannot be retrieved later.') . '\');">';
97
+        $content .= '<input type="hidden" name="ged" value="' . $ctype . '">';
98
+        $content .= '<input type="hidden" name="ctype" value="' . $WT_TREE->getNameHtml() . '">';
99
+        if ($users) {
100
+            $content .= '<label for="touser">' . I18N::translate('Send a message') . '</label>';
101
+            $content .= '<select id="touser" name="touser">';
102
+            $content .= '<option value="">' . I18N::translate('&lt;select&gt;') . '</option>';
103
+            foreach ($users as $user) {
104
+                $content .= sprintf('<option value="%1$s">%2$s - %1$s</option>', Filter::escapeHtml($user->getUserName()), Filter::escapeHtml($user->getRealName()));
105
+            }
106
+            $content .= '</select>';
107
+            $content .= '<input type="button" value="' . I18N::translate('Send') . '" onclick="return message(document.messageform.touser.options[document.messageform.touser.selectedIndex].value, \'messaging2\', \'\');"><br><br>';
108
+        }
109
+        if ($messages) {
110
+            $content .= '<table class="list_table"><tr>';
111
+            $content .= '<th class="list_label">' . I18N::translate('Delete') . '<br><a href="#" onclick="jQuery(\'#' . $this->getName() . $block_id . ' :checkbox\').prop(\'checked\', true); return false;">' . I18N::translate('All') . '</a></th>';
112
+            $content .= '<th class="list_label">' . I18N::translate('Subject') . '</th>';
113
+            $content .= '<th class="list_label">' . I18N::translate('Date sent') . '</th>';
114
+            $content .= '<th class="list_label">' . I18N::translate('Email address') . '</th>';
115
+            $content .= '</tr>';
116
+            foreach ($messages as $message) {
117
+                $content .= '<tr>';
118
+                $content .= '<td class="list_value_wrap"><input type="checkbox" name="message_id[]" value="' . $message->message_id . '" id="cb_message' . $message->message_id . '"></td>';
119
+                $content .= '<td class="list_value_wrap"><a href="#" onclick="return expand_layer(\'message' . $message->message_id . '\');"><i id="message' . $message->message_id . '_img" class="icon-plus"></i> <b dir="auto">' . Filter::escapeHtml($message->subject) . '</b></a></td>';
120
+                $content .= '<td class="list_value_wrap">' . FunctionsDate::formatTimestamp($message->created + WT_TIMESTAMP_OFFSET) . '</td>';
121
+                $content .= '<td class="list_value_wrap">';
122
+                $user = User::findByIdentifier($message->sender);
123
+                if ($user) {
124
+                    $content .= $user->getRealNameHtml();
125
+                    $content .= '  - <span dir="auto">' . $user->getEmail() . '</span>';
126
+                } else {
127
+                    $content .= '<a href="mailto:' . Filter::escapeHtml($message->sender) . '">' . Filter::escapeHtml($message->sender) . '</a>';
128
+                }
129
+                $content .= '</td>';
130
+                $content .= '</tr>';
131
+                $content .= '<tr><td class="list_value_wrap" colspan="4"><div id="message' . $message->message_id . '" style="display:none;">';
132
+                $content .= '<div dir="auto" style="white-space: pre-wrap;">' . Filter::expandUrls($message->body) . '</div><br>';
133
+                if (strpos($message->subject, /* I18N: When replying to an email, the subject becomes “RE: <subject>” */ I18N::translate('RE: ')) !== 0) {
134
+                    $message->subject = I18N::translate('RE: ') . $message->subject;
135
+                }
136
+                if ($user) {
137
+                    $content .= '<button type="button" onclick="reply(\'' . Filter::escapeJs($message->sender) . '\', \'' . Filter::escapeJs($message->subject) . '\'); return false;">' . I18N::translate('Reply') . '</button> ';
138
+                }
139
+                $content .= '<button type="button" onclick="if (confirm(\'' . I18N::translate('Are you sure you want to delete this message? It cannot be retrieved later.') . '\')) {jQuery(\'#messageform :checkbox\').prop(\'checked\', false); jQuery(\'#cb_message' . $message->message_id . '\').prop(\'checked\', true); document.messageform.submit();}">' . I18N::translate('Delete') . '</button></div></td></tr>';
140
+            }
141
+            $content .= '</table>';
142
+            $content .= '<p><button type="submit">' . I18N::translate('Delete selected messages') . '</button></p>';
143
+        }
144
+        $content .= '</form>';
145
+
146
+        if ($template) {
147
+            if ($block) {
148
+                $class .= ' small_inner_block';
149
+            }
150
+
151
+            return Theme::theme()->formatBlock($id, $title, $class, $content);
152
+        } else {
153
+            return $content;
154
+        }
155
+    }
156
+
157
+    /** {@inheritdoc} */
158
+    public function loadAjax() {
159
+        return false;
160
+    }
161
+
162
+    /** {@inheritdoc} */
163
+    public function isUserBlock() {
164
+        return true;
165
+    }
166
+
167
+    /** {@inheritdoc} */
168
+    public function isGedcomBlock() {
169
+        return false;
170
+    }
171
+
172
+    /**
173
+     * An HTML form to edit block settings
174
+     *
175
+     * @param int $block_id
176
+     */
177
+    public function configureBlock($block_id) {
178
+        if (Filter::postBool('save') && Filter::checkCsrf()) {
179
+            $this->setBlockSetting($block_id, 'block', Filter::postBool('block'));
180
+        }
181
+
182
+        $block = $this->getBlockSetting($block_id, 'block', '1');
183
+        echo '<tr><td class="descriptionbox wrap width33">';
184
+        echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow');
185
+        echo '</td><td class="optionbox">';
186
+        echo FunctionsEdit::editFieldYesNo('block', $block);
187
+        echo '</td></tr>';
188
+    }
189 189
 }
Please login to merge, or discard this patch.
Switch Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -46,15 +46,15 @@
 block discarded – undo
46 46
 	 */
47 47
 	public function modAction($mod_action) {
48 48
 		switch ($mod_action) {
49
-		case 'delete':
50
-			$stmt = Database::prepare("DELETE FROM `##message` WHERE user_id = :user_id AND message_id = :message_id");
51
-
52
-			foreach (Filter::postArray('message_id') as $id) {
53
-				$stmt->execute(array(
54
-					'message_id' => $id,
55
-					'user_id'    => Auth::id(),
56
-				));
57
-			}
49
+		    case 'delete':
50
+			    $stmt = Database::prepare("DELETE FROM `##message` WHERE user_id = :user_id AND message_id = :message_id");
51
+
52
+			    foreach (Filter::postArray('message_id') as $id) {
53
+				    $stmt->execute(array(
54
+					    'message_id' => $id,
55
+					    'user_id'    => Auth::id(),
56
+				    ));
57
+			    }
58 58
 		}
59 59
 
60 60
 		$ged   = Filter::post('ged');
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -27,14 +27,17 @@  discard block
 block discarded – undo
27 27
 /**
28 28
  * Class UserMessagesModule
29 29
  */
30
-class UserMessagesModule extends AbstractModule implements ModuleBlockInterface {
30
+class UserMessagesModule extends AbstractModule implements ModuleBlockInterface
31
+{
31 32
 	/** {@inheritdoc} */
32
-	public function getTitle() {
33
+	public function getTitle()
34
+	{
33 35
 		return /* I18N: Name of a module */ I18N::translate('Messages');
34 36
 	}
35 37
 
36 38
 	/** {@inheritdoc} */
37
-	public function getDescription() {
39
+	public function getDescription()
40
+	{
38 41
 		return /* I18N: Description of the “Messages” module */ I18N::translate('Communicate directly with other users, using private messages.');
39 42
 	}
40 43
 
@@ -44,7 +47,8 @@  discard block
 block discarded – undo
44 47
 	 *
45 48
 	 * @param string $mod_action
46 49
 	 */
47
-	public function modAction($mod_action) {
50
+	public function modAction($mod_action)
51
+	{
48 52
 		switch ($mod_action) {
49 53
 		case 'delete':
50 54
 			$stmt = Database::prepare("DELETE FROM `##message` WHERE user_id = :user_id AND message_id = :message_id");
@@ -72,7 +76,8 @@  discard block
 block discarded – undo
72 76
 	 *
73 77
 	 * @return string
74 78
 	 */
75
-	public function getBlock($block_id, $template = true, $cfg = array()) {
79
+	public function getBlock($block_id, $template = true, $cfg = array())
80
+	{
76 81
 		global $ctype, $WT_TREE;
77 82
 
78 83
 		$block = $this->getBlockSetting($block_id, 'block', '1');
@@ -155,17 +160,20 @@  discard block
 block discarded – undo
155 160
 	}
156 161
 
157 162
 	/** {@inheritdoc} */
158
-	public function loadAjax() {
163
+	public function loadAjax()
164
+	{
159 165
 		return false;
160 166
 	}
161 167
 
162 168
 	/** {@inheritdoc} */
163
-	public function isUserBlock() {
169
+	public function isUserBlock()
170
+	{
164 171
 		return true;
165 172
 	}
166 173
 
167 174
 	/** {@inheritdoc} */
168
-	public function isGedcomBlock() {
175
+	public function isGedcomBlock()
176
+	{
169 177
 		return false;
170 178
 	}
171 179
 
@@ -174,7 +182,8 @@  discard block
 block discarded – undo
174 182
 	 *
175 183
 	 * @param int $block_id
176 184
 	 */
177
-	public function configureBlock($block_id) {
185
+	public function configureBlock($block_id)
186
+	{
178 187
 		if (Filter::postBool('save') && Filter::checkCsrf()) {
179 188
 			$this->setBlockSetting($block_id, 'block', Filter::postBool('block'));
180 189
 		}
Please login to merge, or discard this patch.
app/Module/RelatedIndividualsReportModule.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -23,42 +23,42 @@
 block discarded – undo
23 23
  * Class RelatedIndividualsReportModule
24 24
  */
25 25
 class RelatedIndividualsReportModule 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 report */ I18N::translate('Related individuals');
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 report */ I18N::translate('Related individuals');
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 “Related individuals” module */ I18N::translate('A report of the individuals that are closely related to an individual.');
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 “Related individuals” module */ I18N::translate('A report of the individuals that are closely related to an individual.');
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_PRIVATE;
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_PRIVATE;
47
+    }
48 48
 
49
-	/**
50
-	 * Return a menu item for this report.
51
-	 *
52
-	 * @return Menu
53
-	 */
54
-	public function getReportMenu() {
55
-		global $controller, $WT_TREE;
49
+    /**
50
+     * Return a menu item for this report.
51
+     *
52
+     * @return Menu
53
+     */
54
+    public function getReportMenu() {
55
+        global $controller, $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&amp;pid=' . $controller->getSignificantIndividual()->getXref(),
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&amp;pid=' . $controller->getSignificantIndividual()->getXref(),
60
+            'menu-report-' . $this->getName(),
61
+            array('rel' => 'nofollow')
62
+        );
63
+    }
64 64
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,15 +22,18 @@  discard block
 block discarded – undo
22 22
 /**
23 23
  * Class RelatedIndividualsReportModule
24 24
  */
25
-class RelatedIndividualsReportModule extends AbstractModule implements ModuleReportInterface {
25
+class RelatedIndividualsReportModule extends AbstractModule implements ModuleReportInterface
26
+{
26 27
 	/** {@inheritdoc} */
27
-	public function getTitle() {
28
+	public function getTitle()
29
+	{
28 30
 		// This text also appears in the .XML file - update both together
29 31
 		return /* I18N: Name of a report */ I18N::translate('Related individuals');
30 32
 	}
31 33
 
32 34
 	/** {@inheritdoc} */
33
-	public function getDescription() {
35
+	public function getDescription()
36
+	{
34 37
 		// This text also appears in the .XML file - update both together
35 38
 		return /* I18N: Description of the “Related individuals” module */ I18N::translate('A report of the individuals that are closely related to an individual.');
36 39
 	}
@@ -42,7 +45,8 @@  discard block
 block discarded – undo
42 45
 	 *
43 46
 	 * @return int
44 47
 	 */
45
-	public function defaultAccessLevel() {
48
+	public function defaultAccessLevel()
49
+	{
46 50
 		return Auth::PRIV_PRIVATE;
47 51
 	}
48 52
 
@@ -51,7 +55,8 @@  discard block
 block discarded – undo
51 55
 	 *
52 56
 	 * @return Menu
53 57
 	 */
54
-	public function getReportMenu() {
58
+	public function getReportMenu()
59
+	{
55 60
 		global $controller, $WT_TREE;
56 61
 
57 62
 		return new Menu(
Please login to merge, or discard this patch.
app/Module/CensusAssistantModule.php 3 patches
Indentation   +370 added lines, -370 removed lines patch added patch discarded remove patch
@@ -34,110 +34,110 @@  discard block
 block discarded – undo
34 34
  * Class CensusAssistantModule
35 35
  */
36 36
 class CensusAssistantModule extends AbstractModule {
37
-	/** {@inheritdoc} */
38
-	public function getTitle() {
39
-		return /* I18N: Name of a module */ I18N::translate('Census assistant');
40
-	}
41
-
42
-	/** {@inheritdoc} */
43
-	public function getDescription() {
44
-		return /* I18N: Description of the “Census assistant” module */ I18N::translate('An alternative way to enter census transcripts and link them to individuals.');
45
-	}
46
-
47
-	/**
48
-	 * This is a general purpose hook, allowing modules to respond to routes
49
-	 * of the form module.php?mod=FOO&mod_action=BAR
50
-	 *
51
-	 * @param string $mod_action
52
-	 */
53
-	public function modAction($mod_action) {
54
-		switch ($mod_action) {
55
-		case 'census_find':
56
-			self::censusFind();
57
-			break;
58
-		case 'media_find':
59
-			self::mediaFind();
60
-			break;
61
-		case 'media_query_3a':
62
-			self::mediaQuery();
63
-			break;
64
-		default:
65
-			http_response_code(404);
66
-		}
67
-	}
68
-
69
-	/**
70
-	 * Find an individual.
71
-	 */
72
-	private static function censusFind() {
73
-		global $WT_TREE;
74
-
75
-		$controller = new SimpleController;
76
-		$filter     = Filter::get('filter');
77
-		$action     = Filter::get('action');
78
-		$census     = Filter::get('census');
79
-		$census     = new $census;
80
-
81
-		$controller
82
-			->restrictAccess($census instanceof CensusInterface)
83
-			->setPageTitle(I18N::translate('Find an individual'))
84
-			->pageHeader();
85
-
86
-		echo '<table class="list_table width90" border="0">';
87
-		echo '<tr><td style="padding: 10px;" class="facts_label03 width90">';
88
-		echo I18N::translate('Find an individual');
89
-		echo '</td>';
90
-		echo '</table>';
91
-		echo '<br>';
92
-
93
-		if ($action == 'filter') {
94
-			$filter       = trim($filter);
95
-			$filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter));
96
-
97
-			// Output Individual for GEDFact Assistant ======================
98
-			echo '<table class="list_table width90">';
99
-			$myindilist = FunctionsDb::searchIndividualNames($filter_array, array($WT_TREE));
100
-			if ($myindilist) {
101
-				echo '<tr><td class="list_value_wrap"><ul>';
102
-				usort($myindilist, '\Fisharebest\Webtrees\GedcomRecord::compare');
103
-				foreach ($myindilist as $indi) {
104
-					echo '<li>';
105
-					echo '<a href="#" onclick="window.opener.appendCensusRow(\'' . Filter::escapeJs(self::censusTableRow($census, $indi, null)) . '\'); window.close();">';
106
-					echo '<b>' . $indi->getFullName() . '</b>';
107
-					echo '</a>';
108
-					echo $indi->formatFirstMajorFact(WT_EVENTS_BIRT, 1);
109
-					echo $indi->formatFirstMajorFact(WT_EVENTS_DEAT, 1);
110
-					echo '<hr>';
111
-					echo '</li>';
112
-				}
113
-				echo '</ul></td></tr>';
114
-			} else {
115
-				echo '<tr><td class="list_value_wrap">';
116
-				echo I18N::translate('No results found.');
117
-				echo '</td></tr>';
118
-			}
119
-			echo '<tr><td>';
120
-			echo '<button onclick="window.close();">', I18N::translate('close'), '</button>';
121
-			echo '</td></tr>';
122
-			echo '</table>';
123
-		}
124
-	}
125
-
126
-	/**
127
-	 * Find a media object.
128
-	 */
129
-	private static function mediaFind() {
130
-		global $WT_TREE;
131
-
132
-		$controller = new SimpleController;
133
-		$filter     = Filter::get('filter');
134
-		$multiple   = Filter::getBool('multiple');
135
-
136
-		$controller
137
-			->setPageTitle(I18N::translate('Find an individual'))
138
-			->pageHeader();
139
-
140
-		?>
37
+    /** {@inheritdoc} */
38
+    public function getTitle() {
39
+        return /* I18N: Name of a module */ I18N::translate('Census assistant');
40
+    }
41
+
42
+    /** {@inheritdoc} */
43
+    public function getDescription() {
44
+        return /* I18N: Description of the “Census assistant” module */ I18N::translate('An alternative way to enter census transcripts and link them to individuals.');
45
+    }
46
+
47
+    /**
48
+     * This is a general purpose hook, allowing modules to respond to routes
49
+     * of the form module.php?mod=FOO&mod_action=BAR
50
+     *
51
+     * @param string $mod_action
52
+     */
53
+    public function modAction($mod_action) {
54
+        switch ($mod_action) {
55
+        case 'census_find':
56
+            self::censusFind();
57
+            break;
58
+        case 'media_find':
59
+            self::mediaFind();
60
+            break;
61
+        case 'media_query_3a':
62
+            self::mediaQuery();
63
+            break;
64
+        default:
65
+            http_response_code(404);
66
+        }
67
+    }
68
+
69
+    /**
70
+     * Find an individual.
71
+     */
72
+    private static function censusFind() {
73
+        global $WT_TREE;
74
+
75
+        $controller = new SimpleController;
76
+        $filter     = Filter::get('filter');
77
+        $action     = Filter::get('action');
78
+        $census     = Filter::get('census');
79
+        $census     = new $census;
80
+
81
+        $controller
82
+            ->restrictAccess($census instanceof CensusInterface)
83
+            ->setPageTitle(I18N::translate('Find an individual'))
84
+            ->pageHeader();
85
+
86
+        echo '<table class="list_table width90" border="0">';
87
+        echo '<tr><td style="padding: 10px;" class="facts_label03 width90">';
88
+        echo I18N::translate('Find an individual');
89
+        echo '</td>';
90
+        echo '</table>';
91
+        echo '<br>';
92
+
93
+        if ($action == 'filter') {
94
+            $filter       = trim($filter);
95
+            $filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter));
96
+
97
+            // Output Individual for GEDFact Assistant ======================
98
+            echo '<table class="list_table width90">';
99
+            $myindilist = FunctionsDb::searchIndividualNames($filter_array, array($WT_TREE));
100
+            if ($myindilist) {
101
+                echo '<tr><td class="list_value_wrap"><ul>';
102
+                usort($myindilist, '\Fisharebest\Webtrees\GedcomRecord::compare');
103
+                foreach ($myindilist as $indi) {
104
+                    echo '<li>';
105
+                    echo '<a href="#" onclick="window.opener.appendCensusRow(\'' . Filter::escapeJs(self::censusTableRow($census, $indi, null)) . '\'); window.close();">';
106
+                    echo '<b>' . $indi->getFullName() . '</b>';
107
+                    echo '</a>';
108
+                    echo $indi->formatFirstMajorFact(WT_EVENTS_BIRT, 1);
109
+                    echo $indi->formatFirstMajorFact(WT_EVENTS_DEAT, 1);
110
+                    echo '<hr>';
111
+                    echo '</li>';
112
+                }
113
+                echo '</ul></td></tr>';
114
+            } else {
115
+                echo '<tr><td class="list_value_wrap">';
116
+                echo I18N::translate('No results found.');
117
+                echo '</td></tr>';
118
+            }
119
+            echo '<tr><td>';
120
+            echo '<button onclick="window.close();">', I18N::translate('close'), '</button>';
121
+            echo '</td></tr>';
122
+            echo '</table>';
123
+        }
124
+    }
125
+
126
+    /**
127
+     * Find a media object.
128
+     */
129
+    private static function mediaFind() {
130
+        global $WT_TREE;
131
+
132
+        $controller = new SimpleController;
133
+        $filter     = Filter::get('filter');
134
+        $multiple   = Filter::getBool('multiple');
135
+
136
+        $controller
137
+            ->setPageTitle(I18N::translate('Find an individual'))
138
+            ->pageHeader();
139
+
140
+        ?>
141 141
 		<script>
142 142
 		function pasterow(id, name, gend, yob, age, bpl) {
143 143
 			window.opener.opener.insertRowToTable(id, name, '', gend, '', yob, age, 'Y', '', bpl);
@@ -178,27 +178,27 @@  discard block
 block discarded – undo
178 178
 		</script>
179 179
 
180 180
 		<?php
181
-		echo '<div>';
182
-		echo '<table class="list_table width90" border="0">';
183
-		echo '<tr><td style="padding: 10px;" class="facts_label03 width90">'; // start column for find text header
184
-		echo $controller->getPageTitle();
185
-		echo '</td>';
186
-		echo '</tr>';
187
-		echo '</table>';
188
-		echo '<br>';
189
-		echo '<button onclick="window.close();">', I18N::translate('close'), '</button>';
190
-		echo '<br>';
191
-
192
-		$filter       = trim($filter);
193
-		$filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter));
194
-		echo '<table class="tabs_table width90"><tr>';
195
-		$myindilist = FunctionsDb::searchIndividualNames($filter_array, array($WT_TREE));
196
-		if ($myindilist) {
197
-			echo '<td class="list_value_wrap"><ul>';
198
-			usort($myindilist, '\Fisharebest\Webtrees\GedcomRecord::compare');
199
-			foreach ($myindilist as $indi) {
200
-				$nam = Filter::escapeHtml($indi->getFullName());
201
-				echo "<li><a href=\"#\" onclick=\"pasterow(
181
+        echo '<div>';
182
+        echo '<table class="list_table width90" border="0">';
183
+        echo '<tr><td style="padding: 10px;" class="facts_label03 width90">'; // start column for find text header
184
+        echo $controller->getPageTitle();
185
+        echo '</td>';
186
+        echo '</tr>';
187
+        echo '</table>';
188
+        echo '<br>';
189
+        echo '<button onclick="window.close();">', I18N::translate('close'), '</button>';
190
+        echo '<br>';
191
+
192
+        $filter       = trim($filter);
193
+        $filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter));
194
+        echo '<table class="tabs_table width90"><tr>';
195
+        $myindilist = FunctionsDb::searchIndividualNames($filter_array, array($WT_TREE));
196
+        if ($myindilist) {
197
+            echo '<td class="list_value_wrap"><ul>';
198
+            usort($myindilist, '\Fisharebest\Webtrees\GedcomRecord::compare');
199
+            foreach ($myindilist as $indi) {
200
+                $nam = Filter::escapeHtml($indi->getFullName());
201
+                echo "<li><a href=\"#\" onclick=\"pasterow(
202 202
 					'" . $indi->getXref() . "' ,
203 203
 					'" . $nam . "' ,
204 204
 					'" . $indi->getSex() . "' ,
@@ -207,44 +207,44 @@  discard block
 block discarded – undo
207 207
 					'" . $indi->getBirthPlace() . "'); return false;\">
208 208
 					<b>" . $indi->getFullName() . "</b>&nbsp;&nbsp;&nbsp;";
209 209
 
210
-				$born = GedcomTag::getLabel('BIRT');
211
-				echo "</span><br><span class=\"list_item\">", $born, " ", $indi->getBirthYear(), "&nbsp;&nbsp;&nbsp;", $indi->getBirthPlace(), "</span></a></li>";
212
-				echo "<hr>";
213
-			}
214
-			echo '</ul></td></tr><tr><td class="list_label">', I18N::translate('Total individuals: %s', count($myindilist)), '</tr></td>';
215
-		} else {
216
-			echo "<td class=\"list_value_wrap\">";
217
-			echo I18N::translate('No results found.');
218
-			echo "</td></tr>";
219
-		}
220
-		echo "</table>";
221
-		echo '</div>';
222
-	}
223
-
224
-	/**
225
-	 * Search for a media object.
226
-	 */
227
-	private static function mediaQuery() {
228
-		global $WT_TREE;
229
-
230
-		$iid2 = Filter::get('iid', WT_REGEX_XREF);
231
-
232
-		$controller = new SimpleController;
233
-		$controller
234
-			->setPageTitle(I18N::translate('Link to an existing media object'))
235
-			->pageHeader();
236
-
237
-		$record = GedcomRecord::getInstance($iid2, $WT_TREE);
238
-		if ($record) {
239
-			$headjs = '';
240
-			if ($record instanceof Family) {
241
-				if ($record->getHusband()) {
242
-					$headjs = $record->getHusband()->getXref();
243
-				} elseif ($record->getWife()) {
244
-					$headjs = $record->getWife()->getXref();
245
-				}
246
-			}
247
-			?>
210
+                $born = GedcomTag::getLabel('BIRT');
211
+                echo "</span><br><span class=\"list_item\">", $born, " ", $indi->getBirthYear(), "&nbsp;&nbsp;&nbsp;", $indi->getBirthPlace(), "</span></a></li>";
212
+                echo "<hr>";
213
+            }
214
+            echo '</ul></td></tr><tr><td class="list_label">', I18N::translate('Total individuals: %s', count($myindilist)), '</tr></td>';
215
+        } else {
216
+            echo "<td class=\"list_value_wrap\">";
217
+            echo I18N::translate('No results found.');
218
+            echo "</td></tr>";
219
+        }
220
+        echo "</table>";
221
+        echo '</div>';
222
+    }
223
+
224
+    /**
225
+     * Search for a media object.
226
+     */
227
+    private static function mediaQuery() {
228
+        global $WT_TREE;
229
+
230
+        $iid2 = Filter::get('iid', WT_REGEX_XREF);
231
+
232
+        $controller = new SimpleController;
233
+        $controller
234
+            ->setPageTitle(I18N::translate('Link to an existing media object'))
235
+            ->pageHeader();
236
+
237
+        $record = GedcomRecord::getInstance($iid2, $WT_TREE);
238
+        if ($record) {
239
+            $headjs = '';
240
+            if ($record instanceof Family) {
241
+                if ($record->getHusband()) {
242
+                    $headjs = $record->getHusband()->getXref();
243
+                } elseif ($record->getWife()) {
244
+                    $headjs = $record->getWife()->getXref();
245
+                }
246
+            }
247
+            ?>
248 248
 			<script>
249 249
 				function insertId() {
250 250
 					if (window.opener.document.getElementById('addlinkQueue')) {
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 				}
256 256
 			</script>
257 257
 			<?php
258
-		} else {
259
-			?>
258
+        } else {
259
+            ?>
260 260
 			<script>
261 261
 				function insertId() {
262 262
 					window.opener.alert('<?php echo $iid2; ?> - <?php echo I18N::translate('Not a valid individual, family, or source ID'); ?>');
@@ -264,178 +264,178 @@  discard block
 block discarded – undo
264 264
 				}
265 265
 			</script>
266 266
 			<?php
267
-		}
268
-		?>
267
+        }
268
+        ?>
269 269
 		<script>window.onLoad = insertId();</script>
270 270
 		<?php
271
-	}
272
-
273
-	/**
274
-	 * Convert custom markup into HTML
275
-	 *
276
-	 * @param Note $note
277
-	 *
278
-	 * @return string
279
-	 */
280
-	public static function formatCensusNote(Note $note) {
281
-		global $WT_TREE;
282
-
283
-		if (preg_match('/(.*)((?:\n.*)*)\n\.start_formatted_area\.\n(.+)\n(.+(?:\n.+)*)\n.end_formatted_area\.((?:\n.*)*)/', $note->getNote(), $match)) {
284
-			// This looks like a census-assistant shared note
285
-			$title     = Filter::escapeHtml($match[1]);
286
-			$preamble  = Filter::escapeHtml($match[2]);
287
-			$header    = Filter::escapeHtml($match[3]);
288
-			$data      = Filter::escapeHtml($match[4]);
289
-			$postamble = Filter::escapeHtml($match[5]);
290
-
291
-			// Get the column headers for the census to which this note refers
292
-			// requires the fact place & date to match the specific census
293
-			// censusPlace() (Soundex match) and censusDate() functions
294
-			$fmt_headers   = array();
295
-			$linkedRecords = array_merge($note->linkedIndividuals('NOTE'), $note->linkedFamilies('NOTE'));
296
-			$firstRecord   = array_shift($linkedRecords);
297
-			if ($firstRecord) {
298
-				$countryCode = '';
299
-				$date        = '';
300
-				foreach ($firstRecord->getFacts('CENS') as $fact) {
301
-					if (trim($fact->getAttribute('NOTE'), '@') === $note->getXref()) {
302
-						$date        = $fact->getAttribute('DATE');
303
-						$place       = explode(',', strip_tags($fact->getPlace()->getFullName()));
304
-						$countryCode = Soundex::daitchMokotoff(array_pop($place));
305
-						break;
306
-					}
307
-				}
308
-
309
-				foreach (Census::allCensusPlaces() as $censusPlace) {
310
-					if (Soundex::compare($countryCode, Soundex::daitchMokotoff($censusPlace->censusPlace()))) {
311
-						foreach ($censusPlace->allCensusDates() as $census) {
312
-							if ($census->censusDate() == $date) {
313
-								foreach ($census->columns() as $column) {
314
-									$abbrev = $column->abbreviation();
315
-									if ($abbrev) {
316
-										$description          = $column->title() ? $column->title() : I18N::translate('Description unavailable');
317
-										$fmt_headers[$abbrev] = '<span title="' . $description . '">' . $abbrev . '</span>';
318
-									}
319
-								}
320
-								break 2;
321
-							}
322
-						}
323
-					}
324
-				}
325
-			}
326
-			// Substitute header labels and format as HTML
327
-			$thead = '<tr><th>' . strtr(str_replace('|', '</th><th>', $header), $fmt_headers) . '</th></tr>';
328
-			$thead = str_replace('.b.', '', $thead);
329
-
330
-			// Format data as HTML
331
-			$tbody = '';
332
-			foreach (explode("\n", $data) as $row) {
333
-				$tbody .= '<tr>';
334
-				foreach (explode('|', $row) as $column) {
335
-					$tbody .= '<td>' . $column . '</td>';
336
-				}
337
-				$tbody .= '</tr>';
338
-			}
339
-
340
-			return
341
-				$title . "\n" . // The newline allows the framework to expand the details and turn the first line into a link
342
-				'<div class="markdown">' .
343
-				'<p>' . $preamble . '</p>' .
344
-				'<table>' .
345
-				'<thead>' . $thead . '</thead>' .
346
-				'<tbody>' . $tbody . '</tbody>' .
347
-				'</table>' .
348
-				'<p>' . $postamble . '</p>' .
349
-				'</div>';
350
-		} else {
351
-			// Not a census-assistant shared note - apply default formatting
352
-			return Filter::formatText($note->getNote(), $WT_TREE);
353
-		}
354
-	}
355
-
356
-	/**
357
-	 * Generate an HTML row of data for the census header
358
-	 *
359
-	 * Add prefix cell (store XREF and drag/drop)
360
-	 * Add suffix cell (delete button)
361
-	 *
362
-	 * @param CensusInterface $census
363
-	 *
364
-	 * @return string
365
-	 */
366
-	public static function censusTableHeader(CensusInterface $census) {
367
-		$html = '';
368
-		foreach ($census->columns() as $column) {
369
-			$html .= '<th title="' . $column->title() . '">' . $column->abbreviation() . '</th>';
370
-		}
371
-
372
-		return '<tr><th hidden></th>' . $html . '<th></th></tr>';
373
-	}
374
-
375
-	/**
376
-	 * Generate an HTML row of data for the census
377
-	 *
378
-	 * Add prefix cell (store XREF and drag/drop)
379
-	 * Add suffix cell (delete button)
380
-	 *
381
-	 * @param CensusInterface $census
382
-	 *
383
-	 * @return string
384
-	 */
385
-	public static function censusTableEmptyRow(CensusInterface $census) {
386
-		return '<tr><td hidden></td>' . str_repeat('<td><input type="text"></td>', count($census->columns())) . '<td><a class="icon-remove" href="#" title="' . I18N::translate('Remove') . '"></a></td></tr>';
387
-	}
388
-
389
-	/**
390
-	 * Generate an HTML row of data for the census
391
-	 *
392
-	 * Add prefix cell (store XREF and drag/drop)
393
-	 * Add suffix cell (delete button)
394
-	 *
395
-	 * @param CensusInterface $census
396
-	 * @param Individual      $individual
397
-	 * @param Individual|null $head
398
-	 *
399
-	 * @return string
400
-	 */
401
-	public static function censusTableRow(CensusInterface $census, Individual $individual, Individual $head = null) {
402
-		$html = '';
403
-		foreach ($census->columns() as $column) {
404
-			$html .= '<td><input type="text" value="' . $column->generate($individual, $head) . '"></td>';
405
-		}
406
-
407
-		return '<tr><td hidden>' . $individual->getXref() . '</td>' . $html . '<td><a class="icon-remove" href="#" title="' . I18N::translate('Remove') . '"></a></td></tr>';
408
-	}
409
-
410
-	/**
411
-	 * Create a family on the census navigator.
412
-	 *
413
-	 * @param CensusInterface $census
414
-	 * @param Family          $family
415
-	 * @param Individual      $head
416
-	 *
417
-	 * @return string
418
-	 */
419
-	public static function censusNavigatorFamily(CensusInterface $census, Family $family, Individual $head) {
420
-		$headImg2 = '<i class="icon-button_head" title="' . I18N::translate('Head of household') . '"></i>';
421
-
422
-		foreach ($family->getSpouses() as $spouse) {
423
-			$menu = new Menu(Functions::getCloseRelationshipName($head, $spouse));
424
-			foreach ($spouse->getChildFamilies() as $grandparents) {
425
-				foreach ($grandparents->getSpouses() as $grandparent) {
426
-					$submenu = new Menu(
427
-						Functions::getCloseRelationshipName($head, $grandparent) . ' - ' . $grandparent->getFullName(),
428
-						'#',
429
-						'',
430
-						array('onclick' => 'return appendCensusRow("' . Filter::escapeJs(self::censusTableRow($census, $grandparent, $head)) . '");')
431
-					);
432
-					$submenu->addClass('submenuitem', '');
433
-					$menu->addSubmenu($submenu);
434
-					$menu->addClass('', 'submenu');
435
-				}
436
-			}
437
-
438
-			?>
271
+    }
272
+
273
+    /**
274
+     * Convert custom markup into HTML
275
+     *
276
+     * @param Note $note
277
+     *
278
+     * @return string
279
+     */
280
+    public static function formatCensusNote(Note $note) {
281
+        global $WT_TREE;
282
+
283
+        if (preg_match('/(.*)((?:\n.*)*)\n\.start_formatted_area\.\n(.+)\n(.+(?:\n.+)*)\n.end_formatted_area\.((?:\n.*)*)/', $note->getNote(), $match)) {
284
+            // This looks like a census-assistant shared note
285
+            $title     = Filter::escapeHtml($match[1]);
286
+            $preamble  = Filter::escapeHtml($match[2]);
287
+            $header    = Filter::escapeHtml($match[3]);
288
+            $data      = Filter::escapeHtml($match[4]);
289
+            $postamble = Filter::escapeHtml($match[5]);
290
+
291
+            // Get the column headers for the census to which this note refers
292
+            // requires the fact place & date to match the specific census
293
+            // censusPlace() (Soundex match) and censusDate() functions
294
+            $fmt_headers   = array();
295
+            $linkedRecords = array_merge($note->linkedIndividuals('NOTE'), $note->linkedFamilies('NOTE'));
296
+            $firstRecord   = array_shift($linkedRecords);
297
+            if ($firstRecord) {
298
+                $countryCode = '';
299
+                $date        = '';
300
+                foreach ($firstRecord->getFacts('CENS') as $fact) {
301
+                    if (trim($fact->getAttribute('NOTE'), '@') === $note->getXref()) {
302
+                        $date        = $fact->getAttribute('DATE');
303
+                        $place       = explode(',', strip_tags($fact->getPlace()->getFullName()));
304
+                        $countryCode = Soundex::daitchMokotoff(array_pop($place));
305
+                        break;
306
+                    }
307
+                }
308
+
309
+                foreach (Census::allCensusPlaces() as $censusPlace) {
310
+                    if (Soundex::compare($countryCode, Soundex::daitchMokotoff($censusPlace->censusPlace()))) {
311
+                        foreach ($censusPlace->allCensusDates() as $census) {
312
+                            if ($census->censusDate() == $date) {
313
+                                foreach ($census->columns() as $column) {
314
+                                    $abbrev = $column->abbreviation();
315
+                                    if ($abbrev) {
316
+                                        $description          = $column->title() ? $column->title() : I18N::translate('Description unavailable');
317
+                                        $fmt_headers[$abbrev] = '<span title="' . $description . '">' . $abbrev . '</span>';
318
+                                    }
319
+                                }
320
+                                break 2;
321
+                            }
322
+                        }
323
+                    }
324
+                }
325
+            }
326
+            // Substitute header labels and format as HTML
327
+            $thead = '<tr><th>' . strtr(str_replace('|', '</th><th>', $header), $fmt_headers) . '</th></tr>';
328
+            $thead = str_replace('.b.', '', $thead);
329
+
330
+            // Format data as HTML
331
+            $tbody = '';
332
+            foreach (explode("\n", $data) as $row) {
333
+                $tbody .= '<tr>';
334
+                foreach (explode('|', $row) as $column) {
335
+                    $tbody .= '<td>' . $column . '</td>';
336
+                }
337
+                $tbody .= '</tr>';
338
+            }
339
+
340
+            return
341
+                $title . "\n" . // The newline allows the framework to expand the details and turn the first line into a link
342
+                '<div class="markdown">' .
343
+                '<p>' . $preamble . '</p>' .
344
+                '<table>' .
345
+                '<thead>' . $thead . '</thead>' .
346
+                '<tbody>' . $tbody . '</tbody>' .
347
+                '</table>' .
348
+                '<p>' . $postamble . '</p>' .
349
+                '</div>';
350
+        } else {
351
+            // Not a census-assistant shared note - apply default formatting
352
+            return Filter::formatText($note->getNote(), $WT_TREE);
353
+        }
354
+    }
355
+
356
+    /**
357
+     * Generate an HTML row of data for the census header
358
+     *
359
+     * Add prefix cell (store XREF and drag/drop)
360
+     * Add suffix cell (delete button)
361
+     *
362
+     * @param CensusInterface $census
363
+     *
364
+     * @return string
365
+     */
366
+    public static function censusTableHeader(CensusInterface $census) {
367
+        $html = '';
368
+        foreach ($census->columns() as $column) {
369
+            $html .= '<th title="' . $column->title() . '">' . $column->abbreviation() . '</th>';
370
+        }
371
+
372
+        return '<tr><th hidden></th>' . $html . '<th></th></tr>';
373
+    }
374
+
375
+    /**
376
+     * Generate an HTML row of data for the census
377
+     *
378
+     * Add prefix cell (store XREF and drag/drop)
379
+     * Add suffix cell (delete button)
380
+     *
381
+     * @param CensusInterface $census
382
+     *
383
+     * @return string
384
+     */
385
+    public static function censusTableEmptyRow(CensusInterface $census) {
386
+        return '<tr><td hidden></td>' . str_repeat('<td><input type="text"></td>', count($census->columns())) . '<td><a class="icon-remove" href="#" title="' . I18N::translate('Remove') . '"></a></td></tr>';
387
+    }
388
+
389
+    /**
390
+     * Generate an HTML row of data for the census
391
+     *
392
+     * Add prefix cell (store XREF and drag/drop)
393
+     * Add suffix cell (delete button)
394
+     *
395
+     * @param CensusInterface $census
396
+     * @param Individual      $individual
397
+     * @param Individual|null $head
398
+     *
399
+     * @return string
400
+     */
401
+    public static function censusTableRow(CensusInterface $census, Individual $individual, Individual $head = null) {
402
+        $html = '';
403
+        foreach ($census->columns() as $column) {
404
+            $html .= '<td><input type="text" value="' . $column->generate($individual, $head) . '"></td>';
405
+        }
406
+
407
+        return '<tr><td hidden>' . $individual->getXref() . '</td>' . $html . '<td><a class="icon-remove" href="#" title="' . I18N::translate('Remove') . '"></a></td></tr>';
408
+    }
409
+
410
+    /**
411
+     * Create a family on the census navigator.
412
+     *
413
+     * @param CensusInterface $census
414
+     * @param Family          $family
415
+     * @param Individual      $head
416
+     *
417
+     * @return string
418
+     */
419
+    public static function censusNavigatorFamily(CensusInterface $census, Family $family, Individual $head) {
420
+        $headImg2 = '<i class="icon-button_head" title="' . I18N::translate('Head of household') . '"></i>';
421
+
422
+        foreach ($family->getSpouses() as $spouse) {
423
+            $menu = new Menu(Functions::getCloseRelationshipName($head, $spouse));
424
+            foreach ($spouse->getChildFamilies() as $grandparents) {
425
+                foreach ($grandparents->getSpouses() as $grandparent) {
426
+                    $submenu = new Menu(
427
+                        Functions::getCloseRelationshipName($head, $grandparent) . ' - ' . $grandparent->getFullName(),
428
+                        '#',
429
+                        '',
430
+                        array('onclick' => 'return appendCensusRow("' . Filter::escapeJs(self::censusTableRow($census, $grandparent, $head)) . '");')
431
+                    );
432
+                    $submenu->addClass('submenuitem', '');
433
+                    $menu->addSubmenu($submenu);
434
+                    $menu->addClass('', 'submenu');
435
+                }
436
+            }
437
+
438
+            ?>
439 439
 			<tr>
440 440
 				<td class="optionbox">
441 441
 					<?php echo $menu->getMenu(); ?>
@@ -454,38 +454,38 @@  discard block
 block discarded – undo
454 454
 				</td>
455 455
 			</tr>
456 456
 			<?php
457
-		}
458
-
459
-		foreach ($family->getChildren() as $child) {
460
-			$menu = new Menu(Functions::getCloseRelationshipName($head, $child));
461
-			foreach ($child->getSpouseFamilies() as $spouse_family) {
462
-				foreach ($spouse_family->getSpouses() as $spouse_family_spouse) {
463
-					if ($spouse_family_spouse != $child) {
464
-						$submenu = new Menu(
465
-							Functions::getCloseRelationshipName($head, $spouse_family_spouse) . ' - ' . $spouse_family_spouse->getFullName(),
466
-							'#',
467
-							'',
468
-							array('onclick' => 'return appendCensusRow("' . Filter::escapeJs(self::censusTableRow($census, $spouse_family_spouse, $head)) . '");')
469
-						);
470
-						$submenu->addClass('submenuitem', '');
471
-						$menu->addSubmenu($submenu);
472
-						$menu->addClass('', 'submenu');
473
-					}
474
-				}
475
-				foreach ($spouse_family->getChildren() as $spouse_family_child) {
476
-					$submenu = new Menu(
477
-						Functions::getCloseRelationshipName($head, $spouse_family_child) . ' - ' . $spouse_family_child->getFullName(),
478
-						'#',
479
-						'',
480
-						array('onclick' => 'return appendCensusRow("' . Filter::escapeJs(self::censusTableRow($census, $spouse_family_child, $head)) . '");')
481
-					);
482
-					$submenu->addClass('submenuitem', '');
483
-					$menu->addSubmenu($submenu);
484
-					$menu->addClass('', 'submenu');
485
-				}
486
-			}
487
-
488
-			?>
457
+        }
458
+
459
+        foreach ($family->getChildren() as $child) {
460
+            $menu = new Menu(Functions::getCloseRelationshipName($head, $child));
461
+            foreach ($child->getSpouseFamilies() as $spouse_family) {
462
+                foreach ($spouse_family->getSpouses() as $spouse_family_spouse) {
463
+                    if ($spouse_family_spouse != $child) {
464
+                        $submenu = new Menu(
465
+                            Functions::getCloseRelationshipName($head, $spouse_family_spouse) . ' - ' . $spouse_family_spouse->getFullName(),
466
+                            '#',
467
+                            '',
468
+                            array('onclick' => 'return appendCensusRow("' . Filter::escapeJs(self::censusTableRow($census, $spouse_family_spouse, $head)) . '");')
469
+                        );
470
+                        $submenu->addClass('submenuitem', '');
471
+                        $menu->addSubmenu($submenu);
472
+                        $menu->addClass('', 'submenu');
473
+                    }
474
+                }
475
+                foreach ($spouse_family->getChildren() as $spouse_family_child) {
476
+                    $submenu = new Menu(
477
+                        Functions::getCloseRelationshipName($head, $spouse_family_child) . ' - ' . $spouse_family_child->getFullName(),
478
+                        '#',
479
+                        '',
480
+                        array('onclick' => 'return appendCensusRow("' . Filter::escapeJs(self::censusTableRow($census, $spouse_family_child, $head)) . '");')
481
+                    );
482
+                    $submenu->addClass('submenuitem', '');
483
+                    $menu->addSubmenu($submenu);
484
+                    $menu->addClass('', 'submenu');
485
+                }
486
+            }
487
+
488
+            ?>
489 489
 			<tr>
490 490
 				<td class="optionbox">
491 491
 					<?php echo $menu->getMenu(); ?>
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 				</td>
505 505
 			</tr>
506 506
 			<?php
507
-		}
508
-		echo '<tr><td><br></td></tr>';
509
-	}
507
+        }
508
+        echo '<tr><td><br></td></tr>';
509
+    }
510 510
 }
Please login to merge, or discard this patch.
Switch Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -52,17 +52,17 @@
 block discarded – undo
52 52
 	 */
53 53
 	public function modAction($mod_action) {
54 54
 		switch ($mod_action) {
55
-		case 'census_find':
56
-			self::censusFind();
57
-			break;
58
-		case 'media_find':
59
-			self::mediaFind();
60
-			break;
61
-		case 'media_query_3a':
62
-			self::mediaQuery();
63
-			break;
64
-		default:
65
-			http_response_code(404);
55
+		    case 'census_find':
56
+			    self::censusFind();
57
+			    break;
58
+		    case 'media_find':
59
+			    self::mediaFind();
60
+			    break;
61
+		    case 'media_query_3a':
62
+			    self::mediaQuery();
63
+			    break;
64
+		    default:
65
+			    http_response_code(404);
66 66
 		}
67 67
 	}
68 68
 
Please login to merge, or discard this patch.
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -33,14 +33,17 @@  discard block
 block discarded – undo
33 33
 /**
34 34
  * Class CensusAssistantModule
35 35
  */
36
-class CensusAssistantModule extends AbstractModule {
36
+class CensusAssistantModule extends AbstractModule
37
+{
37 38
 	/** {@inheritdoc} */
38
-	public function getTitle() {
39
+	public function getTitle()
40
+	{
39 41
 		return /* I18N: Name of a module */ I18N::translate('Census assistant');
40 42
 	}
41 43
 
42 44
 	/** {@inheritdoc} */
43
-	public function getDescription() {
45
+	public function getDescription()
46
+	{
44 47
 		return /* I18N: Description of the “Census assistant” module */ I18N::translate('An alternative way to enter census transcripts and link them to individuals.');
45 48
 	}
46 49
 
@@ -50,7 +53,8 @@  discard block
 block discarded – undo
50 53
 	 *
51 54
 	 * @param string $mod_action
52 55
 	 */
53
-	public function modAction($mod_action) {
56
+	public function modAction($mod_action)
57
+	{
54 58
 		switch ($mod_action) {
55 59
 		case 'census_find':
56 60
 			self::censusFind();
@@ -69,7 +73,8 @@  discard block
 block discarded – undo
69 73
 	/**
70 74
 	 * Find an individual.
71 75
 	 */
72
-	private static function censusFind() {
76
+	private static function censusFind()
77
+	{
73 78
 		global $WT_TREE;
74 79
 
75 80
 		$controller = new SimpleController;
@@ -126,7 +131,8 @@  discard block
 block discarded – undo
126 131
 	/**
127 132
 	 * Find a media object.
128 133
 	 */
129
-	private static function mediaFind() {
134
+	private static function mediaFind()
135
+	{
130 136
 		global $WT_TREE;
131 137
 
132 138
 		$controller = new SimpleController;
@@ -224,7 +230,8 @@  discard block
 block discarded – undo
224 230
 	/**
225 231
 	 * Search for a media object.
226 232
 	 */
227
-	private static function mediaQuery() {
233
+	private static function mediaQuery()
234
+	{
228 235
 		global $WT_TREE;
229 236
 
230 237
 		$iid2 = Filter::get('iid', WT_REGEX_XREF);
@@ -277,7 +284,8 @@  discard block
 block discarded – undo
277 284
 	 *
278 285
 	 * @return string
279 286
 	 */
280
-	public static function formatCensusNote(Note $note) {
287
+	public static function formatCensusNote(Note $note)
288
+	{
281 289
 		global $WT_TREE;
282 290
 
283 291
 		if (preg_match('/(.*)((?:\n.*)*)\n\.start_formatted_area\.\n(.+)\n(.+(?:\n.+)*)\n.end_formatted_area\.((?:\n.*)*)/', $note->getNote(), $match)) {
@@ -363,7 +371,8 @@  discard block
 block discarded – undo
363 371
 	 *
364 372
 	 * @return string
365 373
 	 */
366
-	public static function censusTableHeader(CensusInterface $census) {
374
+	public static function censusTableHeader(CensusInterface $census)
375
+	{
367 376
 		$html = '';
368 377
 		foreach ($census->columns() as $column) {
369 378
 			$html .= '<th title="' . $column->title() . '">' . $column->abbreviation() . '</th>';
@@ -382,7 +391,8 @@  discard block
 block discarded – undo
382 391
 	 *
383 392
 	 * @return string
384 393
 	 */
385
-	public static function censusTableEmptyRow(CensusInterface $census) {
394
+	public static function censusTableEmptyRow(CensusInterface $census)
395
+	{
386 396
 		return '<tr><td hidden></td>' . str_repeat('<td><input type="text"></td>', count($census->columns())) . '<td><a class="icon-remove" href="#" title="' . I18N::translate('Remove') . '"></a></td></tr>';
387 397
 	}
388 398
 
@@ -398,7 +408,8 @@  discard block
 block discarded – undo
398 408
 	 *
399 409
 	 * @return string
400 410
 	 */
401
-	public static function censusTableRow(CensusInterface $census, Individual $individual, Individual $head = null) {
411
+	public static function censusTableRow(CensusInterface $census, Individual $individual, Individual $head = null)
412
+	{
402 413
 		$html = '';
403 414
 		foreach ($census->columns() as $column) {
404 415
 			$html .= '<td><input type="text" value="' . $column->generate($individual, $head) . '"></td>';
@@ -416,7 +427,8 @@  discard block
 block discarded – undo
416 427
 	 *
417 428
 	 * @return string
418 429
 	 */
419
-	public static function censusNavigatorFamily(CensusInterface $census, Family $family, Individual $head) {
430
+	public static function censusNavigatorFamily(CensusInterface $census, Family $family, Individual $head)
431
+	{
420 432
 		$headImg2 = '<i class="icon-button_head" title="' . I18N::translate('Head of household') . '"></i>';
421 433
 
422 434
 		foreach ($family->getSpouses() as $spouse) {
Please login to merge, or discard this patch.
app/Module/FamilyTreeNews/Schema/Migration2.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -23,24 +23,24 @@
 block discarded – undo
23 23
  * Upgrade the database schema from version 2 to version 3.
24 24
  */
25 25
 class Migration2 implements MigrationInterface {
26
-	/** {@inheritDoc} */
27
-	public function upgrade() {
28
-		// Delete any data that might violate the new constraints
29
-		Database::exec(
30
-			"DELETE FROM `##news`" .
31
-			" WHERE user_id   NOT IN (SELECT user_id   FROM `##user`  )" .
32
-			" OR    gedcom_id NOT IN (SELECT gedcom_id FROM `##gedcom`)"
33
-		);
26
+    /** {@inheritDoc} */
27
+    public function upgrade() {
28
+        // Delete any data that might violate the new constraints
29
+        Database::exec(
30
+            "DELETE FROM `##news`" .
31
+            " WHERE user_id   NOT IN (SELECT user_id   FROM `##user`  )" .
32
+            " OR    gedcom_id NOT IN (SELECT gedcom_id FROM `##gedcom`)"
33
+        );
34 34
 
35
-		// Add the new constraints
36
-		try {
37
-			Database::exec(
38
-				"ALTER TABLE `##news`" .
39
-				" ADD FOREIGN KEY `##news_fk1` (user_id  ) REFERENCES `##user`   (user_id)   ON DELETE CASCADE," .
40
-				" ADD FOREIGN KEY `##news_fk2` (gedcom_id) REFERENCES `##gedcom` (gedcom_id) ON DELETE CASCADE"
41
-			);
42
-		} catch (PDOException $ex) {
43
-			// Already updated?
44
-		}
45
-	}
35
+        // Add the new constraints
36
+        try {
37
+            Database::exec(
38
+                "ALTER TABLE `##news`" .
39
+                " ADD FOREIGN KEY `##news_fk1` (user_id  ) REFERENCES `##user`   (user_id)   ON DELETE CASCADE," .
40
+                " ADD FOREIGN KEY `##news_fk2` (gedcom_id) REFERENCES `##gedcom` (gedcom_id) ON DELETE CASCADE"
41
+            );
42
+        } catch (PDOException $ex) {
43
+            // Already updated?
44
+        }
45
+    }
46 46
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,9 +22,11 @@
 block discarded – undo
22 22
 /**
23 23
  * Upgrade the database schema from version 2 to version 3.
24 24
  */
25
-class Migration2 implements MigrationInterface {
25
+class Migration2 implements MigrationInterface
26
+{
26 27
 	/** {@inheritDoc} */
27
-	public function upgrade() {
28
+	public function upgrade()
29
+	{
28 30
 		// Delete any data that might violate the new constraints
29 31
 		Database::exec(
30 32
 			"DELETE FROM `##news`" .
Please login to merge, or discard this patch.
app/Module/FamilyTreeNews/Schema/Migration1.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -23,54 +23,54 @@
 block discarded – undo
23 23
  * Upgrade the database schema from version 1 to version 2.
24 24
  */
25 25
 class Migration1 implements MigrationInterface {
26
-	/** {@inheritDoc} */
27
-	public function upgrade() {
28
-		// Add new columns
29
-		try {
30
-			Database::exec(
31
-				"ALTER TABLE `##news`" .
32
-				" ADD user_id INTEGER NULL AFTER n_id," .
33
-				" ADD gedcom_id INTEGER NULL AFTER user_id," .
34
-				" ADD updated TIMESTAMP ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP," .
35
-				" ADD KEY news_ix1 (user_id, updated)," .
36
-				" ADD KEY news_ix2 (gedcom_id, updated)"
37
-			);
38
-		} catch (PDOException $ex) {
39
-			// Already updated?
40
-		}
26
+    /** {@inheritDoc} */
27
+    public function upgrade() {
28
+        // Add new columns
29
+        try {
30
+            Database::exec(
31
+                "ALTER TABLE `##news`" .
32
+                " ADD user_id INTEGER NULL AFTER n_id," .
33
+                " ADD gedcom_id INTEGER NULL AFTER user_id," .
34
+                " ADD updated TIMESTAMP ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP," .
35
+                " ADD KEY news_ix1 (user_id, updated)," .
36
+                " ADD KEY news_ix2 (gedcom_id, updated)"
37
+            );
38
+        } catch (PDOException $ex) {
39
+            // Already updated?
40
+        }
41 41
 
42 42
 // Migrate data from the old columns to the new ones
43
-		try {
44
-			Database::exec(
45
-				"UPDATE `##news` n" .
46
-				" LEFT JOIN `##gedcom` g ON (n.n_username=g.gedcom_name)" .
47
-				" LEFT JOIN `##user` u ON (n.n_username=u.user_name)" .
48
-				" SET n.gedcom_id=g.gedcom_id, n.user_id=u.user_id, updated=FROM_UNIXTIME(n_date)"
49
-			);
50
-		} catch (PDOException $ex) {
51
-			// Already updated?
52
-		}
43
+        try {
44
+            Database::exec(
45
+                "UPDATE `##news` n" .
46
+                " LEFT JOIN `##gedcom` g ON (n.n_username=g.gedcom_name)" .
47
+                " LEFT JOIN `##user` u ON (n.n_username=u.user_name)" .
48
+                " SET n.gedcom_id=g.gedcom_id, n.user_id=u.user_id, updated=FROM_UNIXTIME(n_date)"
49
+            );
50
+        } catch (PDOException $ex) {
51
+            // Already updated?
52
+        }
53 53
 
54 54
 // Delete orphaned rows
55
-		try {
56
-			Database::exec(
57
-				"DELETE FROM `##news` WHERE user_id IS NULL AND gedcom_id IS NULL"
58
-			);
59
-		} catch (PDOException $ex) {
60
-			// Already updated?
61
-		}
55
+        try {
56
+            Database::exec(
57
+                "DELETE FROM `##news` WHERE user_id IS NULL AND gedcom_id IS NULL"
58
+            );
59
+        } catch (PDOException $ex) {
60
+            // Already updated?
61
+        }
62 62
 
63 63
 // Delete/rename old columns
64
-		try {
65
-			Database::exec(
66
-				"ALTER TABLE `##news`" .
67
-				" DROP n_username, DROP n_date," .
68
-				" CHANGE n_id news_id INTEGER NOT NULL AUTO_INCREMENT," .
69
-				" CHANGE n_title subject VARCHAR(255) COLLATE utf8_unicode_ci," .
70
-				" CHANGE n_text body TEXT COLLATE utf8_unicode_ci"
71
-			);
72
-		} catch (PDOException $ex) {
73
-			// Already updated?
74
-		}
75
-	}
64
+        try {
65
+            Database::exec(
66
+                "ALTER TABLE `##news`" .
67
+                " DROP n_username, DROP n_date," .
68
+                " CHANGE n_id news_id INTEGER NOT NULL AUTO_INCREMENT," .
69
+                " CHANGE n_title subject VARCHAR(255) COLLATE utf8_unicode_ci," .
70
+                " CHANGE n_text body TEXT COLLATE utf8_unicode_ci"
71
+            );
72
+        } catch (PDOException $ex) {
73
+            // Already updated?
74
+        }
75
+    }
76 76
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,9 +22,11 @@
 block discarded – undo
22 22
 /**
23 23
  * Upgrade the database schema from version 1 to version 2.
24 24
  */
25
-class Migration1 implements MigrationInterface {
25
+class Migration1 implements MigrationInterface
26
+{
26 27
 	/** {@inheritDoc} */
27
-	public function upgrade() {
28
+	public function upgrade()
29
+	{
28 30
 		// Add new columns
29 31
 		try {
30 32
 			Database::exec(
Please login to merge, or discard this patch.
app/Module/FamilyTreeNews/Schema/Migration0.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -22,18 +22,18 @@
 block discarded – undo
22 22
  * Upgrade the database schema from version 0 (empty database) to version 1.
23 23
  */
24 24
 class Migration0 implements MigrationInterface {
25
-	/** {@inheritDoc} */
26
-	public function upgrade() {
27
-		Database::exec(
28
-			"CREATE TABLE IF NOT EXISTS `##news` (" .
29
-			" n_id       INTEGER AUTO_INCREMENT NOT NULL," .
30
-			" n_username VARCHAR(100)           NOT NULL," .
31
-			" n_date     INTEGER                NOT NULL," .
32
-			" n_title    VARCHAR(255)           NOT NULL," .
33
-			" n_text     TEXT                   NOT NULL," .
34
-			" PRIMARY KEY     (n_id)," .
35
-			"         KEY ix1 (n_username)" .
36
-			") COLLATE utf8_unicode_ci ENGINE=InnoDB"
37
-		);
38
-	}
25
+    /** {@inheritDoc} */
26
+    public function upgrade() {
27
+        Database::exec(
28
+            "CREATE TABLE IF NOT EXISTS `##news` (" .
29
+            " n_id       INTEGER AUTO_INCREMENT NOT NULL," .
30
+            " n_username VARCHAR(100)           NOT NULL," .
31
+            " n_date     INTEGER                NOT NULL," .
32
+            " n_title    VARCHAR(255)           NOT NULL," .
33
+            " n_text     TEXT                   NOT NULL," .
34
+            " PRIMARY KEY     (n_id)," .
35
+            "         KEY ix1 (n_username)" .
36
+            ") COLLATE utf8_unicode_ci ENGINE=InnoDB"
37
+        );
38
+    }
39 39
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,9 +21,11 @@
 block discarded – undo
21 21
 /**
22 22
  * Upgrade the database schema from version 0 (empty database) to version 1.
23 23
  */
24
-class Migration0 implements MigrationInterface {
24
+class Migration0 implements MigrationInterface
25
+{
25 26
 	/** {@inheritDoc} */
26
-	public function upgrade() {
27
+	public function upgrade()
28
+	{
27 29
 		Database::exec(
28 30
 			"CREATE TABLE IF NOT EXISTS `##news` (" .
29 31
 			" n_id       INTEGER AUTO_INCREMENT NOT NULL," .
Please login to merge, or discard this patch.