@@ -28,75 +28,75 @@ discard block |
||
28 | 28 | * Class IndividualSidebarModule |
29 | 29 | */ |
30 | 30 | class IndividualSidebarModule extends AbstractModule implements ModuleSidebarInterface { |
31 | - /** {@inheritdoc} */ |
|
32 | - public function getTitle() { |
|
33 | - return /* I18N: Name of a module */ I18N::translate('Individual list'); |
|
34 | - } |
|
31 | + /** {@inheritdoc} */ |
|
32 | + public function getTitle() { |
|
33 | + return /* I18N: Name of a module */ I18N::translate('Individual list'); |
|
34 | + } |
|
35 | 35 | |
36 | - /** {@inheritdoc} */ |
|
37 | - public function getDescription() { |
|
38 | - return /* I18N: Description of “Individuals” module */ I18N::translate('A sidebar showing an alphabetic list of all the individuals in the family tree.'); |
|
39 | - } |
|
36 | + /** {@inheritdoc} */ |
|
37 | + public function getDescription() { |
|
38 | + return /* I18N: Description of “Individuals” module */ I18N::translate('A sidebar showing an alphabetic list of all the individuals in the family tree.'); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * This is a general purpose hook, allowing modules to respond to routes |
|
43 | - * of the form module.php?mod=FOO&mod_action=BAR |
|
44 | - * |
|
45 | - * @param string $mod_action |
|
46 | - */ |
|
47 | - public function modAction($mod_action) { |
|
48 | - switch ($mod_action) { |
|
49 | - case 'ajax': |
|
50 | - header('Content-Type: text/html; charset=UTF-8'); |
|
51 | - echo $this->getSidebarAjaxContent(); |
|
52 | - break; |
|
53 | - default: |
|
54 | - http_response_code(404); |
|
55 | - break; |
|
56 | - } |
|
57 | - } |
|
41 | + /** |
|
42 | + * This is a general purpose hook, allowing modules to respond to routes |
|
43 | + * of the form module.php?mod=FOO&mod_action=BAR |
|
44 | + * |
|
45 | + * @param string $mod_action |
|
46 | + */ |
|
47 | + public function modAction($mod_action) { |
|
48 | + switch ($mod_action) { |
|
49 | + case 'ajax': |
|
50 | + header('Content-Type: text/html; charset=UTF-8'); |
|
51 | + echo $this->getSidebarAjaxContent(); |
|
52 | + break; |
|
53 | + default: |
|
54 | + http_response_code(404); |
|
55 | + break; |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | - /** {@inheritdoc} */ |
|
60 | - public function defaultSidebarOrder() { |
|
61 | - return 40; |
|
62 | - } |
|
59 | + /** {@inheritdoc} */ |
|
60 | + public function defaultSidebarOrder() { |
|
61 | + return 40; |
|
62 | + } |
|
63 | 63 | |
64 | - /** {@inheritdoc} */ |
|
65 | - public function hasSidebarContent() { |
|
66 | - return !Auth::isSearchEngine(); |
|
67 | - } |
|
64 | + /** {@inheritdoc} */ |
|
65 | + public function hasSidebarContent() { |
|
66 | + return !Auth::isSearchEngine(); |
|
67 | + } |
|
68 | 68 | |
69 | - /** {@inheritdoc} */ |
|
70 | - public function getSidebarAjaxContent() { |
|
71 | - global $WT_TREE; |
|
69 | + /** {@inheritdoc} */ |
|
70 | + public function getSidebarAjaxContent() { |
|
71 | + global $WT_TREE; |
|
72 | 72 | |
73 | - $alpha = Filter::get('alpha'); // All surnames beginning with this letter where "@"=unknown and ","=none |
|
74 | - $surname = Filter::get('surname'); // All indis with this surname. |
|
75 | - $search = Filter::get('search'); |
|
73 | + $alpha = Filter::get('alpha'); // All surnames beginning with this letter where "@"=unknown and ","=none |
|
74 | + $surname = Filter::get('surname'); // All indis with this surname. |
|
75 | + $search = Filter::get('search'); |
|
76 | 76 | |
77 | - if ($search) { |
|
78 | - return $this->search($WT_TREE, $search); |
|
79 | - } elseif ($alpha == '@' || $alpha == ',' || $surname) { |
|
80 | - return $this->getSurnameIndis($WT_TREE, $alpha, $surname); |
|
81 | - } elseif ($alpha) { |
|
82 | - return $this->getAlphaSurnames($WT_TREE, $alpha); |
|
83 | - } else { |
|
84 | - return ''; |
|
85 | - } |
|
86 | - } |
|
77 | + if ($search) { |
|
78 | + return $this->search($WT_TREE, $search); |
|
79 | + } elseif ($alpha == '@' || $alpha == ',' || $surname) { |
|
80 | + return $this->getSurnameIndis($WT_TREE, $alpha, $surname); |
|
81 | + } elseif ($alpha) { |
|
82 | + return $this->getAlphaSurnames($WT_TREE, $alpha); |
|
83 | + } else { |
|
84 | + return ''; |
|
85 | + } |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * Load this sidebar synchronously. |
|
90 | - * |
|
91 | - * @return string |
|
92 | - */ |
|
93 | - public function getSidebarContent() { |
|
94 | - global $controller, $WT_TREE; |
|
88 | + /** |
|
89 | + * Load this sidebar synchronously. |
|
90 | + * |
|
91 | + * @return string |
|
92 | + */ |
|
93 | + public function getSidebarContent() { |
|
94 | + global $controller, $WT_TREE; |
|
95 | 95 | |
96 | - // Fetch a list of the initial letters of all surnames in the database |
|
97 | - $initials = QueryName::surnameAlpha($WT_TREE, true, false, false); |
|
96 | + // Fetch a list of the initial letters of all surnames in the database |
|
97 | + $initials = QueryName::surnameAlpha($WT_TREE, true, false, false); |
|
98 | 98 | |
99 | - $controller->addInlineJavascript(' |
|
99 | + $controller->addInlineJavascript(' |
|
100 | 100 | var loadedNames = new Array(); |
101 | 101 | |
102 | 102 | function isearchQ() { |
@@ -147,125 +147,125 @@ discard block |
||
147 | 147 | }); |
148 | 148 | '); |
149 | 149 | |
150 | - $out = '<form method="post" action="module.php?mod=' . $this->getName() . '&mod_action=ajax" onsubmit="return false;"><input type="search" name="sb_indi_name" id="sb_indi_name" placeholder="' . I18N::translate('Search') . '"><p>'; |
|
151 | - foreach ($initials as $letter => $count) { |
|
152 | - switch ($letter) { |
|
153 | - case '@': |
|
154 | - $html = I18N::translateContext('Unknown surname', '…'); |
|
155 | - break; |
|
156 | - case ',': |
|
157 | - $html = I18N::translate('None'); |
|
158 | - break; |
|
159 | - case ' ': |
|
160 | - $html = ' '; |
|
161 | - break; |
|
162 | - default: |
|
163 | - $html = $letter; |
|
164 | - break; |
|
165 | - } |
|
166 | - $html = '<a href="module.php?mod=' . $this->getName() . '&mod_action=ajax&alpha=' . urlencode($letter) . '" class="sb_indi_letter">' . $html . '</a>'; |
|
167 | - $out .= $html . " "; |
|
168 | - } |
|
150 | + $out = '<form method="post" action="module.php?mod=' . $this->getName() . '&mod_action=ajax" onsubmit="return false;"><input type="search" name="sb_indi_name" id="sb_indi_name" placeholder="' . I18N::translate('Search') . '"><p>'; |
|
151 | + foreach ($initials as $letter => $count) { |
|
152 | + switch ($letter) { |
|
153 | + case '@': |
|
154 | + $html = I18N::translateContext('Unknown surname', '…'); |
|
155 | + break; |
|
156 | + case ',': |
|
157 | + $html = I18N::translate('None'); |
|
158 | + break; |
|
159 | + case ' ': |
|
160 | + $html = ' '; |
|
161 | + break; |
|
162 | + default: |
|
163 | + $html = $letter; |
|
164 | + break; |
|
165 | + } |
|
166 | + $html = '<a href="module.php?mod=' . $this->getName() . '&mod_action=ajax&alpha=' . urlencode($letter) . '" class="sb_indi_letter">' . $html . '</a>'; |
|
167 | + $out .= $html . " "; |
|
168 | + } |
|
169 | 169 | |
170 | - $out .= '</p>'; |
|
171 | - $out .= '<div id="sb_indi_content">'; |
|
172 | - $out .= '</div></form>'; |
|
170 | + $out .= '</p>'; |
|
171 | + $out .= '<div id="sb_indi_content">'; |
|
172 | + $out .= '</div></form>'; |
|
173 | 173 | |
174 | - return $out; |
|
175 | - } |
|
174 | + return $out; |
|
175 | + } |
|
176 | 176 | |
177 | - /** |
|
178 | - * Get the initial letters of surnames. |
|
179 | - * |
|
180 | - * @param Tree $tree |
|
181 | - * @param string $alpha |
|
182 | - * |
|
183 | - * @return string |
|
184 | - */ |
|
185 | - private function getAlphaSurnames(Tree $tree, $alpha) { |
|
186 | - $surnames = QueryName::surnames($tree, '', $alpha, true, false); |
|
187 | - $out = '<ul>'; |
|
188 | - foreach (array_keys($surnames) as $surname) { |
|
189 | - $out .= '<li class="sb_indi_surname_li"><a href="#" data-surname="' . Filter::escapeHtml($surname) . '" data-alpha="' . Filter::escapeHtml($alpha) . '" class="sb_indi_surname">' . Filter::escapeHtml($surname) . '</a>'; |
|
190 | - $out .= '<div class="name_tree_div"></div>'; |
|
191 | - $out .= '</li>'; |
|
192 | - } |
|
193 | - $out .= '</ul>'; |
|
177 | + /** |
|
178 | + * Get the initial letters of surnames. |
|
179 | + * |
|
180 | + * @param Tree $tree |
|
181 | + * @param string $alpha |
|
182 | + * |
|
183 | + * @return string |
|
184 | + */ |
|
185 | + private function getAlphaSurnames(Tree $tree, $alpha) { |
|
186 | + $surnames = QueryName::surnames($tree, '', $alpha, true, false); |
|
187 | + $out = '<ul>'; |
|
188 | + foreach (array_keys($surnames) as $surname) { |
|
189 | + $out .= '<li class="sb_indi_surname_li"><a href="#" data-surname="' . Filter::escapeHtml($surname) . '" data-alpha="' . Filter::escapeHtml($alpha) . '" class="sb_indi_surname">' . Filter::escapeHtml($surname) . '</a>'; |
|
190 | + $out .= '<div class="name_tree_div"></div>'; |
|
191 | + $out .= '</li>'; |
|
192 | + } |
|
193 | + $out .= '</ul>'; |
|
194 | 194 | |
195 | - return $out; |
|
196 | - } |
|
195 | + return $out; |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * Format a list of individuals. |
|
200 | - * |
|
201 | - * @param Tree $tree |
|
202 | - * @param string $alpha |
|
203 | - * @param string $surname |
|
204 | - * |
|
205 | - * @return string |
|
206 | - */ |
|
207 | - private function getSurnameIndis(Tree $tree, $alpha, $surname) { |
|
208 | - $indis = QueryName::individuals($tree, $surname, $alpha, '', true, false); |
|
209 | - $out = '<ul>'; |
|
210 | - foreach ($indis as $person) { |
|
211 | - if ($person->canShowName()) { |
|
212 | - $out .= '<li><a href="' . $person->getHtmlUrl() . '">' . $person->getSexImage() . ' ' . $person->getFullName() . ' '; |
|
213 | - if ($person->canShow()) { |
|
214 | - $bd = $person->getLifeSpan(); |
|
215 | - if (!empty($bd)) { |
|
216 | - $out .= ' (' . $bd . ')'; |
|
217 | - } |
|
218 | - } |
|
219 | - $out .= '</a></li>'; |
|
220 | - } |
|
221 | - } |
|
222 | - $out .= '</ul>'; |
|
198 | + /** |
|
199 | + * Format a list of individuals. |
|
200 | + * |
|
201 | + * @param Tree $tree |
|
202 | + * @param string $alpha |
|
203 | + * @param string $surname |
|
204 | + * |
|
205 | + * @return string |
|
206 | + */ |
|
207 | + private function getSurnameIndis(Tree $tree, $alpha, $surname) { |
|
208 | + $indis = QueryName::individuals($tree, $surname, $alpha, '', true, false); |
|
209 | + $out = '<ul>'; |
|
210 | + foreach ($indis as $person) { |
|
211 | + if ($person->canShowName()) { |
|
212 | + $out .= '<li><a href="' . $person->getHtmlUrl() . '">' . $person->getSexImage() . ' ' . $person->getFullName() . ' '; |
|
213 | + if ($person->canShow()) { |
|
214 | + $bd = $person->getLifeSpan(); |
|
215 | + if (!empty($bd)) { |
|
216 | + $out .= ' (' . $bd . ')'; |
|
217 | + } |
|
218 | + } |
|
219 | + $out .= '</a></li>'; |
|
220 | + } |
|
221 | + } |
|
222 | + $out .= '</ul>'; |
|
223 | 223 | |
224 | - return $out; |
|
225 | - } |
|
224 | + return $out; |
|
225 | + } |
|
226 | 226 | |
227 | - /** |
|
228 | - * Search for individuals in a tree. |
|
229 | - * |
|
230 | - * @param Tree $tree Search this tree |
|
231 | - * @param string $query Search for this text |
|
232 | - * |
|
233 | - * @return string |
|
234 | - */ |
|
235 | - private function search(Tree $tree, $query) { |
|
236 | - if (strlen($query) < 2) { |
|
237 | - return ''; |
|
238 | - } |
|
239 | - $rows = Database::prepare( |
|
240 | - "SELECT i_id AS xref, i_gedcom AS gedcom" . |
|
241 | - " FROM `##individuals`, `##name`" . |
|
242 | - " WHERE (i_id LIKE CONCAT('%', :query_1, '%') OR n_sort LIKE CONCAT('%', :query_2, '%'))" . |
|
243 | - " AND i_id = n_id AND i_file = n_file AND i_file = :tree_id" . |
|
244 | - " ORDER BY n_sort COLLATE :collation" . |
|
245 | - " LIMIT 50" |
|
246 | - )->execute(array( |
|
247 | - 'query_1' => $query, |
|
248 | - 'query_2' => $query, |
|
249 | - 'tree_id' => $tree->getTreeId(), |
|
250 | - 'collation' => I18N::collation(), |
|
251 | - ))->fetchAll(); |
|
227 | + /** |
|
228 | + * Search for individuals in a tree. |
|
229 | + * |
|
230 | + * @param Tree $tree Search this tree |
|
231 | + * @param string $query Search for this text |
|
232 | + * |
|
233 | + * @return string |
|
234 | + */ |
|
235 | + private function search(Tree $tree, $query) { |
|
236 | + if (strlen($query) < 2) { |
|
237 | + return ''; |
|
238 | + } |
|
239 | + $rows = Database::prepare( |
|
240 | + "SELECT i_id AS xref, i_gedcom AS gedcom" . |
|
241 | + " FROM `##individuals`, `##name`" . |
|
242 | + " WHERE (i_id LIKE CONCAT('%', :query_1, '%') OR n_sort LIKE CONCAT('%', :query_2, '%'))" . |
|
243 | + " AND i_id = n_id AND i_file = n_file AND i_file = :tree_id" . |
|
244 | + " ORDER BY n_sort COLLATE :collation" . |
|
245 | + " LIMIT 50" |
|
246 | + )->execute(array( |
|
247 | + 'query_1' => $query, |
|
248 | + 'query_2' => $query, |
|
249 | + 'tree_id' => $tree->getTreeId(), |
|
250 | + 'collation' => I18N::collation(), |
|
251 | + ))->fetchAll(); |
|
252 | 252 | |
253 | - $out = '<ul>'; |
|
254 | - foreach ($rows as $row) { |
|
255 | - $person = Individual::getInstance($row->xref, $tree, $row->gedcom); |
|
256 | - if ($person->canShowName()) { |
|
257 | - $out .= '<li><a href="' . $person->getHtmlUrl() . '">' . $person->getSexImage() . ' ' . $person->getFullName() . ' '; |
|
258 | - if ($person->canShow()) { |
|
259 | - $bd = $person->getLifeSpan(); |
|
260 | - if (!empty($bd)) { |
|
261 | - $out .= ' (' . $bd . ')'; |
|
262 | - } |
|
263 | - } |
|
264 | - $out .= '</a></li>'; |
|
265 | - } |
|
266 | - } |
|
267 | - $out .= '</ul>'; |
|
253 | + $out = '<ul>'; |
|
254 | + foreach ($rows as $row) { |
|
255 | + $person = Individual::getInstance($row->xref, $tree, $row->gedcom); |
|
256 | + if ($person->canShowName()) { |
|
257 | + $out .= '<li><a href="' . $person->getHtmlUrl() . '">' . $person->getSexImage() . ' ' . $person->getFullName() . ' '; |
|
258 | + if ($person->canShow()) { |
|
259 | + $bd = $person->getLifeSpan(); |
|
260 | + if (!empty($bd)) { |
|
261 | + $out .= ' (' . $bd . ')'; |
|
262 | + } |
|
263 | + } |
|
264 | + $out .= '</a></li>'; |
|
265 | + } |
|
266 | + } |
|
267 | + $out .= '</ul>'; |
|
268 | 268 | |
269 | - return $out; |
|
270 | - } |
|
269 | + return $out; |
|
270 | + } |
|
271 | 271 | } |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function modAction($mod_action) { |
48 | 48 | switch ($mod_action) { |
49 | - case 'ajax': |
|
50 | - header('Content-Type: text/html; charset=UTF-8'); |
|
51 | - echo $this->getSidebarAjaxContent(); |
|
52 | - break; |
|
53 | - default: |
|
54 | - http_response_code(404); |
|
55 | - break; |
|
49 | + case 'ajax': |
|
50 | + header('Content-Type: text/html; charset=UTF-8'); |
|
51 | + echo $this->getSidebarAjaxContent(); |
|
52 | + break; |
|
53 | + default: |
|
54 | + http_response_code(404); |
|
55 | + break; |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -150,18 +150,18 @@ discard block |
||
150 | 150 | $out = '<form method="post" action="module.php?mod=' . $this->getName() . '&mod_action=ajax" onsubmit="return false;"><input type="search" name="sb_indi_name" id="sb_indi_name" placeholder="' . I18N::translate('Search') . '"><p>'; |
151 | 151 | foreach ($initials as $letter => $count) { |
152 | 152 | switch ($letter) { |
153 | - case '@': |
|
154 | - $html = I18N::translateContext('Unknown surname', '…'); |
|
155 | - break; |
|
156 | - case ',': |
|
157 | - $html = I18N::translate('None'); |
|
158 | - break; |
|
159 | - case ' ': |
|
160 | - $html = ' '; |
|
161 | - break; |
|
162 | - default: |
|
163 | - $html = $letter; |
|
164 | - break; |
|
153 | + case '@': |
|
154 | + $html = I18N::translateContext('Unknown surname', '…'); |
|
155 | + break; |
|
156 | + case ',': |
|
157 | + $html = I18N::translate('None'); |
|
158 | + break; |
|
159 | + case ' ': |
|
160 | + $html = ' '; |
|
161 | + break; |
|
162 | + default: |
|
163 | + $html = $letter; |
|
164 | + break; |
|
165 | 165 | } |
166 | 166 | $html = '<a href="module.php?mod=' . $this->getName() . '&mod_action=ajax&alpha=' . urlencode($letter) . '" class="sb_indi_letter">' . $html . '</a>'; |
167 | 167 | $out .= $html . " "; |
@@ -27,14 +27,17 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * Class IndividualSidebarModule |
29 | 29 | */ |
30 | -class IndividualSidebarModule extends AbstractModule implements ModuleSidebarInterface { |
|
30 | +class IndividualSidebarModule extends AbstractModule implements ModuleSidebarInterface |
|
31 | +{ |
|
31 | 32 | /** {@inheritdoc} */ |
32 | - public function getTitle() { |
|
33 | + public function getTitle() |
|
34 | + { |
|
33 | 35 | return /* I18N: Name of a module */ I18N::translate('Individual list'); |
34 | 36 | } |
35 | 37 | |
36 | 38 | /** {@inheritdoc} */ |
37 | - public function getDescription() { |
|
39 | + public function getDescription() |
|
40 | + { |
|
38 | 41 | return /* I18N: Description of “Individuals” module */ I18N::translate('A sidebar showing an alphabetic list of all the individuals in the family tree.'); |
39 | 42 | } |
40 | 43 | |
@@ -44,7 +47,8 @@ discard block |
||
44 | 47 | * |
45 | 48 | * @param string $mod_action |
46 | 49 | */ |
47 | - public function modAction($mod_action) { |
|
50 | + public function modAction($mod_action) |
|
51 | + { |
|
48 | 52 | switch ($mod_action) { |
49 | 53 | case 'ajax': |
50 | 54 | header('Content-Type: text/html; charset=UTF-8'); |
@@ -57,17 +61,20 @@ discard block |
||
57 | 61 | } |
58 | 62 | |
59 | 63 | /** {@inheritdoc} */ |
60 | - public function defaultSidebarOrder() { |
|
64 | + public function defaultSidebarOrder() |
|
65 | + { |
|
61 | 66 | return 40; |
62 | 67 | } |
63 | 68 | |
64 | 69 | /** {@inheritdoc} */ |
65 | - public function hasSidebarContent() { |
|
70 | + public function hasSidebarContent() |
|
71 | + { |
|
66 | 72 | return !Auth::isSearchEngine(); |
67 | 73 | } |
68 | 74 | |
69 | 75 | /** {@inheritdoc} */ |
70 | - public function getSidebarAjaxContent() { |
|
76 | + public function getSidebarAjaxContent() |
|
77 | + { |
|
71 | 78 | global $WT_TREE; |
72 | 79 | |
73 | 80 | $alpha = Filter::get('alpha'); // All surnames beginning with this letter where "@"=unknown and ","=none |
@@ -90,7 +97,8 @@ discard block |
||
90 | 97 | * |
91 | 98 | * @return string |
92 | 99 | */ |
93 | - public function getSidebarContent() { |
|
100 | + public function getSidebarContent() |
|
101 | + { |
|
94 | 102 | global $controller, $WT_TREE; |
95 | 103 | |
96 | 104 | // Fetch a list of the initial letters of all surnames in the database |
@@ -182,7 +190,8 @@ discard block |
||
182 | 190 | * |
183 | 191 | * @return string |
184 | 192 | */ |
185 | - private function getAlphaSurnames(Tree $tree, $alpha) { |
|
193 | + private function getAlphaSurnames(Tree $tree, $alpha) |
|
194 | + { |
|
186 | 195 | $surnames = QueryName::surnames($tree, '', $alpha, true, false); |
187 | 196 | $out = '<ul>'; |
188 | 197 | foreach (array_keys($surnames) as $surname) { |
@@ -204,7 +213,8 @@ discard block |
||
204 | 213 | * |
205 | 214 | * @return string |
206 | 215 | */ |
207 | - private function getSurnameIndis(Tree $tree, $alpha, $surname) { |
|
216 | + private function getSurnameIndis(Tree $tree, $alpha, $surname) |
|
217 | + { |
|
208 | 218 | $indis = QueryName::individuals($tree, $surname, $alpha, '', true, false); |
209 | 219 | $out = '<ul>'; |
210 | 220 | foreach ($indis as $person) { |
@@ -232,7 +242,8 @@ discard block |
||
232 | 242 | * |
233 | 243 | * @return string |
234 | 244 | */ |
235 | - private function search(Tree $tree, $query) { |
|
245 | + private function search(Tree $tree, $query) |
|
246 | + { |
|
236 | 247 | if (strlen($query) < 2) { |
237 | 248 | return ''; |
238 | 249 | } |
@@ -23,42 +23,42 @@ |
||
23 | 23 | * Class PedigreeReportModule |
24 | 24 | */ |
25 | 25 | class PedigreeReportModule extends AbstractModule implements ModuleReportInterface { |
26 | - /** {@inheritdoc} */ |
|
27 | - public function getTitle() { |
|
28 | - // This text also appears in the .XML file - update both together |
|
29 | - return /* I18N: Name of a report */ I18N::translate('Pedigree'); |
|
30 | - } |
|
26 | + /** {@inheritdoc} */ |
|
27 | + public function getTitle() { |
|
28 | + // This text also appears in the .XML file - update both together |
|
29 | + return /* I18N: Name of a report */ I18N::translate('Pedigree'); |
|
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 “Pedigree” module */ I18N::translate('A report of an individual’s ancestors, formatted as a tree.'); |
|
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 “Pedigree” module */ I18N::translate('A report of an individual’s ancestors, formatted as a tree.'); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * What is the default access level for this module? |
|
40 | - * |
|
41 | - * Some modules are aimed at admins or managers, and are not generally shown to users. |
|
42 | - * |
|
43 | - * @return int |
|
44 | - */ |
|
45 | - public function defaultAccessLevel() { |
|
46 | - return Auth::PRIV_PRIVATE; |
|
47 | - } |
|
38 | + /** |
|
39 | + * What is the default access level for this module? |
|
40 | + * |
|
41 | + * Some modules are aimed at admins or managers, and are not generally shown to users. |
|
42 | + * |
|
43 | + * @return int |
|
44 | + */ |
|
45 | + public function defaultAccessLevel() { |
|
46 | + return Auth::PRIV_PRIVATE; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Return a menu item for this report. |
|
51 | - * |
|
52 | - * @return Menu |
|
53 | - */ |
|
54 | - public function getReportMenu() { |
|
55 | - global $controller, $WT_TREE; |
|
49 | + /** |
|
50 | + * Return a menu item for this report. |
|
51 | + * |
|
52 | + * @return Menu |
|
53 | + */ |
|
54 | + public function getReportMenu() { |
|
55 | + global $controller, $WT_TREE; |
|
56 | 56 | |
57 | - return new Menu( |
|
58 | - $this->getTitle(), |
|
59 | - 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), |
|
60 | - 'menu-report-' . $this->getName(), |
|
61 | - array('rel' => 'nofollow') |
|
62 | - ); |
|
63 | - } |
|
57 | + return new Menu( |
|
58 | + $this->getTitle(), |
|
59 | + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), |
|
60 | + 'menu-report-' . $this->getName(), |
|
61 | + array('rel' => 'nofollow') |
|
62 | + ); |
|
63 | + } |
|
64 | 64 | } |
@@ -22,15 +22,18 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * Class PedigreeReportModule |
24 | 24 | */ |
25 | -class PedigreeReportModule extends AbstractModule implements ModuleReportInterface { |
|
25 | +class PedigreeReportModule extends AbstractModule implements ModuleReportInterface |
|
26 | +{ |
|
26 | 27 | /** {@inheritdoc} */ |
27 | - public function getTitle() { |
|
28 | + public function getTitle() |
|
29 | + { |
|
28 | 30 | // This text also appears in the .XML file - update both together |
29 | 31 | return /* I18N: Name of a report */ I18N::translate('Pedigree'); |
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 “Pedigree” module */ I18N::translate('A report of an individual’s ancestors, formatted as a tree.'); |
36 | 39 | } |
@@ -42,7 +45,8 @@ discard block |
||
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 |
||
51 | 55 | * |
52 | 56 | * @return Menu |
53 | 57 | */ |
54 | - public function getReportMenu() { |
|
58 | + public function getReportMenu() |
|
59 | + { |
|
55 | 60 | global $controller, $WT_TREE; |
56 | 61 | |
57 | 62 | return new Menu( |
@@ -29,134 +29,134 @@ discard block |
||
29 | 29 | * Class FrequentlyAskedQuestionsModule |
30 | 30 | */ |
31 | 31 | class FrequentlyAskedQuestionsModule extends AbstractModule implements ModuleMenuInterface, ModuleConfigInterface { |
32 | - /** {@inheritdoc} */ |
|
33 | - public function getTitle() { |
|
34 | - return /* I18N: Name of a module. Abbreviation for “Frequently Asked Questions” */ I18N::translate('FAQ'); |
|
35 | - } |
|
36 | - |
|
37 | - /** {@inheritdoc} */ |
|
38 | - public function getDescription() { |
|
39 | - return /* I18N: Description of the “FAQ” module */ I18N::translate('A list of frequently asked questions and answers.'); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * This is a general purpose hook, allowing modules to respond to routes |
|
44 | - * of the form module.php?mod=FOO&mod_action=BAR |
|
45 | - * |
|
46 | - * @param string $mod_action |
|
47 | - */ |
|
48 | - public function modAction($mod_action) { |
|
49 | - switch ($mod_action) { |
|
50 | - case 'admin_config': |
|
51 | - $this->config(); |
|
52 | - break; |
|
53 | - case 'admin_delete': |
|
54 | - if (Auth::isAdmin()) { |
|
55 | - $this->delete(); |
|
56 | - } |
|
57 | - header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
58 | - break; |
|
59 | - case 'admin_edit': |
|
60 | - $this->edit(); |
|
61 | - break; |
|
62 | - case 'admin_edit_save': |
|
63 | - if (Auth::isAdmin()) { |
|
64 | - $this->editSave(); |
|
65 | - } |
|
66 | - header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
67 | - break; |
|
68 | - case 'admin_movedown': |
|
69 | - if (Auth::isAdmin()) { |
|
70 | - $this->movedown(); |
|
71 | - } |
|
72 | - header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
73 | - break; |
|
74 | - case 'admin_moveup': |
|
75 | - if (Auth::isAdmin()) { |
|
76 | - $this->moveup(); |
|
77 | - } |
|
78 | - header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
79 | - break; |
|
80 | - case 'show': |
|
81 | - $this->show(); |
|
82 | - break; |
|
83 | - default: |
|
84 | - http_response_code(404); |
|
85 | - } |
|
86 | - } |
|
87 | - |
|
88 | - /** {@inheritdoc} */ |
|
89 | - public function getConfigLink() { |
|
90 | - return 'module.php?mod=' . $this->getName() . '&mod_action=admin_config'; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Action from the configuration page |
|
95 | - */ |
|
96 | - private function editSave() { |
|
97 | - if (Filter::checkCsrf()) { |
|
98 | - $block_id = Filter::postInteger('block_id'); |
|
99 | - if ($block_id) { |
|
100 | - Database::prepare( |
|
101 | - "UPDATE `##block` SET gedcom_id = NULLIF(:tree_id, '0'), block_order = :block_order WHERE block_id = :block_id" |
|
102 | - )->execute(array( |
|
103 | - 'tree_id' => Filter::postInteger('gedcom_id'), |
|
104 | - 'block_order' => Filter::postInteger('block_order'), |
|
105 | - 'block_id' => $block_id, |
|
106 | - )); |
|
107 | - } else { |
|
108 | - Database::prepare( |
|
109 | - "INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(:tree_id, '0'), :module_name, :block_order)" |
|
110 | - )->execute(array( |
|
111 | - 'tree_id' => Filter::postInteger('gedcom_id'), |
|
112 | - 'module_name' => $this->getName(), |
|
113 | - 'block_order' => Filter::postInteger('block_order'), |
|
114 | - )); |
|
115 | - $block_id = Database::getInstance()->lastInsertId(); |
|
116 | - } |
|
117 | - $this->setBlockSetting($block_id, 'header', Filter::post('header')); |
|
118 | - $this->setBlockSetting($block_id, 'faqbody', Filter::post('faqbody')); |
|
119 | - |
|
120 | - $languages = Filter::postArray('lang'); |
|
121 | - $this->setBlockSetting($block_id, 'languages', implode(',', $languages)); |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Action from the configuration page |
|
127 | - */ |
|
128 | - private function edit() { |
|
129 | - global $WT_TREE; |
|
130 | - |
|
131 | - $controller = new PageController; |
|
132 | - $controller->restrictAccess(Auth::isAdmin()); |
|
133 | - |
|
134 | - $block_id = Filter::getInteger('block_id'); |
|
135 | - if ($block_id) { |
|
136 | - $controller->setPageTitle(/* I18N: FAQ = “Frequently Asked Question” */ I18N::translate('Edit the FAQ')); |
|
137 | - $header = $this->getBlockSetting($block_id, 'header'); |
|
138 | - $faqbody = $this->getBlockSetting($block_id, 'faqbody'); |
|
139 | - $block_order = Database::prepare( |
|
140 | - "SELECT block_order FROM `##block` WHERE block_id = :block_id" |
|
141 | - )->execute(array('block_id' => $block_id))->fetchOne(); |
|
142 | - $gedcom_id = Database::prepare( |
|
143 | - "SELECT gedcom_id FROM `##block` WHERE block_id = :block_id" |
|
144 | - )->execute(array('block_id' => $block_id))->fetchOne(); |
|
145 | - } else { |
|
146 | - $controller->setPageTitle(/* I18N: FAQ = “Frequently Asked Question” */ I18N::translate('Add an FAQ')); |
|
147 | - $header = ''; |
|
148 | - $faqbody = ''; |
|
149 | - $block_order = Database::prepare( |
|
150 | - "SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name = :module_name" |
|
151 | - )->execute(array('module_name' => $this->getName()))->fetchOne(); |
|
152 | - $gedcom_id = $WT_TREE->getTreeId(); |
|
153 | - } |
|
154 | - $controller->pageHeader(); |
|
155 | - if (Module::getModuleByName('ckeditor')) { |
|
156 | - CkeditorModule::enableEditor($controller); |
|
157 | - } |
|
158 | - |
|
159 | - ?> |
|
32 | + /** {@inheritdoc} */ |
|
33 | + public function getTitle() { |
|
34 | + return /* I18N: Name of a module. Abbreviation for “Frequently Asked Questions” */ I18N::translate('FAQ'); |
|
35 | + } |
|
36 | + |
|
37 | + /** {@inheritdoc} */ |
|
38 | + public function getDescription() { |
|
39 | + return /* I18N: Description of the “FAQ” module */ I18N::translate('A list of frequently asked questions and answers.'); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * This is a general purpose hook, allowing modules to respond to routes |
|
44 | + * of the form module.php?mod=FOO&mod_action=BAR |
|
45 | + * |
|
46 | + * @param string $mod_action |
|
47 | + */ |
|
48 | + public function modAction($mod_action) { |
|
49 | + switch ($mod_action) { |
|
50 | + case 'admin_config': |
|
51 | + $this->config(); |
|
52 | + break; |
|
53 | + case 'admin_delete': |
|
54 | + if (Auth::isAdmin()) { |
|
55 | + $this->delete(); |
|
56 | + } |
|
57 | + header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
58 | + break; |
|
59 | + case 'admin_edit': |
|
60 | + $this->edit(); |
|
61 | + break; |
|
62 | + case 'admin_edit_save': |
|
63 | + if (Auth::isAdmin()) { |
|
64 | + $this->editSave(); |
|
65 | + } |
|
66 | + header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
67 | + break; |
|
68 | + case 'admin_movedown': |
|
69 | + if (Auth::isAdmin()) { |
|
70 | + $this->movedown(); |
|
71 | + } |
|
72 | + header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
73 | + break; |
|
74 | + case 'admin_moveup': |
|
75 | + if (Auth::isAdmin()) { |
|
76 | + $this->moveup(); |
|
77 | + } |
|
78 | + header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
79 | + break; |
|
80 | + case 'show': |
|
81 | + $this->show(); |
|
82 | + break; |
|
83 | + default: |
|
84 | + http_response_code(404); |
|
85 | + } |
|
86 | + } |
|
87 | + |
|
88 | + /** {@inheritdoc} */ |
|
89 | + public function getConfigLink() { |
|
90 | + return 'module.php?mod=' . $this->getName() . '&mod_action=admin_config'; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Action from the configuration page |
|
95 | + */ |
|
96 | + private function editSave() { |
|
97 | + if (Filter::checkCsrf()) { |
|
98 | + $block_id = Filter::postInteger('block_id'); |
|
99 | + if ($block_id) { |
|
100 | + Database::prepare( |
|
101 | + "UPDATE `##block` SET gedcom_id = NULLIF(:tree_id, '0'), block_order = :block_order WHERE block_id = :block_id" |
|
102 | + )->execute(array( |
|
103 | + 'tree_id' => Filter::postInteger('gedcom_id'), |
|
104 | + 'block_order' => Filter::postInteger('block_order'), |
|
105 | + 'block_id' => $block_id, |
|
106 | + )); |
|
107 | + } else { |
|
108 | + Database::prepare( |
|
109 | + "INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(:tree_id, '0'), :module_name, :block_order)" |
|
110 | + )->execute(array( |
|
111 | + 'tree_id' => Filter::postInteger('gedcom_id'), |
|
112 | + 'module_name' => $this->getName(), |
|
113 | + 'block_order' => Filter::postInteger('block_order'), |
|
114 | + )); |
|
115 | + $block_id = Database::getInstance()->lastInsertId(); |
|
116 | + } |
|
117 | + $this->setBlockSetting($block_id, 'header', Filter::post('header')); |
|
118 | + $this->setBlockSetting($block_id, 'faqbody', Filter::post('faqbody')); |
|
119 | + |
|
120 | + $languages = Filter::postArray('lang'); |
|
121 | + $this->setBlockSetting($block_id, 'languages', implode(',', $languages)); |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Action from the configuration page |
|
127 | + */ |
|
128 | + private function edit() { |
|
129 | + global $WT_TREE; |
|
130 | + |
|
131 | + $controller = new PageController; |
|
132 | + $controller->restrictAccess(Auth::isAdmin()); |
|
133 | + |
|
134 | + $block_id = Filter::getInteger('block_id'); |
|
135 | + if ($block_id) { |
|
136 | + $controller->setPageTitle(/* I18N: FAQ = “Frequently Asked Question” */ I18N::translate('Edit the FAQ')); |
|
137 | + $header = $this->getBlockSetting($block_id, 'header'); |
|
138 | + $faqbody = $this->getBlockSetting($block_id, 'faqbody'); |
|
139 | + $block_order = Database::prepare( |
|
140 | + "SELECT block_order FROM `##block` WHERE block_id = :block_id" |
|
141 | + )->execute(array('block_id' => $block_id))->fetchOne(); |
|
142 | + $gedcom_id = Database::prepare( |
|
143 | + "SELECT gedcom_id FROM `##block` WHERE block_id = :block_id" |
|
144 | + )->execute(array('block_id' => $block_id))->fetchOne(); |
|
145 | + } else { |
|
146 | + $controller->setPageTitle(/* I18N: FAQ = “Frequently Asked Question” */ I18N::translate('Add an FAQ')); |
|
147 | + $header = ''; |
|
148 | + $faqbody = ''; |
|
149 | + $block_order = Database::prepare( |
|
150 | + "SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name = :module_name" |
|
151 | + )->execute(array('module_name' => $this->getName()))->fetchOne(); |
|
152 | + $gedcom_id = $WT_TREE->getTreeId(); |
|
153 | + } |
|
154 | + $controller->pageHeader(); |
|
155 | + if (Module::getModuleByName('ckeditor')) { |
|
156 | + CkeditorModule::enableEditor($controller); |
|
157 | + } |
|
158 | + |
|
159 | + ?> |
|
160 | 160 | <ol class="breadcrumb small"> |
161 | 161 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
162 | 162 | <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li> |
@@ -236,204 +236,204 @@ discard block |
||
236 | 236 | |
237 | 237 | </form> |
238 | 238 | <?php |
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Delete an FAQ. |
|
243 | - */ |
|
244 | - private function delete() { |
|
245 | - $block_id = Filter::getInteger('block_id'); |
|
246 | - |
|
247 | - Database::prepare( |
|
248 | - "DELETE FROM `##block_setting` WHERE block_id = :block_id" |
|
249 | - )->execute(array('block_id' => $block_id)); |
|
250 | - |
|
251 | - Database::prepare( |
|
252 | - "DELETE FROM `##block` WHERE block_id = :block_id" |
|
253 | - )->execute(array('block_id' => $block_id)); |
|
254 | - } |
|
255 | - |
|
256 | - /** |
|
257 | - * Move an FAQ up the list. |
|
258 | - */ |
|
259 | - private function moveup() { |
|
260 | - $block_id = Filter::getInteger('block_id'); |
|
261 | - |
|
262 | - $block_order = Database::prepare( |
|
263 | - "SELECT block_order FROM `##block` WHERE block_id = :block_id" |
|
264 | - )->execute(array('block_id' => $block_id))->fetchOne(); |
|
265 | - |
|
266 | - $swap_block = Database::prepare( |
|
267 | - "SELECT block_order, block_id" . |
|
268 | - " FROM `##block`" . |
|
269 | - " WHERE block_order = (" . |
|
270 | - " SELECT MAX(block_order) FROM `##block` WHERE block_order < :block_order AND module_name = :module_name_1" . |
|
271 | - " ) AND module_name = :module_name_2" . |
|
272 | - " LIMIT 1" |
|
273 | - )->execute(array( |
|
274 | - 'block_order' => $block_order, |
|
275 | - 'module_name_1' => $this->getName(), |
|
276 | - 'module_name_2' => $this->getName(), |
|
277 | - ))->fetchOneRow(); |
|
278 | - if ($swap_block) { |
|
279 | - Database::prepare( |
|
280 | - "UPDATE `##block` SET block_order = :block_order WHERE block_id = :block_id" |
|
281 | - )->execute(array( |
|
282 | - 'block_order' => $swap_block->block_order, |
|
283 | - 'block_id' => $block_id, |
|
284 | - )); |
|
285 | - Database::prepare( |
|
286 | - "UPDATE `##block` SET block_order = :block_order WHERE block_id = :block_id" |
|
287 | - )->execute(array( |
|
288 | - 'block_order' => $block_order, |
|
289 | - 'block_id' => $swap_block->block_id, |
|
290 | - )); |
|
291 | - } |
|
292 | - } |
|
293 | - |
|
294 | - /** |
|
295 | - * Move an FAQ down the list. |
|
296 | - */ |
|
297 | - private function movedown() { |
|
298 | - $block_id = Filter::get('block_id'); |
|
299 | - |
|
300 | - $block_order = Database::prepare( |
|
301 | - "SELECT block_order FROM `##block` WHERE block_id = :block_id" |
|
302 | - )->execute(array( |
|
303 | - 'block_id' => $block_id, |
|
304 | - ))->fetchOne(); |
|
305 | - |
|
306 | - $swap_block = Database::prepare( |
|
307 | - "SELECT block_order, block_id" . |
|
308 | - " FROM `##block`" . |
|
309 | - " WHERE block_order=(" . |
|
310 | - " SELECT MIN(block_order) FROM `##block` WHERE block_order > :block_order AND module_name = :module_name_1" . |
|
311 | - " ) AND module_name = :module_name_2" . |
|
312 | - " LIMIT 1" |
|
313 | - )->execute(array( |
|
314 | - 'block_order' => $block_order, |
|
315 | - 'module_name_1' => $this->getName(), |
|
316 | - 'module_name_2' => $this->getName(), |
|
317 | - ))->fetchOneRow(); |
|
318 | - if ($swap_block) { |
|
319 | - Database::prepare( |
|
320 | - "UPDATE `##block` SET block_order = :block_order WHERE block_id = :block_id" |
|
321 | - )->execute(array( |
|
322 | - 'block_order' => $swap_block->block_order, |
|
323 | - 'block_id' => $block_id, |
|
324 | - )); |
|
325 | - Database::prepare( |
|
326 | - "UPDATE `##block` SET block_order = :block_order WHERE block_id = :block_id" |
|
327 | - )->execute(array( |
|
328 | - 'block_order' => $block_order, |
|
329 | - 'block_id' => $swap_block->block_id, |
|
330 | - )); |
|
331 | - } |
|
332 | - } |
|
333 | - |
|
334 | - /** |
|
335 | - * Show a list of FAQs |
|
336 | - */ |
|
337 | - private function show() { |
|
338 | - global $controller, $WT_TREE; |
|
339 | - |
|
340 | - $controller = new PageController; |
|
341 | - $controller |
|
342 | - ->setPageTitle(I18N::translate('Frequently asked questions')) |
|
343 | - ->pageHeader(); |
|
344 | - |
|
345 | - $faqs = Database::prepare( |
|
346 | - "SELECT block_id, bs1.setting_value AS header, bs2.setting_value AS body, bs3.setting_value AS languages" . |
|
347 | - " FROM `##block` b" . |
|
348 | - " JOIN `##block_setting` bs1 USING (block_id)" . |
|
349 | - " JOIN `##block_setting` bs2 USING (block_id)" . |
|
350 | - " JOIN `##block_setting` bs3 USING (block_id)" . |
|
351 | - " WHERE module_name = :module_name" . |
|
352 | - " AND bs1.setting_name = 'header'" . |
|
353 | - " AND bs2.setting_name = 'faqbody'" . |
|
354 | - " AND bs3.setting_name = 'languages'" . |
|
355 | - " AND IFNULL(gedcom_id, :tree_id_1) = :tree_id_2" . |
|
356 | - " ORDER BY block_order" |
|
357 | - )->execute(array( |
|
358 | - 'module_name' => $this->getName(), |
|
359 | - 'tree_id_1' => $WT_TREE->getTreeId(), |
|
360 | - 'tree_id_2' => $WT_TREE->getTreeId(), |
|
361 | - ))->fetchAll(); |
|
362 | - |
|
363 | - echo '<h2 class="center">', I18N::translate('Frequently asked questions'); |
|
364 | - if (Auth::isManager($WT_TREE)) { |
|
365 | - echo ' — <a href="module.php?mod=', $this->getName(), '&mod_action=admin_config">', I18N::translate('edit'), '</a>'; |
|
366 | - } |
|
367 | - echo '</h2>'; |
|
368 | - $row_count = 0; |
|
369 | - echo '<table class="faq">'; |
|
370 | - // List of titles |
|
371 | - foreach ($faqs as $id => $faq) { |
|
372 | - if (!$faq->languages || in_array(WT_LOCALE, explode(',', $faq->languages))) { |
|
373 | - $row_color = ($row_count % 2) ? 'odd' : 'even'; |
|
374 | - // NOTE: Print the header of the current item |
|
375 | - echo '<tr class="', $row_color, '"><td style="padding: 5px;">'; |
|
376 | - echo '<a href="#faq', $id, '">', $faq->header, '</a>'; |
|
377 | - echo '</td></tr>'; |
|
378 | - $row_count++; |
|
379 | - } |
|
380 | - } |
|
381 | - echo '</table><hr>'; |
|
382 | - // Detailed entries |
|
383 | - foreach ($faqs as $id => $faq) { |
|
384 | - if (!$faq->languages || in_array(WT_LOCALE, explode(',', $faq->languages))) { |
|
385 | - echo '<div class="faq_title" id="faq', $id, '">', $faq->header; |
|
386 | - echo '<div class="faq_top faq_italic">'; |
|
387 | - echo '<a href="#content">', I18N::translate('back to top'), '</a>'; |
|
388 | - echo '</div>'; |
|
389 | - echo '</div>'; |
|
390 | - echo '<div class="faq_body">', substr($faq->body, 0, 1) == '<' ? $faq->body : nl2br($faq->body, false), '</div>'; |
|
391 | - echo '<hr>'; |
|
392 | - } |
|
393 | - } |
|
394 | - } |
|
395 | - |
|
396 | - /** |
|
397 | - * Provide a form to manage the FAQs. |
|
398 | - */ |
|
399 | - private function config() { |
|
400 | - global $WT_TREE; |
|
401 | - |
|
402 | - $controller = new PageController; |
|
403 | - $controller |
|
404 | - ->restrictAccess(Auth::isAdmin()) |
|
405 | - ->setPageTitle(I18N::translate('Frequently asked questions')) |
|
406 | - ->pageHeader(); |
|
407 | - |
|
408 | - $faqs = Database::prepare( |
|
409 | - "SELECT block_id, block_order, gedcom_id, bs1.setting_value AS header, bs2.setting_value AS faqbody" . |
|
410 | - " FROM `##block` b" . |
|
411 | - " JOIN `##block_setting` bs1 USING (block_id)" . |
|
412 | - " JOIN `##block_setting` bs2 USING (block_id)" . |
|
413 | - " WHERE module_name = :module_name" . |
|
414 | - " AND bs1.setting_name = 'header'" . |
|
415 | - " AND bs2.setting_name = 'faqbody'" . |
|
416 | - " AND IFNULL(gedcom_id, :tree_id_1) = :tree_id_2" . |
|
417 | - " ORDER BY block_order" |
|
418 | - )->execute(array( |
|
419 | - 'module_name' => $this->getName(), |
|
420 | - 'tree_id_1' => $WT_TREE->getTreeId(), |
|
421 | - 'tree_id_2' => $WT_TREE->getTreeId(), |
|
422 | - ))->fetchAll(); |
|
423 | - |
|
424 | - $min_block_order = Database::prepare( |
|
425 | - "SELECT MIN(block_order) FROM `##block` WHERE module_name = 'faq' AND (gedcom_id = :tree_id OR gedcom_id IS NULL)" |
|
426 | - )->execute(array( |
|
427 | - 'tree_id' => $WT_TREE->getTreeId(), |
|
428 | - ))->fetchOne(); |
|
429 | - |
|
430 | - $max_block_order = Database::prepare( |
|
431 | - "SELECT MAX(block_order) FROM `##block` WHERE module_name = 'faq' AND (gedcom_id = :tree_id OR gedcom_id IS NULL)" |
|
432 | - )->execute(array( |
|
433 | - 'tree_id' => $WT_TREE->getTreeId(), |
|
434 | - ))->fetchOne(); |
|
435 | - |
|
436 | - ?> |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Delete an FAQ. |
|
243 | + */ |
|
244 | + private function delete() { |
|
245 | + $block_id = Filter::getInteger('block_id'); |
|
246 | + |
|
247 | + Database::prepare( |
|
248 | + "DELETE FROM `##block_setting` WHERE block_id = :block_id" |
|
249 | + )->execute(array('block_id' => $block_id)); |
|
250 | + |
|
251 | + Database::prepare( |
|
252 | + "DELETE FROM `##block` WHERE block_id = :block_id" |
|
253 | + )->execute(array('block_id' => $block_id)); |
|
254 | + } |
|
255 | + |
|
256 | + /** |
|
257 | + * Move an FAQ up the list. |
|
258 | + */ |
|
259 | + private function moveup() { |
|
260 | + $block_id = Filter::getInteger('block_id'); |
|
261 | + |
|
262 | + $block_order = Database::prepare( |
|
263 | + "SELECT block_order FROM `##block` WHERE block_id = :block_id" |
|
264 | + )->execute(array('block_id' => $block_id))->fetchOne(); |
|
265 | + |
|
266 | + $swap_block = Database::prepare( |
|
267 | + "SELECT block_order, block_id" . |
|
268 | + " FROM `##block`" . |
|
269 | + " WHERE block_order = (" . |
|
270 | + " SELECT MAX(block_order) FROM `##block` WHERE block_order < :block_order AND module_name = :module_name_1" . |
|
271 | + " ) AND module_name = :module_name_2" . |
|
272 | + " LIMIT 1" |
|
273 | + )->execute(array( |
|
274 | + 'block_order' => $block_order, |
|
275 | + 'module_name_1' => $this->getName(), |
|
276 | + 'module_name_2' => $this->getName(), |
|
277 | + ))->fetchOneRow(); |
|
278 | + if ($swap_block) { |
|
279 | + Database::prepare( |
|
280 | + "UPDATE `##block` SET block_order = :block_order WHERE block_id = :block_id" |
|
281 | + )->execute(array( |
|
282 | + 'block_order' => $swap_block->block_order, |
|
283 | + 'block_id' => $block_id, |
|
284 | + )); |
|
285 | + Database::prepare( |
|
286 | + "UPDATE `##block` SET block_order = :block_order WHERE block_id = :block_id" |
|
287 | + )->execute(array( |
|
288 | + 'block_order' => $block_order, |
|
289 | + 'block_id' => $swap_block->block_id, |
|
290 | + )); |
|
291 | + } |
|
292 | + } |
|
293 | + |
|
294 | + /** |
|
295 | + * Move an FAQ down the list. |
|
296 | + */ |
|
297 | + private function movedown() { |
|
298 | + $block_id = Filter::get('block_id'); |
|
299 | + |
|
300 | + $block_order = Database::prepare( |
|
301 | + "SELECT block_order FROM `##block` WHERE block_id = :block_id" |
|
302 | + )->execute(array( |
|
303 | + 'block_id' => $block_id, |
|
304 | + ))->fetchOne(); |
|
305 | + |
|
306 | + $swap_block = Database::prepare( |
|
307 | + "SELECT block_order, block_id" . |
|
308 | + " FROM `##block`" . |
|
309 | + " WHERE block_order=(" . |
|
310 | + " SELECT MIN(block_order) FROM `##block` WHERE block_order > :block_order AND module_name = :module_name_1" . |
|
311 | + " ) AND module_name = :module_name_2" . |
|
312 | + " LIMIT 1" |
|
313 | + )->execute(array( |
|
314 | + 'block_order' => $block_order, |
|
315 | + 'module_name_1' => $this->getName(), |
|
316 | + 'module_name_2' => $this->getName(), |
|
317 | + ))->fetchOneRow(); |
|
318 | + if ($swap_block) { |
|
319 | + Database::prepare( |
|
320 | + "UPDATE `##block` SET block_order = :block_order WHERE block_id = :block_id" |
|
321 | + )->execute(array( |
|
322 | + 'block_order' => $swap_block->block_order, |
|
323 | + 'block_id' => $block_id, |
|
324 | + )); |
|
325 | + Database::prepare( |
|
326 | + "UPDATE `##block` SET block_order = :block_order WHERE block_id = :block_id" |
|
327 | + )->execute(array( |
|
328 | + 'block_order' => $block_order, |
|
329 | + 'block_id' => $swap_block->block_id, |
|
330 | + )); |
|
331 | + } |
|
332 | + } |
|
333 | + |
|
334 | + /** |
|
335 | + * Show a list of FAQs |
|
336 | + */ |
|
337 | + private function show() { |
|
338 | + global $controller, $WT_TREE; |
|
339 | + |
|
340 | + $controller = new PageController; |
|
341 | + $controller |
|
342 | + ->setPageTitle(I18N::translate('Frequently asked questions')) |
|
343 | + ->pageHeader(); |
|
344 | + |
|
345 | + $faqs = Database::prepare( |
|
346 | + "SELECT block_id, bs1.setting_value AS header, bs2.setting_value AS body, bs3.setting_value AS languages" . |
|
347 | + " FROM `##block` b" . |
|
348 | + " JOIN `##block_setting` bs1 USING (block_id)" . |
|
349 | + " JOIN `##block_setting` bs2 USING (block_id)" . |
|
350 | + " JOIN `##block_setting` bs3 USING (block_id)" . |
|
351 | + " WHERE module_name = :module_name" . |
|
352 | + " AND bs1.setting_name = 'header'" . |
|
353 | + " AND bs2.setting_name = 'faqbody'" . |
|
354 | + " AND bs3.setting_name = 'languages'" . |
|
355 | + " AND IFNULL(gedcom_id, :tree_id_1) = :tree_id_2" . |
|
356 | + " ORDER BY block_order" |
|
357 | + )->execute(array( |
|
358 | + 'module_name' => $this->getName(), |
|
359 | + 'tree_id_1' => $WT_TREE->getTreeId(), |
|
360 | + 'tree_id_2' => $WT_TREE->getTreeId(), |
|
361 | + ))->fetchAll(); |
|
362 | + |
|
363 | + echo '<h2 class="center">', I18N::translate('Frequently asked questions'); |
|
364 | + if (Auth::isManager($WT_TREE)) { |
|
365 | + echo ' — <a href="module.php?mod=', $this->getName(), '&mod_action=admin_config">', I18N::translate('edit'), '</a>'; |
|
366 | + } |
|
367 | + echo '</h2>'; |
|
368 | + $row_count = 0; |
|
369 | + echo '<table class="faq">'; |
|
370 | + // List of titles |
|
371 | + foreach ($faqs as $id => $faq) { |
|
372 | + if (!$faq->languages || in_array(WT_LOCALE, explode(',', $faq->languages))) { |
|
373 | + $row_color = ($row_count % 2) ? 'odd' : 'even'; |
|
374 | + // NOTE: Print the header of the current item |
|
375 | + echo '<tr class="', $row_color, '"><td style="padding: 5px;">'; |
|
376 | + echo '<a href="#faq', $id, '">', $faq->header, '</a>'; |
|
377 | + echo '</td></tr>'; |
|
378 | + $row_count++; |
|
379 | + } |
|
380 | + } |
|
381 | + echo '</table><hr>'; |
|
382 | + // Detailed entries |
|
383 | + foreach ($faqs as $id => $faq) { |
|
384 | + if (!$faq->languages || in_array(WT_LOCALE, explode(',', $faq->languages))) { |
|
385 | + echo '<div class="faq_title" id="faq', $id, '">', $faq->header; |
|
386 | + echo '<div class="faq_top faq_italic">'; |
|
387 | + echo '<a href="#content">', I18N::translate('back to top'), '</a>'; |
|
388 | + echo '</div>'; |
|
389 | + echo '</div>'; |
|
390 | + echo '<div class="faq_body">', substr($faq->body, 0, 1) == '<' ? $faq->body : nl2br($faq->body, false), '</div>'; |
|
391 | + echo '<hr>'; |
|
392 | + } |
|
393 | + } |
|
394 | + } |
|
395 | + |
|
396 | + /** |
|
397 | + * Provide a form to manage the FAQs. |
|
398 | + */ |
|
399 | + private function config() { |
|
400 | + global $WT_TREE; |
|
401 | + |
|
402 | + $controller = new PageController; |
|
403 | + $controller |
|
404 | + ->restrictAccess(Auth::isAdmin()) |
|
405 | + ->setPageTitle(I18N::translate('Frequently asked questions')) |
|
406 | + ->pageHeader(); |
|
407 | + |
|
408 | + $faqs = Database::prepare( |
|
409 | + "SELECT block_id, block_order, gedcom_id, bs1.setting_value AS header, bs2.setting_value AS faqbody" . |
|
410 | + " FROM `##block` b" . |
|
411 | + " JOIN `##block_setting` bs1 USING (block_id)" . |
|
412 | + " JOIN `##block_setting` bs2 USING (block_id)" . |
|
413 | + " WHERE module_name = :module_name" . |
|
414 | + " AND bs1.setting_name = 'header'" . |
|
415 | + " AND bs2.setting_name = 'faqbody'" . |
|
416 | + " AND IFNULL(gedcom_id, :tree_id_1) = :tree_id_2" . |
|
417 | + " ORDER BY block_order" |
|
418 | + )->execute(array( |
|
419 | + 'module_name' => $this->getName(), |
|
420 | + 'tree_id_1' => $WT_TREE->getTreeId(), |
|
421 | + 'tree_id_2' => $WT_TREE->getTreeId(), |
|
422 | + ))->fetchAll(); |
|
423 | + |
|
424 | + $min_block_order = Database::prepare( |
|
425 | + "SELECT MIN(block_order) FROM `##block` WHERE module_name = 'faq' AND (gedcom_id = :tree_id OR gedcom_id IS NULL)" |
|
426 | + )->execute(array( |
|
427 | + 'tree_id' => $WT_TREE->getTreeId(), |
|
428 | + ))->fetchOne(); |
|
429 | + |
|
430 | + $max_block_order = Database::prepare( |
|
431 | + "SELECT MAX(block_order) FROM `##block` WHERE module_name = 'faq' AND (gedcom_id = :tree_id OR gedcom_id IS NULL)" |
|
432 | + )->execute(array( |
|
433 | + 'tree_id' => $WT_TREE->getTreeId(), |
|
434 | + ))->fetchOne(); |
|
435 | + |
|
436 | + ?> |
|
437 | 437 | <ol class="breadcrumb small"> |
438 | 438 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
439 | 439 | <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li> |
@@ -465,79 +465,79 @@ discard block |
||
465 | 465 | </p> |
466 | 466 | |
467 | 467 | <?php |
468 | - echo '<table class="table table-bordered">'; |
|
469 | - foreach ($faqs as $faq) { |
|
470 | - // NOTE: Print the position of the current item |
|
471 | - echo '<tr class="faq_edit_pos"><td>'; |
|
472 | - echo I18N::translate('#%s', $faq->block_order + 1), ' '; |
|
473 | - if ($faq->gedcom_id === null) { |
|
474 | - echo I18N::translate('All'); |
|
475 | - } else { |
|
476 | - echo $WT_TREE->getTitleHtml(); |
|
477 | - } |
|
478 | - echo '</td>'; |
|
479 | - // NOTE: Print the edit options of the current item |
|
480 | - echo '<td>'; |
|
481 | - if ($faq->block_order == $min_block_order) { |
|
482 | - echo ' '; |
|
483 | - } else { |
|
484 | - echo '<a href="module.php?mod=', $this->getName(), '&mod_action=admin_moveup&block_id=', $faq->block_id, '"><i class="fa fa-arrow-up"></i></i> ', I18N::translate('Move up'), '</a>'; |
|
485 | - } |
|
486 | - echo '</td><td>'; |
|
487 | - if ($faq->block_order == $max_block_order) { |
|
488 | - echo ' '; |
|
489 | - } else { |
|
490 | - echo '<a href="module.php?mod=', $this->getName(), '&mod_action=admin_movedown&block_id=', $faq->block_id, '"><i class="fa fa-arrow-down"></i></i> ', I18N::translate('Move down'), '</a>'; |
|
491 | - } |
|
492 | - echo '</td><td>'; |
|
493 | - echo '<a href="module.php?mod=', $this->getName(), '&mod_action=admin_edit&block_id=', $faq->block_id, '"><i class="fa fa-pencil"></i> ', I18N::translate('Edit'), '</a>'; |
|
494 | - echo '</td><td>'; |
|
495 | - echo '<a href="module.php?mod=', $this->getName(), '&mod_action=admin_delete&block_id=', $faq->block_id, '" onclick="return confirm(\'', I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($faq->header)), '\');"><i class="fa fa-trash"></i> ', I18N::translate('Delete'), '</a>'; |
|
496 | - echo '</td></tr>'; |
|
497 | - // NOTE: Print the title text of the current item |
|
498 | - echo '<tr><td colspan="5">'; |
|
499 | - echo '<div class="faq_edit_item">'; |
|
500 | - echo '<div class="faq_edit_title">', $faq->header, '</div>'; |
|
501 | - // NOTE: Print the body text of the current item |
|
502 | - echo '<div class="faq_edit_content">', substr($faq->faqbody, 0, 1) == '<' ? $faq->faqbody : nl2br($faq->faqbody, false), '</div></div></td></tr>'; |
|
503 | - } |
|
504 | - echo '</table>'; |
|
505 | - } |
|
506 | - |
|
507 | - /** |
|
508 | - * The user can re-order menus. Until they do, they are shown in this order. |
|
509 | - * |
|
510 | - * @return int |
|
511 | - */ |
|
512 | - public function defaultMenuOrder() { |
|
513 | - return 40; |
|
514 | - } |
|
515 | - |
|
516 | - /** |
|
517 | - * A menu, to be added to the main application menu. |
|
518 | - * |
|
519 | - * @return Menu|null |
|
520 | - */ |
|
521 | - public function getMenu() { |
|
522 | - global $WT_TREE; |
|
523 | - |
|
524 | - $faqs = Database::prepare( |
|
525 | - "SELECT block_id FROM `##block`" . |
|
526 | - " JOIN `##block_setting` USING (block_id)" . |
|
527 | - " WHERE module_name = :module_name AND IFNULL(gedcom_id, :tree_id_1) = :tree_id_2" . |
|
528 | - " AND setting_name='languages' AND (setting_value LIKE CONCAT('%', :locale, '%') OR setting_value='')" |
|
529 | - )->execute(array( |
|
530 | - 'module_name' => $this->getName(), |
|
531 | - 'tree_id_1' => $WT_TREE->getTreeId(), |
|
532 | - 'tree_id_2' => $WT_TREE->getTreeId(), |
|
533 | - 'locale' => WT_LOCALE, |
|
534 | - ))->fetchAll(); |
|
535 | - |
|
536 | - if ($faqs) { |
|
537 | - return new Menu($this->getTitle(), 'module.php?mod=faq&mod_action=show', 'menu-help'); |
|
538 | - } else { |
|
539 | - return null; |
|
540 | - } |
|
541 | - |
|
542 | - } |
|
468 | + echo '<table class="table table-bordered">'; |
|
469 | + foreach ($faqs as $faq) { |
|
470 | + // NOTE: Print the position of the current item |
|
471 | + echo '<tr class="faq_edit_pos"><td>'; |
|
472 | + echo I18N::translate('#%s', $faq->block_order + 1), ' '; |
|
473 | + if ($faq->gedcom_id === null) { |
|
474 | + echo I18N::translate('All'); |
|
475 | + } else { |
|
476 | + echo $WT_TREE->getTitleHtml(); |
|
477 | + } |
|
478 | + echo '</td>'; |
|
479 | + // NOTE: Print the edit options of the current item |
|
480 | + echo '<td>'; |
|
481 | + if ($faq->block_order == $min_block_order) { |
|
482 | + echo ' '; |
|
483 | + } else { |
|
484 | + echo '<a href="module.php?mod=', $this->getName(), '&mod_action=admin_moveup&block_id=', $faq->block_id, '"><i class="fa fa-arrow-up"></i></i> ', I18N::translate('Move up'), '</a>'; |
|
485 | + } |
|
486 | + echo '</td><td>'; |
|
487 | + if ($faq->block_order == $max_block_order) { |
|
488 | + echo ' '; |
|
489 | + } else { |
|
490 | + echo '<a href="module.php?mod=', $this->getName(), '&mod_action=admin_movedown&block_id=', $faq->block_id, '"><i class="fa fa-arrow-down"></i></i> ', I18N::translate('Move down'), '</a>'; |
|
491 | + } |
|
492 | + echo '</td><td>'; |
|
493 | + echo '<a href="module.php?mod=', $this->getName(), '&mod_action=admin_edit&block_id=', $faq->block_id, '"><i class="fa fa-pencil"></i> ', I18N::translate('Edit'), '</a>'; |
|
494 | + echo '</td><td>'; |
|
495 | + echo '<a href="module.php?mod=', $this->getName(), '&mod_action=admin_delete&block_id=', $faq->block_id, '" onclick="return confirm(\'', I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($faq->header)), '\');"><i class="fa fa-trash"></i> ', I18N::translate('Delete'), '</a>'; |
|
496 | + echo '</td></tr>'; |
|
497 | + // NOTE: Print the title text of the current item |
|
498 | + echo '<tr><td colspan="5">'; |
|
499 | + echo '<div class="faq_edit_item">'; |
|
500 | + echo '<div class="faq_edit_title">', $faq->header, '</div>'; |
|
501 | + // NOTE: Print the body text of the current item |
|
502 | + echo '<div class="faq_edit_content">', substr($faq->faqbody, 0, 1) == '<' ? $faq->faqbody : nl2br($faq->faqbody, false), '</div></div></td></tr>'; |
|
503 | + } |
|
504 | + echo '</table>'; |
|
505 | + } |
|
506 | + |
|
507 | + /** |
|
508 | + * The user can re-order menus. Until they do, they are shown in this order. |
|
509 | + * |
|
510 | + * @return int |
|
511 | + */ |
|
512 | + public function defaultMenuOrder() { |
|
513 | + return 40; |
|
514 | + } |
|
515 | + |
|
516 | + /** |
|
517 | + * A menu, to be added to the main application menu. |
|
518 | + * |
|
519 | + * @return Menu|null |
|
520 | + */ |
|
521 | + public function getMenu() { |
|
522 | + global $WT_TREE; |
|
523 | + |
|
524 | + $faqs = Database::prepare( |
|
525 | + "SELECT block_id FROM `##block`" . |
|
526 | + " JOIN `##block_setting` USING (block_id)" . |
|
527 | + " WHERE module_name = :module_name AND IFNULL(gedcom_id, :tree_id_1) = :tree_id_2" . |
|
528 | + " AND setting_name='languages' AND (setting_value LIKE CONCAT('%', :locale, '%') OR setting_value='')" |
|
529 | + )->execute(array( |
|
530 | + 'module_name' => $this->getName(), |
|
531 | + 'tree_id_1' => $WT_TREE->getTreeId(), |
|
532 | + 'tree_id_2' => $WT_TREE->getTreeId(), |
|
533 | + 'locale' => WT_LOCALE, |
|
534 | + ))->fetchAll(); |
|
535 | + |
|
536 | + if ($faqs) { |
|
537 | + return new Menu($this->getTitle(), 'module.php?mod=faq&mod_action=show', 'menu-help'); |
|
538 | + } else { |
|
539 | + return null; |
|
540 | + } |
|
541 | + |
|
542 | + } |
|
543 | 543 | } |
@@ -47,41 +47,41 @@ |
||
47 | 47 | */ |
48 | 48 | public function modAction($mod_action) { |
49 | 49 | switch ($mod_action) { |
50 | - case 'admin_config': |
|
51 | - $this->config(); |
|
52 | - break; |
|
53 | - case 'admin_delete': |
|
54 | - if (Auth::isAdmin()) { |
|
55 | - $this->delete(); |
|
56 | - } |
|
57 | - header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
58 | - break; |
|
59 | - case 'admin_edit': |
|
60 | - $this->edit(); |
|
61 | - break; |
|
62 | - case 'admin_edit_save': |
|
63 | - if (Auth::isAdmin()) { |
|
64 | - $this->editSave(); |
|
65 | - } |
|
66 | - header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
67 | - break; |
|
68 | - case 'admin_movedown': |
|
69 | - if (Auth::isAdmin()) { |
|
70 | - $this->movedown(); |
|
71 | - } |
|
72 | - header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
73 | - break; |
|
74 | - case 'admin_moveup': |
|
75 | - if (Auth::isAdmin()) { |
|
76 | - $this->moveup(); |
|
77 | - } |
|
78 | - header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
79 | - break; |
|
80 | - case 'show': |
|
81 | - $this->show(); |
|
82 | - break; |
|
83 | - default: |
|
84 | - http_response_code(404); |
|
50 | + case 'admin_config': |
|
51 | + $this->config(); |
|
52 | + break; |
|
53 | + case 'admin_delete': |
|
54 | + if (Auth::isAdmin()) { |
|
55 | + $this->delete(); |
|
56 | + } |
|
57 | + header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
58 | + break; |
|
59 | + case 'admin_edit': |
|
60 | + $this->edit(); |
|
61 | + break; |
|
62 | + case 'admin_edit_save': |
|
63 | + if (Auth::isAdmin()) { |
|
64 | + $this->editSave(); |
|
65 | + } |
|
66 | + header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
67 | + break; |
|
68 | + case 'admin_movedown': |
|
69 | + if (Auth::isAdmin()) { |
|
70 | + $this->movedown(); |
|
71 | + } |
|
72 | + header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
73 | + break; |
|
74 | + case 'admin_moveup': |
|
75 | + if (Auth::isAdmin()) { |
|
76 | + $this->moveup(); |
|
77 | + } |
|
78 | + header('Location: ' . WT_BASE_URL . 'module.php?mod=faq&mod_action=admin_config'); |
|
79 | + break; |
|
80 | + case 'show': |
|
81 | + $this->show(); |
|
82 | + break; |
|
83 | + default: |
|
84 | + http_response_code(404); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 |
@@ -30,12 +30,14 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class FrequentlyAskedQuestionsModule extends AbstractModule implements ModuleMenuInterface, ModuleConfigInterface { |
32 | 32 | /** {@inheritdoc} */ |
33 | - public function getTitle() { |
|
33 | + public function getTitle() |
|
34 | + { |
|
34 | 35 | return /* I18N: Name of a module. Abbreviation for “Frequently Asked Questions” */ I18N::translate('FAQ'); |
35 | 36 | } |
36 | 37 | |
37 | 38 | /** {@inheritdoc} */ |
38 | - public function getDescription() { |
|
39 | + public function getDescription() |
|
40 | + { |
|
39 | 41 | return /* I18N: Description of the “FAQ” module */ I18N::translate('A list of frequently asked questions and answers.'); |
40 | 42 | } |
41 | 43 | |
@@ -45,7 +47,8 @@ discard block |
||
45 | 47 | * |
46 | 48 | * @param string $mod_action |
47 | 49 | */ |
48 | - public function modAction($mod_action) { |
|
50 | + public function modAction($mod_action) |
|
51 | + { |
|
49 | 52 | switch ($mod_action) { |
50 | 53 | case 'admin_config': |
51 | 54 | $this->config(); |
@@ -86,14 +89,16 @@ discard block |
||
86 | 89 | } |
87 | 90 | |
88 | 91 | /** {@inheritdoc} */ |
89 | - public function getConfigLink() { |
|
92 | + public function getConfigLink() |
|
93 | + { |
|
90 | 94 | return 'module.php?mod=' . $this->getName() . '&mod_action=admin_config'; |
91 | 95 | } |
92 | 96 | |
93 | 97 | /** |
94 | 98 | * Action from the configuration page |
95 | 99 | */ |
96 | - private function editSave() { |
|
100 | + private function editSave() |
|
101 | + { |
|
97 | 102 | if (Filter::checkCsrf()) { |
98 | 103 | $block_id = Filter::postInteger('block_id'); |
99 | 104 | if ($block_id) { |
@@ -125,7 +130,8 @@ discard block |
||
125 | 130 | /** |
126 | 131 | * Action from the configuration page |
127 | 132 | */ |
128 | - private function edit() { |
|
133 | + private function edit() |
|
134 | + { |
|
129 | 135 | global $WT_TREE; |
130 | 136 | |
131 | 137 | $controller = new PageController; |
@@ -241,7 +247,8 @@ discard block |
||
241 | 247 | /** |
242 | 248 | * Delete an FAQ. |
243 | 249 | */ |
244 | - private function delete() { |
|
250 | + private function delete() |
|
251 | + { |
|
245 | 252 | $block_id = Filter::getInteger('block_id'); |
246 | 253 | |
247 | 254 | Database::prepare( |
@@ -256,7 +263,8 @@ discard block |
||
256 | 263 | /** |
257 | 264 | * Move an FAQ up the list. |
258 | 265 | */ |
259 | - private function moveup() { |
|
266 | + private function moveup() |
|
267 | + { |
|
260 | 268 | $block_id = Filter::getInteger('block_id'); |
261 | 269 | |
262 | 270 | $block_order = Database::prepare( |
@@ -294,7 +302,8 @@ discard block |
||
294 | 302 | /** |
295 | 303 | * Move an FAQ down the list. |
296 | 304 | */ |
297 | - private function movedown() { |
|
305 | + private function movedown() |
|
306 | + { |
|
298 | 307 | $block_id = Filter::get('block_id'); |
299 | 308 | |
300 | 309 | $block_order = Database::prepare( |
@@ -334,7 +343,8 @@ discard block |
||
334 | 343 | /** |
335 | 344 | * Show a list of FAQs |
336 | 345 | */ |
337 | - private function show() { |
|
346 | + private function show() |
|
347 | + { |
|
338 | 348 | global $controller, $WT_TREE; |
339 | 349 | |
340 | 350 | $controller = new PageController; |
@@ -396,7 +406,8 @@ discard block |
||
396 | 406 | /** |
397 | 407 | * Provide a form to manage the FAQs. |
398 | 408 | */ |
399 | - private function config() { |
|
409 | + private function config() |
|
410 | + { |
|
400 | 411 | global $WT_TREE; |
401 | 412 | |
402 | 413 | $controller = new PageController; |
@@ -509,7 +520,8 @@ discard block |
||
509 | 520 | * |
510 | 521 | * @return int |
511 | 522 | */ |
512 | - public function defaultMenuOrder() { |
|
523 | + public function defaultMenuOrder() |
|
524 | + { |
|
513 | 525 | return 40; |
514 | 526 | } |
515 | 527 | |
@@ -518,7 +530,8 @@ discard block |
||
518 | 530 | * |
519 | 531 | * @return Menu|null |
520 | 532 | */ |
521 | - public function getMenu() { |
|
533 | + public function getMenu() |
|
534 | + { |
|
522 | 535 | global $WT_TREE; |
523 | 536 | |
524 | 537 | $faqs = Database::prepare( |
@@ -22,10 +22,10 @@ |
||
22 | 22 | * Upgrade the database schema from version 2 to version 3. |
23 | 23 | */ |
24 | 24 | class Migration2 implements MigrationInterface { |
25 | - /** {@inheritDoc} */ |
|
26 | - public function upgrade() { |
|
27 | - // Convert flag icons from .gif to .png |
|
25 | + /** {@inheritDoc} */ |
|
26 | + public function upgrade() { |
|
27 | + // Convert flag icons from .gif to .png |
|
28 | 28 | |
29 | - Database::exec("UPDATE `##placelocation` SET pl_icon=REPLACE(pl_icon, '.gif', '.png')"); |
|
30 | - } |
|
29 | + Database::exec("UPDATE `##placelocation` SET pl_icon=REPLACE(pl_icon, '.gif', '.png')"); |
|
30 | + } |
|
31 | 31 | } |
@@ -21,9 +21,11 @@ |
||
21 | 21 | /** |
22 | 22 | * Upgrade the database schema from version 2 to version 3. |
23 | 23 | */ |
24 | -class Migration2 implements MigrationInterface { |
|
24 | +class Migration2 implements MigrationInterface |
|
25 | +{ |
|
25 | 26 | /** {@inheritDoc} */ |
26 | - public function upgrade() { |
|
27 | + public function upgrade() |
|
28 | + { |
|
27 | 29 | // Convert flag icons from .gif to .png |
28 | 30 | |
29 | 31 | Database::exec("UPDATE `##placelocation` SET pl_icon=REPLACE(pl_icon, '.gif', '.png')"); |
@@ -23,22 +23,22 @@ |
||
23 | 23 | * Upgrade the database schema from version 1 to version 2. |
24 | 24 | */ |
25 | 25 | class Migration1 implements MigrationInterface { |
26 | - /** {@inheritDoc} */ |
|
27 | - public function upgrade() { |
|
28 | - // Update the tables to support streetview |
|
29 | - try { |
|
30 | - Database::exec( |
|
31 | - "ALTER TABLE `##placelocation` ADD (" . |
|
32 | - " pl_media VARCHAR(60) NULL," . |
|
33 | - " sv_long FLOAT NOT NULL DEFAULT 0," . |
|
34 | - " sv_lati FLOAT NOT NULL DEFAULT 0," . |
|
35 | - " sv_bearing FLOAT NOT NULL DEFAULT 0," . |
|
36 | - " sv_elevation FLOAT NOT NULL DEFAULT 0," . |
|
37 | - " sv_zoom FLOAT NOT NULL DEFAULT 1" . |
|
38 | - ")" |
|
39 | - ); |
|
40 | - } catch (PDOException $ex) { |
|
41 | - // Already done this? |
|
42 | - } |
|
43 | - } |
|
26 | + /** {@inheritDoc} */ |
|
27 | + public function upgrade() { |
|
28 | + // Update the tables to support streetview |
|
29 | + try { |
|
30 | + Database::exec( |
|
31 | + "ALTER TABLE `##placelocation` ADD (" . |
|
32 | + " pl_media VARCHAR(60) NULL," . |
|
33 | + " sv_long FLOAT NOT NULL DEFAULT 0," . |
|
34 | + " sv_lati FLOAT NOT NULL DEFAULT 0," . |
|
35 | + " sv_bearing FLOAT NOT NULL DEFAULT 0," . |
|
36 | + " sv_elevation FLOAT NOT NULL DEFAULT 0," . |
|
37 | + " sv_zoom FLOAT NOT NULL DEFAULT 1" . |
|
38 | + ")" |
|
39 | + ); |
|
40 | + } catch (PDOException $ex) { |
|
41 | + // Already done this? |
|
42 | + } |
|
43 | + } |
|
44 | 44 | } |
@@ -22,9 +22,11 @@ |
||
22 | 22 | /** |
23 | 23 | * Upgrade the database schema from version 1 to version 2. |
24 | 24 | */ |
25 | -class Migration1 implements MigrationInterface { |
|
25 | +class Migration1 implements MigrationInterface |
|
26 | +{ |
|
26 | 27 | /** {@inheritDoc} */ |
27 | - public function upgrade() { |
|
28 | + public function upgrade() |
|
29 | + { |
|
28 | 30 | // Update the tables to support streetview |
29 | 31 | try { |
30 | 32 | Database::exec( |
@@ -22,26 +22,26 @@ |
||
22 | 22 | * Upgrade the database schema from version 5 to version 6. |
23 | 23 | */ |
24 | 24 | class Migration5 implements MigrationInterface { |
25 | - /** {@inheritDoc} */ |
|
26 | - public function upgrade() { |
|
27 | - // Default settings |
|
28 | - Database::prepare( |
|
29 | - "INSERT IGNORE INTO `##module_setting` (module_name, setting_name, setting_value) VALUES " . |
|
30 | - " ('googlemap', 'GM_MAP_TYPE', 'G_NORMAL_MAP')," . |
|
31 | - " ('googlemap', 'GM_MAX_ZOOM', '15')," . |
|
32 | - " ('googlemap', 'GM_MIN_ZOOM', '2')," . |
|
33 | - " ('googlemap', 'GM_PRECISION_0', '0')," . |
|
34 | - " ('googlemap', 'GM_PRECISION_1', '1')," . |
|
35 | - " ('googlemap', 'GM_PRECISION_2', '2')," . |
|
36 | - " ('googlemap', 'GM_PRECISION_3', '3')," . |
|
37 | - " ('googlemap', 'GM_PRECISION_4', '4')," . |
|
38 | - " ('googlemap', 'GM_PRECISION_5', '5')," . |
|
39 | - " ('googlemap', 'GM_XSIZE', '600')," . |
|
40 | - " ('googlemap', 'GM_YSIZE', '400')," . |
|
41 | - " ('googlemap', 'GM_PH_XSIZE', '500')," . |
|
42 | - " ('googlemap', 'GM_PH_YSIZE', '350')," . |
|
43 | - " ('googlemap', 'GM_PH_MARKER', 'G_FLAG')," . |
|
44 | - " ('googlemap', 'GM_DISP_SHORT_PLACE', '0')" |
|
45 | - )->execute(); |
|
46 | - } |
|
25 | + /** {@inheritDoc} */ |
|
26 | + public function upgrade() { |
|
27 | + // Default settings |
|
28 | + Database::prepare( |
|
29 | + "INSERT IGNORE INTO `##module_setting` (module_name, setting_name, setting_value) VALUES " . |
|
30 | + " ('googlemap', 'GM_MAP_TYPE', 'G_NORMAL_MAP')," . |
|
31 | + " ('googlemap', 'GM_MAX_ZOOM', '15')," . |
|
32 | + " ('googlemap', 'GM_MIN_ZOOM', '2')," . |
|
33 | + " ('googlemap', 'GM_PRECISION_0', '0')," . |
|
34 | + " ('googlemap', 'GM_PRECISION_1', '1')," . |
|
35 | + " ('googlemap', 'GM_PRECISION_2', '2')," . |
|
36 | + " ('googlemap', 'GM_PRECISION_3', '3')," . |
|
37 | + " ('googlemap', 'GM_PRECISION_4', '4')," . |
|
38 | + " ('googlemap', 'GM_PRECISION_5', '5')," . |
|
39 | + " ('googlemap', 'GM_XSIZE', '600')," . |
|
40 | + " ('googlemap', 'GM_YSIZE', '400')," . |
|
41 | + " ('googlemap', 'GM_PH_XSIZE', '500')," . |
|
42 | + " ('googlemap', 'GM_PH_YSIZE', '350')," . |
|
43 | + " ('googlemap', 'GM_PH_MARKER', 'G_FLAG')," . |
|
44 | + " ('googlemap', 'GM_DISP_SHORT_PLACE', '0')" |
|
45 | + )->execute(); |
|
46 | + } |
|
47 | 47 | } |
@@ -21,9 +21,11 @@ |
||
21 | 21 | /** |
22 | 22 | * Upgrade the database schema from version 5 to version 6. |
23 | 23 | */ |
24 | -class Migration5 implements MigrationInterface { |
|
24 | +class Migration5 implements MigrationInterface |
|
25 | +{ |
|
25 | 26 | /** {@inheritDoc} */ |
26 | - public function upgrade() { |
|
27 | + public function upgrade() |
|
28 | + { |
|
27 | 29 | // Default settings |
28 | 30 | Database::prepare( |
29 | 31 | "INSERT IGNORE INTO `##module_setting` (module_name, setting_name, setting_value) VALUES " . |
@@ -22,27 +22,27 @@ |
||
22 | 22 | * Upgrade the database schema from version 0 (empty database) to version 1. |
23 | 23 | */ |
24 | 24 | class Migration0 implements MigrationInterface { |
25 | - /** {@inheritDoc} */ |
|
26 | - public function upgrade() { |
|
27 | - // Create the tables, as per PhpGedView 4.2.1 |
|
25 | + /** {@inheritDoc} */ |
|
26 | + public function upgrade() { |
|
27 | + // Create the tables, as per PhpGedView 4.2.1 |
|
28 | 28 | |
29 | - Database::exec( |
|
30 | - "CREATE TABLE IF NOT EXISTS `##placelocation` (" . |
|
31 | - " pl_id INTEGER NOT NULL," . |
|
32 | - " pl_parent_id INTEGER NULL," . |
|
33 | - " pl_level INTEGER NULL," . |
|
34 | - " pl_place VARCHAR(255) NULL," . |
|
35 | - " pl_long VARCHAR(30) NULL," . |
|
36 | - " pl_lati VARCHAR(30) NULL," . |
|
37 | - " pl_zoom INTEGER NULL," . |
|
38 | - " pl_icon VARCHAR(255) NULL," . |
|
39 | - " PRIMARY KEY (pl_id)," . |
|
40 | - " KEY ix1 (pl_level)," . |
|
41 | - " KEY ix2 (pl_long)," . |
|
42 | - " KEY ix3 (pl_lati)," . |
|
43 | - " KEY ix4 (pl_place)," . |
|
44 | - " KEY ix5 (pl_parent_id)" . |
|
45 | - ") COLLATE utf8_unicode_ci ENGINE=InnoDB" |
|
46 | - ); |
|
47 | - } |
|
29 | + Database::exec( |
|
30 | + "CREATE TABLE IF NOT EXISTS `##placelocation` (" . |
|
31 | + " pl_id INTEGER NOT NULL," . |
|
32 | + " pl_parent_id INTEGER NULL," . |
|
33 | + " pl_level INTEGER NULL," . |
|
34 | + " pl_place VARCHAR(255) NULL," . |
|
35 | + " pl_long VARCHAR(30) NULL," . |
|
36 | + " pl_lati VARCHAR(30) NULL," . |
|
37 | + " pl_zoom INTEGER NULL," . |
|
38 | + " pl_icon VARCHAR(255) NULL," . |
|
39 | + " PRIMARY KEY (pl_id)," . |
|
40 | + " KEY ix1 (pl_level)," . |
|
41 | + " KEY ix2 (pl_long)," . |
|
42 | + " KEY ix3 (pl_lati)," . |
|
43 | + " KEY ix4 (pl_place)," . |
|
44 | + " KEY ix5 (pl_parent_id)" . |
|
45 | + ") COLLATE utf8_unicode_ci ENGINE=InnoDB" |
|
46 | + ); |
|
47 | + } |
|
48 | 48 | } |
@@ -21,9 +21,11 @@ |
||
21 | 21 | /** |
22 | 22 | * Upgrade the database schema from version 0 (empty database) to version 1. |
23 | 23 | */ |
24 | -class Migration0 implements MigrationInterface { |
|
24 | +class Migration0 implements MigrationInterface |
|
25 | +{ |
|
25 | 26 | /** {@inheritDoc} */ |
26 | - public function upgrade() { |
|
27 | + public function upgrade() |
|
28 | + { |
|
27 | 29 | // Create the tables, as per PhpGedView 4.2.1 |
28 | 30 | |
29 | 31 | Database::exec( |
@@ -22,15 +22,15 @@ |
||
22 | 22 | * Upgrade the database schema from version 3 to version 4. |
23 | 23 | */ |
24 | 24 | class Migration3 implements MigrationInterface { |
25 | - /** {@inheritDoc} */ |
|
26 | - public function upgrade() { |
|
27 | - // Combine the two ways of enabling the GM module |
|
28 | - Database::exec( |
|
29 | - "UPDATE `##module` m, `##module_setting` ms SET m.status=CASE WHEN (m.status=1 AND ms.setting_value=1) THEN 'enabled' ELSE 'disabled' END WHERE m.module_name=ms.module_name AND m.module_name='googlemap' AND ms.setting_name='GM_ENABLED'" |
|
30 | - ); |
|
25 | + /** {@inheritDoc} */ |
|
26 | + public function upgrade() { |
|
27 | + // Combine the two ways of enabling the GM module |
|
28 | + Database::exec( |
|
29 | + "UPDATE `##module` m, `##module_setting` ms SET m.status=CASE WHEN (m.status=1 AND ms.setting_value=1) THEN 'enabled' ELSE 'disabled' END WHERE m.module_name=ms.module_name AND m.module_name='googlemap' AND ms.setting_name='GM_ENABLED'" |
|
30 | + ); |
|
31 | 31 | |
32 | - Database::exec( |
|
33 | - "DELETE FROM `##module_setting` WHERE module_name='googlemap' AND setting_name='GM_ENABLED'" |
|
34 | - ); |
|
35 | - } |
|
32 | + Database::exec( |
|
33 | + "DELETE FROM `##module_setting` WHERE module_name='googlemap' AND setting_name='GM_ENABLED'" |
|
34 | + ); |
|
35 | + } |
|
36 | 36 | } |
@@ -21,9 +21,11 @@ |
||
21 | 21 | /** |
22 | 22 | * Upgrade the database schema from version 3 to version 4. |
23 | 23 | */ |
24 | -class Migration3 implements MigrationInterface { |
|
24 | +class Migration3 implements MigrationInterface |
|
25 | +{ |
|
25 | 26 | /** {@inheritDoc} */ |
26 | - public function upgrade() { |
|
27 | + public function upgrade() |
|
28 | + { |
|
27 | 29 | // Combine the two ways of enabling the GM module |
28 | 30 | Database::exec( |
29 | 31 | "UPDATE `##module` m, `##module_setting` ms SET m.status=CASE WHEN (m.status=1 AND ms.setting_value=1) THEN 'enabled' ELSE 'disabled' END WHERE m.module_name=ms.module_name AND m.module_name='googlemap' AND ms.setting_name='GM_ENABLED'" |
@@ -22,12 +22,12 @@ |
||
22 | 22 | * Upgrade the database schema from version 4 to version 5. |
23 | 23 | */ |
24 | 24 | class Migration4 implements MigrationInterface { |
25 | - /** {@inheritDoc} */ |
|
26 | - public function upgrade() { |
|
27 | - // Delete some old/unused configuration settings |
|
28 | - Database::exec( |
|
29 | - "DELETE FROM `##module_setting` WHERE module_name='googlemap' AND setting_name IN ( |
|
25 | + /** {@inheritDoc} */ |
|
26 | + public function upgrade() { |
|
27 | + // Delete some old/unused configuration settings |
|
28 | + Database::exec( |
|
29 | + "DELETE FROM `##module_setting` WHERE module_name='googlemap' AND setting_name IN ( |
|
30 | 30 | 'GM_API_KEY', 'GM_DEFAULT_TOP_VALUE', 'GM_DISP_COUNT', 'GM_MAX_NOF_LEVELS', 'GM_PH_CONTROLS', 'GM_PH_WHEEL', 'GM_PRE_POST_MODE_1', 'GM_PRE_POST_MODE_2', 'GM_PRE_POST_MODE_3', 'GM_PRE_POST_MODE_4', 'GM_PRE_POST_MODE_5', 'GM_PRE_POST_MODE_6', 'GM_PRE_POST_MODE_7', 'GM_PRE_POST_MODE_8', 'GM_PRE_POST_MODE_9')" |
31 | - ); |
|
32 | - } |
|
31 | + ); |
|
32 | + } |
|
33 | 33 | } |
@@ -21,9 +21,11 @@ |
||
21 | 21 | /** |
22 | 22 | * Upgrade the database schema from version 4 to version 5. |
23 | 23 | */ |
24 | -class Migration4 implements MigrationInterface { |
|
24 | +class Migration4 implements MigrationInterface |
|
25 | +{ |
|
25 | 26 | /** {@inheritDoc} */ |
26 | - public function upgrade() { |
|
27 | + public function upgrade() |
|
28 | + { |
|
27 | 29 | // Delete some old/unused configuration settings |
28 | 30 | Database::exec( |
29 | 31 | "DELETE FROM `##module_setting` WHERE module_name='googlemap' AND setting_name IN ( |