@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | * {@inhericDoc} |
24 | 24 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
25 | 25 | */ |
26 | - protected function renderContent() { |
|
26 | + protected function renderContent() { |
|
27 | 27 | |
28 | - /** @var Tree $tree */ |
|
29 | - $tree = $this->data->get('tree'); |
|
30 | - $root_url = $this->data->get('root_url'); |
|
31 | - $other_trees = $this->data->get('other_trees'); |
|
32 | - $table_id = $this->data->get('table_id'); |
|
33 | - ?> |
|
28 | + /** @var Tree $tree */ |
|
29 | + $tree = $this->data->get('tree'); |
|
30 | + $root_url = $this->data->get('root_url'); |
|
31 | + $other_trees = $this->data->get('other_trees'); |
|
32 | + $table_id = $this->data->get('table_id'); |
|
33 | + ?> |
|
34 | 34 | <ol class="breadcrumb small"> |
35 | 35 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
36 | 36 | <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li> |
@@ -63,23 +63,23 @@ discard block |
||
63 | 63 | <p> |
64 | 64 | <?php $places_hierarchy = $this->data->get('places_hierarchy'); |
65 | 65 | if($places_hierarchy && $places_hierarchy['type'] != 'none') { |
66 | - switch ($places_hierarchy['type']) { |
|
67 | - case 'header': |
|
68 | - echo I18N::translate('According to the GEDCOM header, the places within your file follows the structure: '); |
|
69 | - break; |
|
70 | - case 'data': |
|
71 | - echo I18N::translate('Your GEDCOM header does not contain any indication of place structure.'). |
|
72 | - '<br/>'. |
|
73 | - I18N::translate('Here is an example of your place data: '); |
|
74 | - break; |
|
75 | - default: |
|
76 | - break; |
|
77 | - } |
|
78 | - $str_hierarchy = array(); |
|
79 | - foreach($places_hierarchy['hierarchy'] as $key => $level) { |
|
80 | - $str_hierarchy[] = I18N::translate('(%d) %s', $key + 1, $level); |
|
81 | - } |
|
82 | - echo '<strong>' . implode(I18N::$list_separator, $str_hierarchy) . '</strong>'; |
|
66 | + switch ($places_hierarchy['type']) { |
|
67 | + case 'header': |
|
68 | + echo I18N::translate('According to the GEDCOM header, the places within your file follows the structure: '); |
|
69 | + break; |
|
70 | + case 'data': |
|
71 | + echo I18N::translate('Your GEDCOM header does not contain any indication of place structure.'). |
|
72 | + '<br/>'. |
|
73 | + I18N::translate('Here is an example of your place data: '); |
|
74 | + break; |
|
75 | + default: |
|
76 | + break; |
|
77 | + } |
|
78 | + $str_hierarchy = array(); |
|
79 | + foreach($places_hierarchy['hierarchy'] as $key => $level) { |
|
80 | + $str_hierarchy[] = I18N::translate('(%d) %s', $key + 1, $level); |
|
81 | + } |
|
82 | + echo '<strong>' . implode(I18N::$list_separator, $str_hierarchy) . '</strong>'; |
|
83 | 83 | } |
84 | 84 | ?> |
85 | 85 | </p> |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | </a> |
110 | 110 | |
111 | 111 | <?php |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | 114 | } |
115 | 115 | |
116 | 116 | \ No newline at end of file |
@@ -36,58 +36,58 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class AdminConfigController extends MvcController |
38 | 38 | { |
39 | - /** |
|
40 | - * GeoAnalysis Provider |
|
41 | - * @var GeoAnalysisProvider $provider |
|
42 | - */ |
|
43 | - protected $provider; |
|
39 | + /** |
|
40 | + * GeoAnalysis Provider |
|
41 | + * @var GeoAnalysisProvider $provider |
|
42 | + */ |
|
43 | + protected $provider; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Constructor for Admin Config controller |
|
47 | - * @param AbstractModule $module |
|
48 | - */ |
|
49 | - public function __construct(AbstractModule $module) { |
|
50 | - parent::__construct($module); |
|
45 | + /** |
|
46 | + * Constructor for Admin Config controller |
|
47 | + * @param AbstractModule $module |
|
48 | + */ |
|
49 | + public function __construct(AbstractModule $module) { |
|
50 | + parent::__construct($module); |
|
51 | 51 | |
52 | - $this->provider = $this->module->getProvider(); |
|
53 | - } |
|
52 | + $this->provider = $this->module->getProvider(); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Pages |
|
57 | - */ |
|
55 | + /** |
|
56 | + * Pages |
|
57 | + */ |
|
58 | 58 | |
59 | - /** |
|
60 | - * AdminConfig@index |
|
61 | - */ |
|
62 | - public function index() { |
|
63 | - $wt_tree = Globals::getTree(); |
|
64 | - Theme::theme(new AdministrationTheme)->init($wt_tree); |
|
65 | - $controller = new PageController(); |
|
66 | - $controller |
|
67 | - ->restrictAccess(Auth::isManager($wt_tree)) |
|
68 | - ->setPageTitle($this->module->getTitle()); |
|
59 | + /** |
|
60 | + * AdminConfig@index |
|
61 | + */ |
|
62 | + public function index() { |
|
63 | + $wt_tree = Globals::getTree(); |
|
64 | + Theme::theme(new AdministrationTheme)->init($wt_tree); |
|
65 | + $controller = new PageController(); |
|
66 | + $controller |
|
67 | + ->restrictAccess(Auth::isManager($wt_tree)) |
|
68 | + ->setPageTitle($this->module->getTitle()); |
|
69 | 69 | |
70 | - $data = new ViewBag(); |
|
71 | - $data->set('title', $controller->getPageTitle()); |
|
72 | - $data->set('tree', $wt_tree); |
|
70 | + $data = new ViewBag(); |
|
71 | + $data->set('title', $controller->getPageTitle()); |
|
72 | + $data->set('tree', $wt_tree); |
|
73 | 73 | |
74 | - $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'); |
|
74 | + $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'); |
|
75 | 75 | |
76 | - $table_id = 'table-geoanalysis-' . Uuid::uuid4(); |
|
77 | - $data->set('table_id', $table_id); |
|
76 | + $table_id = 'table-geoanalysis-' . Uuid::uuid4(); |
|
77 | + $data->set('table_id', $table_id); |
|
78 | 78 | |
79 | - $other_trees = array(); |
|
80 | - foreach (Tree::getAll() as $tree) { |
|
81 | - if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree; |
|
82 | - } |
|
83 | - $data->set('other_trees', $other_trees); |
|
79 | + $other_trees = array(); |
|
80 | + foreach (Tree::getAll() as $tree) { |
|
81 | + if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree; |
|
82 | + } |
|
83 | + $data->set('other_trees', $other_trees); |
|
84 | 84 | |
85 | - $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
85 | + $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
86 | 86 | |
87 | - $controller |
|
88 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
89 | - ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
90 | - ->addInlineJavascript(' |
|
87 | + $controller |
|
88 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
89 | + ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
90 | + ->addInlineJavascript(' |
|
91 | 91 | jQuery.fn.dataTableExt.oSort["text-asc"] = textCompareAsc; |
92 | 92 | jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc; |
93 | 93 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | }); |
120 | 120 | |
121 | 121 | ') |
122 | - ->addInlineJavascript(' |
|
122 | + ->addInlineJavascript(' |
|
123 | 123 | function set_geoanalysis_status(ga_id, status, gedcom) { |
124 | 124 | jQuery.ajax({ |
125 | 125 | url: "module.php", |
@@ -163,54 +163,54 @@ discard block |
||
163 | 163 | '); |
164 | 164 | |
165 | 165 | |
166 | - ViewFactory::make('AdminConfig', $this, $controller, $data)->render(); |
|
167 | - } |
|
166 | + ViewFactory::make('AdminConfig', $this, $controller, $data)->render(); |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * AdminConfig@jsonGeoAnalysisList |
|
171 | - */ |
|
172 | - public function jsonGeoAnalysisList() { |
|
173 | - $wt_tree = Globals::getTree(); |
|
174 | - $controller = new JsonController(); |
|
175 | - $controller |
|
176 | - ->restrictAccess(Auth::isManager($wt_tree)); |
|
169 | + /** |
|
170 | + * AdminConfig@jsonGeoAnalysisList |
|
171 | + */ |
|
172 | + public function jsonGeoAnalysisList() { |
|
173 | + $wt_tree = Globals::getTree(); |
|
174 | + $controller = new JsonController(); |
|
175 | + $controller |
|
176 | + ->restrictAccess(Auth::isManager($wt_tree)); |
|
177 | 177 | |
178 | - // Generate an AJAX/JSON response for datatables to load a block of rows |
|
179 | - $search = Filter::postArray('search'); |
|
180 | - if($search) $search = $search['value']; |
|
181 | - $start = Filter::postInteger('start'); |
|
182 | - $length = Filter::postInteger('length'); |
|
183 | - $order = Filter::postArray('order'); |
|
178 | + // Generate an AJAX/JSON response for datatables to load a block of rows |
|
179 | + $search = Filter::postArray('search'); |
|
180 | + if($search) $search = $search['value']; |
|
181 | + $start = Filter::postInteger('start'); |
|
182 | + $length = Filter::postInteger('length'); |
|
183 | + $order = Filter::postArray('order'); |
|
184 | 184 | |
185 | - foreach($order as $key => &$value) { |
|
186 | - switch($value['column']) { |
|
187 | - case 3: |
|
188 | - $value['column'] = 'majgd_descr'; |
|
189 | - break; |
|
190 | - case 5; |
|
191 | - $value['column'] = 'majgd_sublevel'; |
|
192 | - break; |
|
193 | - default: |
|
194 | - unset($order[$key]); |
|
195 | - } |
|
196 | - } |
|
185 | + foreach($order as $key => &$value) { |
|
186 | + switch($value['column']) { |
|
187 | + case 3: |
|
188 | + $value['column'] = 'majgd_descr'; |
|
189 | + break; |
|
190 | + case 5; |
|
191 | + $value['column'] = 'majgd_sublevel'; |
|
192 | + break; |
|
193 | + default: |
|
194 | + unset($order[$key]); |
|
195 | + } |
|
196 | + } |
|
197 | 197 | |
198 | - /** @var GeoAnalysisProvider $provider */ |
|
199 | - $provider = $this->module->getProvider(); |
|
198 | + /** @var GeoAnalysisProvider $provider */ |
|
199 | + $provider = $this->module->getProvider(); |
|
200 | 200 | |
201 | - $list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length); |
|
202 | - $recordsFiltered = count($list); |
|
203 | - $recordsTotal = $this->provider->getGeoAnalysisCount(); |
|
201 | + $list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length); |
|
202 | + $recordsFiltered = count($list); |
|
203 | + $recordsTotal = $this->provider->getGeoAnalysisCount(); |
|
204 | 204 | |
205 | - $data = array(); |
|
206 | - $place_hierarchy = $this->provider->getPlacesHierarchy(); |
|
207 | - foreach($list as $ga) { |
|
208 | - /** @var GeoAnalysis $ga */ |
|
205 | + $data = array(); |
|
206 | + $place_hierarchy = $this->provider->getPlacesHierarchy(); |
|
207 | + foreach($list as $ga) { |
|
208 | + /** @var GeoAnalysis $ga */ |
|
209 | 209 | |
210 | - $datum = array(); |
|
211 | - $options= $ga->getOptions(); |
|
210 | + $datum = array(); |
|
211 | + $options= $ga->getOptions(); |
|
212 | 212 | |
213 | - $datum[0] = ' |
|
213 | + $datum[0] = ' |
|
214 | 214 | <div class="btn-group"> |
215 | 215 | <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> |
216 | 216 | <i class="fa fa-pencil"></i><span class="caret"></span> |
@@ -234,116 +234,116 @@ discard block |
||
234 | 234 | </li> |
235 | 235 | </ul> |
236 | 236 | </div>'; |
237 | - $datum[1] = $ga->getId(); |
|
238 | - $datum[2] = $ga->isEnabled() ? |
|
237 | + $datum[1] = $ga->getId(); |
|
238 | + $datum[2] = $ga->isEnabled() ? |
|
239 | 239 | '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : |
240 | 240 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
241 | - $datum[3] = $ga->getTitle(); |
|
242 | - $analysis_level = $ga->getAnalysisLevel(); |
|
243 | - if($place_hierarchy['type'] == 'header') { |
|
244 | - $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1]; |
|
245 | - } elseif ($place_hierarchy['type'] == 'data') { |
|
246 | - $datum[4] = $analysis_level . ' (' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')'; |
|
247 | - } else { |
|
248 | - $datum[4] = $analysis_level; |
|
249 | - } |
|
250 | - $datum[5] = $ga->getAnalysisLevel(); |
|
251 | - $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
252 | - $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
253 | - if($ga->hasMap()) { |
|
254 | - if($options->getMap()->isLoaded()) { |
|
255 | - $datum[6] = $options->getMap()->getDescription(); |
|
256 | - $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />'; |
|
257 | - $top_level = $options->getMapLevel(); |
|
258 | - if($place_hierarchy['type'] == 'header') { |
|
259 | - $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1]; |
|
260 | - } elseif ($place_hierarchy['type'] == 'data') { |
|
261 | - $datum[7] .= $top_level . ' (' . $place_hierarchy['hierarchy'][$top_level - 1] . ')'; |
|
262 | - } else { |
|
263 | - $datum[7] .= $top_level; |
|
264 | - } |
|
265 | - $datum[7] .= '</span>'; |
|
266 | - } |
|
267 | - else { |
|
268 | - $datum[6] = I18N::translate('Error when loading map.'); |
|
269 | - } |
|
270 | - } |
|
271 | - $datum[8] = $options->isUsingFlags() ? |
|
241 | + $datum[3] = $ga->getTitle(); |
|
242 | + $analysis_level = $ga->getAnalysisLevel(); |
|
243 | + if($place_hierarchy['type'] == 'header') { |
|
244 | + $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1]; |
|
245 | + } elseif ($place_hierarchy['type'] == 'data') { |
|
246 | + $datum[4] = $analysis_level . ' (' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')'; |
|
247 | + } else { |
|
248 | + $datum[4] = $analysis_level; |
|
249 | + } |
|
250 | + $datum[5] = $ga->getAnalysisLevel(); |
|
251 | + $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
252 | + $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
253 | + if($ga->hasMap()) { |
|
254 | + if($options->getMap()->isLoaded()) { |
|
255 | + $datum[6] = $options->getMap()->getDescription(); |
|
256 | + $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />'; |
|
257 | + $top_level = $options->getMapLevel(); |
|
258 | + if($place_hierarchy['type'] == 'header') { |
|
259 | + $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1]; |
|
260 | + } elseif ($place_hierarchy['type'] == 'data') { |
|
261 | + $datum[7] .= $top_level . ' (' . $place_hierarchy['hierarchy'][$top_level - 1] . ')'; |
|
262 | + } else { |
|
263 | + $datum[7] .= $top_level; |
|
264 | + } |
|
265 | + $datum[7] .= '</span>'; |
|
266 | + } |
|
267 | + else { |
|
268 | + $datum[6] = I18N::translate('Error when loading map.'); |
|
269 | + } |
|
270 | + } |
|
271 | + $datum[8] = $options->isUsingFlags() ? |
|
272 | 272 | '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : |
273 | 273 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
274 | - $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All'); |
|
274 | + $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All'); |
|
275 | 275 | |
276 | - $data[] = $datum; |
|
277 | - } |
|
276 | + $data[] = $datum; |
|
277 | + } |
|
278 | 278 | |
279 | - $controller->pageHeader(); |
|
279 | + $controller->pageHeader(); |
|
280 | 280 | |
281 | - $controller->encode(array( |
|
282 | - 'draw' => Filter::getInteger('draw'), |
|
283 | - 'recordsTotal' => $recordsTotal, |
|
284 | - 'recordsFiltered' => $recordsFiltered, |
|
285 | - 'data' => $data |
|
286 | - )); |
|
281 | + $controller->encode(array( |
|
282 | + 'draw' => Filter::getInteger('draw'), |
|
283 | + 'recordsTotal' => $recordsTotal, |
|
284 | + 'recordsFiltered' => $recordsFiltered, |
|
285 | + 'data' => $data |
|
286 | + )); |
|
287 | 287 | |
288 | - } |
|
288 | + } |
|
289 | 289 | |
290 | - /** |
|
291 | - * AdminConfig@edit |
|
292 | - */ |
|
293 | - public function edit() { |
|
294 | - $ga_id = Filter::getInteger('ga_id'); |
|
295 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
290 | + /** |
|
291 | + * AdminConfig@edit |
|
292 | + */ |
|
293 | + public function edit() { |
|
294 | + $ga_id = Filter::getInteger('ga_id'); |
|
295 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
296 | 296 | |
297 | - $this->renderEdit($ga); |
|
298 | - } |
|
297 | + $this->renderEdit($ga); |
|
298 | + } |
|
299 | 299 | |
300 | - /** |
|
301 | - * AdminConfig@add |
|
302 | - */ |
|
303 | - public function add() { |
|
304 | - $this->renderEdit(null); |
|
305 | - } |
|
300 | + /** |
|
301 | + * AdminConfig@add |
|
302 | + */ |
|
303 | + public function add() { |
|
304 | + $this->renderEdit(null); |
|
305 | + } |
|
306 | 306 | |
307 | - /** |
|
308 | - * AdminConfig@save |
|
309 | - */ |
|
310 | - public function save() { |
|
311 | - $wt_tree = Globals::getTree(); |
|
312 | - $tmp_contrl = new PageController(); |
|
313 | - $tmp_contrl->restrictAccess( |
|
314 | - Auth::isManager($wt_tree) |
|
315 | - && Filter::checkCsrf() |
|
316 | - ); |
|
307 | + /** |
|
308 | + * AdminConfig@save |
|
309 | + */ |
|
310 | + public function save() { |
|
311 | + $wt_tree = Globals::getTree(); |
|
312 | + $tmp_contrl = new PageController(); |
|
313 | + $tmp_contrl->restrictAccess( |
|
314 | + Auth::isManager($wt_tree) |
|
315 | + && Filter::checkCsrf() |
|
316 | + ); |
|
317 | 317 | |
318 | - $ga_id = Filter::postInteger('ga_id'); |
|
319 | - $description = Filter::post('description'); |
|
320 | - $analysislevel = Filter::postInteger('analysislevel'); |
|
321 | - $use_map = Filter::postBool('use_map'); |
|
322 | - if($use_map) { |
|
323 | - $map_file = base64_decode(Filter::post('map_file')); |
|
324 | - $map_top_level = Filter::postInteger('map_top_level'); |
|
325 | - } |
|
326 | - $use_flags = Filter::postBool('use_flags'); |
|
327 | - $gen_details = Filter::postInteger('gen_details'); |
|
318 | + $ga_id = Filter::postInteger('ga_id'); |
|
319 | + $description = Filter::post('description'); |
|
320 | + $analysislevel = Filter::postInteger('analysislevel'); |
|
321 | + $use_map = Filter::postBool('use_map'); |
|
322 | + if($use_map) { |
|
323 | + $map_file = base64_decode(Filter::post('map_file')); |
|
324 | + $map_top_level = Filter::postInteger('map_top_level'); |
|
325 | + } |
|
326 | + $use_flags = Filter::postBool('use_flags'); |
|
327 | + $gen_details = Filter::postInteger('gen_details'); |
|
328 | 328 | |
329 | - $success = false; |
|
330 | - if($ga_id) { |
|
331 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
332 | - if($ga) { |
|
333 | - $ga->setTitle($description); |
|
334 | - $ga->setAnalysisLevel($analysislevel + 1); |
|
335 | - $options = $ga->getOptions(); |
|
336 | - if($options) { |
|
337 | - $options->setUsingFlags($use_flags); |
|
338 | - $options->setMaxDetailsInGen($gen_details); |
|
339 | - if($use_map) { |
|
340 | - $options->setMap(new OutlineMap($map_file)); |
|
341 | - $options->setMapLevel($map_top_level + 1); |
|
342 | - } |
|
343 | - else { |
|
344 | - $options->setMap(null); |
|
345 | - } |
|
346 | - } |
|
329 | + $success = false; |
|
330 | + if($ga_id) { |
|
331 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
332 | + if($ga) { |
|
333 | + $ga->setTitle($description); |
|
334 | + $ga->setAnalysisLevel($analysislevel + 1); |
|
335 | + $options = $ga->getOptions(); |
|
336 | + if($options) { |
|
337 | + $options->setUsingFlags($use_flags); |
|
338 | + $options->setMaxDetailsInGen($gen_details); |
|
339 | + if($use_map) { |
|
340 | + $options->setMap(new OutlineMap($map_file)); |
|
341 | + $options->setMapLevel($map_top_level + 1); |
|
342 | + } |
|
343 | + else { |
|
344 | + $options->setMap(null); |
|
345 | + } |
|
346 | + } |
|
347 | 347 | |
348 | 348 | $res = $this->provider->updateGeoAnalysis($ga); |
349 | 349 | if($res) { |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger'); |
357 | 357 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.'); |
358 | 358 | } |
359 | - } |
|
360 | - } else { |
|
359 | + } |
|
360 | + } else { |
|
361 | 361 | $ga = $this->provider->createGeoAnalysis( |
362 | 362 | $description, |
363 | 363 | $analysislevel + 1, |
@@ -375,33 +375,33 @@ discard block |
||
375 | 375 | FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger'); |
376 | 376 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis “'.$description.'” could not be added. See error log.'); |
377 | 377 | } |
378 | - } |
|
378 | + } |
|
379 | 379 | |
380 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl(); |
|
381 | - if(!$success) { |
|
382 | - if($ga) { |
|
383 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl(); |
|
384 | - } |
|
385 | - else { |
|
386 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl(); |
|
387 | - } |
|
388 | - } |
|
389 | - header('Location: ' . WT_BASE_URL . $redirection_url); |
|
380 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl(); |
|
381 | + if(!$success) { |
|
382 | + if($ga) { |
|
383 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl(); |
|
384 | + } |
|
385 | + else { |
|
386 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl(); |
|
387 | + } |
|
388 | + } |
|
389 | + header('Location: ' . WT_BASE_URL . $redirection_url); |
|
390 | 390 | |
391 | - } |
|
391 | + } |
|
392 | 392 | |
393 | 393 | /** |
394 | 394 | * Renders the edit form, whether it is an edition of an existing GeoAnalysis, or the addition of a new one. |
395 | 395 | * |
396 | 396 | * @param (GeoAnalysis!null) $ga GeoAnalysis to edit |
397 | 397 | */ |
398 | - protected function renderEdit(GeoAnalysis $ga = null) { |
|
399 | - $wt_tree = Globals::getTree(); |
|
400 | - Theme::theme(new AdministrationTheme)->init($wt_tree); |
|
401 | - $controller = new PageController(); |
|
402 | - $controller |
|
403 | - ->restrictAccess(Auth::isManager($wt_tree)) |
|
404 | - ->addInlineJavascript(' |
|
398 | + protected function renderEdit(GeoAnalysis $ga = null) { |
|
399 | + $wt_tree = Globals::getTree(); |
|
400 | + Theme::theme(new AdministrationTheme)->init($wt_tree); |
|
401 | + $controller = new PageController(); |
|
402 | + $controller |
|
403 | + ->restrictAccess(Auth::isManager($wt_tree)) |
|
404 | + ->addInlineJavascript(' |
|
405 | 405 | function toggleMapOptions() { |
406 | 406 | if($("input:radio[name=\'use_map\']:checked").val() == 1) { |
407 | 407 | $("#map_options").show(); |
@@ -415,34 +415,34 @@ discard block |
||
415 | 415 | toggleMapOptions(); |
416 | 416 | '); |
417 | 417 | |
418 | - $data = new ViewBag(); |
|
419 | - if($ga) { |
|
420 | - $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis')); |
|
421 | - $data->set('geo_analysis', $ga); |
|
422 | - } else { |
|
423 | - $controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis')); |
|
424 | - } |
|
418 | + $data = new ViewBag(); |
|
419 | + if($ga) { |
|
420 | + $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis')); |
|
421 | + $data->set('geo_analysis', $ga); |
|
422 | + } else { |
|
423 | + $controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis')); |
|
424 | + } |
|
425 | 425 | |
426 | - $data->set('title', $controller->getPageTitle()); |
|
427 | - $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl()); |
|
428 | - $data->set('module_title', $this->module->getTitle()); |
|
429 | - $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $wt_tree->getNameUrl()); |
|
430 | - $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
426 | + $data->set('title', $controller->getPageTitle()); |
|
427 | + $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl()); |
|
428 | + $data->set('module_title', $this->module->getTitle()); |
|
429 | + $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $wt_tree->getNameUrl()); |
|
430 | + $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
431 | 431 | |
432 | - $map_list = array_map( |
|
433 | - function(OutlineMap $map) { |
|
434 | - return $map->getDescription(); |
|
435 | - }, |
|
436 | - $this->provider->getOutlineMapsList() |
|
437 | - ); |
|
438 | - asort($map_list); |
|
439 | - $data->set('map_list', $map_list); |
|
432 | + $map_list = array_map( |
|
433 | + function(OutlineMap $map) { |
|
434 | + return $map->getDescription(); |
|
435 | + }, |
|
436 | + $this->provider->getOutlineMapsList() |
|
437 | + ); |
|
438 | + asort($map_list); |
|
439 | + $data->set('map_list', $map_list); |
|
440 | 440 | |
441 | - $gen_details = array(0 => I18N::translate('All')); |
|
442 | - for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
443 | - $data->set('generation_details', $gen_details); |
|
441 | + $gen_details = array(0 => I18N::translate('All')); |
|
442 | + for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
443 | + $data->set('generation_details', $gen_details); |
|
444 | 444 | |
445 | - ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |
|
446 | - } |
|
445 | + ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |
|
446 | + } |
|
447 | 447 | |
448 | 448 | } |
449 | 449 | \ No newline at end of file |
@@ -24,68 +24,68 @@ |
||
24 | 24 | class LineageRootNode extends LineageNode |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @var Collection $places Places for the lineage node |
|
29 | - */ |
|
30 | - private $places; |
|
27 | + /** |
|
28 | + * @var Collection $places Places for the lineage node |
|
29 | + */ |
|
30 | + private $places; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @var int $nb_children Number of node childs |
|
34 | - */ |
|
35 | - private $nb_children; |
|
32 | + /** |
|
33 | + * @var int $nb_children Number of node childs |
|
34 | + */ |
|
35 | + private $nb_children; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor for LineageRootNode |
|
39 | - * |
|
40 | - * @param Individual|null $node_indi |
|
41 | - */ |
|
42 | - public function __construct(?Individual $node_indi = null) |
|
43 | - { |
|
44 | - parent::__construct($node_indi, $this); |
|
45 | - $this->places = new Collection(); |
|
46 | - $this->nb_children = 0; |
|
47 | - } |
|
37 | + /** |
|
38 | + * Constructor for LineageRootNode |
|
39 | + * |
|
40 | + * @param Individual|null $node_indi |
|
41 | + */ |
|
42 | + public function __construct(?Individual $node_indi = null) |
|
43 | + { |
|
44 | + parent::__construct($node_indi, $this); |
|
45 | + $this->places = new Collection(); |
|
46 | + $this->nb_children = 0; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Adds a place to the list of lineage's place |
|
51 | - * |
|
52 | - * @param Place $place |
|
53 | - */ |
|
54 | - public function addPlace(Place $place): void |
|
55 | - { |
|
56 | - $place_name = $place->gedcomName(); |
|
57 | - if (mb_strlen($place_name) > 0) { |
|
58 | - $this->places->put($place_name, $this->places->get($place_name, 0) + 1); |
|
59 | - } |
|
60 | - } |
|
49 | + /** |
|
50 | + * Adds a place to the list of lineage's place |
|
51 | + * |
|
52 | + * @param Place $place |
|
53 | + */ |
|
54 | + public function addPlace(Place $place): void |
|
55 | + { |
|
56 | + $place_name = $place->gedcomName(); |
|
57 | + if (mb_strlen($place_name) > 0) { |
|
58 | + $this->places->put($place_name, $this->places->get($place_name, 0) + 1); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Returns the number of child nodes. |
|
64 | - * This number is more to be used as indication rather than an accurate one. |
|
65 | - * |
|
66 | - * @return int |
|
67 | - */ |
|
68 | - public function numberChildNodes(): int |
|
69 | - { |
|
70 | - return $this->nb_children; |
|
71 | - } |
|
62 | + /** |
|
63 | + * Returns the number of child nodes. |
|
64 | + * This number is more to be used as indication rather than an accurate one. |
|
65 | + * |
|
66 | + * @return int |
|
67 | + */ |
|
68 | + public function numberChildNodes(): int |
|
69 | + { |
|
70 | + return $this->nb_children; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Increments the number of child nodes by one |
|
75 | - * |
|
76 | - */ |
|
77 | - public function incrementChildNodes(): void |
|
78 | - { |
|
79 | - $this->nb_children++; |
|
80 | - } |
|
73 | + /** |
|
74 | + * Increments the number of child nodes by one |
|
75 | + * |
|
76 | + */ |
|
77 | + public function incrementChildNodes(): void |
|
78 | + { |
|
79 | + $this->nb_children++; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Returns the list of place for the lineage |
|
84 | - * |
|
85 | - * @return Collection |
|
86 | - */ |
|
87 | - public function places(): Collection |
|
88 | - { |
|
89 | - return $this->places; |
|
90 | - } |
|
82 | + /** |
|
83 | + * Returns the list of place for the lineage |
|
84 | + * |
|
85 | + * @return Collection |
|
86 | + */ |
|
87 | + public function places(): Collection |
|
88 | + { |
|
89 | + return $this->places; |
|
90 | + } |
|
91 | 91 | } |
@@ -26,89 +26,89 @@ |
||
26 | 26 | */ |
27 | 27 | abstract class AbstractModuleMaj extends AbstractModule implements ModuleCustomInterface |
28 | 28 | { |
29 | - use ModuleCustomTrait; |
|
29 | + use ModuleCustomTrait; |
|
30 | 30 | |
31 | - /** |
|
32 | - * {@inheritDoc} |
|
33 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
34 | - */ |
|
35 | - public function boot() : void |
|
36 | - { |
|
37 | - View::registerNamespace($this->name(), $this->resourcesFolder() . 'views/'); |
|
31 | + /** |
|
32 | + * {@inheritDoc} |
|
33 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
34 | + */ |
|
35 | + public function boot() : void |
|
36 | + { |
|
37 | + View::registerNamespace($this->name(), $this->resourcesFolder() . 'views/'); |
|
38 | 38 | |
39 | - $this->loadRoutes(app(RouterContainer::class)->getMap()); |
|
40 | - } |
|
39 | + $this->loadRoutes(app(RouterContainer::class)->getMap()); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * {@inheritDoc} |
|
44 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::resourcesFolder() |
|
45 | - */ |
|
46 | - public function resourcesFolder(): string |
|
47 | - { |
|
48 | - return Webtrees::MODULES_DIR . trim($this->name(), '_') . '/resources/'; |
|
49 | - } |
|
42 | + /** |
|
43 | + * {@inheritDoc} |
|
44 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::resourcesFolder() |
|
45 | + */ |
|
46 | + public function resourcesFolder(): string |
|
47 | + { |
|
48 | + return Webtrees::MODULES_DIR . trim($this->name(), '_') . '/resources/'; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * {@inheritDoc} |
|
53 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleAuthorName() |
|
54 | - */ |
|
55 | - public function customModuleAuthorName() : string |
|
56 | - { |
|
57 | - return 'Jonathan Jaubart'; |
|
58 | - } |
|
51 | + /** |
|
52 | + * {@inheritDoc} |
|
53 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleAuthorName() |
|
54 | + */ |
|
55 | + public function customModuleAuthorName() : string |
|
56 | + { |
|
57 | + return 'Jonathan Jaubart'; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * {@inheritDoc} |
|
62 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleSupportUrl() |
|
63 | - */ |
|
64 | - public function customModuleSupportUrl() : string |
|
65 | - { |
|
66 | - return 'https://github.com/jon48/webtrees-lib'; |
|
67 | - } |
|
60 | + /** |
|
61 | + * {@inheritDoc} |
|
62 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleSupportUrl() |
|
63 | + */ |
|
64 | + public function customModuleSupportUrl() : string |
|
65 | + { |
|
66 | + return 'https://github.com/jon48/webtrees-lib'; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * {@inheritDoc} |
|
71 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customTranslations() |
|
72 | - */ |
|
73 | - public function customTranslations(string $language) : array |
|
74 | - { |
|
75 | - $translation_file = $this->resourcesFolder() . 'lang/' . $language . '/messages.php'; |
|
69 | + /** |
|
70 | + * {@inheritDoc} |
|
71 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customTranslations() |
|
72 | + */ |
|
73 | + public function customTranslations(string $language) : array |
|
74 | + { |
|
75 | + $translation_file = $this->resourcesFolder() . 'lang/' . $language . '/messages.php'; |
|
76 | 76 | |
77 | - try { |
|
78 | - $translation = new Translation($translation_file); |
|
79 | - return $translation->asArray(); |
|
80 | - } catch (\Exception $e) { } |
|
77 | + try { |
|
78 | + $translation = new Translation($translation_file); |
|
79 | + return $translation->asArray(); |
|
80 | + } catch (\Exception $e) { } |
|
81 | 81 | |
82 | - return array(); |
|
83 | - } |
|
82 | + return array(); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * Add module routes to webtrees route loader |
|
87 | - * |
|
88 | - * @param Map $router |
|
89 | - */ |
|
90 | - public abstract function loadRoutes(Map $router) : void; |
|
85 | + /** |
|
86 | + * Add module routes to webtrees route loader |
|
87 | + * |
|
88 | + * @param Map $router |
|
89 | + */ |
|
90 | + public abstract function loadRoutes(Map $router) : void; |
|
91 | 91 | |
92 | - /** |
|
93 | - * Returns the URL of the module specific stylesheets. |
|
94 | - * It will look for a CSS file matching the theme name (e.g. xenea.min.css), |
|
95 | - * and fallback to default.min.css if none are found |
|
96 | - * |
|
97 | - * @return string |
|
98 | - */ |
|
99 | - public function moduleCssUrl() : string |
|
100 | - { |
|
101 | - /** @var ModuleThemeInterface $theme */ |
|
102 | - $theme = app(ModuleThemeInterface::class); |
|
103 | - $css_file = $this->resourcesFolder() . 'css/' . $theme->name() . '.min.css'; |
|
92 | + /** |
|
93 | + * Returns the URL of the module specific stylesheets. |
|
94 | + * It will look for a CSS file matching the theme name (e.g. xenea.min.css), |
|
95 | + * and fallback to default.min.css if none are found |
|
96 | + * |
|
97 | + * @return string |
|
98 | + */ |
|
99 | + public function moduleCssUrl() : string |
|
100 | + { |
|
101 | + /** @var ModuleThemeInterface $theme */ |
|
102 | + $theme = app(ModuleThemeInterface::class); |
|
103 | + $css_file = $this->resourcesFolder() . 'css/' . $theme->name() . '.min.css'; |
|
104 | 104 | |
105 | - if(file_exists($css_file)) { |
|
106 | - return $this->assetUrl('css/' . $theme->name() . '.min.css'); |
|
107 | - } |
|
108 | - else { |
|
109 | - return $this->assetUrl('css/default.min.css'); |
|
110 | - } |
|
111 | - } |
|
105 | + if(file_exists($css_file)) { |
|
106 | + return $this->assetUrl('css/' . $theme->name() . '.min.css'); |
|
107 | + } |
|
108 | + else { |
|
109 | + return $this->assetUrl('css/default.min.css'); |
|
110 | + } |
|
111 | + } |
|
112 | 112 | |
113 | 113 | } |
114 | 114 | |
115 | 115 | \ No newline at end of file |
@@ -30,65 +30,65 @@ |
||
30 | 30 | class TaskStatusAction implements RequestHandlerInterface |
31 | 31 | { |
32 | 32 | |
33 | - /** |
|
34 | - * @var AdminTasksModule $module |
|
35 | - */ |
|
36 | - private $module; |
|
33 | + /** |
|
34 | + * @var AdminTasksModule $module |
|
35 | + */ |
|
36 | + private $module; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var TaskScheduleService $taskschedules_service |
|
40 | - */ |
|
41 | - private $taskschedules_service; |
|
38 | + /** |
|
39 | + * @var TaskScheduleService $taskschedules_service |
|
40 | + */ |
|
41 | + private $taskschedules_service; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Constructor for TaskStatusAction Request Handler |
|
45 | - * |
|
46 | - * @param ModuleService $module_service |
|
47 | - * @param TaskScheduleService $taskschedules_service |
|
48 | - */ |
|
49 | - public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service) |
|
50 | - { |
|
51 | - $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
52 | - $this->taskschedules_service = $taskschedules_service; |
|
53 | - } |
|
43 | + /** |
|
44 | + * Constructor for TaskStatusAction Request Handler |
|
45 | + * |
|
46 | + * @param ModuleService $module_service |
|
47 | + * @param TaskScheduleService $taskschedules_service |
|
48 | + */ |
|
49 | + public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service) |
|
50 | + { |
|
51 | + $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
52 | + $this->taskschedules_service = $taskschedules_service; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * {@inheritDoc} |
|
57 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
58 | - */ |
|
59 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
60 | - { |
|
61 | - $task_sched_id = (int) $request->getAttribute('task'); |
|
62 | - $task_schedule = $this->taskschedules_service->find($task_sched_id); |
|
55 | + /** |
|
56 | + * {@inheritDoc} |
|
57 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
58 | + */ |
|
59 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
60 | + { |
|
61 | + $task_sched_id = (int) $request->getAttribute('task'); |
|
62 | + $task_schedule = $this->taskschedules_service->find($task_sched_id); |
|
63 | 63 | |
64 | - $admin_config_route = route(AdminConfigPage::class); |
|
64 | + $admin_config_route = route(AdminConfigPage::class); |
|
65 | 65 | |
66 | - if ($task_schedule === null) { |
|
67 | - FlashMessages::addMessage( |
|
68 | - I18N::translate('The task shedule with ID “%d” does not exist.', I18N::number($task_sched_id)), |
|
69 | - 'danger' |
|
70 | - ); |
|
71 | - return redirect($admin_config_route); |
|
72 | - } |
|
66 | + if ($task_schedule === null) { |
|
67 | + FlashMessages::addMessage( |
|
68 | + I18N::translate('The task shedule with ID “%d” does not exist.', I18N::number($task_sched_id)), |
|
69 | + 'danger' |
|
70 | + ); |
|
71 | + return redirect($admin_config_route); |
|
72 | + } |
|
73 | 73 | |
74 | - ((bool) $request->getAttribute('enable', false)) ? $task_schedule->enable() : $task_schedule->disable(); |
|
74 | + ((bool) $request->getAttribute('enable', false)) ? $task_schedule->enable() : $task_schedule->disable(); |
|
75 | 75 | |
76 | - if ($this->taskschedules_service->update($task_schedule) > 0) { |
|
77 | - FlashMessages::addMessage( |
|
78 | - I18N::translate('The scheduled task has been successfully updated'), |
|
79 | - 'success' |
|
80 | - ); |
|
81 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
82 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.'); |
|
83 | - } else { |
|
84 | - FlashMessages::addMessage( |
|
85 | - I18N::translate('An error occured while updating the scheduled task'), |
|
86 | - 'danger' |
|
87 | - ); |
|
88 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
89 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.'); |
|
90 | - } |
|
76 | + if ($this->taskschedules_service->update($task_schedule) > 0) { |
|
77 | + FlashMessages::addMessage( |
|
78 | + I18N::translate('The scheduled task has been successfully updated'), |
|
79 | + 'success' |
|
80 | + ); |
|
81 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
82 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.'); |
|
83 | + } else { |
|
84 | + FlashMessages::addMessage( |
|
85 | + I18N::translate('An error occured while updating the scheduled task'), |
|
86 | + 'danger' |
|
87 | + ); |
|
88 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
89 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.'); |
|
90 | + } |
|
91 | 91 | |
92 | - return redirect($admin_config_route); |
|
93 | - } |
|
92 | + return redirect($admin_config_route); |
|
93 | + } |
|
94 | 94 | } |
@@ -30,55 +30,55 @@ |
||
30 | 30 | */ |
31 | 31 | class AdminConfigPage implements RequestHandlerInterface |
32 | 32 | { |
33 | - use ViewResponseTrait; |
|
33 | + use ViewResponseTrait; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @var AdminTasksModule $module |
|
37 | - */ |
|
38 | - private $module; |
|
35 | + /** |
|
36 | + * @var AdminTasksModule $module |
|
37 | + */ |
|
38 | + private $module; |
|
39 | 39 | |
40 | - /** |
|
41 | - * |
|
42 | - * @var UserService $user_service |
|
43 | - */ |
|
44 | - private $user_service; |
|
40 | + /** |
|
41 | + * |
|
42 | + * @var UserService $user_service |
|
43 | + */ |
|
44 | + private $user_service; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Constructor for Admin Config request handler |
|
48 | - * |
|
49 | - * @param ModuleService $module_service |
|
50 | - * @param UserService $user_service |
|
51 | - */ |
|
52 | - public function __construct(ModuleService $module_service, UserService $user_service) |
|
53 | - { |
|
54 | - $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
55 | - $this->user_service = $user_service; |
|
56 | - } |
|
46 | + /** |
|
47 | + * Constructor for Admin Config request handler |
|
48 | + * |
|
49 | + * @param ModuleService $module_service |
|
50 | + * @param UserService $user_service |
|
51 | + */ |
|
52 | + public function __construct(ModuleService $module_service, UserService $user_service) |
|
53 | + { |
|
54 | + $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
55 | + $this->user_service = $user_service; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * {@inheritDoc} |
|
60 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
61 | - */ |
|
62 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
63 | - { |
|
64 | - $this->layout = 'layouts/administration'; |
|
58 | + /** |
|
59 | + * {@inheritDoc} |
|
60 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
61 | + */ |
|
62 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
63 | + { |
|
64 | + $this->layout = 'layouts/administration'; |
|
65 | 65 | |
66 | - if ($this->module === null) { |
|
67 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
68 | - } |
|
66 | + if ($this->module === null) { |
|
67 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
68 | + } |
|
69 | 69 | |
70 | - $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN'); |
|
71 | - if ($token === '') { |
|
72 | - $token = Functions::generateRandomToken(); |
|
73 | - $this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token); |
|
74 | - } |
|
70 | + $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN'); |
|
71 | + if ($token === '') { |
|
72 | + $token = Functions::generateRandomToken(); |
|
73 | + $this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token); |
|
74 | + } |
|
75 | 75 | |
76 | - return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
77 | - 'title' => $this->module->title(), |
|
78 | - 'trigger_token' => $token, |
|
79 | - 'trigger_route' => route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']), |
|
80 | - 'new_token_route' => route(TokenGenerate::class), |
|
81 | - 'tasks_data_route' => route(TasksList::class) |
|
82 | - ]); |
|
83 | - } |
|
76 | + return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
77 | + 'title' => $this->module->title(), |
|
78 | + 'trigger_token' => $token, |
|
79 | + 'trigger_route' => route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']), |
|
80 | + 'new_token_route' => route(TokenGenerate::class), |
|
81 | + 'tasks_data_route' => route(TasksList::class) |
|
82 | + ]); |
|
83 | + } |
|
84 | 84 | } |
@@ -29,48 +29,48 @@ |
||
29 | 29 | */ |
30 | 30 | class TaskTrigger implements RequestHandlerInterface |
31 | 31 | { |
32 | - /** |
|
33 | - * @var AdminTasksModule $module |
|
34 | - */ |
|
35 | - private $module; |
|
32 | + /** |
|
33 | + * @var AdminTasksModule $module |
|
34 | + */ |
|
35 | + private $module; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @var TaskScheduleService $taskschedules_service |
|
39 | - */ |
|
40 | - private $taskschedules_service; |
|
37 | + /** |
|
38 | + * @var TaskScheduleService $taskschedules_service |
|
39 | + */ |
|
40 | + private $taskschedules_service; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Constructor for TaskTrigger request handler |
|
44 | - * @param ModuleService $module_service |
|
45 | - * @param TaskScheduleService $taskschedules_service |
|
46 | - */ |
|
47 | - public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service) |
|
48 | - { |
|
49 | - $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
50 | - $this->taskschedules_service = $taskschedules_service; |
|
51 | - } |
|
42 | + /** |
|
43 | + * Constructor for TaskTrigger request handler |
|
44 | + * @param ModuleService $module_service |
|
45 | + * @param TaskScheduleService $taskschedules_service |
|
46 | + */ |
|
47 | + public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service) |
|
48 | + { |
|
49 | + $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
50 | + $this->taskschedules_service = $taskschedules_service; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * {@inheritDoc} |
|
55 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
56 | - */ |
|
57 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
58 | - { |
|
59 | - if ($this->module === null) { |
|
60 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
61 | - } |
|
53 | + /** |
|
54 | + * {@inheritDoc} |
|
55 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
56 | + */ |
|
57 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
58 | + { |
|
59 | + if ($this->module === null) { |
|
60 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
61 | + } |
|
62 | 62 | |
63 | - $task_id = $request->getAttribute('task'); |
|
64 | - $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN'); |
|
65 | - $force_token = $request->getQueryParams()['force'] ?? ''; |
|
66 | - $force = $token == $force_token; |
|
63 | + $task_id = $request->getAttribute('task'); |
|
64 | + $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN'); |
|
65 | + $force_token = $request->getQueryParams()['force'] ?? ''; |
|
66 | + $force = $token == $force_token; |
|
67 | 67 | |
68 | - $task_schedules = $this->taskschedules_service->findTasksToRun($force, $task_id); |
|
68 | + $task_schedules = $this->taskschedules_service->findTasksToRun($force, $task_id); |
|
69 | 69 | |
70 | - foreach ($task_schedules as $task_schedule) { |
|
71 | - $this->taskschedules_service->run($task_schedule, $force); |
|
72 | - } |
|
70 | + foreach ($task_schedules as $task_schedule) { |
|
71 | + $this->taskschedules_service->run($task_schedule, $force); |
|
72 | + } |
|
73 | 73 | |
74 | - return response(); |
|
75 | - } |
|
74 | + return response(); |
|
75 | + } |
|
76 | 76 | } |
@@ -22,12 +22,12 @@ |
||
22 | 22 | class Migration0 implements MigrationInterface |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * {@inheritDoc} |
|
27 | - * @see MigrationInterface::upgrade() |
|
28 | - */ |
|
29 | - public function upgrade(): void |
|
30 | - { |
|
31 | - // These migrations have been merged into migration 1. |
|
32 | - } |
|
25 | + /** |
|
26 | + * {@inheritDoc} |
|
27 | + * @see MigrationInterface::upgrade() |
|
28 | + */ |
|
29 | + public function upgrade(): void |
|
30 | + { |
|
31 | + // These migrations have been merged into migration 1. |
|
32 | + } |
|
33 | 33 | } |
@@ -22,20 +22,20 @@ |
||
22 | 22 | interface ConfigurableTaskInterface |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * Returns the HTML code to display the specific task configuration. |
|
27 | - * |
|
28 | - * @param ServerRequestInterface $request |
|
29 | - * @return string HTML code |
|
30 | - */ |
|
31 | - public function configView(ServerRequestInterface $request): string; |
|
25 | + /** |
|
26 | + * Returns the HTML code to display the specific task configuration. |
|
27 | + * |
|
28 | + * @param ServerRequestInterface $request |
|
29 | + * @return string HTML code |
|
30 | + */ |
|
31 | + public function configView(ServerRequestInterface $request): string; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Update the specific configuration of the task. |
|
35 | - * |
|
36 | - * @param ServerRequestInterface $request |
|
37 | - * @param TaskSchedule $task_schedule |
|
38 | - * @return bool Result of the update |
|
39 | - */ |
|
40 | - public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool; |
|
33 | + /** |
|
34 | + * Update the specific configuration of the task. |
|
35 | + * |
|
36 | + * @param ServerRequestInterface $request |
|
37 | + * @param TaskSchedule $task_schedule |
|
38 | + * @return bool Result of the update |
|
39 | + */ |
|
40 | + public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool; |
|
41 | 41 | } |