Passed
Push — 1.7 ( 23cbb7...8df8a8 )
by Greg
08:15
created
app/Module/MarriageReportModule.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 MarriageReportModule
24 24
  */
25 25
 class MarriageReportModule extends AbstractModule implements ModuleReportInterface {
26
-	/** {@inheritdoc} */
27
-	public function getTitle() {
28
-		// This text also appears in the .XML file - update both together
29
-		return /* I18N: Name of a module/report */ I18N::translate('Marriages');
30
-	}
26
+    /** {@inheritdoc} */
27
+    public function getTitle() {
28
+        // This text also appears in the .XML file - update both together
29
+        return /* I18N: Name of a module/report */ I18N::translate('Marriages');
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 “Marriages” module */ I18N::translate('A report of individuals who were married in a given time or place.');
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 “Marriages” module */ I18N::translate('A report of individuals who were married in a given time or place.');
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 $WT_TREE;
49
+    /**
50
+     * Return a menu item for this report.
51
+     *
52
+     * @return Menu
53
+     */
54
+    public function getReportMenu() {
55
+        global $WT_TREE;
56 56
 
57
-		return new Menu(
58
-			$this->getTitle(),
59
-			'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
60
-			'menu-report-' . $this->getName(),
61
-			array('rel' => 'nofollow')
62
-		);
63
-	}
57
+        return new Menu(
58
+            $this->getTitle(),
59
+            'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
60
+            'menu-report-' . $this->getName(),
61
+            array('rel' => 'nofollow')
62
+        );
63
+    }
64 64
 }
Please login to merge, or discard this patch.
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 MarriageReportModule
24 24
  */
25
-class MarriageReportModule extends AbstractModule implements ModuleReportInterface {
25
+class MarriageReportModule 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 module/report */ I18N::translate('Marriages');
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 “Marriages” module */ I18N::translate('A report of individuals who were married in a given time or place.');
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 $WT_TREE;
56 61
 
57 62
 		return new Menu(
Please login to merge, or discard this patch.
app/Module/FamilyNavigatorModule.php 2 patches
Indentation   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -25,44 +25,44 @@  discard block
 block discarded – undo
25 25
  * Class FamilyNavigatorModule
26 26
  */
27 27
 class FamilyNavigatorModule extends AbstractModule implements ModuleSidebarInterface {
28
-	const TTL = "<div class='flyout2'>%s</div>";
29
-	const LNK = "<div class='flyout3' data-href='%s'>%s</div>";
30
-	const MSG = "<div class='flyout4'>(%s)</div>"; // class flyout4 not used in standard themes
28
+    const TTL = "<div class='flyout2'>%s</div>";
29
+    const LNK = "<div class='flyout3' data-href='%s'>%s</div>";
30
+    const MSG = "<div class='flyout4'>(%s)</div>"; // class flyout4 not used in standard themes
31 31
 
32
-	/** {@inheritdoc} */
33
-	public function getTitle() {
34
-		return /* I18N: Name of a module/sidebar */ I18N::translate('Family navigator');
35
-	}
32
+    /** {@inheritdoc} */
33
+    public function getTitle() {
34
+        return /* I18N: Name of a module/sidebar */ I18N::translate('Family navigator');
35
+    }
36 36
 
37
-	/** {@inheritdoc} */
38
-	public function getDescription() {
39
-		return /* I18N: Description of the “Family navigator” module */ I18N::translate('A sidebar showing an individual’s close families and relatives.');
40
-	}
37
+    /** {@inheritdoc} */
38
+    public function getDescription() {
39
+        return /* I18N: Description of the “Family navigator” module */ I18N::translate('A sidebar showing an individual’s close families and relatives.');
40
+    }
41 41
 
42
-	/** {@inheritdoc} */
43
-	public function defaultSidebarOrder() {
44
-		return 20;
45
-	}
42
+    /** {@inheritdoc} */
43
+    public function defaultSidebarOrder() {
44
+        return 20;
45
+    }
46 46
 
47
-	/** {@inheritdoc} */
48
-	public function hasSidebarContent() {
49
-		return true;
50
-	}
47
+    /** {@inheritdoc} */
48
+    public function hasSidebarContent() {
49
+        return true;
50
+    }
51 51
 
52
-	/** {@inheritdoc} */
53
-	public function getSidebarAjaxContent() {
54
-		return '';
55
-	}
52
+    /** {@inheritdoc} */
53
+    public function getSidebarAjaxContent() {
54
+        return '';
55
+    }
56 56
 
57
-	/**
58
-	 * Load this sidebar synchronously.
59
-	 *
60
-	 * @return string
61
-	 */
62
-	public function getSidebarContent() {
63
-		global $controller;
57
+    /**
58
+     * Load this sidebar synchronously.
59
+     *
60
+     * @return string
61
+     */
62
+    public function getSidebarContent() {
63
+        global $controller;
64 64
 
65
-		$controller->addInlineJavascript('
65
+        $controller->addInlineJavascript('
66 66
 			jQuery("#sb_family_nav_content")
67 67
 				.on("click", ".flyout a", function() {
68 68
 					return false;
@@ -73,47 +73,47 @@  discard block
 block discarded – undo
73 73
 				});
74 74
 		');
75 75
 
76
-		ob_start();
76
+        ob_start();
77 77
 
78
-		?>
78
+        ?>
79 79
 		<div id="sb_family_nav_content">
80 80
 			<table class="nav_content">
81 81
 
82 82
 		<?php
83
-		//-- parent families -------------------------------------------------------------
84
-		foreach ($controller->record->getChildFamilies() as $family) {
85
-			$this->drawFamily($family, $controller->record->getChildFamilyLabel($family));
86
-		}
87
-		//-- step parents ----------------------------------------------------------------
88
-		foreach ($controller->record->getChildStepFamilies() as $family) {
89
-			$this->drawFamily($family, $controller->record->getStepFamilyLabel($family));
90
-		}
91
-		//-- spouse and children --------------------------------------------------
92
-		foreach ($controller->record->getSpouseFamilies() as $family) {
93
-			$this->drawFamily($family, $controller->getSpouseFamilyLabel($family, $controller->record));
94
-		}
95
-		//-- step children ----------------------------------------------------------------
96
-		foreach ($controller->record->getSpouseStepFamilies() as $family) {
97
-			$this->drawFamily($family, $family->getFullName());
98
-		}
99
-		?>
83
+        //-- parent families -------------------------------------------------------------
84
+        foreach ($controller->record->getChildFamilies() as $family) {
85
+            $this->drawFamily($family, $controller->record->getChildFamilyLabel($family));
86
+        }
87
+        //-- step parents ----------------------------------------------------------------
88
+        foreach ($controller->record->getChildStepFamilies() as $family) {
89
+            $this->drawFamily($family, $controller->record->getStepFamilyLabel($family));
90
+        }
91
+        //-- spouse and children --------------------------------------------------
92
+        foreach ($controller->record->getSpouseFamilies() as $family) {
93
+            $this->drawFamily($family, $controller->getSpouseFamilyLabel($family, $controller->record));
94
+        }
95
+        //-- step children ----------------------------------------------------------------
96
+        foreach ($controller->record->getSpouseStepFamilies() as $family) {
97
+            $this->drawFamily($family, $family->getFullName());
98
+        }
99
+        ?>
100 100
 			</table>
101 101
 		</div>
102 102
 		<?php
103 103
 
104
-		return ob_get_clean();
105
-	}
104
+        return ob_get_clean();
105
+    }
106 106
 
107
-	/**
108
-	 * Format a family.
109
-	 *
110
-	 * @param Family $family
111
-	 * @param string $title
112
-	 */
113
-	private function drawFamily(Family $family, $title) {
114
-		global $controller;
107
+    /**
108
+     * Format a family.
109
+     *
110
+     * @param Family $family
111
+     * @param string $title
112
+     */
113
+    private function drawFamily(Family $family, $title) {
114
+        global $controller;
115 115
 
116
-		?>
116
+        ?>
117 117
 		<tr>
118 118
 			<td class="center" colspan="2">
119 119
 				<a class="famnav_title" href="<?php echo $family->getHtmlUrl(); ?>">
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 			</td>
123 123
 		</tr>
124 124
 		<?php
125
-		foreach ($family->getSpouses() as $spouse) {
126
-			$menu = new Menu(Functions::getCloseRelationshipName($controller->record, $spouse));
127
-			$menu->addClass('', 'submenu flyout');
128
-			$menu->addSubmenu(new Menu($this->getParents($spouse)));
129
-			?>
125
+        foreach ($family->getSpouses() as $spouse) {
126
+            $menu = new Menu(Functions::getCloseRelationshipName($controller->record, $spouse));
127
+            $menu->addClass('', 'submenu flyout');
128
+            $menu->addSubmenu(new Menu($this->getParents($spouse)));
129
+            ?>
130 130
 			<tr>
131 131
 				<td class="facts_label">
132 132
 					<?php echo $menu->getMenu(); ?>
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 				</td>
146 146
 			</tr>
147 147
 		<?php
148
-		}
148
+        }
149 149
 
150
-		foreach ($family->getChildren() as $child) {
151
-			$menu = new Menu(Functions::getCloseRelationshipName($controller->record, $child));
152
-			$menu->addClass('', 'submenu flyout');
153
-			$menu->addSubmenu(new Menu($this->getFamily($child)));
154
-			?>
150
+        foreach ($family->getChildren() as $child) {
151
+            $menu = new Menu(Functions::getCloseRelationshipName($controller->record, $child));
152
+            $menu->addClass('', 'submenu flyout');
153
+            $menu->addSubmenu(new Menu($this->getFamily($child)));
154
+            ?>
155 155
 			<tr>
156 156
 				<td class="facts_label">
157 157
 					<?php echo $menu->getMenu(); ?>
@@ -170,97 +170,97 @@  discard block
 block discarded – undo
170 170
 				</td>
171 171
 			</tr>
172 172
 		<?php
173
-		}
174
-	}
173
+        }
174
+    }
175 175
 
176
-	/**
177
-	 * Format an individual.
178
-	 *
179
-	 * @param      $person
180
-	 * @param bool $showUnknown
181
-	 *
182
-	 * @return string
183
-	 */
184
-	private function getHTML($person, $showUnknown = false) {
185
-		if ($person instanceof Individual) {
186
-			return sprintf(self::LNK, $person->getHtmlUrl(), $person->getFullName());
187
-		} elseif ($showUnknown) {
188
-			return sprintf(self::MSG, I18N::translate('unknown'));
189
-		} else {
190
-			return '';
191
-		}
192
-	}
176
+    /**
177
+     * Format an individual.
178
+     *
179
+     * @param      $person
180
+     * @param bool $showUnknown
181
+     *
182
+     * @return string
183
+     */
184
+    private function getHTML($person, $showUnknown = false) {
185
+        if ($person instanceof Individual) {
186
+            return sprintf(self::LNK, $person->getHtmlUrl(), $person->getFullName());
187
+        } elseif ($showUnknown) {
188
+            return sprintf(self::MSG, I18N::translate('unknown'));
189
+        } else {
190
+            return '';
191
+        }
192
+    }
193 193
 
194
-	/**
195
-	 * Forat the parents of an individual.
196
-	 *
197
-	 * @param Individual $person
198
-	 *
199
-	 * @return string
200
-	 */
201
-	private function getParents(Individual $person) {
202
-		$father = null;
203
-		$mother = null;
204
-		$html   = sprintf(self::TTL, I18N::translate('Parents'));
205
-		$family = $person->getPrimaryChildFamily();
206
-		if ($person->canShowName() && $family !== null) {
207
-			$father = $family->getHusband();
208
-			$mother = $family->getWife();
209
-			$html .= $this->getHTML($father) .
210
-					 $this->getHTML($mother);
194
+    /**
195
+     * Forat the parents of an individual.
196
+     *
197
+     * @param Individual $person
198
+     *
199
+     * @return string
200
+     */
201
+    private function getParents(Individual $person) {
202
+        $father = null;
203
+        $mother = null;
204
+        $html   = sprintf(self::TTL, I18N::translate('Parents'));
205
+        $family = $person->getPrimaryChildFamily();
206
+        if ($person->canShowName() && $family !== null) {
207
+            $father = $family->getHusband();
208
+            $mother = $family->getWife();
209
+            $html .= $this->getHTML($father) .
210
+                        $this->getHTML($mother);
211 211
 
212
-			// Can only have a step parent if one & only one parent found at this point
213
-			if ($father instanceof Individual xor $mother instanceof Individual) {
214
-				$stepParents = '';
215
-				foreach ($person->getChildStepFamilies() as $family) {
216
-					if (!$father instanceof Individual) {
217
-						$stepParents .= $this->getHTML($family->getHusband());
218
-					} else {
219
-						$stepParents .= $this->getHTML($family->getWife());
220
-					}
221
-				}
222
-				if ($stepParents) {
223
-					$relationship = $father instanceof Individual ?
224
-						I18N::translateContext("father’s wife", "step-mother") : I18N::translateContext("mother’s husband", "step-father");
225
-					$html .= sprintf(self::TTL, $relationship) . $stepParents;
226
-				}
227
-			}
228
-		}
229
-		if (!($father instanceof Individual || $mother instanceof Individual)) {
230
-			$html .= sprintf(self::MSG, I18N::translateContext('unknown family', 'unknown'));
231
-		}
212
+            // Can only have a step parent if one & only one parent found at this point
213
+            if ($father instanceof Individual xor $mother instanceof Individual) {
214
+                $stepParents = '';
215
+                foreach ($person->getChildStepFamilies() as $family) {
216
+                    if (!$father instanceof Individual) {
217
+                        $stepParents .= $this->getHTML($family->getHusband());
218
+                    } else {
219
+                        $stepParents .= $this->getHTML($family->getWife());
220
+                    }
221
+                }
222
+                if ($stepParents) {
223
+                    $relationship = $father instanceof Individual ?
224
+                        I18N::translateContext("father’s wife", "step-mother") : I18N::translateContext("mother’s husband", "step-father");
225
+                    $html .= sprintf(self::TTL, $relationship) . $stepParents;
226
+                }
227
+            }
228
+        }
229
+        if (!($father instanceof Individual || $mother instanceof Individual)) {
230
+            $html .= sprintf(self::MSG, I18N::translateContext('unknown family', 'unknown'));
231
+        }
232 232
 
233
-		return $html;
234
-	}
233
+        return $html;
234
+    }
235 235
 
236
-	/**
237
-	 * Format a family.
238
-	 *
239
-	 * @param Individual $person
240
-	 *
241
-	 * @return string
242
-	 */
243
-	private function getFamily(Individual $person) {
244
-		$html = '';
245
-		if ($person->canShowName()) {
246
-			foreach ($person->getSpouseFamilies() as $family) {
247
-				$spouse = $family->getSpouse($person);
248
-				$html .= $this->getHTML($spouse, true);
249
-				$children = $family->getChildren();
250
-				if (count($children) > 0) {
251
-					$html .= "<ul class='clist'>";
252
-					foreach ($children as $child) {
253
-						$html .= '<li>' . $this->getHTML($child) . '</li>';
254
-					}
255
-					$html .= '</ul>';
256
-				}
257
-			}
258
-		}
259
-		if (!$html) {
260
-			$html = sprintf(self::MSG, I18N::translate('none'));
261
-		}
236
+    /**
237
+     * Format a family.
238
+     *
239
+     * @param Individual $person
240
+     *
241
+     * @return string
242
+     */
243
+    private function getFamily(Individual $person) {
244
+        $html = '';
245
+        if ($person->canShowName()) {
246
+            foreach ($person->getSpouseFamilies() as $family) {
247
+                $spouse = $family->getSpouse($person);
248
+                $html .= $this->getHTML($spouse, true);
249
+                $children = $family->getChildren();
250
+                if (count($children) > 0) {
251
+                    $html .= "<ul class='clist'>";
252
+                    foreach ($children as $child) {
253
+                        $html .= '<li>' . $this->getHTML($child) . '</li>';
254
+                    }
255
+                    $html .= '</ul>';
256
+                }
257
+            }
258
+        }
259
+        if (!$html) {
260
+            $html = sprintf(self::MSG, I18N::translate('none'));
261
+        }
262 262
 
263
-		return sprintf(self::TTL, I18N::translate('Family')) . $html;
264
-	}
263
+        return sprintf(self::TTL, I18N::translate('Family')) . $html;
264
+    }
265 265
 
266 266
 }
Please login to merge, or discard this patch.
Braces   +32 added lines, -15 removed lines patch added patch discarded remove patch
@@ -24,33 +24,39 @@  discard block
 block discarded – undo
24 24
 /**
25 25
  * Class FamilyNavigatorModule
26 26
  */
27
-class FamilyNavigatorModule extends AbstractModule implements ModuleSidebarInterface {
27
+class FamilyNavigatorModule extends AbstractModule implements ModuleSidebarInterface
28
+{
28 29
 	const TTL = "<div class='flyout2'>%s</div>";
29 30
 	const LNK = "<div class='flyout3' data-href='%s'>%s</div>";
30 31
 	const MSG = "<div class='flyout4'>(%s)</div>"; // class flyout4 not used in standard themes
31 32
 
32 33
 	/** {@inheritdoc} */
33
-	public function getTitle() {
34
+	public function getTitle()
35
+	{
34 36
 		return /* I18N: Name of a module/sidebar */ I18N::translate('Family navigator');
35 37
 	}
36 38
 
37 39
 	/** {@inheritdoc} */
38
-	public function getDescription() {
40
+	public function getDescription()
41
+	{
39 42
 		return /* I18N: Description of the “Family navigator” module */ I18N::translate('A sidebar showing an individual’s close families and relatives.');
40 43
 	}
41 44
 
42 45
 	/** {@inheritdoc} */
43
-	public function defaultSidebarOrder() {
46
+	public function defaultSidebarOrder()
47
+	{
44 48
 		return 20;
45 49
 	}
46 50
 
47 51
 	/** {@inheritdoc} */
48
-	public function hasSidebarContent() {
52
+	public function hasSidebarContent()
53
+	{
49 54
 		return true;
50 55
 	}
51 56
 
52 57
 	/** {@inheritdoc} */
53
-	public function getSidebarAjaxContent() {
58
+	public function getSidebarAjaxContent()
59
+	{
54 60
 		return '';
55 61
 	}
56 62
 
@@ -59,7 +65,8 @@  discard block
 block discarded – undo
59 65
 	 *
60 66
 	 * @return string
61 67
 	 */
62
-	public function getSidebarContent() {
68
+	public function getSidebarContent()
69
+	{
63 70
 		global $controller;
64 71
 
65 72
 		$controller->addInlineJavascript('
@@ -110,7 +117,8 @@  discard block
 block discarded – undo
110 117
 	 * @param Family $family
111 118
 	 * @param string $title
112 119
 	 */
113
-	private function drawFamily(Family $family, $title) {
120
+	private function drawFamily(Family $family, $title)
121
+	{
114 122
 		global $controller;
115 123
 
116 124
 		?>
@@ -139,8 +147,11 @@  discard block
 block discarded – undo
139 147
 					<div class="font9">
140 148
 						<?php echo $spouse->getLifeSpan(); ?>
141 149
 					</div>
142
-					<?php else: ?>
143
-						<?php echo $spouse->getFullName(); ?>
150
+					<?php else {
151
+    : ?>
152
+						<?php echo $spouse->getFullName();
153
+}
154
+?>
144 155
 					<?php endif; ?>
145 156
 				</td>
146 157
 			</tr>
@@ -164,8 +175,11 @@  discard block
 block discarded – undo
164 175
 					<div class="font9">
165 176
 						<?php echo $child->getLifeSpan(); ?>
166 177
 					</div>
167
-					<?php else: ?>
168
-						<?php echo $child->getFullName(); ?>
178
+					<?php else {
179
+    : ?>
180
+						<?php echo $child->getFullName();
181
+}
182
+?>
169 183
 					<?php endif; ?>
170 184
 				</td>
171 185
 			</tr>
@@ -181,7 +195,8 @@  discard block
 block discarded – undo
181 195
 	 *
182 196
 	 * @return string
183 197
 	 */
184
-	private function getHTML($person, $showUnknown = false) {
198
+	private function getHTML($person, $showUnknown = false)
199
+	{
185 200
 		if ($person instanceof Individual) {
186 201
 			return sprintf(self::LNK, $person->getHtmlUrl(), $person->getFullName());
187 202
 		} elseif ($showUnknown) {
@@ -198,7 +213,8 @@  discard block
 block discarded – undo
198 213
 	 *
199 214
 	 * @return string
200 215
 	 */
201
-	private function getParents(Individual $person) {
216
+	private function getParents(Individual $person)
217
+	{
202 218
 		$father = null;
203 219
 		$mother = null;
204 220
 		$html   = sprintf(self::TTL, I18N::translate('Parents'));
@@ -240,7 +256,8 @@  discard block
 block discarded – undo
240 256
 	 *
241 257
 	 * @return string
242 258
 	 */
243
-	private function getFamily(Individual $person) {
259
+	private function getFamily(Individual $person)
260
+	{
244 261
 		$html = '';
245 262
 		if ($person->canShowName()) {
246 263
 			foreach ($person->getSpouseFamilies() as $family) {
Please login to merge, or discard this patch.
app/Module/BirthReportModule.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 BirthReportModule
24 24
  */
25 25
 class BirthReportModule extends AbstractModule implements ModuleReportInterface {
26
-	/** {@inheritdoc} */
27
-	public function getTitle() {
28
-		// This text also appears in the .XML file - update both together
29
-		return /* I18N: Name of a module/report */ I18N::translate('Births');
30
-	}
26
+    /** {@inheritdoc} */
27
+    public function getTitle() {
28
+        // This text also appears in the .XML file - update both together
29
+        return /* I18N: Name of a module/report */ I18N::translate('Births');
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 “Births” module */ I18N::translate('A report of individuals who were born in a given time or place.');
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 “Births” module */ I18N::translate('A report of individuals who were born in a given time or place.');
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 $WT_TREE;
49
+    /**
50
+     * Return a menu item for this report.
51
+     *
52
+     * @return Menu
53
+     */
54
+    public function getReportMenu() {
55
+        global $WT_TREE;
56 56
 
57
-		return new Menu(
58
-			$this->getTitle(),
59
-			'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
60
-			'menu-report-' . $this->getName(),
61
-			array('rel' => 'nofollow')
62
-		);
63
-	}
57
+        return new Menu(
58
+            $this->getTitle(),
59
+            'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
60
+            'menu-report-' . $this->getName(),
61
+            array('rel' => 'nofollow')
62
+        );
63
+    }
64 64
 }
Please login to merge, or discard this patch.
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 BirthReportModule
24 24
  */
25
-class BirthReportModule extends AbstractModule implements ModuleReportInterface {
25
+class BirthReportModule 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 module/report */ I18N::translate('Births');
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 “Births” module */ I18N::translate('A report of individuals who were born in a given time or place.');
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 $WT_TREE;
56 61
 
57 62
 		return new Menu(
Please login to merge, or discard this patch.
app/Module/CkeditorModule.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -22,42 +22,42 @@
 block discarded – undo
22 22
  * Class CkeditorModule
23 23
  */
24 24
 class CkeditorModule extends AbstractModule {
25
-	/** {@inheritdoc} */
26
-	public function getTitle() {
27
-		return /* I18N: Name of a module. CKEditor is a trademark. Do not translate it? http://ckeditor.com */ I18N::translate('CKEditor™');
28
-	}
25
+    /** {@inheritdoc} */
26
+    public function getTitle() {
27
+        return /* I18N: Name of a module. CKEditor is a trademark. Do not translate it? http://ckeditor.com */ I18N::translate('CKEditor™');
28
+    }
29 29
 
30
-	/** {@inheritdoc} */
31
-	public function getDescription() {
32
-		return /* I18N: Description of the “CKEditor” module. WYSIWYG = “what you see is what you get” */ I18N::translate('Allow other modules to edit text using a “WYSIWYG” editor, instead of using HTML codes.');
33
-	}
30
+    /** {@inheritdoc} */
31
+    public function getDescription() {
32
+        return /* I18N: Description of the “CKEditor” module. WYSIWYG = “what you see is what you get” */ I18N::translate('Allow other modules to edit text using a “WYSIWYG” editor, instead of using HTML codes.');
33
+    }
34 34
 
35
-	/**
36
-	 * Convert <textarea class="html-edit"> fields to CKEditor fields
37
-	 *
38
-	 * This function needs to be called *after* we have sent the page header and
39
-	 * before we have sent the page footer.
40
-	 *
41
-	 * @param BaseController $controller
42
-	 */
43
-	public static function enableEditor($controller) {
44
-		$controller
45
-			->addExternalJavascript(WT_CKEDITOR_BASE_URL . 'ckeditor.js')
46
-			->addExternalJavascript(WT_CKEDITOR_BASE_URL . 'adapters/jquery.js')
47
-			// Need to specify the path before we load the libary
48
-			->addInlineJavascript(
49
-				'var CKEDITOR_BASEPATH="' . WT_CKEDITOR_BASE_URL . '";',
50
-				BaseController::JS_PRIORITY_HIGH
51
-			)
52
-			// Enable for all browsers
53
-			->addInlineJavascript('CKEDITOR.env.isCompatible = true;')
54
-			// Disable toolbars
55
-			->addInlineJavascript('CKEDITOR.config.removePlugins = "forms,newpage,preview,print,save,templates";')
56
-			->addInlineJavascript('CKEDITOR.config.extraAllowedContent = 
35
+    /**
36
+     * Convert <textarea class="html-edit"> fields to CKEditor fields
37
+     *
38
+     * This function needs to be called *after* we have sent the page header and
39
+     * before we have sent the page footer.
40
+     *
41
+     * @param BaseController $controller
42
+     */
43
+    public static function enableEditor($controller) {
44
+        $controller
45
+            ->addExternalJavascript(WT_CKEDITOR_BASE_URL . 'ckeditor.js')
46
+            ->addExternalJavascript(WT_CKEDITOR_BASE_URL . 'adapters/jquery.js')
47
+            // Need to specify the path before we load the libary
48
+            ->addInlineJavascript(
49
+                'var CKEDITOR_BASEPATH="' . WT_CKEDITOR_BASE_URL . '";',
50
+                BaseController::JS_PRIORITY_HIGH
51
+            )
52
+            // Enable for all browsers
53
+            ->addInlineJavascript('CKEDITOR.env.isCompatible = true;')
54
+            // Disable toolbars
55
+            ->addInlineJavascript('CKEDITOR.config.removePlugins = "forms,newpage,preview,print,save,templates";')
56
+            ->addInlineJavascript('CKEDITOR.config.extraAllowedContent = 
57 57
     "area[shape,coords,href,target,alt,title];map[name];img[usemap];*[class,style]";')
58
-			// Activate the editor
59
-			->addInlineJavascript('jQuery(".html-edit").ckeditor(function(config){config.removePlugins = "forms";}, {
58
+            // Activate the editor
59
+            ->addInlineJavascript('jQuery(".html-edit").ckeditor(function(config){config.removePlugins = "forms";}, {
60 60
 				language: "' . strtolower(WT_LOCALE) . '"
61 61
 			});');
62
-	}
62
+    }
63 63
 }
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,14 +21,17 @@  discard block
 block discarded – undo
21 21
 /**
22 22
  * Class CkeditorModule
23 23
  */
24
-class CkeditorModule extends AbstractModule {
24
+class CkeditorModule extends AbstractModule
25
+{
25 26
 	/** {@inheritdoc} */
26
-	public function getTitle() {
27
+	public function getTitle()
28
+	{
27 29
 		return /* I18N: Name of a module. CKEditor is a trademark. Do not translate it? http://ckeditor.com */ I18N::translate('CKEditor™');
28 30
 	}
29 31
 
30 32
 	/** {@inheritdoc} */
31
-	public function getDescription() {
33
+	public function getDescription()
34
+	{
32 35
 		return /* I18N: Description of the “CKEditor” module. WYSIWYG = “what you see is what you get” */ I18N::translate('Allow other modules to edit text using a “WYSIWYG” editor, instead of using HTML codes.');
33 36
 	}
34 37
 
@@ -40,7 +43,8 @@  discard block
 block discarded – undo
40 43
 	 *
41 44
 	 * @param BaseController $controller
42 45
 	 */
43
-	public static function enableEditor($controller) {
46
+	public static function enableEditor($controller)
47
+	{
44 48
 		$controller
45 49
 			->addExternalJavascript(WT_CKEDITOR_BASE_URL . 'ckeditor.js')
46 50
 			->addExternalJavascript(WT_CKEDITOR_BASE_URL . 'adapters/jquery.js')
Please login to merge, or discard this patch.
app/Module/SiteMapModule.php 3 patches
Indentation   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -31,267 +31,267 @@  discard block
 block discarded – undo
31 31
  * Class SiteMapModule
32 32
  */
33 33
 class SiteMapModule extends AbstractModule implements ModuleConfigInterface {
34
-	const RECORDS_PER_VOLUME = 500; // Keep sitemap files small, for memory, CPU and max_allowed_packet limits.
35
-	const CACHE_LIFE         = 1209600; // Two weeks
34
+    const RECORDS_PER_VOLUME = 500; // Keep sitemap files small, for memory, CPU and max_allowed_packet limits.
35
+    const CACHE_LIFE         = 1209600; // Two weeks
36 36
 
37
-	/** {@inheritdoc} */
38
-	public function getTitle() {
39
-		return /* I18N: Name of a module - see http://en.wikipedia.org/wiki/Sitemaps */ I18N::translate('Sitemaps');
40
-	}
37
+    /** {@inheritdoc} */
38
+    public function getTitle() {
39
+        return /* I18N: Name of a module - see http://en.wikipedia.org/wiki/Sitemaps */ I18N::translate('Sitemaps');
40
+    }
41 41
 
42
-	/** {@inheritdoc} */
43
-	public function getDescription() {
44
-		return /* I18N: Description of the “Sitemaps” module */ I18N::translate('Generate sitemap files for search engines.');
45
-	}
42
+    /** {@inheritdoc} */
43
+    public function getDescription() {
44
+        return /* I18N: Description of the “Sitemaps” module */ I18N::translate('Generate sitemap files for search engines.');
45
+    }
46 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 'admin':
56
-			$this->admin();
57
-			break;
58
-		case 'generate':
59
-			$this->generate(Filter::get('file'));
60
-			break;
61
-		default:
62
-			http_response_code(404);
63
-		}
64
-	}
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 'admin':
56
+            $this->admin();
57
+            break;
58
+        case 'generate':
59
+            $this->generate(Filter::get('file'));
60
+            break;
61
+        default:
62
+            http_response_code(404);
63
+        }
64
+    }
65 65
 
66
-	/**
67
-	 * Generate an XML file.
68
-	 *
69
-	 * @param string $file
70
-	 */
71
-	private function generate($file) {
72
-		if ($file == 'sitemap.xml') {
73
-			$this->generateIndex();
74
-		} elseif (preg_match('/^sitemap-(\d+)-([isrmn])-(\d+).xml$/', $file, $match)) {
75
-			$this->generateFile($match[1], $match[2], $match[3]);
76
-		} else {
77
-			http_response_code(404);
78
-		}
79
-	}
66
+    /**
67
+     * Generate an XML file.
68
+     *
69
+     * @param string $file
70
+     */
71
+    private function generate($file) {
72
+        if ($file == 'sitemap.xml') {
73
+            $this->generateIndex();
74
+        } elseif (preg_match('/^sitemap-(\d+)-([isrmn])-(\d+).xml$/', $file, $match)) {
75
+            $this->generateFile($match[1], $match[2], $match[3]);
76
+        } else {
77
+            http_response_code(404);
78
+        }
79
+    }
80 80
 
81
-	/**
82
-	 * The index file contains references to all the other files.
83
-	 * These files are the same for visitors/users/admins.
84
-	 */
85
-	private function generateIndex() {
86
-		// Check the cache
87
-		$timestamp = $this->getSetting('sitemap.timestamp');
88
-		if ($timestamp > WT_TIMESTAMP - self::CACHE_LIFE) {
89
-			$data = $this->getSetting('sitemap.xml');
90
-		} else {
91
-			$data    = '';
92
-			$lastmod = '<lastmod>' . date('Y-m-d') . '</lastmod>';
93
-			foreach (Tree::getAll() as $tree) {
94
-				if ($tree->getPreference('include_in_sitemap')) {
95
-					$n = Database::prepare(
96
-						"SELECT COUNT(*) FROM `##individuals` WHERE i_file = :tree_id"
97
-					)->execute(array('tree_id' => $tree->getTreeId()))->fetchOne();
98
-					for ($i = 0; $i <= $n / self::RECORDS_PER_VOLUME; ++$i) {
99
-						$data .= '<sitemap><loc>' . WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap-' . $tree->getTreeId() . '-i-' . $i . '.xml</loc>' . $lastmod . '</sitemap>' . PHP_EOL;
100
-					}
101
-					$n = Database::prepare(
102
-						"SELECT COUNT(*) FROM `##sources` WHERE s_file = :tree_id"
103
-					)->execute(array('tree_id' => $tree->getTreeId()))->fetchOne();
104
-					if ($n) {
105
-						for ($i = 0; $i <= $n / self::RECORDS_PER_VOLUME; ++$i) {
106
-							$data .= '<sitemap><loc>' . WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap-' . $tree->getTreeId() . '-s-' . $i . '.xml</loc>' . $lastmod . '</sitemap>' . PHP_EOL;
107
-						}
108
-					}
109
-					$n = Database::prepare(
110
-						"SELECT COUNT(*) FROM `##other` WHERE o_file = :tree_id AND o_type = 'REPO'"
111
-					)->execute(array('tree_id' => $tree->getTreeId()))->fetchOne();
112
-					if ($n) {
113
-						for ($i = 0; $i <= $n / self::RECORDS_PER_VOLUME; ++$i) {
114
-							$data .= '<sitemap><loc>' . WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap-' . $tree->getTreeId() . '-r-' . $i . '.xml</loc>' . $lastmod . '</sitemap>' . PHP_EOL;
115
-						}
116
-					}
117
-					$n = Database::prepare(
118
-						"SELECT COUNT(*) FROM `##other` WHERE o_file = :tree_id AND o_type = 'NOTE'"
119
-					)->execute(array('tree_id' => $tree->getTreeId()))->fetchOne();
120
-					if ($n) {
121
-						for ($i = 0; $i <= $n / self::RECORDS_PER_VOLUME; ++$i) {
122
-							$data .= '<sitemap><loc>' . WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap-' . $tree->getTreeId() . '-n-' . $i . '.xml</loc>' . $lastmod . '</sitemap>' . PHP_EOL;
123
-						}
124
-					}
125
-					$n = Database::prepare(
126
-						"SELECT COUNT(*) FROM `##media` WHERE m_file = :tree_id"
127
-					)->execute(array('tree_id' => $tree->getTreeId()))->fetchOne();
128
-					if ($n) {
129
-						for ($i = 0; $i <= $n / self::RECORDS_PER_VOLUME; ++$i) {
130
-							$data .= '<sitemap><loc>' . WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap-' . $tree->getTreeId() . '-m-' . $i . '.xml</loc>' . $lastmod . '</sitemap>' . PHP_EOL;
131
-						}
132
-					}
133
-				}
134
-			}
135
-			$data = '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . PHP_EOL . '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL . $data . '</sitemapindex>' . PHP_EOL;
136
-			// Cache this data.
137
-			$this->setSetting('sitemap.xml', $data);
138
-			$this->setSetting('sitemap.timestamp', WT_TIMESTAMP);
139
-		}
140
-		header('Content-Type: application/xml');
141
-		header('Content-Length: ' . strlen($data));
142
-		echo $data;
143
-	}
81
+    /**
82
+     * The index file contains references to all the other files.
83
+     * These files are the same for visitors/users/admins.
84
+     */
85
+    private function generateIndex() {
86
+        // Check the cache
87
+        $timestamp = $this->getSetting('sitemap.timestamp');
88
+        if ($timestamp > WT_TIMESTAMP - self::CACHE_LIFE) {
89
+            $data = $this->getSetting('sitemap.xml');
90
+        } else {
91
+            $data    = '';
92
+            $lastmod = '<lastmod>' . date('Y-m-d') . '</lastmod>';
93
+            foreach (Tree::getAll() as $tree) {
94
+                if ($tree->getPreference('include_in_sitemap')) {
95
+                    $n = Database::prepare(
96
+                        "SELECT COUNT(*) FROM `##individuals` WHERE i_file = :tree_id"
97
+                    )->execute(array('tree_id' => $tree->getTreeId()))->fetchOne();
98
+                    for ($i = 0; $i <= $n / self::RECORDS_PER_VOLUME; ++$i) {
99
+                        $data .= '<sitemap><loc>' . WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap-' . $tree->getTreeId() . '-i-' . $i . '.xml</loc>' . $lastmod . '</sitemap>' . PHP_EOL;
100
+                    }
101
+                    $n = Database::prepare(
102
+                        "SELECT COUNT(*) FROM `##sources` WHERE s_file = :tree_id"
103
+                    )->execute(array('tree_id' => $tree->getTreeId()))->fetchOne();
104
+                    if ($n) {
105
+                        for ($i = 0; $i <= $n / self::RECORDS_PER_VOLUME; ++$i) {
106
+                            $data .= '<sitemap><loc>' . WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap-' . $tree->getTreeId() . '-s-' . $i . '.xml</loc>' . $lastmod . '</sitemap>' . PHP_EOL;
107
+                        }
108
+                    }
109
+                    $n = Database::prepare(
110
+                        "SELECT COUNT(*) FROM `##other` WHERE o_file = :tree_id AND o_type = 'REPO'"
111
+                    )->execute(array('tree_id' => $tree->getTreeId()))->fetchOne();
112
+                    if ($n) {
113
+                        for ($i = 0; $i <= $n / self::RECORDS_PER_VOLUME; ++$i) {
114
+                            $data .= '<sitemap><loc>' . WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap-' . $tree->getTreeId() . '-r-' . $i . '.xml</loc>' . $lastmod . '</sitemap>' . PHP_EOL;
115
+                        }
116
+                    }
117
+                    $n = Database::prepare(
118
+                        "SELECT COUNT(*) FROM `##other` WHERE o_file = :tree_id AND o_type = 'NOTE'"
119
+                    )->execute(array('tree_id' => $tree->getTreeId()))->fetchOne();
120
+                    if ($n) {
121
+                        for ($i = 0; $i <= $n / self::RECORDS_PER_VOLUME; ++$i) {
122
+                            $data .= '<sitemap><loc>' . WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap-' . $tree->getTreeId() . '-n-' . $i . '.xml</loc>' . $lastmod . '</sitemap>' . PHP_EOL;
123
+                        }
124
+                    }
125
+                    $n = Database::prepare(
126
+                        "SELECT COUNT(*) FROM `##media` WHERE m_file = :tree_id"
127
+                    )->execute(array('tree_id' => $tree->getTreeId()))->fetchOne();
128
+                    if ($n) {
129
+                        for ($i = 0; $i <= $n / self::RECORDS_PER_VOLUME; ++$i) {
130
+                            $data .= '<sitemap><loc>' . WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap-' . $tree->getTreeId() . '-m-' . $i . '.xml</loc>' . $lastmod . '</sitemap>' . PHP_EOL;
131
+                        }
132
+                    }
133
+                }
134
+            }
135
+            $data = '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . PHP_EOL . '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL . $data . '</sitemapindex>' . PHP_EOL;
136
+            // Cache this data.
137
+            $this->setSetting('sitemap.xml', $data);
138
+            $this->setSetting('sitemap.timestamp', WT_TIMESTAMP);
139
+        }
140
+        header('Content-Type: application/xml');
141
+        header('Content-Length: ' . strlen($data));
142
+        echo $data;
143
+    }
144 144
 
145
-	/**
146
-	 * A separate file for each family tree and each record type.
147
-	 * These files depend on access levels, so only cache for visitors.
148
-	 *
149
-	 * @param int    $ged_id
150
-	 * @param string $rec_type
151
-	 * @param string $volume
152
-	 */
153
-	private function generateFile($ged_id, $rec_type, $volume) {
154
-		$tree = Tree::findById($ged_id);
155
-		// Check the cache
156
-		$timestamp = $this->getSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.timestamp');
157
-		if ($timestamp > WT_TIMESTAMP - self::CACHE_LIFE && !Auth::check()) {
158
-			$data = $this->getSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.xml');
159
-		} else {
160
-			$data    = '<url><loc>' . WT_BASE_URL . 'index.php?ctype=gedcom&amp;ged=' . $tree->getNameUrl() . '</loc></url>' . PHP_EOL;
161
-			$records = array();
162
-			switch ($rec_type) {
163
-			case 'i':
164
-				$rows = Database::prepare(
165
-					"SELECT i_id AS xref, i_gedcom AS gedcom" .
166
-					" FROM `##individuals`" .
167
-					" WHERE i_file = :tree_id" .
168
-					" ORDER BY i_id" .
169
-					" LIMIT :limit OFFSET :offset"
170
-				)->execute(array(
171
-					'tree_id' => $ged_id,
172
-					'limit'   => self::RECORDS_PER_VOLUME,
173
-					'offset'  => self::RECORDS_PER_VOLUME * $volume,
174
-				))->fetchAll();
175
-				foreach ($rows as $row) {
176
-					$records[] = Individual::getInstance($row->xref, $tree, $row->gedcom);
177
-				}
178
-				break;
179
-			case 's':
180
-				$rows = Database::prepare(
181
-					"SELECT s_id AS xref, s_gedcom AS gedcom" .
182
-					" FROM `##sources`" .
183
-					" WHERE s_file = :tree_id" .
184
-					" ORDER BY s_id" .
185
-					" LIMIT :limit OFFSET :offset"
186
-				)->execute(array(
187
-					'tree_id' => $ged_id,
188
-					'limit'   => self::RECORDS_PER_VOLUME,
189
-					'offset'  => self::RECORDS_PER_VOLUME * $volume,
190
-				))->fetchAll();
191
-				foreach ($rows as $row) {
192
-					$records[] = Source::getInstance($row->xref, $tree, $row->gedcom);
193
-				}
194
-				break;
195
-			case 'r':
196
-				$rows = Database::prepare(
197
-					"SELECT o_id AS xref, o_gedcom AS gedcom" .
198
-					" FROM `##other`" .
199
-					" WHERE o_file = :tree_id AND o_type = 'REPO'" .
200
-					" ORDER BY o_id" .
201
-					" LIMIT :limit OFFSET :offset"
202
-				)->execute(array(
203
-					'tree_id' => $ged_id,
204
-					'limit'   => self::RECORDS_PER_VOLUME,
205
-					'offset'  => self::RECORDS_PER_VOLUME * $volume,
206
-				))->fetchAll();
207
-				foreach ($rows as $row) {
208
-					$records[] = Repository::getInstance($row->xref, $tree, $row->gedcom);
209
-				}
210
-				break;
211
-			case 'n':
212
-				$rows = Database::prepare(
213
-					"SELECT o_id AS xref, o_gedcom AS gedcom" .
214
-					" FROM `##other`" .
215
-					" WHERE o_file = :tree_id AND o_type = 'NOTE'" .
216
-					" ORDER BY o_id" .
217
-					" LIMIT :limit OFFSET :offset"
218
-				)->execute(array(
219
-					'tree_id' => $ged_id,
220
-					'limit'   => self::RECORDS_PER_VOLUME,
221
-					'offset'  => self::RECORDS_PER_VOLUME * $volume,
222
-				))->fetchAll();
223
-				foreach ($rows as $row) {
224
-					$records[] = Note::getInstance($row->xref, $tree, $row->gedcom);
225
-				}
226
-				break;
227
-			case 'm':
228
-				$rows = Database::prepare(
229
-					"SELECT m_id AS xref, m_gedcom AS gedcom" .
230
-					" FROM `##media`" .
231
-					" WHERE m_file = :tree_id" .
232
-					" ORDER BY m_id" .
233
-					" LIMIT :limit OFFSET :offset"
234
-				)->execute(array(
235
-					'tree_id' => $ged_id,
236
-					'limit'   => self::RECORDS_PER_VOLUME,
237
-					'offset'  => self::RECORDS_PER_VOLUME * $volume,
238
-				))->fetchAll();
239
-				foreach ($rows as $row) {
240
-					$records[] = Media::getInstance($row->xref, $tree, $row->gedcom);
241
-				}
242
-				break;
243
-			}
244
-			foreach ($records as $record) {
245
-				if ($record->canShowName()) {
246
-					$data .= '<url>';
247
-					$data .= '<loc>' . WT_BASE_URL . $record->getHtmlUrl() . '</loc>';
248
-					$chan = $record->getFirstFact('CHAN');
249
-					if ($chan) {
250
-						$date = $chan->getDate();
251
-						if ($date->isOK()) {
252
-							$data .= '<lastmod>' . $date->minimumDate()->Format('%Y-%m-%d') . '</lastmod>';
253
-						}
254
-					}
255
-					$data .= '</url>' . PHP_EOL;
256
-				}
257
-			}
258
-			$data = '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . PHP_EOL . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . PHP_EOL . $data . '</urlset>' . PHP_EOL;
259
-			// Cache this data - but only for visitors, as we don’t want
260
-			// visitors to see data created by signed-in users.
261
-			if (!Auth::check()) {
262
-				$this->setSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.xml', $data);
263
-				$this->setSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.timestamp', WT_TIMESTAMP);
264
-			}
265
-		}
266
-		header('Content-Type: application/xml');
267
-		header('Content-Length: ' . strlen($data));
268
-		echo $data;
269
-	}
145
+    /**
146
+     * A separate file for each family tree and each record type.
147
+     * These files depend on access levels, so only cache for visitors.
148
+     *
149
+     * @param int    $ged_id
150
+     * @param string $rec_type
151
+     * @param string $volume
152
+     */
153
+    private function generateFile($ged_id, $rec_type, $volume) {
154
+        $tree = Tree::findById($ged_id);
155
+        // Check the cache
156
+        $timestamp = $this->getSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.timestamp');
157
+        if ($timestamp > WT_TIMESTAMP - self::CACHE_LIFE && !Auth::check()) {
158
+            $data = $this->getSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.xml');
159
+        } else {
160
+            $data    = '<url><loc>' . WT_BASE_URL . 'index.php?ctype=gedcom&amp;ged=' . $tree->getNameUrl() . '</loc></url>' . PHP_EOL;
161
+            $records = array();
162
+            switch ($rec_type) {
163
+            case 'i':
164
+                $rows = Database::prepare(
165
+                    "SELECT i_id AS xref, i_gedcom AS gedcom" .
166
+                    " FROM `##individuals`" .
167
+                    " WHERE i_file = :tree_id" .
168
+                    " ORDER BY i_id" .
169
+                    " LIMIT :limit OFFSET :offset"
170
+                )->execute(array(
171
+                    'tree_id' => $ged_id,
172
+                    'limit'   => self::RECORDS_PER_VOLUME,
173
+                    'offset'  => self::RECORDS_PER_VOLUME * $volume,
174
+                ))->fetchAll();
175
+                foreach ($rows as $row) {
176
+                    $records[] = Individual::getInstance($row->xref, $tree, $row->gedcom);
177
+                }
178
+                break;
179
+            case 's':
180
+                $rows = Database::prepare(
181
+                    "SELECT s_id AS xref, s_gedcom AS gedcom" .
182
+                    " FROM `##sources`" .
183
+                    " WHERE s_file = :tree_id" .
184
+                    " ORDER BY s_id" .
185
+                    " LIMIT :limit OFFSET :offset"
186
+                )->execute(array(
187
+                    'tree_id' => $ged_id,
188
+                    'limit'   => self::RECORDS_PER_VOLUME,
189
+                    'offset'  => self::RECORDS_PER_VOLUME * $volume,
190
+                ))->fetchAll();
191
+                foreach ($rows as $row) {
192
+                    $records[] = Source::getInstance($row->xref, $tree, $row->gedcom);
193
+                }
194
+                break;
195
+            case 'r':
196
+                $rows = Database::prepare(
197
+                    "SELECT o_id AS xref, o_gedcom AS gedcom" .
198
+                    " FROM `##other`" .
199
+                    " WHERE o_file = :tree_id AND o_type = 'REPO'" .
200
+                    " ORDER BY o_id" .
201
+                    " LIMIT :limit OFFSET :offset"
202
+                )->execute(array(
203
+                    'tree_id' => $ged_id,
204
+                    'limit'   => self::RECORDS_PER_VOLUME,
205
+                    'offset'  => self::RECORDS_PER_VOLUME * $volume,
206
+                ))->fetchAll();
207
+                foreach ($rows as $row) {
208
+                    $records[] = Repository::getInstance($row->xref, $tree, $row->gedcom);
209
+                }
210
+                break;
211
+            case 'n':
212
+                $rows = Database::prepare(
213
+                    "SELECT o_id AS xref, o_gedcom AS gedcom" .
214
+                    " FROM `##other`" .
215
+                    " WHERE o_file = :tree_id AND o_type = 'NOTE'" .
216
+                    " ORDER BY o_id" .
217
+                    " LIMIT :limit OFFSET :offset"
218
+                )->execute(array(
219
+                    'tree_id' => $ged_id,
220
+                    'limit'   => self::RECORDS_PER_VOLUME,
221
+                    'offset'  => self::RECORDS_PER_VOLUME * $volume,
222
+                ))->fetchAll();
223
+                foreach ($rows as $row) {
224
+                    $records[] = Note::getInstance($row->xref, $tree, $row->gedcom);
225
+                }
226
+                break;
227
+            case 'm':
228
+                $rows = Database::prepare(
229
+                    "SELECT m_id AS xref, m_gedcom AS gedcom" .
230
+                    " FROM `##media`" .
231
+                    " WHERE m_file = :tree_id" .
232
+                    " ORDER BY m_id" .
233
+                    " LIMIT :limit OFFSET :offset"
234
+                )->execute(array(
235
+                    'tree_id' => $ged_id,
236
+                    'limit'   => self::RECORDS_PER_VOLUME,
237
+                    'offset'  => self::RECORDS_PER_VOLUME * $volume,
238
+                ))->fetchAll();
239
+                foreach ($rows as $row) {
240
+                    $records[] = Media::getInstance($row->xref, $tree, $row->gedcom);
241
+                }
242
+                break;
243
+            }
244
+            foreach ($records as $record) {
245
+                if ($record->canShowName()) {
246
+                    $data .= '<url>';
247
+                    $data .= '<loc>' . WT_BASE_URL . $record->getHtmlUrl() . '</loc>';
248
+                    $chan = $record->getFirstFact('CHAN');
249
+                    if ($chan) {
250
+                        $date = $chan->getDate();
251
+                        if ($date->isOK()) {
252
+                            $data .= '<lastmod>' . $date->minimumDate()->Format('%Y-%m-%d') . '</lastmod>';
253
+                        }
254
+                    }
255
+                    $data .= '</url>' . PHP_EOL;
256
+                }
257
+            }
258
+            $data = '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . PHP_EOL . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . PHP_EOL . $data . '</urlset>' . PHP_EOL;
259
+            // Cache this data - but only for visitors, as we don’t want
260
+            // visitors to see data created by signed-in users.
261
+            if (!Auth::check()) {
262
+                $this->setSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.xml', $data);
263
+                $this->setSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.timestamp', WT_TIMESTAMP);
264
+            }
265
+        }
266
+        header('Content-Type: application/xml');
267
+        header('Content-Length: ' . strlen($data));
268
+        echo $data;
269
+    }
270 270
 
271
-	/**
272
-	 * Edit the configuration
273
-	 */
274
-	private function admin() {
275
-		$controller = new PageController;
276
-		$controller
277
-			->restrictAccess(Auth::isAdmin())
278
-			->setPageTitle($this->getTitle())
279
-			->pageHeader();
271
+    /**
272
+     * Edit the configuration
273
+     */
274
+    private function admin() {
275
+        $controller = new PageController;
276
+        $controller
277
+            ->restrictAccess(Auth::isAdmin())
278
+            ->setPageTitle($this->getTitle())
279
+            ->pageHeader();
280 280
 
281
-		// Save the updated preferences
282
-		if (Filter::post('action') == 'save') {
283
-			foreach (Tree::getAll() as $tree) {
284
-				$tree->setPreference('include_in_sitemap', Filter::postBool('include' . $tree->getTreeId()));
285
-			}
286
-			// Clear cache and force files to be regenerated
287
-			Database::prepare(
288
-				"DELETE FROM `##module_setting` WHERE setting_name LIKE 'sitemap%'"
289
-			)->execute();
290
-		}
281
+        // Save the updated preferences
282
+        if (Filter::post('action') == 'save') {
283
+            foreach (Tree::getAll() as $tree) {
284
+                $tree->setPreference('include_in_sitemap', Filter::postBool('include' . $tree->getTreeId()));
285
+            }
286
+            // Clear cache and force files to be regenerated
287
+            Database::prepare(
288
+                "DELETE FROM `##module_setting` WHERE setting_name LIKE 'sitemap%'"
289
+            )->execute();
290
+        }
291 291
 
292
-		$include_any = false;
292
+        $include_any = false;
293 293
 
294
-		?>
294
+        ?>
295 295
 		<ol class="breadcrumb small">
296 296
 			<li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li>
297 297
 			<li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li>
@@ -300,46 +300,46 @@  discard block
 block discarded – undo
300 300
 		<h1><?php echo $controller->getPageTitle(); ?></h1>
301 301
 		<?php
302 302
 
303
-		echo
304
-		'<p>',
305
-			/* I18N: The www.sitemaps.org site is translated into many languages (e.g. http://www.sitemaps.org/fr/) - choose an appropriate URL. */
306
-			I18N::translate('Sitemaps are a way for webmasters to tell search engines about the pages on a website that are available for crawling. All major search engines support sitemaps. For more information, see <a href="http://www.sitemaps.org/">www.sitemaps.org</a>.') .
307
-			'</p>',
308
-		'<p>', /* I18N: Label for a configuration option */ I18N::translate('Which family trees should be included in the sitemaps'), '</p>',
309
-			'<form method="post" action="module.php?mod=' . $this->getName() . '&amp;mod_action=admin">',
310
-		'<input type="hidden" name="action" value="save">';
311
-		foreach (Tree::getAll() as $tree) {
312
-			echo '<div class="checkbox"><label><input type="checkbox" name="include', $tree->getTreeId(), '" ';
313
-			if ($tree->getPreference('include_in_sitemap')) {
314
-				echo 'checked';
315
-				$include_any = true;
316
-			}
317
-			echo '>', $tree->getTitleHtml(), '</label></div>';
318
-		}
319
-		echo
320
-		'<input type="submit" value="', I18N::translate('save'), '">',
321
-		'</form>',
322
-		'<hr>';
303
+        echo
304
+        '<p>',
305
+            /* I18N: The www.sitemaps.org site is translated into many languages (e.g. http://www.sitemaps.org/fr/) - choose an appropriate URL. */
306
+            I18N::translate('Sitemaps are a way for webmasters to tell search engines about the pages on a website that are available for crawling. All major search engines support sitemaps. For more information, see <a href="http://www.sitemaps.org/">www.sitemaps.org</a>.') .
307
+            '</p>',
308
+        '<p>', /* I18N: Label for a configuration option */ I18N::translate('Which family trees should be included in the sitemaps'), '</p>',
309
+            '<form method="post" action="module.php?mod=' . $this->getName() . '&amp;mod_action=admin">',
310
+        '<input type="hidden" name="action" value="save">';
311
+        foreach (Tree::getAll() as $tree) {
312
+            echo '<div class="checkbox"><label><input type="checkbox" name="include', $tree->getTreeId(), '" ';
313
+            if ($tree->getPreference('include_in_sitemap')) {
314
+                echo 'checked';
315
+                $include_any = true;
316
+            }
317
+            echo '>', $tree->getTitleHtml(), '</label></div>';
318
+        }
319
+        echo
320
+        '<input type="submit" value="', I18N::translate('save'), '">',
321
+        '</form>',
322
+        '<hr>';
323 323
 
324
-		if ($include_any) {
325
-			$site_map_url1 = WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap.xml';
326
-			$site_map_url2 = rawurlencode(WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&mod_action=generate&file=sitemap.xml');
327
-			echo
328
-				'<p>', I18N::translate('To tell search engines that sitemaps are available, you should add the following line to your robots.txt file.'), '</p>',
329
-				'<pre>Sitemap: ', $site_map_url1, '</pre>',
330
-				'<hr>',
331
-				'<p>', I18N::translate('To tell search engines that sitemaps are available, you can use the following links.'), '</p>',
332
-				'<ul>',
333
-				// This list comes from http://en.wikipedia.org/wiki/Sitemaps
334
-				'<li><a href="https://www.bing.com/webmaster/ping.aspx?siteMap=' . $site_map_url2 . '">Bing</a></li>',
335
-				'<li><a href="https://www.google.com/webmasters/tools/ping?sitemap=' . $site_map_url2 . '">Google</a></li>',
336
-				'</ul>';
324
+        if ($include_any) {
325
+            $site_map_url1 = WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap.xml';
326
+            $site_map_url2 = rawurlencode(WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&mod_action=generate&file=sitemap.xml');
327
+            echo
328
+                '<p>', I18N::translate('To tell search engines that sitemaps are available, you should add the following line to your robots.txt file.'), '</p>',
329
+                '<pre>Sitemap: ', $site_map_url1, '</pre>',
330
+                '<hr>',
331
+                '<p>', I18N::translate('To tell search engines that sitemaps are available, you can use the following links.'), '</p>',
332
+                '<ul>',
333
+                // This list comes from http://en.wikipedia.org/wiki/Sitemaps
334
+                '<li><a href="https://www.bing.com/webmaster/ping.aspx?siteMap=' . $site_map_url2 . '">Bing</a></li>',
335
+                '<li><a href="https://www.google.com/webmasters/tools/ping?sitemap=' . $site_map_url2 . '">Google</a></li>',
336
+                '</ul>';
337 337
 
338
-		}
339
-	}
338
+        }
339
+    }
340 340
 
341
-	/** {@inheritdoc} */
342
-	public function getConfigLink() {
343
-		return 'module.php?mod=' . $this->getName() . '&amp;mod_action=admin';
344
-	}
341
+    /** {@inheritdoc} */
342
+    public function getConfigLink() {
343
+        return 'module.php?mod=' . $this->getName() . '&amp;mod_action=admin';
344
+    }
345 345
 }
Please login to merge, or discard this patch.
Switch Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function modAction($mod_action) {
54 54
 		switch ($mod_action) {
55
-		case 'admin':
56
-			$this->admin();
57
-			break;
58
-		case 'generate':
59
-			$this->generate(Filter::get('file'));
60
-			break;
61
-		default:
62
-			http_response_code(404);
55
+		    case 'admin':
56
+			    $this->admin();
57
+			    break;
58
+		    case 'generate':
59
+			    $this->generate(Filter::get('file'));
60
+			    break;
61
+		    default:
62
+			    http_response_code(404);
63 63
 		}
64 64
 	}
65 65
 
@@ -160,86 +160,86 @@  discard block
 block discarded – undo
160 160
 			$data    = '<url><loc>' . WT_BASE_URL . 'index.php?ctype=gedcom&amp;ged=' . $tree->getNameUrl() . '</loc></url>' . PHP_EOL;
161 161
 			$records = array();
162 162
 			switch ($rec_type) {
163
-			case 'i':
164
-				$rows = Database::prepare(
165
-					"SELECT i_id AS xref, i_gedcom AS gedcom" .
166
-					" FROM `##individuals`" .
167
-					" WHERE i_file = :tree_id" .
168
-					" ORDER BY i_id" .
169
-					" LIMIT :limit OFFSET :offset"
170
-				)->execute(array(
171
-					'tree_id' => $ged_id,
172
-					'limit'   => self::RECORDS_PER_VOLUME,
173
-					'offset'  => self::RECORDS_PER_VOLUME * $volume,
174
-				))->fetchAll();
175
-				foreach ($rows as $row) {
176
-					$records[] = Individual::getInstance($row->xref, $tree, $row->gedcom);
177
-				}
178
-				break;
179
-			case 's':
180
-				$rows = Database::prepare(
181
-					"SELECT s_id AS xref, s_gedcom AS gedcom" .
182
-					" FROM `##sources`" .
183
-					" WHERE s_file = :tree_id" .
184
-					" ORDER BY s_id" .
185
-					" LIMIT :limit OFFSET :offset"
186
-				)->execute(array(
187
-					'tree_id' => $ged_id,
188
-					'limit'   => self::RECORDS_PER_VOLUME,
189
-					'offset'  => self::RECORDS_PER_VOLUME * $volume,
190
-				))->fetchAll();
191
-				foreach ($rows as $row) {
192
-					$records[] = Source::getInstance($row->xref, $tree, $row->gedcom);
193
-				}
194
-				break;
195
-			case 'r':
196
-				$rows = Database::prepare(
197
-					"SELECT o_id AS xref, o_gedcom AS gedcom" .
198
-					" FROM `##other`" .
199
-					" WHERE o_file = :tree_id AND o_type = 'REPO'" .
200
-					" ORDER BY o_id" .
201
-					" LIMIT :limit OFFSET :offset"
202
-				)->execute(array(
203
-					'tree_id' => $ged_id,
204
-					'limit'   => self::RECORDS_PER_VOLUME,
205
-					'offset'  => self::RECORDS_PER_VOLUME * $volume,
206
-				))->fetchAll();
207
-				foreach ($rows as $row) {
208
-					$records[] = Repository::getInstance($row->xref, $tree, $row->gedcom);
209
-				}
210
-				break;
211
-			case 'n':
212
-				$rows = Database::prepare(
213
-					"SELECT o_id AS xref, o_gedcom AS gedcom" .
214
-					" FROM `##other`" .
215
-					" WHERE o_file = :tree_id AND o_type = 'NOTE'" .
216
-					" ORDER BY o_id" .
217
-					" LIMIT :limit OFFSET :offset"
218
-				)->execute(array(
219
-					'tree_id' => $ged_id,
220
-					'limit'   => self::RECORDS_PER_VOLUME,
221
-					'offset'  => self::RECORDS_PER_VOLUME * $volume,
222
-				))->fetchAll();
223
-				foreach ($rows as $row) {
224
-					$records[] = Note::getInstance($row->xref, $tree, $row->gedcom);
225
-				}
226
-				break;
227
-			case 'm':
228
-				$rows = Database::prepare(
229
-					"SELECT m_id AS xref, m_gedcom AS gedcom" .
230
-					" FROM `##media`" .
231
-					" WHERE m_file = :tree_id" .
232
-					" ORDER BY m_id" .
233
-					" LIMIT :limit OFFSET :offset"
234
-				)->execute(array(
235
-					'tree_id' => $ged_id,
236
-					'limit'   => self::RECORDS_PER_VOLUME,
237
-					'offset'  => self::RECORDS_PER_VOLUME * $volume,
238
-				))->fetchAll();
239
-				foreach ($rows as $row) {
240
-					$records[] = Media::getInstance($row->xref, $tree, $row->gedcom);
241
-				}
242
-				break;
163
+			    case 'i':
164
+				    $rows = Database::prepare(
165
+					    "SELECT i_id AS xref, i_gedcom AS gedcom" .
166
+					    " FROM `##individuals`" .
167
+					    " WHERE i_file = :tree_id" .
168
+					    " ORDER BY i_id" .
169
+					    " LIMIT :limit OFFSET :offset"
170
+				    )->execute(array(
171
+					    'tree_id' => $ged_id,
172
+					    'limit'   => self::RECORDS_PER_VOLUME,
173
+					    'offset'  => self::RECORDS_PER_VOLUME * $volume,
174
+				    ))->fetchAll();
175
+				    foreach ($rows as $row) {
176
+					    $records[] = Individual::getInstance($row->xref, $tree, $row->gedcom);
177
+				    }
178
+				    break;
179
+			    case 's':
180
+				    $rows = Database::prepare(
181
+					    "SELECT s_id AS xref, s_gedcom AS gedcom" .
182
+					    " FROM `##sources`" .
183
+					    " WHERE s_file = :tree_id" .
184
+					    " ORDER BY s_id" .
185
+					    " LIMIT :limit OFFSET :offset"
186
+				    )->execute(array(
187
+					    'tree_id' => $ged_id,
188
+					    'limit'   => self::RECORDS_PER_VOLUME,
189
+					    'offset'  => self::RECORDS_PER_VOLUME * $volume,
190
+				    ))->fetchAll();
191
+				    foreach ($rows as $row) {
192
+					    $records[] = Source::getInstance($row->xref, $tree, $row->gedcom);
193
+				    }
194
+				    break;
195
+			    case 'r':
196
+				    $rows = Database::prepare(
197
+					    "SELECT o_id AS xref, o_gedcom AS gedcom" .
198
+					    " FROM `##other`" .
199
+					    " WHERE o_file = :tree_id AND o_type = 'REPO'" .
200
+					    " ORDER BY o_id" .
201
+					    " LIMIT :limit OFFSET :offset"
202
+				    )->execute(array(
203
+					    'tree_id' => $ged_id,
204
+					    'limit'   => self::RECORDS_PER_VOLUME,
205
+					    'offset'  => self::RECORDS_PER_VOLUME * $volume,
206
+				    ))->fetchAll();
207
+				    foreach ($rows as $row) {
208
+					    $records[] = Repository::getInstance($row->xref, $tree, $row->gedcom);
209
+				    }
210
+				    break;
211
+			    case 'n':
212
+				    $rows = Database::prepare(
213
+					    "SELECT o_id AS xref, o_gedcom AS gedcom" .
214
+					    " FROM `##other`" .
215
+					    " WHERE o_file = :tree_id AND o_type = 'NOTE'" .
216
+					    " ORDER BY o_id" .
217
+					    " LIMIT :limit OFFSET :offset"
218
+				    )->execute(array(
219
+					    'tree_id' => $ged_id,
220
+					    'limit'   => self::RECORDS_PER_VOLUME,
221
+					    'offset'  => self::RECORDS_PER_VOLUME * $volume,
222
+				    ))->fetchAll();
223
+				    foreach ($rows as $row) {
224
+					    $records[] = Note::getInstance($row->xref, $tree, $row->gedcom);
225
+				    }
226
+				    break;
227
+			    case 'm':
228
+				    $rows = Database::prepare(
229
+					    "SELECT m_id AS xref, m_gedcom AS gedcom" .
230
+					    " FROM `##media`" .
231
+					    " WHERE m_file = :tree_id" .
232
+					    " ORDER BY m_id" .
233
+					    " LIMIT :limit OFFSET :offset"
234
+				    )->execute(array(
235
+					    'tree_id' => $ged_id,
236
+					    'limit'   => self::RECORDS_PER_VOLUME,
237
+					    'offset'  => self::RECORDS_PER_VOLUME * $volume,
238
+				    ))->fetchAll();
239
+				    foreach ($rows as $row) {
240
+					    $records[] = Media::getInstance($row->xref, $tree, $row->gedcom);
241
+				    }
242
+				    break;
243 243
 			}
244 244
 			foreach ($records as $record) {
245 245
 				if ($record->canShowName()) {
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,17 +30,20 @@  discard block
 block discarded – undo
30 30
 /**
31 31
  * Class SiteMapModule
32 32
  */
33
-class SiteMapModule extends AbstractModule implements ModuleConfigInterface {
33
+class SiteMapModule extends AbstractModule implements ModuleConfigInterface
34
+{
34 35
 	const RECORDS_PER_VOLUME = 500; // Keep sitemap files small, for memory, CPU and max_allowed_packet limits.
35 36
 	const CACHE_LIFE         = 1209600; // Two weeks
36 37
 
37 38
 	/** {@inheritdoc} */
38
-	public function getTitle() {
39
+	public function getTitle()
40
+	{
39 41
 		return /* I18N: Name of a module - see http://en.wikipedia.org/wiki/Sitemaps */ I18N::translate('Sitemaps');
40 42
 	}
41 43
 
42 44
 	/** {@inheritdoc} */
43
-	public function getDescription() {
45
+	public function getDescription()
46
+	{
44 47
 		return /* I18N: Description of the “Sitemaps” module */ I18N::translate('Generate sitemap files for search engines.');
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 'admin':
56 60
 			$this->admin();
@@ -68,7 +72,8 @@  discard block
 block discarded – undo
68 72
 	 *
69 73
 	 * @param string $file
70 74
 	 */
71
-	private function generate($file) {
75
+	private function generate($file)
76
+	{
72 77
 		if ($file == 'sitemap.xml') {
73 78
 			$this->generateIndex();
74 79
 		} elseif (preg_match('/^sitemap-(\d+)-([isrmn])-(\d+).xml$/', $file, $match)) {
@@ -82,7 +87,8 @@  discard block
 block discarded – undo
82 87
 	 * The index file contains references to all the other files.
83 88
 	 * These files are the same for visitors/users/admins.
84 89
 	 */
85
-	private function generateIndex() {
90
+	private function generateIndex()
91
+	{
86 92
 		// Check the cache
87 93
 		$timestamp = $this->getSetting('sitemap.timestamp');
88 94
 		if ($timestamp > WT_TIMESTAMP - self::CACHE_LIFE) {
@@ -150,7 +156,8 @@  discard block
 block discarded – undo
150 156
 	 * @param string $rec_type
151 157
 	 * @param string $volume
152 158
 	 */
153
-	private function generateFile($ged_id, $rec_type, $volume) {
159
+	private function generateFile($ged_id, $rec_type, $volume)
160
+	{
154 161
 		$tree = Tree::findById($ged_id);
155 162
 		// Check the cache
156 163
 		$timestamp = $this->getSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.timestamp');
@@ -271,7 +278,8 @@  discard block
 block discarded – undo
271 278
 	/**
272 279
 	 * Edit the configuration
273 280
 	 */
274
-	private function admin() {
281
+	private function admin()
282
+	{
275 283
 		$controller = new PageController;
276 284
 		$controller
277 285
 			->restrictAccess(Auth::isAdmin())
@@ -339,7 +347,8 @@  discard block
 block discarded – undo
339 347
 	}
340 348
 
341 349
 	/** {@inheritdoc} */
342
-	public function getConfigLink() {
350
+	public function getConfigLink()
351
+	{
343 352
 		return 'module.php?mod=' . $this->getName() . '&amp;mod_action=admin';
344 353
 	}
345 354
 }
Please login to merge, or discard this patch.
app/Module/FamilyTreeNewsModule.php 3 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -26,144 +26,144 @@
 block discarded – undo
26 26
  * Class FamilyTreeNewsModule
27 27
  */
28 28
 class FamilyTreeNewsModule extends AbstractModule implements ModuleBlockInterface {
29
-	// How to update the database schema for this module
30
-	const SCHEMA_TARGET_VERSION   = 3;
31
-	const SCHEMA_SETTING_NAME     = 'NB_SCHEMA_VERSION';
32
-	const SCHEMA_MIGRATION_PREFIX = '\Fisharebest\Webtrees\Module\FamilyTreeNews\Schema';
33
-
34
-	/**
35
-	 * Create a new module.
36
-	 *
37
-	 * @param string $directory Where is this module installed
38
-	 */
39
-	public function __construct($directory) {
40
-		parent::__construct($directory);
41
-
42
-		// Create/update the database tables.
43
-		// NOTE: if we want to set any module-settings, we'll need to move this.
44
-		Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
45
-	}
46
-
47
-	/**
48
-	 * How should this module be labelled on tabs, menus, etc.?
49
-	 *
50
-	 * @return string
51
-	 */
52
-	public function getTitle() {
53
-		return /* I18N: Name of a module */ I18N::translate('News');
54
-	}
55
-
56
-	/**
57
-	 * A sentence describing what this module does.
58
-	 *
59
-	 * @return string
60
-	 */
61
-	public function getDescription() {
62
-		return /* I18N: Description of the “News” module */ I18N::translate('Family news and site announcements.');
63
-	}
64
-
65
-	/**
66
-	 * Generate the HTML content of this block.
67
-	 *
68
-	 * @param int      $block_id
69
-	 * @param bool     $template
70
-	 * @param string[] $cfg
71
-	 *
72
-	 * @return string
73
-	 */
74
-	public function getBlock($block_id, $template = true, $cfg = array()) {
75
-		global $ctype, $WT_TREE;
76
-
77
-		switch (Filter::get('action')) {
78
-		case 'deletenews':
79
-			$news_id = Filter::get('news_id');
80
-			if ($news_id) {
81
-				Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id));
82
-			}
83
-			break;
84
-		}
85
-
86
-		$more_news = Filter::getInteger('more_news');
87
-		$limit     = 5 * (1 + $more_news);
88
-
89
-		$articles = Database::prepare(
90
-			"SELECT news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) + :offset AS updated, subject, body FROM `##news` WHERE gedcom_id = :tree_id ORDER BY updated DESC LIMIT :limit"
91
-		)->execute(array(
92
-			'offset'  => WT_TIMESTAMP_OFFSET,
93
-			'tree_id' => $WT_TREE->getTreeId(),
94
-			'limit'   => $limit,
95
-		))->fetchAll();
96
-
97
-		$count = Database::prepare(
98
-			"SELECT COUNT(*) FROM `##news` WHERE gedcom_id = :tree_id"
99
-		)->execute(array(
100
-			'tree_id' => $WT_TREE->getTreeId(),
101
-		))->fetchOne();
102
-
103
-		$id      = $this->getName() . $block_id;
104
-		$class   = $this->getName() . '_block';
105
-		$title   = $this->getTitle();
106
-		$content = '';
107
-
108
-		if (empty($articles)) {
109
-			$content .= I18N::translate('No news articles have been submitted.');
110
-		}
111
-
112
-		foreach ($articles as $article) {
113
-			$content .= '<div class="news_box">';
114
-			$content .= '<div class="news_title">' . Filter::escapeHtml($article->subject) . '</div>';
115
-			$content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($article->updated) . '</div>';
116
-			if ($article->body == strip_tags($article->body)) {
117
-				$article->body = nl2br($article->body, false);
118
-			}
119
-			$content .= $article->body;
120
-			if (Auth::isManager($WT_TREE)) {
121
-				$content .= '<hr>';
122
-				$content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $article->news_id . ', \'_blank\', news_window_specs); return false;">' . I18N::translate('Edit') . '</a>';
123
-				$content .= ' | ';
124
-				$content .= '<a href="index.php?action=deletenews&amp;news_id=' . $article->news_id . '&amp;ctype=' . $ctype . '&amp;ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($article->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>';
125
-			}
126
-			$content .= '</div>';
127
-		}
128
-
129
-		if (Auth::isManager($WT_TREE)) {
130
-			$content .= '<a href="#" onclick="window.open(\'editnews.php?gedcom_id=' . $WT_TREE->getTreeId() . '\', \'_blank\', news_window_specs); return false;">' . I18N::translate('Add a news article') . '</a>';
131
-		}
132
-
133
-		if ($count > $limit) {
134
-			if (Auth::isManager($WT_TREE)) {
135
-				$content .= ' | ';
136
-			}
137
-			$content .= '<a href="#" onclick="jQuery(\'#' . $id . '\').load(\'index.php?ctype=gedcom&amp;ged=' . $WT_TREE->getNameUrl() . '&amp;block_id=' . $block_id . '&amp;action=ajax&amp;more_news=' . ($more_news + 1) . '\'); return false;">' . I18N::translate('More news articles') . "</a>";
138
-		}
139
-
140
-		if ($template) {
141
-			return Theme::theme()->formatBlock($id, $title, $class, $content);
142
-		} else {
143
-			return $content;
144
-		}
145
-	}
146
-
147
-	/** {@inheritdoc} */
148
-	public function loadAjax() {
149
-		return false;
150
-	}
151
-
152
-	/** {@inheritdoc} */
153
-	public function isUserBlock() {
154
-		return false;
155
-	}
156
-
157
-	/** {@inheritdoc} */
158
-	public function isGedcomBlock() {
159
-		return true;
160
-	}
161
-
162
-	/**
163
-	 * An HTML form to edit block settings
164
-	 *
165
-	 * @param int $block_id
166
-	 */
167
-	public function configureBlock($block_id) {
168
-	}
29
+    // How to update the database schema for this module
30
+    const SCHEMA_TARGET_VERSION   = 3;
31
+    const SCHEMA_SETTING_NAME     = 'NB_SCHEMA_VERSION';
32
+    const SCHEMA_MIGRATION_PREFIX = '\Fisharebest\Webtrees\Module\FamilyTreeNews\Schema';
33
+
34
+    /**
35
+     * Create a new module.
36
+     *
37
+     * @param string $directory Where is this module installed
38
+     */
39
+    public function __construct($directory) {
40
+        parent::__construct($directory);
41
+
42
+        // Create/update the database tables.
43
+        // NOTE: if we want to set any module-settings, we'll need to move this.
44
+        Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
45
+    }
46
+
47
+    /**
48
+     * How should this module be labelled on tabs, menus, etc.?
49
+     *
50
+     * @return string
51
+     */
52
+    public function getTitle() {
53
+        return /* I18N: Name of a module */ I18N::translate('News');
54
+    }
55
+
56
+    /**
57
+     * A sentence describing what this module does.
58
+     *
59
+     * @return string
60
+     */
61
+    public function getDescription() {
62
+        return /* I18N: Description of the “News” module */ I18N::translate('Family news and site announcements.');
63
+    }
64
+
65
+    /**
66
+     * Generate the HTML content of this block.
67
+     *
68
+     * @param int      $block_id
69
+     * @param bool     $template
70
+     * @param string[] $cfg
71
+     *
72
+     * @return string
73
+     */
74
+    public function getBlock($block_id, $template = true, $cfg = array()) {
75
+        global $ctype, $WT_TREE;
76
+
77
+        switch (Filter::get('action')) {
78
+        case 'deletenews':
79
+            $news_id = Filter::get('news_id');
80
+            if ($news_id) {
81
+                Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id));
82
+            }
83
+            break;
84
+        }
85
+
86
+        $more_news = Filter::getInteger('more_news');
87
+        $limit     = 5 * (1 + $more_news);
88
+
89
+        $articles = Database::prepare(
90
+            "SELECT news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) + :offset AS updated, subject, body FROM `##news` WHERE gedcom_id = :tree_id ORDER BY updated DESC LIMIT :limit"
91
+        )->execute(array(
92
+            'offset'  => WT_TIMESTAMP_OFFSET,
93
+            'tree_id' => $WT_TREE->getTreeId(),
94
+            'limit'   => $limit,
95
+        ))->fetchAll();
96
+
97
+        $count = Database::prepare(
98
+            "SELECT COUNT(*) FROM `##news` WHERE gedcom_id = :tree_id"
99
+        )->execute(array(
100
+            'tree_id' => $WT_TREE->getTreeId(),
101
+        ))->fetchOne();
102
+
103
+        $id      = $this->getName() . $block_id;
104
+        $class   = $this->getName() . '_block';
105
+        $title   = $this->getTitle();
106
+        $content = '';
107
+
108
+        if (empty($articles)) {
109
+            $content .= I18N::translate('No news articles have been submitted.');
110
+        }
111
+
112
+        foreach ($articles as $article) {
113
+            $content .= '<div class="news_box">';
114
+            $content .= '<div class="news_title">' . Filter::escapeHtml($article->subject) . '</div>';
115
+            $content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($article->updated) . '</div>';
116
+            if ($article->body == strip_tags($article->body)) {
117
+                $article->body = nl2br($article->body, false);
118
+            }
119
+            $content .= $article->body;
120
+            if (Auth::isManager($WT_TREE)) {
121
+                $content .= '<hr>';
122
+                $content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $article->news_id . ', \'_blank\', news_window_specs); return false;">' . I18N::translate('Edit') . '</a>';
123
+                $content .= ' | ';
124
+                $content .= '<a href="index.php?action=deletenews&amp;news_id=' . $article->news_id . '&amp;ctype=' . $ctype . '&amp;ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($article->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>';
125
+            }
126
+            $content .= '</div>';
127
+        }
128
+
129
+        if (Auth::isManager($WT_TREE)) {
130
+            $content .= '<a href="#" onclick="window.open(\'editnews.php?gedcom_id=' . $WT_TREE->getTreeId() . '\', \'_blank\', news_window_specs); return false;">' . I18N::translate('Add a news article') . '</a>';
131
+        }
132
+
133
+        if ($count > $limit) {
134
+            if (Auth::isManager($WT_TREE)) {
135
+                $content .= ' | ';
136
+            }
137
+            $content .= '<a href="#" onclick="jQuery(\'#' . $id . '\').load(\'index.php?ctype=gedcom&amp;ged=' . $WT_TREE->getNameUrl() . '&amp;block_id=' . $block_id . '&amp;action=ajax&amp;more_news=' . ($more_news + 1) . '\'); return false;">' . I18N::translate('More news articles') . "</a>";
138
+        }
139
+
140
+        if ($template) {
141
+            return Theme::theme()->formatBlock($id, $title, $class, $content);
142
+        } else {
143
+            return $content;
144
+        }
145
+    }
146
+
147
+    /** {@inheritdoc} */
148
+    public function loadAjax() {
149
+        return false;
150
+    }
151
+
152
+    /** {@inheritdoc} */
153
+    public function isUserBlock() {
154
+        return false;
155
+    }
156
+
157
+    /** {@inheritdoc} */
158
+    public function isGedcomBlock() {
159
+        return true;
160
+    }
161
+
162
+    /**
163
+     * An HTML form to edit block settings
164
+     *
165
+     * @param int $block_id
166
+     */
167
+    public function configureBlock($block_id) {
168
+    }
169 169
 }
Please login to merge, or discard this patch.
Switch Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -75,12 +75,12 @@
 block discarded – undo
75 75
 		global $ctype, $WT_TREE;
76 76
 
77 77
 		switch (Filter::get('action')) {
78
-		case 'deletenews':
79
-			$news_id = Filter::get('news_id');
80
-			if ($news_id) {
81
-				Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id));
82
-			}
83
-			break;
78
+		    case 'deletenews':
79
+			    $news_id = Filter::get('news_id');
80
+			    if ($news_id) {
81
+				    Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id));
82
+			    }
83
+			    break;
84 84
 		}
85 85
 
86 86
 		$more_news = Filter::getInteger('more_news');
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@  discard block
 block discarded – undo
25 25
 /**
26 26
  * Class FamilyTreeNewsModule
27 27
  */
28
-class FamilyTreeNewsModule extends AbstractModule implements ModuleBlockInterface {
28
+class FamilyTreeNewsModule extends AbstractModule implements ModuleBlockInterface
29
+{
29 30
 	// How to update the database schema for this module
30 31
 	const SCHEMA_TARGET_VERSION   = 3;
31 32
 	const SCHEMA_SETTING_NAME     = 'NB_SCHEMA_VERSION';
@@ -36,7 +37,8 @@  discard block
 block discarded – undo
36 37
 	 *
37 38
 	 * @param string $directory Where is this module installed
38 39
 	 */
39
-	public function __construct($directory) {
40
+	public function __construct($directory)
41
+	{
40 42
 		parent::__construct($directory);
41 43
 
42 44
 		// Create/update the database tables.
@@ -49,7 +51,8 @@  discard block
 block discarded – undo
49 51
 	 *
50 52
 	 * @return string
51 53
 	 */
52
-	public function getTitle() {
54
+	public function getTitle()
55
+	{
53 56
 		return /* I18N: Name of a module */ I18N::translate('News');
54 57
 	}
55 58
 
@@ -58,7 +61,8 @@  discard block
 block discarded – undo
58 61
 	 *
59 62
 	 * @return string
60 63
 	 */
61
-	public function getDescription() {
64
+	public function getDescription()
65
+	{
62 66
 		return /* I18N: Description of the “News” module */ I18N::translate('Family news and site announcements.');
63 67
 	}
64 68
 
@@ -71,7 +75,8 @@  discard block
 block discarded – undo
71 75
 	 *
72 76
 	 * @return string
73 77
 	 */
74
-	public function getBlock($block_id, $template = true, $cfg = array()) {
78
+	public function getBlock($block_id, $template = true, $cfg = array())
79
+	{
75 80
 		global $ctype, $WT_TREE;
76 81
 
77 82
 		switch (Filter::get('action')) {
@@ -145,17 +150,20 @@  discard block
 block discarded – undo
145 150
 	}
146 151
 
147 152
 	/** {@inheritdoc} */
148
-	public function loadAjax() {
153
+	public function loadAjax()
154
+	{
149 155
 		return false;
150 156
 	}
151 157
 
152 158
 	/** {@inheritdoc} */
153
-	public function isUserBlock() {
159
+	public function isUserBlock()
160
+	{
154 161
 		return false;
155 162
 	}
156 163
 
157 164
 	/** {@inheritdoc} */
158
-	public function isGedcomBlock() {
165
+	public function isGedcomBlock()
166
+	{
159 167
 		return true;
160 168
 	}
161 169
 
@@ -164,6 +172,7 @@  discard block
 block discarded – undo
164 172
 	 *
165 173
 	 * @param int $block_id
166 174
 	 */
167
-	public function configureBlock($block_id) {
175
+	public function configureBlock($block_id)
176
+	{
168 177
 	}
169 178
 }
Please login to merge, or discard this patch.
app/Module/SourcesTabModule.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -26,42 +26,42 @@  discard block
 block discarded – undo
26 26
  * Class SourcesTabModule
27 27
  */
28 28
 class SourcesTabModule extends AbstractModule implements ModuleTabInterface {
29
-	/** @var Fact[] All facts belonging to this source. */
30
-	private $facts;
31
-
32
-	/** {@inheritdoc} */
33
-	public function getTitle() {
34
-		return /* I18N: Name of a module */ I18N::translate('Sources');
35
-	}
36
-
37
-	/** {@inheritdoc} */
38
-	public function getDescription() {
39
-		return /* I18N: Description of the “Sources” module */ I18N::translate('A tab showing the sources linked to an individual.');
40
-	}
41
-
42
-	/** {@inheritdoc} */
43
-	public function defaultTabOrder() {
44
-		return 30;
45
-	}
46
-
47
-	/** {@inheritdoc} */
48
-	public function hasTabContent() {
49
-		global $WT_TREE;
50
-
51
-		return Auth::isEditor($WT_TREE) || $this->getFactsWithSources();
52
-	}
53
-
54
-	/** {@inheritdoc} */
55
-	public function isGrayedOut() {
56
-		return !$this->getFactsWithSources();
57
-	}
58
-
59
-	/** {@inheritdoc} */
60
-	public function getTabContent() {
61
-		global $controller;
62
-
63
-		ob_start();
64
-		?>
29
+    /** @var Fact[] All facts belonging to this source. */
30
+    private $facts;
31
+
32
+    /** {@inheritdoc} */
33
+    public function getTitle() {
34
+        return /* I18N: Name of a module */ I18N::translate('Sources');
35
+    }
36
+
37
+    /** {@inheritdoc} */
38
+    public function getDescription() {
39
+        return /* I18N: Description of the “Sources” module */ I18N::translate('A tab showing the sources linked to an individual.');
40
+    }
41
+
42
+    /** {@inheritdoc} */
43
+    public function defaultTabOrder() {
44
+        return 30;
45
+    }
46
+
47
+    /** {@inheritdoc} */
48
+    public function hasTabContent() {
49
+        global $WT_TREE;
50
+
51
+        return Auth::isEditor($WT_TREE) || $this->getFactsWithSources();
52
+    }
53
+
54
+    /** {@inheritdoc} */
55
+    public function isGrayedOut() {
56
+        return !$this->getFactsWithSources();
57
+    }
58
+
59
+    /** {@inheritdoc} */
60
+    public function getTabContent() {
61
+        global $controller;
62
+
63
+        ob_start();
64
+        ?>
65 65
 		<table class="facts_table">
66 66
 			<tr class="noprint">
67 67
 				<td colspan="2" class="descriptionbox rela">
@@ -72,20 +72,20 @@  discard block
 block discarded – undo
72 72
 				</td>
73 73
 			</tr>
74 74
 			<?php
75
-			foreach ($this->getFactsWithSources() as $fact) {
76
-				if ($fact->getTag() == 'SOUR') {
77
-					FunctionsPrintFacts::printMainSources($fact, 1);
78
-				} else {
79
-					FunctionsPrintFacts::printMainSources($fact, 2);
80
-				}
81
-			}
82
-			if (!$this->getFactsWithSources()) {
83
-				echo '<tr><td id="no_tab4" colspan="2" class="facts_value">', I18N::translate('There are no source citations for this individual.'), '</td></tr>';
84
-			}
85
-
86
-			// New Source Link
87
-			if ($controller->record->canEdit()) {
88
-				?>
75
+            foreach ($this->getFactsWithSources() as $fact) {
76
+                if ($fact->getTag() == 'SOUR') {
77
+                    FunctionsPrintFacts::printMainSources($fact, 1);
78
+                } else {
79
+                    FunctionsPrintFacts::printMainSources($fact, 2);
80
+                }
81
+            }
82
+            if (!$this->getFactsWithSources()) {
83
+                echo '<tr><td id="no_tab4" colspan="2" class="facts_value">', I18N::translate('There are no source citations for this individual.'), '</td></tr>';
84
+            }
85
+
86
+            // New Source Link
87
+            if ($controller->record->canEdit()) {
88
+                ?>
89 89
 				<tr class="noprint">
90 90
 					<td class="facts_label">
91 91
 						<?php echo GedcomTag::getLabel('SOUR'); ?>
@@ -97,53 +97,53 @@  discard block
 block discarded – undo
97 97
 					</td>
98 98
 				</tr>
99 99
 			<?php
100
-			}
101
-			?>
100
+            }
101
+            ?>
102 102
 		</table>
103 103
 		<script>
104 104
 			persistent_toggle("show-level-2-sources", ".row_sour2");
105 105
 		</script>
106 106
 		<?php
107 107
 
108
-		return '<div id="' . $this->getName() . '_content">' . ob_get_clean() . '</div>';
109
-	}
110
-
111
-	/**
112
-	 * Get all the facts for an individual which contain sources.
113
-	 *
114
-	 * @return Fact[]
115
-	 */
116
-	private function getFactsWithSources() {
117
-		global $controller;
118
-
119
-		if ($this->facts === null) {
120
-			$facts = $controller->record->getFacts();
121
-			foreach ($controller->record->getSpouseFamilies() as $family) {
122
-				if ($family->canShow()) {
123
-					foreach ($family->getFacts() as $fact) {
124
-						$facts[] = $fact;
125
-					}
126
-				}
127
-			}
128
-			$this->facts = array();
129
-			foreach ($facts as $fact) {
130
-				if (preg_match('/(?:^1|\n\d) SOUR/', $fact->getGedcom())) {
131
-					$this->facts[] = $fact;
132
-				}
133
-			}
134
-			Functions::sortFacts($this->facts);
135
-		}
136
-
137
-		return $this->facts;
138
-	}
139
-
140
-	/** {@inheritdoc} */
141
-	public function canLoadAjax() {
142
-		return !Auth::isSearchEngine(); // Search engines cannot use AJAX
143
-	}
144
-
145
-	/** {@inheritdoc} */
146
-	public function getPreLoadContent() {
147
-		return '';
148
-	}
108
+        return '<div id="' . $this->getName() . '_content">' . ob_get_clean() . '</div>';
109
+    }
110
+
111
+    /**
112
+     * Get all the facts for an individual which contain sources.
113
+     *
114
+     * @return Fact[]
115
+     */
116
+    private function getFactsWithSources() {
117
+        global $controller;
118
+
119
+        if ($this->facts === null) {
120
+            $facts = $controller->record->getFacts();
121
+            foreach ($controller->record->getSpouseFamilies() as $family) {
122
+                if ($family->canShow()) {
123
+                    foreach ($family->getFacts() as $fact) {
124
+                        $facts[] = $fact;
125
+                    }
126
+                }
127
+            }
128
+            $this->facts = array();
129
+            foreach ($facts as $fact) {
130
+                if (preg_match('/(?:^1|\n\d) SOUR/', $fact->getGedcom())) {
131
+                    $this->facts[] = $fact;
132
+                }
133
+            }
134
+            Functions::sortFacts($this->facts);
135
+        }
136
+
137
+        return $this->facts;
138
+    }
139
+
140
+    /** {@inheritdoc} */
141
+    public function canLoadAjax() {
142
+        return !Auth::isSearchEngine(); // Search engines cannot use AJAX
143
+    }
144
+
145
+    /** {@inheritdoc} */
146
+    public function getPreLoadContent() {
147
+        return '';
148
+    }
149 149
 }
Please login to merge, or discard this patch.
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,39 +25,46 @@  discard block
 block discarded – undo
25 25
 /**
26 26
  * Class SourcesTabModule
27 27
  */
28
-class SourcesTabModule extends AbstractModule implements ModuleTabInterface {
28
+class SourcesTabModule extends AbstractModule implements ModuleTabInterface
29
+{
29 30
 	/** @var Fact[] All facts belonging to this source. */
30 31
 	private $facts;
31 32
 
32 33
 	/** {@inheritdoc} */
33
-	public function getTitle() {
34
+	public function getTitle()
35
+	{
34 36
 		return /* I18N: Name of a module */ I18N::translate('Sources');
35 37
 	}
36 38
 
37 39
 	/** {@inheritdoc} */
38
-	public function getDescription() {
40
+	public function getDescription()
41
+	{
39 42
 		return /* I18N: Description of the “Sources” module */ I18N::translate('A tab showing the sources linked to an individual.');
40 43
 	}
41 44
 
42 45
 	/** {@inheritdoc} */
43
-	public function defaultTabOrder() {
46
+	public function defaultTabOrder()
47
+	{
44 48
 		return 30;
45 49
 	}
46 50
 
47 51
 	/** {@inheritdoc} */
48
-	public function hasTabContent() {
52
+	public function hasTabContent()
53
+	{
49 54
 		global $WT_TREE;
50 55
 
51 56
 		return Auth::isEditor($WT_TREE) || $this->getFactsWithSources();
52 57
 	}
53 58
 
54 59
 	/** {@inheritdoc} */
55
-	public function isGrayedOut() {
60
+	public function isGrayedOut()
61
+	{
56 62
 		return !$this->getFactsWithSources();
57 63
 	}
58 64
 
59 65
 	/** {@inheritdoc} */
60
-	public function getTabContent() {
66
+	public function getTabContent()
67
+	{
61 68
 		global $controller;
62 69
 
63 70
 		ob_start();
@@ -113,7 +120,8 @@  discard block
 block discarded – undo
113 120
 	 *
114 121
 	 * @return Fact[]
115 122
 	 */
116
-	private function getFactsWithSources() {
123
+	private function getFactsWithSources()
124
+	{
117 125
 		global $controller;
118 126
 
119 127
 		if ($this->facts === null) {
@@ -138,12 +146,14 @@  discard block
 block discarded – undo
138 146
 	}
139 147
 
140 148
 	/** {@inheritdoc} */
141
-	public function canLoadAjax() {
149
+	public function canLoadAjax()
150
+	{
142 151
 		return !Auth::isSearchEngine(); // Search engines cannot use AJAX
143 152
 	}
144 153
 
145 154
 	/** {@inheritdoc} */
146
-	public function getPreLoadContent() {
155
+	public function getPreLoadContent()
156
+	{
147 157
 		return '';
148 158
 	}
149 159
 }
Please login to merge, or discard this patch.
app/Module/FamiliesSidebarModule.php 3 patches
Indentation   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -27,75 +27,75 @@  discard block
 block discarded – undo
27 27
  * Class FamiliesSidebarModule
28 28
  */
29 29
 class FamiliesSidebarModule extends AbstractModule implements ModuleSidebarInterface {
30
-	/** {@inheritdoc} */
31
-	public function getTitle() {
32
-		return /* I18N: Name of a module/sidebar */ I18N::translate('Family list');
33
-	}
30
+    /** {@inheritdoc} */
31
+    public function getTitle() {
32
+        return /* I18N: Name of a module/sidebar */ I18N::translate('Family list');
33
+    }
34 34
 
35
-	/** {@inheritdoc} */
36
-	public function getDescription() {
37
-		return /* I18N: Description of the “Families” module */ I18N::translate('A sidebar showing an alphabetic list of all the families in the family tree.');
38
-	}
35
+    /** {@inheritdoc} */
36
+    public function getDescription() {
37
+        return /* I18N: Description of the “Families” module */ I18N::translate('A sidebar showing an alphabetic list of all the families in the family tree.');
38
+    }
39 39
 
40
-	/**
41
-	 * This is a general purpose hook, allowing modules to respond to routes
42
-	 * of the form module.php?mod=FOO&mod_action=BAR
43
-	 *
44
-	 * @param string $mod_action
45
-	 */
46
-	public function modAction($mod_action) {
47
-		switch ($mod_action) {
48
-		case 'ajax':
49
-			header('Content-Type: text/html; charset=UTF-8');
50
-			echo $this->getSidebarAjaxContent();
51
-			break;
52
-		default:
53
-			http_response_code(404);
54
-			break;
55
-		}
56
-	}
40
+    /**
41
+     * This is a general purpose hook, allowing modules to respond to routes
42
+     * of the form module.php?mod=FOO&mod_action=BAR
43
+     *
44
+     * @param string $mod_action
45
+     */
46
+    public function modAction($mod_action) {
47
+        switch ($mod_action) {
48
+        case 'ajax':
49
+            header('Content-Type: text/html; charset=UTF-8');
50
+            echo $this->getSidebarAjaxContent();
51
+            break;
52
+        default:
53
+            http_response_code(404);
54
+            break;
55
+        }
56
+    }
57 57
 
58
-	/** {@inheritdoc} */
59
-	public function defaultSidebarOrder() {
60
-		return 50;
61
-	}
58
+    /** {@inheritdoc} */
59
+    public function defaultSidebarOrder() {
60
+        return 50;
61
+    }
62 62
 
63
-	/** {@inheritdoc} */
64
-	public function hasSidebarContent() {
65
-		return true;
66
-	}
63
+    /** {@inheritdoc} */
64
+    public function hasSidebarContent() {
65
+        return true;
66
+    }
67 67
 
68
-	/** {@inheritdoc} */
69
-	public function getSidebarAjaxContent() {
70
-		global $WT_TREE;
68
+    /** {@inheritdoc} */
69
+    public function getSidebarAjaxContent() {
70
+        global $WT_TREE;
71 71
 
72
-		$alpha   = Filter::get('alpha'); // All surnames beginning with this letter where "@"=unknown and ","=none
73
-		$surname = Filter::get('surname'); // All indis with this surname.
74
-		$search  = Filter::get('search');
72
+        $alpha   = Filter::get('alpha'); // All surnames beginning with this letter where "@"=unknown and ","=none
73
+        $surname = Filter::get('surname'); // All indis with this surname.
74
+        $search  = Filter::get('search');
75 75
 
76
-		if ($search) {
77
-			return $this->search($WT_TREE, $search);
78
-		} elseif ($alpha == '@' || $alpha == ',' || $surname) {
79
-			return $this->getSurnameFams($WT_TREE, $alpha, $surname);
80
-		} elseif ($alpha) {
81
-			return $this->getAlphaSurnames($WT_TREE, $alpha);
82
-		} else {
83
-			return '';
84
-		}
85
-	}
76
+        if ($search) {
77
+            return $this->search($WT_TREE, $search);
78
+        } elseif ($alpha == '@' || $alpha == ',' || $surname) {
79
+            return $this->getSurnameFams($WT_TREE, $alpha, $surname);
80
+        } elseif ($alpha) {
81
+            return $this->getAlphaSurnames($WT_TREE, $alpha);
82
+        } else {
83
+            return '';
84
+        }
85
+    }
86 86
 
87
-	/**
88
-	 * Load this sidebar synchronously.
89
-	 *
90
-	 * @return string
91
-	 */
92
-	public function getSidebarContent() {
93
-		global $controller, $WT_TREE;
87
+    /**
88
+     * Load this sidebar synchronously.
89
+     *
90
+     * @return string
91
+     */
92
+    public function getSidebarContent() {
93
+        global $controller, $WT_TREE;
94 94
 
95
-		// Fetch a list of the initial letters of all surnames in the database
96
-		$initials = QueryName::surnameAlpha($WT_TREE, true, false, false);
95
+        // Fetch a list of the initial letters of all surnames in the database
96
+        $initials = QueryName::surnameAlpha($WT_TREE, true, false, false);
97 97
 
98
-		$controller->addInlineJavascript('
98
+        $controller->addInlineJavascript('
99 99
 			var famloadedNames = new Array();
100 100
 
101 101
 			function fsearchQ() {
@@ -146,147 +146,147 @@  discard block
 block discarded – undo
146 146
 			});
147 147
 		');
148 148
 
149
-		$out = '<form method="post" action="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax" onsubmit="return false;"><input type="search" name="sb_fam_name" id="sb_fam_name" placeholder="' . I18N::translate('Search') . '"><p>';
150
-		foreach ($initials as $letter => $count) {
151
-			switch ($letter) {
152
-			case '@':
153
-				$html = I18N::translateContext('Unknown surname', '…');
154
-				break;
155
-			case ',':
156
-				$html = I18N::translate('None');
157
-				break;
158
-			case ' ':
159
-				$html = '&nbsp;';
160
-				break;
161
-			default:
162
-				$html = $letter;
163
-				break;
164
-			}
165
-			$html = '<a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;alpha=' . urlencode($letter) . '" class="sb_fam_letter">' . $html . '</a>';
166
-			$out .= $html . " ";
167
-		}
149
+        $out = '<form method="post" action="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax" onsubmit="return false;"><input type="search" name="sb_fam_name" id="sb_fam_name" placeholder="' . I18N::translate('Search') . '"><p>';
150
+        foreach ($initials as $letter => $count) {
151
+            switch ($letter) {
152
+            case '@':
153
+                $html = I18N::translateContext('Unknown surname', '…');
154
+                break;
155
+            case ',':
156
+                $html = I18N::translate('None');
157
+                break;
158
+            case ' ':
159
+                $html = '&nbsp;';
160
+                break;
161
+            default:
162
+                $html = $letter;
163
+                break;
164
+            }
165
+            $html = '<a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;alpha=' . urlencode($letter) . '" class="sb_fam_letter">' . $html . '</a>';
166
+            $out .= $html . " ";
167
+        }
168 168
 
169
-		$out .= '</p>';
170
-		$out .= '<div id="sb_fam_content">';
171
-		$out .= '</div></form>';
169
+        $out .= '</p>';
170
+        $out .= '<div id="sb_fam_content">';
171
+        $out .= '</div></form>';
172 172
 
173
-		return $out;
174
-	}
173
+        return $out;
174
+    }
175 175
 
176
-	/**
177
-	 * Get a list of surname initials.
178
-	 *
179
-	 * @param Tree   $tree
180
-	 * @param string $alpha
181
-	 *
182
-	 * @return string
183
-	 */
184
-	private function getAlphaSurnames(Tree $tree, $alpha) {
185
-		$surnames = QueryName::surnames($tree, '', $alpha, true, true);
186
-		$out      = '<ul>';
187
-		foreach (array_keys($surnames) as $surname) {
188
-			$out .= '<li class="sb_fam_surname_li"><a href="#" data-surname="' . Filter::escapeHtml($surname) . '" data-alpha="' . Filter::escapeHtml($alpha) . '" class="sb_fam_surname">' . Filter::escapeHtml($surname) . '</a>';
189
-			$out .= '<div class="name_tree_div"></div>';
190
-			$out .= '</li>';
191
-		}
192
-		$out .= '</ul>';
176
+    /**
177
+     * Get a list of surname initials.
178
+     *
179
+     * @param Tree   $tree
180
+     * @param string $alpha
181
+     *
182
+     * @return string
183
+     */
184
+    private function getAlphaSurnames(Tree $tree, $alpha) {
185
+        $surnames = QueryName::surnames($tree, '', $alpha, true, true);
186
+        $out      = '<ul>';
187
+        foreach (array_keys($surnames) as $surname) {
188
+            $out .= '<li class="sb_fam_surname_li"><a href="#" data-surname="' . Filter::escapeHtml($surname) . '" data-alpha="' . Filter::escapeHtml($alpha) . '" class="sb_fam_surname">' . Filter::escapeHtml($surname) . '</a>';
189
+            $out .= '<div class="name_tree_div"></div>';
190
+            $out .= '</li>';
191
+        }
192
+        $out .= '</ul>';
193 193
 
194
-		return $out;
195
-	}
194
+        return $out;
195
+    }
196 196
 
197
-	/**
198
-	 * Get a list of surnames.
199
-	 *
200
-	 * @param Tree   $tree
201
-	 * @param string $alpha
202
-	 * @param string $surname
203
-	 *
204
-	 * @return string
205
-	 */
206
-	public function getSurnameFams(Tree $tree, $alpha, $surname) {
207
-		$families = QueryName::families($tree, $surname, $alpha, '', true);
208
-		$out      = '<ul>';
209
-		foreach ($families as $family) {
210
-			if ($family->canShowName()) {
211
-				$out .= '<li><a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . ' ';
212
-				if ($family->canShow()) {
213
-					$marriage_year = $family->getMarriageYear();
214
-					if ($marriage_year) {
215
-						$out .= ' (' . $marriage_year . ')';
216
-					}
217
-				}
218
-				$out .= '</a></li>';
219
-			}
220
-		}
221
-		$out .= '</ul>';
197
+    /**
198
+     * Get a list of surnames.
199
+     *
200
+     * @param Tree   $tree
201
+     * @param string $alpha
202
+     * @param string $surname
203
+     *
204
+     * @return string
205
+     */
206
+    public function getSurnameFams(Tree $tree, $alpha, $surname) {
207
+        $families = QueryName::families($tree, $surname, $alpha, '', true);
208
+        $out      = '<ul>';
209
+        foreach ($families as $family) {
210
+            if ($family->canShowName()) {
211
+                $out .= '<li><a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . ' ';
212
+                if ($family->canShow()) {
213
+                    $marriage_year = $family->getMarriageYear();
214
+                    if ($marriage_year) {
215
+                        $out .= ' (' . $marriage_year . ')';
216
+                    }
217
+                }
218
+                $out .= '</a></li>';
219
+            }
220
+        }
221
+        $out .= '</ul>';
222 222
 
223
-		return $out;
224
-	}
223
+        return $out;
224
+    }
225 225
 
226
-	/**
227
-	 * Autocomplete search for families.
228
-	 *
229
-	 * @param Tree   $tree  Search this tree
230
-	 * @param string $query Search for this text
231
-	 *
232
-	 * @return string
233
-	 */
234
-	private function search(Tree $tree, $query) {
235
-		if (strlen($query) < 2) {
236
-			return '';
237
-		}
238
-		$rows = Database::prepare(
239
-			"SELECT i_id AS xref" .
240
-			" FROM `##individuals`, `##name`" .
241
-			" WHERE (i_id LIKE CONCAT('%', :query_1, '%') OR n_sort LIKE CONCAT('%', :query_2, '%'))" .
242
-			" AND i_id = n_id AND i_file = n_file AND i_file = :tree_id" .
243
-			" ORDER BY n_sort COLLATE :collation" .
244
-			" LIMIT 50"
245
-		)->execute(array(
246
-			'query_1'   => $query,
247
-			'query_2'   => $query,
248
-			'tree_id'   => $tree->getTreeId(),
249
-			'collation' => I18N::collation(),
250
-		))->fetchAll();
226
+    /**
227
+     * Autocomplete search for families.
228
+     *
229
+     * @param Tree   $tree  Search this tree
230
+     * @param string $query Search for this text
231
+     *
232
+     * @return string
233
+     */
234
+    private function search(Tree $tree, $query) {
235
+        if (strlen($query) < 2) {
236
+            return '';
237
+        }
238
+        $rows = Database::prepare(
239
+            "SELECT i_id AS xref" .
240
+            " FROM `##individuals`, `##name`" .
241
+            " WHERE (i_id LIKE CONCAT('%', :query_1, '%') OR n_sort LIKE CONCAT('%', :query_2, '%'))" .
242
+            " AND i_id = n_id AND i_file = n_file AND i_file = :tree_id" .
243
+            " ORDER BY n_sort COLLATE :collation" .
244
+            " LIMIT 50"
245
+        )->execute(array(
246
+            'query_1'   => $query,
247
+            'query_2'   => $query,
248
+            'tree_id'   => $tree->getTreeId(),
249
+            'collation' => I18N::collation(),
250
+        ))->fetchAll();
251 251
 
252
-		$ids = array();
253
-		foreach ($rows as $row) {
254
-			$ids[] = $row->xref;
255
-		}
252
+        $ids = array();
253
+        foreach ($rows as $row) {
254
+            $ids[] = $row->xref;
255
+        }
256 256
 
257
-		$vars = array();
258
-		if (empty($ids)) {
259
-			//-- no match : search for FAM id
260
-			$where  = "f_id LIKE CONCAT('%', ?, '%')";
261
-			$vars[] = $query;
262
-		} else {
263
-			//-- search for spouses
264
-			$qs    = implode(',', array_fill(0, count($ids), '?'));
265
-			$where = "(f_husb IN ($qs) OR f_wife IN ($qs))";
266
-			$vars  = array_merge($vars, $ids, $ids);
267
-		}
257
+        $vars = array();
258
+        if (empty($ids)) {
259
+            //-- no match : search for FAM id
260
+            $where  = "f_id LIKE CONCAT('%', ?, '%')";
261
+            $vars[] = $query;
262
+        } else {
263
+            //-- search for spouses
264
+            $qs    = implode(',', array_fill(0, count($ids), '?'));
265
+            $where = "(f_husb IN ($qs) OR f_wife IN ($qs))";
266
+            $vars  = array_merge($vars, $ids, $ids);
267
+        }
268 268
 
269
-		$vars[] = $tree->getTreeId();
270
-		$rows   = Database::prepare("SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom FROM `##families` WHERE {$where} AND f_file=?")
271
-		->execute($vars)
272
-		->fetchAll();
269
+        $vars[] = $tree->getTreeId();
270
+        $rows   = Database::prepare("SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom FROM `##families` WHERE {$where} AND f_file=?")
271
+        ->execute($vars)
272
+        ->fetchAll();
273 273
 
274
-		$out = '<ul>';
275
-		foreach ($rows as $row) {
276
-			$family = Family::getInstance($row->xref, $tree, $row->gedcom);
277
-			if ($family->canShowName()) {
278
-				$out .= '<li><a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . ' ';
279
-				if ($family->canShow()) {
280
-					$marriage_year = $family->getMarriageYear();
281
-					if ($marriage_year) {
282
-						$out .= ' (' . $marriage_year . ')';
283
-					}
284
-				}
285
-				$out .= '</a></li>';
286
-			}
287
-		}
288
-		$out .= '</ul>';
274
+        $out = '<ul>';
275
+        foreach ($rows as $row) {
276
+            $family = Family::getInstance($row->xref, $tree, $row->gedcom);
277
+            if ($family->canShowName()) {
278
+                $out .= '<li><a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . ' ';
279
+                if ($family->canShow()) {
280
+                    $marriage_year = $family->getMarriageYear();
281
+                    if ($marriage_year) {
282
+                        $out .= ' (' . $marriage_year . ')';
283
+                    }
284
+                }
285
+                $out .= '</a></li>';
286
+            }
287
+        }
288
+        $out .= '</ul>';
289 289
 
290
-		return $out;
291
-	}
290
+        return $out;
291
+    }
292 292
 }
Please login to merge, or discard this patch.
Switch Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	public function modAction($mod_action) {
47 47
 		switch ($mod_action) {
48
-		case 'ajax':
49
-			header('Content-Type: text/html; charset=UTF-8');
50
-			echo $this->getSidebarAjaxContent();
51
-			break;
52
-		default:
53
-			http_response_code(404);
54
-			break;
48
+		    case 'ajax':
49
+			    header('Content-Type: text/html; charset=UTF-8');
50
+			    echo $this->getSidebarAjaxContent();
51
+			    break;
52
+		    default:
53
+			    http_response_code(404);
54
+			    break;
55 55
 		}
56 56
 	}
57 57
 
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
 		$out = '<form method="post" action="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax" onsubmit="return false;"><input type="search" name="sb_fam_name" id="sb_fam_name" placeholder="' . I18N::translate('Search') . '"><p>';
150 150
 		foreach ($initials as $letter => $count) {
151 151
 			switch ($letter) {
152
-			case '@':
153
-				$html = I18N::translateContext('Unknown surname', '…');
154
-				break;
155
-			case ',':
156
-				$html = I18N::translate('None');
157
-				break;
158
-			case ' ':
159
-				$html = '&nbsp;';
160
-				break;
161
-			default:
162
-				$html = $letter;
163
-				break;
152
+			    case '@':
153
+				    $html = I18N::translateContext('Unknown surname', '…');
154
+				    break;
155
+			    case ',':
156
+				    $html = I18N::translate('None');
157
+				    break;
158
+			    case ' ':
159
+				    $html = '&nbsp;';
160
+				    break;
161
+			    default:
162
+				    $html = $letter;
163
+				    break;
164 164
 			}
165 165
 			$html = '<a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;alpha=' . urlencode($letter) . '" class="sb_fam_letter">' . $html . '</a>';
166 166
 			$out .= $html . " ";
Please login to merge, or discard this patch.
Braces   +22 added lines, -11 removed lines patch added patch discarded remove patch
@@ -26,14 +26,17 @@  discard block
 block discarded – undo
26 26
 /**
27 27
  * Class FamiliesSidebarModule
28 28
  */
29
-class FamiliesSidebarModule extends AbstractModule implements ModuleSidebarInterface {
29
+class FamiliesSidebarModule extends AbstractModule implements ModuleSidebarInterface
30
+{
30 31
 	/** {@inheritdoc} */
31
-	public function getTitle() {
32
+	public function getTitle()
33
+	{
32 34
 		return /* I18N: Name of a module/sidebar */ I18N::translate('Family list');
33 35
 	}
34 36
 
35 37
 	/** {@inheritdoc} */
36
-	public function getDescription() {
38
+	public function getDescription()
39
+	{
37 40
 		return /* I18N: Description of the “Families” module */ I18N::translate('A sidebar showing an alphabetic list of all the families in the family tree.');
38 41
 	}
39 42
 
@@ -43,7 +46,8 @@  discard block
 block discarded – undo
43 46
 	 *
44 47
 	 * @param string $mod_action
45 48
 	 */
46
-	public function modAction($mod_action) {
49
+	public function modAction($mod_action)
50
+	{
47 51
 		switch ($mod_action) {
48 52
 		case 'ajax':
49 53
 			header('Content-Type: text/html; charset=UTF-8');
@@ -56,17 +60,20 @@  discard block
 block discarded – undo
56 60
 	}
57 61
 
58 62
 	/** {@inheritdoc} */
59
-	public function defaultSidebarOrder() {
63
+	public function defaultSidebarOrder()
64
+	{
60 65
 		return 50;
61 66
 	}
62 67
 
63 68
 	/** {@inheritdoc} */
64
-	public function hasSidebarContent() {
69
+	public function hasSidebarContent()
70
+	{
65 71
 		return true;
66 72
 	}
67 73
 
68 74
 	/** {@inheritdoc} */
69
-	public function getSidebarAjaxContent() {
75
+	public function getSidebarAjaxContent()
76
+	{
70 77
 		global $WT_TREE;
71 78
 
72 79
 		$alpha   = Filter::get('alpha'); // All surnames beginning with this letter where "@"=unknown and ","=none
@@ -89,7 +96,8 @@  discard block
 block discarded – undo
89 96
 	 *
90 97
 	 * @return string
91 98
 	 */
92
-	public function getSidebarContent() {
99
+	public function getSidebarContent()
100
+	{
93 101
 		global $controller, $WT_TREE;
94 102
 
95 103
 		// Fetch a list of the initial letters of all surnames in the database
@@ -181,7 +189,8 @@  discard block
 block discarded – undo
181 189
 	 *
182 190
 	 * @return string
183 191
 	 */
184
-	private function getAlphaSurnames(Tree $tree, $alpha) {
192
+	private function getAlphaSurnames(Tree $tree, $alpha)
193
+	{
185 194
 		$surnames = QueryName::surnames($tree, '', $alpha, true, true);
186 195
 		$out      = '<ul>';
187 196
 		foreach (array_keys($surnames) as $surname) {
@@ -203,7 +212,8 @@  discard block
 block discarded – undo
203 212
 	 *
204 213
 	 * @return string
205 214
 	 */
206
-	public function getSurnameFams(Tree $tree, $alpha, $surname) {
215
+	public function getSurnameFams(Tree $tree, $alpha, $surname)
216
+	{
207 217
 		$families = QueryName::families($tree, $surname, $alpha, '', true);
208 218
 		$out      = '<ul>';
209 219
 		foreach ($families as $family) {
@@ -231,7 +241,8 @@  discard block
 block discarded – undo
231 241
 	 *
232 242
 	 * @return string
233 243
 	 */
234
-	private function search(Tree $tree, $query) {
244
+	private function search(Tree $tree, $query)
245
+	{
235 246
 		if (strlen($query) < 2) {
236 247
 			return '';
237 248
 		}
Please login to merge, or discard this patch.
app/Module/StoriesModule.php 3 patches
Indentation   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -31,183 +31,183 @@  discard block
 block discarded – undo
31 31
  * Class StoriesModule
32 32
  */
33 33
 class StoriesModule extends AbstractModule implements ModuleTabInterface, ModuleConfigInterface, ModuleMenuInterface {
34
-	/** {@inheritdoc} */
35
-	public function getTitle() {
36
-		return /* I18N: Name of a module */ I18N::translate('Stories');
37
-	}
38
-
39
-	/** {@inheritdoc} */
40
-	public function getDescription() {
41
-		return /* I18N: Description of the “Stories” module */ I18N::translate('Add narrative stories to individuals in the family tree.');
42
-	}
43
-
44
-	/**
45
-	 * This is a general purpose hook, allowing modules to respond to routes
46
-	 * of the form module.php?mod=FOO&mod_action=BAR
47
-	 *
48
-	 * @param string $mod_action
49
-	 */
50
-	public function modAction($mod_action) {
51
-		switch ($mod_action) {
52
-		case 'admin_edit':
53
-			$this->edit();
54
-			break;
55
-		case 'admin_delete':
56
-			$this->delete();
57
-			$this->config();
58
-			break;
59
-		case 'admin_config':
60
-			$this->config();
61
-			break;
62
-		case 'show_list':
63
-			$this->showList();
64
-			break;
65
-		default:
66
-			http_response_code(404);
67
-		}
68
-	}
69
-
70
-	/** {@inheritdoc} */
71
-	public function getConfigLink() {
72
-		return 'module.php?mod=' . $this->getName() . '&amp;mod_action=admin_config';
73
-	}
74
-
75
-	/** {@inheritdoc} */
76
-	public function defaultTabOrder() {
77
-		return 55;
78
-	}
79
-
80
-	/** {@inheritdoc} */
81
-	public function getTabContent() {
82
-		global $controller, $WT_TREE;
83
-
84
-		$block_ids =
85
-			Database::prepare(
86
-				"SELECT block_id" .
87
-				" FROM `##block`" .
88
-				" WHERE module_name=?" .
89
-				" AND xref=?" .
90
-				" AND gedcom_id=?"
91
-			)->execute(array(
92
-				$this->getName(),
93
-				$controller->record->getXref(),
94
-				$controller->record->getTree()->getTreeId(),
95
-			))->fetchOneColumn();
96
-
97
-		$html = '';
98
-		foreach ($block_ids as $block_id) {
99
-			// Only show this block for certain languages
100
-			$languages = $this->getBlockSetting($block_id, 'languages');
101
-			if (!$languages || in_array(WT_LOCALE, explode(',', $languages))) {
102
-				$html .= '<div class="story_title descriptionbox center rela">' . $this->getBlockSetting($block_id, 'title') . '</div>';
103
-				$html .= '<div class="story_body optionbox">' . $this->getBlockSetting($block_id, 'story_body') . '</div>';
104
-				if (Auth::isEditor($WT_TREE)) {
105
-					$html .= '<div class="story_edit"><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=admin_edit&amp;block_id=' . $block_id . '">';
106
-					$html .= I18N::translate('Edit the story') . '</a></div>';
107
-				}
108
-			}
109
-		}
110
-		if (Auth::isManager($WT_TREE) && !$html) {
111
-			$html .= '<div class="news_title center">' . $this->getTitle() . '</div>';
112
-			$html .= '<div><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=admin_edit&amp;xref=' . $controller->record->getXref() . '">';
113
-			$html .= I18N::translate('Add a story') . '</a></div><br>';
114
-		}
115
-
116
-		return $html;
117
-	}
118
-
119
-	/** {@inheritdoc} */
120
-	public function hasTabContent() {
121
-		return $this->getTabContent() != '';
122
-	}
123
-
124
-	/** {@inheritdoc} */
125
-	public function isGrayedOut() {
126
-		global $controller;
127
-
128
-		$count_of_stories =
129
-			Database::prepare(
130
-				"SELECT COUNT(block_id)" .
131
-				" FROM `##block`" .
132
-				" WHERE module_name=?" .
133
-				" AND xref=?" .
134
-				" AND gedcom_id=?"
135
-			)->execute(array(
136
-				$this->getName(),
137
-				$controller->record->getXref(),
138
-				$controller->record->getTree()->getTreeId(),
139
-			))->fetchOne();
140
-
141
-		return $count_of_stories == 0;
142
-	}
143
-
144
-	/** {@inheritdoc} */
145
-	public function canLoadAjax() {
146
-		return false;
147
-	}
148
-
149
-	/** {@inheritdoc} */
150
-	public function getPreLoadContent() {
151
-		return '';
152
-	}
153
-
154
-	/**
155
-	 * Show and process a form to edit a story.
156
-	 */
157
-	private function edit() {
158
-		global $WT_TREE;
159
-
160
-		if (Auth::isEditor($WT_TREE)) {
161
-			if (Filter::postBool('save') && Filter::checkCsrf()) {
162
-				$block_id = Filter::postInteger('block_id');
163
-				if ($block_id) {
164
-					Database::prepare(
165
-						"UPDATE `##block` SET gedcom_id=?, xref=? WHERE block_id=?"
166
-					)->execute(array(Filter::postInteger('gedcom_id'), Filter::post('xref', WT_REGEX_XREF), $block_id));
167
-				} else {
168
-					Database::prepare(
169
-						"INSERT INTO `##block` (gedcom_id, xref, module_name, block_order) VALUES (?, ?, ?, ?)"
170
-					)->execute(array(
171
-						Filter::postInteger('gedcom_id'),
172
-						Filter::post('xref', WT_REGEX_XREF),
173
-						$this->getName(),
174
-						0,
175
-					));
176
-					$block_id = Database::getInstance()->lastInsertId();
177
-				}
178
-				$this->setBlockSetting($block_id, 'title', Filter::post('title'));
179
-				$this->setBlockSetting($block_id, 'story_body', Filter::post('story_body'));
180
-				$languages = Filter::postArray('lang');
181
-				$this->setBlockSetting($block_id, 'languages', implode(',', $languages));
182
-				$this->config();
183
-			} else {
184
-				$block_id = Filter::getInteger('block_id');
185
-
186
-				$controller = new PageController;
187
-				if ($block_id) {
188
-					$controller->setPageTitle(I18N::translate('Edit the story'));
189
-					$title      = $this->getBlockSetting($block_id, 'title');
190
-					$story_body = $this->getBlockSetting($block_id, 'story_body');
191
-					$xref       = Database::prepare(
192
-						"SELECT xref FROM `##block` WHERE block_id=?"
193
-					)->execute(array($block_id))->fetchOne();
194
-				} else {
195
-					$controller->setPageTitle(I18N::translate('Add a story'));
196
-					$title      = '';
197
-					$story_body = '';
198
-					$xref       = Filter::get('xref', WT_REGEX_XREF);
199
-				}
200
-				$controller
201
-					->pageHeader()
202
-					->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
203
-					->addInlineJavascript('autocomplete();');
204
-				if (Module::getModuleByName('ckeditor')) {
205
-					CkeditorModule::enableEditor($controller);
206
-				}
207
-
208
-				$individual = Individual::getInstance($xref, $WT_TREE);
209
-
210
-				?>
34
+    /** {@inheritdoc} */
35
+    public function getTitle() {
36
+        return /* I18N: Name of a module */ I18N::translate('Stories');
37
+    }
38
+
39
+    /** {@inheritdoc} */
40
+    public function getDescription() {
41
+        return /* I18N: Description of the “Stories” module */ I18N::translate('Add narrative stories to individuals in the family tree.');
42
+    }
43
+
44
+    /**
45
+     * This is a general purpose hook, allowing modules to respond to routes
46
+     * of the form module.php?mod=FOO&mod_action=BAR
47
+     *
48
+     * @param string $mod_action
49
+     */
50
+    public function modAction($mod_action) {
51
+        switch ($mod_action) {
52
+        case 'admin_edit':
53
+            $this->edit();
54
+            break;
55
+        case 'admin_delete':
56
+            $this->delete();
57
+            $this->config();
58
+            break;
59
+        case 'admin_config':
60
+            $this->config();
61
+            break;
62
+        case 'show_list':
63
+            $this->showList();
64
+            break;
65
+        default:
66
+            http_response_code(404);
67
+        }
68
+    }
69
+
70
+    /** {@inheritdoc} */
71
+    public function getConfigLink() {
72
+        return 'module.php?mod=' . $this->getName() . '&amp;mod_action=admin_config';
73
+    }
74
+
75
+    /** {@inheritdoc} */
76
+    public function defaultTabOrder() {
77
+        return 55;
78
+    }
79
+
80
+    /** {@inheritdoc} */
81
+    public function getTabContent() {
82
+        global $controller, $WT_TREE;
83
+
84
+        $block_ids =
85
+            Database::prepare(
86
+                "SELECT block_id" .
87
+                " FROM `##block`" .
88
+                " WHERE module_name=?" .
89
+                " AND xref=?" .
90
+                " AND gedcom_id=?"
91
+            )->execute(array(
92
+                $this->getName(),
93
+                $controller->record->getXref(),
94
+                $controller->record->getTree()->getTreeId(),
95
+            ))->fetchOneColumn();
96
+
97
+        $html = '';
98
+        foreach ($block_ids as $block_id) {
99
+            // Only show this block for certain languages
100
+            $languages = $this->getBlockSetting($block_id, 'languages');
101
+            if (!$languages || in_array(WT_LOCALE, explode(',', $languages))) {
102
+                $html .= '<div class="story_title descriptionbox center rela">' . $this->getBlockSetting($block_id, 'title') . '</div>';
103
+                $html .= '<div class="story_body optionbox">' . $this->getBlockSetting($block_id, 'story_body') . '</div>';
104
+                if (Auth::isEditor($WT_TREE)) {
105
+                    $html .= '<div class="story_edit"><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=admin_edit&amp;block_id=' . $block_id . '">';
106
+                    $html .= I18N::translate('Edit the story') . '</a></div>';
107
+                }
108
+            }
109
+        }
110
+        if (Auth::isManager($WT_TREE) && !$html) {
111
+            $html .= '<div class="news_title center">' . $this->getTitle() . '</div>';
112
+            $html .= '<div><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=admin_edit&amp;xref=' . $controller->record->getXref() . '">';
113
+            $html .= I18N::translate('Add a story') . '</a></div><br>';
114
+        }
115
+
116
+        return $html;
117
+    }
118
+
119
+    /** {@inheritdoc} */
120
+    public function hasTabContent() {
121
+        return $this->getTabContent() != '';
122
+    }
123
+
124
+    /** {@inheritdoc} */
125
+    public function isGrayedOut() {
126
+        global $controller;
127
+
128
+        $count_of_stories =
129
+            Database::prepare(
130
+                "SELECT COUNT(block_id)" .
131
+                " FROM `##block`" .
132
+                " WHERE module_name=?" .
133
+                " AND xref=?" .
134
+                " AND gedcom_id=?"
135
+            )->execute(array(
136
+                $this->getName(),
137
+                $controller->record->getXref(),
138
+                $controller->record->getTree()->getTreeId(),
139
+            ))->fetchOne();
140
+
141
+        return $count_of_stories == 0;
142
+    }
143
+
144
+    /** {@inheritdoc} */
145
+    public function canLoadAjax() {
146
+        return false;
147
+    }
148
+
149
+    /** {@inheritdoc} */
150
+    public function getPreLoadContent() {
151
+        return '';
152
+    }
153
+
154
+    /**
155
+     * Show and process a form to edit a story.
156
+     */
157
+    private function edit() {
158
+        global $WT_TREE;
159
+
160
+        if (Auth::isEditor($WT_TREE)) {
161
+            if (Filter::postBool('save') && Filter::checkCsrf()) {
162
+                $block_id = Filter::postInteger('block_id');
163
+                if ($block_id) {
164
+                    Database::prepare(
165
+                        "UPDATE `##block` SET gedcom_id=?, xref=? WHERE block_id=?"
166
+                    )->execute(array(Filter::postInteger('gedcom_id'), Filter::post('xref', WT_REGEX_XREF), $block_id));
167
+                } else {
168
+                    Database::prepare(
169
+                        "INSERT INTO `##block` (gedcom_id, xref, module_name, block_order) VALUES (?, ?, ?, ?)"
170
+                    )->execute(array(
171
+                        Filter::postInteger('gedcom_id'),
172
+                        Filter::post('xref', WT_REGEX_XREF),
173
+                        $this->getName(),
174
+                        0,
175
+                    ));
176
+                    $block_id = Database::getInstance()->lastInsertId();
177
+                }
178
+                $this->setBlockSetting($block_id, 'title', Filter::post('title'));
179
+                $this->setBlockSetting($block_id, 'story_body', Filter::post('story_body'));
180
+                $languages = Filter::postArray('lang');
181
+                $this->setBlockSetting($block_id, 'languages', implode(',', $languages));
182
+                $this->config();
183
+            } else {
184
+                $block_id = Filter::getInteger('block_id');
185
+
186
+                $controller = new PageController;
187
+                if ($block_id) {
188
+                    $controller->setPageTitle(I18N::translate('Edit the story'));
189
+                    $title      = $this->getBlockSetting($block_id, 'title');
190
+                    $story_body = $this->getBlockSetting($block_id, 'story_body');
191
+                    $xref       = Database::prepare(
192
+                        "SELECT xref FROM `##block` WHERE block_id=?"
193
+                    )->execute(array($block_id))->fetchOne();
194
+                } else {
195
+                    $controller->setPageTitle(I18N::translate('Add a story'));
196
+                    $title      = '';
197
+                    $story_body = '';
198
+                    $xref       = Filter::get('xref', WT_REGEX_XREF);
199
+                }
200
+                $controller
201
+                    ->pageHeader()
202
+                    ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
203
+                    ->addInlineJavascript('autocomplete();');
204
+                if (Module::getModuleByName('ckeditor')) {
205
+                    CkeditorModule::enableEditor($controller);
206
+                }
207
+
208
+                $individual = Individual::getInstance($xref, $WT_TREE);
209
+
210
+                ?>
211 211
 				<ol class="breadcrumb small">
212 212
 					<li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li>
213 213
 					<li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li>
@@ -274,48 +274,48 @@  discard block
 block discarded – undo
274 274
 
275 275
 				</form>
276 276
 				<?php
277
-			}
278
-		} else {
279
-			header('Location: ' . WT_BASE_URL);
280
-		}
281
-	}
282
-
283
-	/**
284
-	 * Respond to a request to delete a story.
285
-	 */
286
-	private function delete() {
287
-		global $WT_TREE;
288
-
289
-		if (Auth::isEditor($WT_TREE)) {
290
-			$block_id = Filter::getInteger('block_id');
291
-
292
-			Database::prepare(
293
-				"DELETE FROM `##block_setting` WHERE block_id=?"
294
-			)->execute(array($block_id));
295
-
296
-			Database::prepare(
297
-				"DELETE FROM `##block` WHERE block_id=?"
298
-			)->execute(array($block_id));
299
-		} else {
300
-			header('Location: ' . WT_BASE_URL);
301
-			exit;
302
-		}
303
-	}
304
-
305
-	/**
306
-	 * The admin view - list, create, edit, delete stories.
307
-	 */
308
-	private function config() {
309
-		global $WT_TREE;
310
-
311
-		$controller = new PageController;
312
-		$controller
313
-			->restrictAccess(Auth::isAdmin())
314
-			->setPageTitle($this->getTitle())
315
-			->pageHeader()
316
-			->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
317
-			->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
318
-			->addInlineJavascript('
277
+            }
278
+        } else {
279
+            header('Location: ' . WT_BASE_URL);
280
+        }
281
+    }
282
+
283
+    /**
284
+     * Respond to a request to delete a story.
285
+     */
286
+    private function delete() {
287
+        global $WT_TREE;
288
+
289
+        if (Auth::isEditor($WT_TREE)) {
290
+            $block_id = Filter::getInteger('block_id');
291
+
292
+            Database::prepare(
293
+                "DELETE FROM `##block_setting` WHERE block_id=?"
294
+            )->execute(array($block_id));
295
+
296
+            Database::prepare(
297
+                "DELETE FROM `##block` WHERE block_id=?"
298
+            )->execute(array($block_id));
299
+        } else {
300
+            header('Location: ' . WT_BASE_URL);
301
+            exit;
302
+        }
303
+    }
304
+
305
+    /**
306
+     * The admin view - list, create, edit, delete stories.
307
+     */
308
+    private function config() {
309
+        global $WT_TREE;
310
+
311
+        $controller = new PageController;
312
+        $controller
313
+            ->restrictAccess(Auth::isAdmin())
314
+            ->setPageTitle($this->getTitle())
315
+            ->pageHeader()
316
+            ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
317
+            ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
318
+            ->addInlineJavascript('
319 319
 				jQuery("#story_table").dataTable({
320 320
 					' . I18N::datatablesI18N() . ',
321 321
 					autoWidth: false,
@@ -334,15 +334,15 @@  discard block
 block discarded – undo
334 334
 				});
335 335
 			');
336 336
 
337
-		$stories = Database::prepare(
338
-			"SELECT block_id, xref" .
339
-			" FROM `##block` b" .
340
-			" WHERE module_name=?" .
341
-			" AND gedcom_id=?" .
342
-			" ORDER BY xref"
343
-		)->execute(array($this->getName(), $WT_TREE->getTreeId()))->fetchAll();
337
+        $stories = Database::prepare(
338
+            "SELECT block_id, xref" .
339
+            " FROM `##block` b" .
340
+            " WHERE module_name=?" .
341
+            " AND gedcom_id=?" .
342
+            " ORDER BY xref"
343
+        )->execute(array($this->getName(), $WT_TREE->getTreeId()))->fetchAll();
344 344
 
345
-		?>
345
+        ?>
346 346
 		<ol class="breadcrumb small">
347 347
 			<li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li>
348 348
 			<li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li>
@@ -411,20 +411,20 @@  discard block
 block discarded – undo
411 411
 			</tbody>
412 412
 		</table>
413 413
 		<?php
414
-	}
415
-
416
-	/**
417
-	 * Show the list of stories
418
-	 */
419
-	private function showList() {
420
-		global $controller, $WT_TREE;
421
-
422
-		$controller = new PageController;
423
-		$controller
424
-			->setPageTitle($this->getTitle())
425
-			->pageHeader()
426
-			->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
427
-			->addInlineJavascript('
414
+    }
415
+
416
+    /**
417
+     * Show the list of stories
418
+     */
419
+    private function showList() {
420
+        global $controller, $WT_TREE;
421
+
422
+        $controller = new PageController;
423
+        $controller
424
+            ->setPageTitle($this->getTitle())
425
+            ->pageHeader()
426
+            ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
427
+            ->addInlineJavascript('
428 428
 				jQuery("#story_table").dataTable({
429 429
 					dom: \'<"H"pf<"dt-clear">irl>t<"F"pl>\',
430 430
 					' . I18N::datatablesI18N() . ',
@@ -443,68 +443,68 @@  discard block
 block discarded – undo
443 443
 				});
444 444
 			');
445 445
 
446
-		$stories = Database::prepare(
447
-			"SELECT block_id, xref" .
448
-			" FROM `##block` b" .
449
-			" WHERE module_name=?" .
450
-			" AND gedcom_id=?" .
451
-			" ORDER BY xref"
452
-		)->execute(array($this->getName(), $WT_TREE->getTreeId()))->fetchAll();
453
-
454
-		echo '<h2 class="center">', I18N::translate('Stories'), '</h2>';
455
-		if (count($stories) > 0) {
456
-			echo '<table id="story_table" class="width100">';
457
-			echo '<thead><tr>
446
+        $stories = Database::prepare(
447
+            "SELECT block_id, xref" .
448
+            " FROM `##block` b" .
449
+            " WHERE module_name=?" .
450
+            " AND gedcom_id=?" .
451
+            " ORDER BY xref"
452
+        )->execute(array($this->getName(), $WT_TREE->getTreeId()))->fetchAll();
453
+
454
+        echo '<h2 class="center">', I18N::translate('Stories'), '</h2>';
455
+        if (count($stories) > 0) {
456
+            echo '<table id="story_table" class="width100">';
457
+            echo '<thead><tr>
458 458
 				<th>', I18N::translate('Story title'), '</th>
459 459
 				<th>', I18N::translate('Individual'), '</th>
460 460
 				</tr></thead>
461 461
 				<tbody>';
462
-			foreach ($stories as $story) {
463
-				$indi        = Individual::getInstance($story->xref, $WT_TREE);
464
-				$story_title = $this->getBlockSetting($story->block_id, 'title');
465
-				$languages   = $this->getBlockSetting($story->block_id, 'languages');
466
-				if (!$languages || in_array(WT_LOCALE, explode(',', $languages))) {
467
-					if ($indi) {
468
-						if ($indi->canShow()) {
469
-							echo '<tr><td><a href="' . $indi->getHtmlUrl() . '#stories">' . $story_title . '</a></td><td><a href="' . $indi->getHtmlUrl() . '#stories">' . $indi->getFullName() . '</a></td></tr>';
470
-						}
471
-					} else {
472
-						echo '<tr><td>', $story_title, '</td><td class="error">', $story->xref, '</td></tr>';
473
-					}
474
-				}
475
-			}
476
-			echo '</tbody></table>';
477
-		}
478
-	}
479
-
480
-	/**
481
-	 * The user can re-order menus. Until they do, they are shown in this order.
482
-	 *
483
-	 * @return int
484
-	 */
485
-	public function defaultMenuOrder() {
486
-		return 30;
487
-	}
488
-
489
-	/**
490
-	 * What is the default access level for this module?
491
-	 *
492
-	 * Some modules are aimed at admins or managers, and are not generally shown to users.
493
-	 *
494
-	 * @return int
495
-	 */
496
-	public function defaultAccessLevel() {
497
-		return Auth::PRIV_HIDE;
498
-	}
499
-
500
-	/**
501
-	 * A menu, to be added to the main application menu.
502
-	 *
503
-	 * @return Menu|null
504
-	 */
505
-	public function getMenu() {
506
-		$menu = new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&amp;mod_action=show_list', 'menu-story');
507
-
508
-		return $menu;
509
-	}
462
+            foreach ($stories as $story) {
463
+                $indi        = Individual::getInstance($story->xref, $WT_TREE);
464
+                $story_title = $this->getBlockSetting($story->block_id, 'title');
465
+                $languages   = $this->getBlockSetting($story->block_id, 'languages');
466
+                if (!$languages || in_array(WT_LOCALE, explode(',', $languages))) {
467
+                    if ($indi) {
468
+                        if ($indi->canShow()) {
469
+                            echo '<tr><td><a href="' . $indi->getHtmlUrl() . '#stories">' . $story_title . '</a></td><td><a href="' . $indi->getHtmlUrl() . '#stories">' . $indi->getFullName() . '</a></td></tr>';
470
+                        }
471
+                    } else {
472
+                        echo '<tr><td>', $story_title, '</td><td class="error">', $story->xref, '</td></tr>';
473
+                    }
474
+                }
475
+            }
476
+            echo '</tbody></table>';
477
+        }
478
+    }
479
+
480
+    /**
481
+     * The user can re-order menus. Until they do, they are shown in this order.
482
+     *
483
+     * @return int
484
+     */
485
+    public function defaultMenuOrder() {
486
+        return 30;
487
+    }
488
+
489
+    /**
490
+     * What is the default access level for this module?
491
+     *
492
+     * Some modules are aimed at admins or managers, and are not generally shown to users.
493
+     *
494
+     * @return int
495
+     */
496
+    public function defaultAccessLevel() {
497
+        return Auth::PRIV_HIDE;
498
+    }
499
+
500
+    /**
501
+     * A menu, to be added to the main application menu.
502
+     *
503
+     * @return Menu|null
504
+     */
505
+    public function getMenu() {
506
+        $menu = new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&amp;mod_action=show_list', 'menu-story');
507
+
508
+        return $menu;
509
+    }
510 510
 }
Please login to merge, or discard this patch.
Switch Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -49,21 +49,21 @@
 block discarded – undo
49 49
 	 */
50 50
 	public function modAction($mod_action) {
51 51
 		switch ($mod_action) {
52
-		case 'admin_edit':
53
-			$this->edit();
54
-			break;
55
-		case 'admin_delete':
56
-			$this->delete();
57
-			$this->config();
58
-			break;
59
-		case 'admin_config':
60
-			$this->config();
61
-			break;
62
-		case 'show_list':
63
-			$this->showList();
64
-			break;
65
-		default:
66
-			http_response_code(404);
52
+		    case 'admin_edit':
53
+			    $this->edit();
54
+			    break;
55
+		    case 'admin_delete':
56
+			    $this->delete();
57
+			    $this->config();
58
+			    break;
59
+		    case 'admin_config':
60
+			    $this->config();
61
+			    break;
62
+		    case 'show_list':
63
+			    $this->showList();
64
+			    break;
65
+		    default:
66
+			    http_response_code(404);
67 67
 		}
68 68
 	}
69 69
 
Please login to merge, or discard this patch.
Braces   +39 added lines, -19 removed lines patch added patch discarded remove patch
@@ -32,12 +32,14 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class StoriesModule extends AbstractModule implements ModuleTabInterface, ModuleConfigInterface, ModuleMenuInterface {
34 34
 	/** {@inheritdoc} */
35
-	public function getTitle() {
35
+	public function getTitle()
36
+	{
36 37
 		return /* I18N: Name of a module */ I18N::translate('Stories');
37 38
 	}
38 39
 
39 40
 	/** {@inheritdoc} */
40
-	public function getDescription() {
41
+	public function getDescription()
42
+	{
41 43
 		return /* I18N: Description of the “Stories” module */ I18N::translate('Add narrative stories to individuals in the family tree.');
42 44
 	}
43 45
 
@@ -47,7 +49,8 @@  discard block
 block discarded – undo
47 49
 	 *
48 50
 	 * @param string $mod_action
49 51
 	 */
50
-	public function modAction($mod_action) {
52
+	public function modAction($mod_action)
53
+	{
51 54
 		switch ($mod_action) {
52 55
 		case 'admin_edit':
53 56
 			$this->edit();
@@ -68,17 +71,20 @@  discard block
 block discarded – undo
68 71
 	}
69 72
 
70 73
 	/** {@inheritdoc} */
71
-	public function getConfigLink() {
74
+	public function getConfigLink()
75
+	{
72 76
 		return 'module.php?mod=' . $this->getName() . '&amp;mod_action=admin_config';
73 77
 	}
74 78
 
75 79
 	/** {@inheritdoc} */
76
-	public function defaultTabOrder() {
80
+	public function defaultTabOrder()
81
+	{
77 82
 		return 55;
78 83
 	}
79 84
 
80 85
 	/** {@inheritdoc} */
81
-	public function getTabContent() {
86
+	public function getTabContent()
87
+	{
82 88
 		global $controller, $WT_TREE;
83 89
 
84 90
 		$block_ids =
@@ -117,12 +123,14 @@  discard block
 block discarded – undo
117 123
 	}
118 124
 
119 125
 	/** {@inheritdoc} */
120
-	public function hasTabContent() {
126
+	public function hasTabContent()
127
+	{
121 128
 		return $this->getTabContent() != '';
122 129
 	}
123 130
 
124 131
 	/** {@inheritdoc} */
125
-	public function isGrayedOut() {
132
+	public function isGrayedOut()
133
+	{
126 134
 		global $controller;
127 135
 
128 136
 		$count_of_stories =
@@ -142,19 +150,22 @@  discard block
 block discarded – undo
142 150
 	}
143 151
 
144 152
 	/** {@inheritdoc} */
145
-	public function canLoadAjax() {
153
+	public function canLoadAjax()
154
+	{
146 155
 		return false;
147 156
 	}
148 157
 
149 158
 	/** {@inheritdoc} */
150
-	public function getPreLoadContent() {
159
+	public function getPreLoadContent()
160
+	{
151 161
 		return '';
152 162
 	}
153 163
 
154 164
 	/**
155 165
 	 * Show and process a form to edit a story.
156 166
 	 */
157
-	private function edit() {
167
+	private function edit()
168
+	{
158 169
 		global $WT_TREE;
159 170
 
160 171
 		if (Auth::isEditor($WT_TREE)) {
@@ -283,7 +294,8 @@  discard block
 block discarded – undo
283 294
 	/**
284 295
 	 * Respond to a request to delete a story.
285 296
 	 */
286
-	private function delete() {
297
+	private function delete()
298
+	{
287 299
 		global $WT_TREE;
288 300
 
289 301
 		if (Auth::isEditor($WT_TREE)) {
@@ -305,7 +317,8 @@  discard block
 block discarded – undo
305 317
 	/**
306 318
 	 * The admin view - list, create, edit, delete stories.
307 319
 	 */
308
-	private function config() {
320
+	private function config()
321
+	{
309 322
 		global $WT_TREE;
310 323
 
311 324
 		$controller = new PageController;
@@ -389,8 +402,11 @@  discard block
 block discarded – undo
389 402
 						<a href="<?php echo $individual->getHtmlUrl(); ?>#stories">
390 403
 							<?php echo $individual->getFullName(); ?>
391 404
 						</a>
392
-						<?php else: ?>
393
-							<?php echo $story->xref; ?>
405
+						<?php else {
406
+    : ?>
407
+							<?php echo $story->xref;
408
+}
409
+?>
394 410
 						<?php endif; ?>
395 411
 						</td>
396 412
 						<td>
@@ -416,7 +432,8 @@  discard block
 block discarded – undo
416 432
 	/**
417 433
 	 * Show the list of stories
418 434
 	 */
419
-	private function showList() {
435
+	private function showList()
436
+	{
420 437
 		global $controller, $WT_TREE;
421 438
 
422 439
 		$controller = new PageController;
@@ -482,7 +499,8 @@  discard block
 block discarded – undo
482 499
 	 *
483 500
 	 * @return int
484 501
 	 */
485
-	public function defaultMenuOrder() {
502
+	public function defaultMenuOrder()
503
+	{
486 504
 		return 30;
487 505
 	}
488 506
 
@@ -493,7 +511,8 @@  discard block
 block discarded – undo
493 511
 	 *
494 512
 	 * @return int
495 513
 	 */
496
-	public function defaultAccessLevel() {
514
+	public function defaultAccessLevel()
515
+	{
497 516
 		return Auth::PRIV_HIDE;
498 517
 	}
499 518
 
@@ -502,7 +521,8 @@  discard block
 block discarded – undo
502 521
 	 *
503 522
 	 * @return Menu|null
504 523
 	 */
505
-	public function getMenu() {
524
+	public function getMenu()
525
+	{
506 526
 		$menu = new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&amp;mod_action=show_list', 'menu-story');
507 527
 
508 528
 		return $menu;
Please login to merge, or discard this patch.