@@ -73,7 +73,7 @@ |
||
73 | 73 | $this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token); |
74 | 74 | } |
75 | 75 | |
76 | - return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
76 | + return $this->viewResponse($this->module->name().'::admin/config', [ |
|
77 | 77 | 'title' => $this->module->title(), |
78 | 78 | 'trigger_token' => $token, |
79 | 79 | 'trigger_route' => route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']), |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function handle(ServerRequestInterface $request): ResponseInterface |
64 | 64 | { |
65 | - $task_sched_id = (int) $request->getAttribute('task'); |
|
65 | + $task_sched_id = (int)$request->getAttribute('task'); |
|
66 | 66 | $task_schedule = $this->taskschedules_service->find($task_sched_id); |
67 | 67 | |
68 | 68 | $admin_config_route = route(AdminConfigPage::class); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | 'success' |
85 | 85 | ); |
86 | 86 | //phpcs:ignore Generic.Files.LineLength.TooLong |
87 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.'); |
|
87 | + Log::addConfigurationLog('Module '.$this->module->title().' : Task Schedule “'.$task_schedule->id().'” has been updated.'); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | return redirect($admin_config_route); |
@@ -99,17 +99,17 @@ discard block |
||
99 | 99 | */ |
100 | 100 | private function updateGeneralSettings(TaskSchedule $task_schedule, ServerRequestInterface $request): bool |
101 | 101 | { |
102 | - $params = (array) $request->getParsedBody(); |
|
102 | + $params = (array)$request->getParsedBody(); |
|
103 | 103 | |
104 | - $frequency = (int) $params['frequency']; |
|
104 | + $frequency = (int)$params['frequency']; |
|
105 | 105 | if ($frequency > 0) { |
106 | 106 | $task_schedule->setFrequency(CarbonInterval::minutes($frequency)); |
107 | 107 | } else { |
108 | 108 | FlashMessages::addMessage(I18N::translate('The frequency is not in a valid format'), 'danger'); |
109 | 109 | } |
110 | 110 | |
111 | - $is_limited = (bool) $params['is_limited']; |
|
112 | - $nb_occur = (int) $params['nb_occur']; |
|
111 | + $is_limited = (bool)$params['is_limited']; |
|
112 | + $nb_occur = (int)$params['nb_occur']; |
|
113 | 113 | |
114 | 114 | if ($is_limited) { |
115 | 115 | if ($nb_occur > 0) { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | FlashMessages::addMessage(I18N::translate('An error occured while updating the scheduled task'), 'danger'); |
141 | 141 | //@phpcs:ignore Generic.Files.LineLength.TooLong |
142 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.'); |
|
142 | + Log::addConfigurationLog('Module '.$this->module->title().' : Task Schedule “'.$task_schedule->id().'” could not be updated. See error log.'); |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | 'danger' |
168 | 168 | ); |
169 | 169 | //phpcs:ignore Generic.Files.LineLength.TooLong |
170 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : AdminTask “' . $task->name() . '” specific settings could not be updated. See error log.'); |
|
170 | + Log::addConfigurationLog('Module '.$this->module->title().' : AdminTask “'.$task->name().'” specific settings could not be updated. See error log.'); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | return true; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $interval_lastrun = $task_schedule->lastRunTime()->diffAsCarbonInterval(Carbon::now()); |
137 | 137 | //@phpcs:ignore Generic.Files.LineLength.TooLong |
138 | 138 | $interval = $interval_lastrun->greaterThan($task_schedule->frequency()) ? $interval_lastrun : $task_schedule->frequency(); |
139 | - $nb_days = (int) $interval->ceilDay()->totalDays; |
|
139 | + $nb_days = (int)$interval->ceilDay()->totalDays; |
|
140 | 140 | |
141 | 141 | $view_params_site = [ |
142 | 142 | 'nb_days' => $nb_days, |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | continue; |
156 | 156 | } |
157 | 157 | |
158 | - $webmaster = $this->user_service->find((int) $tree->getPreference('WEBMASTER_USER_ID')); |
|
158 | + $webmaster = $this->user_service->find((int)$tree->getPreference('WEBMASTER_USER_ID')); |
|
159 | 159 | if ($webmaster === null) { |
160 | 160 | continue; |
161 | 161 | } |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | new TreeUser($tree), |
177 | 177 | $webmaster, |
178 | 178 | new NoReplyUser(), |
179 | - I18N::translate('Health Check Report') . ' - ' . I18N::translate('Tree %s', $tree->name()), |
|
180 | - view($this->module->name() . '::tasks/healthcheck/email-healthcheck-text', $view_params), |
|
181 | - view($this->module->name() . '::tasks/healthcheck/email-healthcheck-html', $view_params) |
|
179 | + I18N::translate('Health Check Report').' - '.I18N::translate('Tree %s', $tree->name()), |
|
180 | + view($this->module->name().'::tasks/healthcheck/email-healthcheck-text', $view_params), |
|
181 | + view($this->module->name().'::tasks/healthcheck/email-healthcheck-html', $view_params) |
|
182 | 182 | ); |
183 | 183 | } |
184 | 184 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function configView(ServerRequestInterface $request): string |
193 | 193 | { |
194 | - return view($this->module->name() . '::tasks/healthcheck/config', [ |
|
194 | + return view($this->module->name().'::tasks/healthcheck/config', [ |
|
195 | 195 | 'all_trees' => $this->tree_service->all() |
196 | 196 | ]); |
197 | 197 | } |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool |
204 | 204 | { |
205 | 205 | try { |
206 | - $params = (array) $request->getParsedBody(); |
|
206 | + $params = (array)$request->getParsedBody(); |
|
207 | 207 | |
208 | 208 | foreach ($this->tree_service->all() as $tree) { |
209 | 209 | if (Auth::isManager($tree)) { |
210 | - $tree_enabled = (bool) ($params['HEALTHCHECK_ENABLED_' . $tree->id()] ?? false); |
|
210 | + $tree_enabled = (bool)($params['HEALTHCHECK_ENABLED_'.$tree->id()] ?? false); |
|
211 | 211 | $tree->setPreference(self::TREE_PREFERENCE_NAME, $tree_enabled ? '1' : '0'); |
212 | 212 | } |
213 | 213 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
68 | 68 | } |
69 | 69 | |
70 | - $task_sched_id = (int) $request->getAttribute('task'); |
|
70 | + $task_sched_id = (int)$request->getAttribute('task'); |
|
71 | 71 | $task_schedule = $this->taskschedules_service->find($task_sched_id); |
72 | 72 | |
73 | 73 | if ($task_schedule === null) { |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | /** @var TaskInterface&ConfigurableTaskInterface $task */ |
84 | 84 | $has_task_config = $task instanceof ConfigurableTaskInterface; |
85 | 85 | |
86 | - return $this->viewResponse($this->module->name() . '::admin/tasks-edit', [ |
|
86 | + return $this->viewResponse($this->module->name().'::admin/tasks-edit', [ |
|
87 | 87 | 'module' => $this->module, |
88 | - 'title' => I18N::translate('Edit the administrative task') . ' - ' . $task->name(), |
|
88 | + 'title' => I18N::translate('Edit the administrative task').' - '.$task->name(), |
|
89 | 89 | 'task_schedule' => $task_schedule, |
90 | 90 | 'task' => $task, |
91 | 91 | 'has_task_config' => $has_task_config, |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @param string $text Text to display |
34 | 34 | */ |
35 | - static public function promptAlert($text){ |
|
35 | + static public function promptAlert($text) { |
|
36 | 36 | echo '<script>'; |
37 | - echo 'alert("',fw\Filter::escapeHtml($text),'")'; |
|
37 | + echo 'alert("', fw\Filter::escapeHtml($text), '")'; |
|
38 | 38 | echo '</script>'; |
39 | 39 | } |
40 | 40 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @return float Result of the safe division |
48 | 48 | */ |
49 | 49 | public static function safeDivision($num, $denom, $default = 0) { |
50 | - if($denom && $denom!=0){ |
|
50 | + if ($denom && $denom != 0) { |
|
51 | 51 | return $num / $denom; |
52 | 52 | } |
53 | 53 | return $default; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param float $default Default value if denominator null or 0 |
62 | 62 | * @return float Percentage |
63 | 63 | */ |
64 | - public static function getPercentage($num, $denom, $default = 0){ |
|
64 | + public static function getPercentage($num, $denom, $default = 0) { |
|
65 | 65 | return 100 * self::safeDivision($num, $denom, $default); |
66 | 66 | } |
67 | 67 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @param int $target The final max width/height |
73 | 73 | * @return array array of ($width, $height). One of them must be $target |
74 | 74 | */ |
75 | - static public function getResizedImageSize($file, $target=25){ |
|
76 | - list($width, $height, , ) = getimagesize($file); |
|
75 | + static public function getResizedImageSize($file, $target = 25) { |
|
76 | + list($width, $height,,) = getimagesize($file); |
|
77 | 77 | $max = max($width, $height); |
78 | 78 | $rapp = $target / $max; |
79 | 79 | $width = intval($rapp * $width); |
@@ -103,21 +103,21 @@ discard block |
||
103 | 103 | * @param int $length Length of the token, default to 32 |
104 | 104 | * @return string Random token |
105 | 105 | */ |
106 | - public static function generateRandomToken($length=32) { |
|
106 | + public static function generateRandomToken($length = 32) { |
|
107 | 107 | $chars = str_split('abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'); |
108 | 108 | $len_chars = count($chars); |
109 | 109 | $token = ''; |
110 | 110 | |
111 | 111 | for ($i = 0; $i < $length; $i++) |
112 | - $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
112 | + $token .= $chars[mt_rand(0, $len_chars - 1)]; |
|
113 | 113 | |
114 | 114 | # Number of 32 char chunks |
115 | - $chunks = ceil( strlen($token) / 32 ); |
|
115 | + $chunks = ceil(strlen($token) / 32); |
|
116 | 116 | $md5token = ''; |
117 | 117 | |
118 | 118 | # Run each chunk through md5 |
119 | - for ( $i=1; $i<=$chunks; $i++ ) |
|
120 | - $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
119 | + for ($i = 1; $i <= $chunks; $i++) |
|
120 | + $md5token .= md5(substr($token, $i * 32 - 32, 32)); |
|
121 | 121 | |
122 | 122 | # Trim the token |
123 | 123 | return substr($md5token, 0, $length); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | protected static function getBase64EncryptionKey() { |
132 | 132 | $key = 'STANDARDKEYIFNOSERVER'; |
133 | - if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
133 | + if (!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
134 | 134 | $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
135 | 135 | |
136 | 136 | return $key; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param string $data Text to encrypt |
144 | 144 | * @return string Encrypted and encoded text |
145 | 145 | */ |
146 | - public static function encryptToSafeBase64($data){ |
|
146 | + public static function encryptToSafeBase64($data) { |
|
147 | 147 | $nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES); |
148 | 148 | $id = sodium_crypto_secretbox($data, $nonce, self::getBase64EncryptionKey()); |
149 | 149 | $encrypted = base64_encode($nonce.$id); |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | * @param string $encrypted Text to decrypt |
164 | 164 | * @return string Decrypted text |
165 | 165 | */ |
166 | - public static function decryptFromSafeBase64($encrypted){ |
|
166 | + public static function decryptFromSafeBase64($encrypted) { |
|
167 | 167 | $encrypted = str_replace('-', '+', $encrypted); |
168 | 168 | $encrypted = str_replace('_', '/', $encrypted); |
169 | 169 | $encrypted = str_replace('*', '=', $encrypted); |
170 | 170 | $encrypted = base64_decode($encrypted); |
171 | - if($encrypted === false) |
|
171 | + if ($encrypted === false) |
|
172 | 172 | throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
173 | 173 | |
174 | 174 | if (mb_strlen($encrypted, '8bit') < (SODIUM_CRYPTO_SECRETBOX_NONCEBYTES + SODIUM_CRYPTO_SECRETBOX_MACBYTES)) |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | $decrypted = sodium_crypto_secretbox_open($ciphertext, $nonce, self::getBase64EncryptionKey()); |
181 | 181 | |
182 | - if($decrypted === false) { |
|
182 | + if ($decrypted === false) { |
|
183 | 183 | throw new \InvalidArgumentException('The message has been tampered with in transit.'); |
184 | 184 | } |
185 | 185 | |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | * @param string $string Filesystem encoded string to encode |
195 | 195 | * @return string UTF-8 encoded string |
196 | 196 | */ |
197 | - public static function encodeFileSystemToUtf8($string){ |
|
197 | + public static function encodeFileSystemToUtf8($string) { |
|
198 | 198 | if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
199 | - return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
199 | + return iconv('cp1252', 'utf-8//IGNORE', $string); |
|
200 | 200 | } |
201 | 201 | return $string; |
202 | 202 | } |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | * @param string $string UTF-8 encoded string to encode |
208 | 208 | * @return string Filesystem encoded string |
209 | 209 | */ |
210 | - public static function encodeUtf8ToFileSystem($string){ |
|
210 | + public static function encodeUtf8ToFileSystem($string) { |
|
211 | 211 | if (preg_match('//u', $string) && strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
212 | - return iconv('utf-8', 'cp1252//IGNORE' , $string); |
|
212 | + return iconv('utf-8', 'cp1252//IGNORE', $string); |
|
213 | 213 | } |
214 | 214 | return $string; |
215 | 215 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @return boolean True if path valid |
223 | 223 | */ |
224 | 224 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
225 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
225 | + if (strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
226 | 226 | return false; |
227 | 227 | } |
228 | 228 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @return array Array of month short names |
235 | 235 | */ |
236 | 236 | public static function getCalendarShortMonths($calendarId = 0) { |
237 | - if(!isset(self::$calendarShortMonths[$calendarId])) { |
|
237 | + if (!isset(self::$calendarShortMonths[$calendarId])) { |
|
238 | 238 | $calendar_info = cal_info($calendarId); |
239 | 239 | self::$calendarShortMonths[$calendarId] = $calendar_info['abbrevmonths']; |
240 | 240 | } |
@@ -75,16 +75,16 @@ |
||
75 | 75 | |
76 | 76 | $initial = mb_substr($surname, 0, 1); |
77 | 77 | $initials_list = collect($this->indilist_module->surnameAlpha($tree, false, false, I18N::locale())) |
78 | - ->reject(function ($count, $initial): bool { |
|
78 | + ->reject(function($count, $initial): bool { |
|
79 | 79 | |
80 | 80 | return $initial === '@' || $initial === ','; |
81 | 81 | }); |
82 | 82 | |
83 | - $title = I18N::translate('Patronymic Lineages') . ' — ' . $surname; |
|
83 | + $title = I18N::translate('Patronymic Lineages').' — '.$surname; |
|
84 | 84 | |
85 | 85 | $lineages = app()->make(LineageBuilder::class, ['surname' => $surname])->buildLineages(); |
86 | 86 | |
87 | - return $this->viewResponse($this->module->name() . '::lineages-page', [ |
|
87 | + return $this->viewResponse($this->module->name().'::lineages-page', [ |
|
88 | 88 | 'title' => $title, |
89 | 89 | 'module' => $this->module, |
90 | 90 | 'tree' => $tree, |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | $initial = $request->getAttribute('alpha'); |
74 | 74 | $initials_list = collect($this->indilist_module->surnameAlpha($tree, false, false, I18N::locale())) |
75 | - ->reject(function ($count, $initial): bool { |
|
75 | + ->reject(function($count, $initial): bool { |
|
76 | 76 | |
77 | 77 | return $initial === '@' || $initial === ','; |
78 | 78 | }); |
@@ -80,17 +80,17 @@ discard block |
||
80 | 80 | $show_all = $request->getQueryParams()['show_all'] ?? 'no'; |
81 | 81 | |
82 | 82 | if ($show_all === 'yes') { |
83 | - $title = I18N::translate('Patronymic Lineages') . ' — ' . I18N::translate('All'); |
|
83 | + $title = I18N::translate('Patronymic Lineages').' — '.I18N::translate('All'); |
|
84 | 84 | $surnames = $this->indilist_module->surnames($tree, '', '', false, false, I18N::locale()); |
85 | 85 | } elseif ($initial !== null && mb_strlen($initial) == 1) { |
86 | - $title = I18N::translate('Patronymic Lineages') . ' — ' . $initial; |
|
86 | + $title = I18N::translate('Patronymic Lineages').' — '.$initial; |
|
87 | 87 | $surnames = $this->indilist_module->surnames($tree, '', $initial, false, false, I18N::locale()); |
88 | 88 | } else { |
89 | - $title = I18N::translate('Patronymic Lineages'); |
|
89 | + $title = I18N::translate('Patronymic Lineages'); |
|
90 | 90 | $surnames = []; |
91 | 91 | } |
92 | 92 | |
93 | - return $this->viewResponse($this->module->name() . '::surnames-page', [ |
|
93 | + return $this->viewResponse($this->module->name().'::surnames-page', [ |
|
94 | 94 | 'title' => $title, |
95 | 95 | 'module' => $this->module, |
96 | 96 | 'tree' => $tree, |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function loadRoutes(Map $router): void |
63 | 63 | { |
64 | - $router->attach('', '', static function (Map $router): void { |
|
64 | + $router->attach('', '', static function(Map $router): void { |
|
65 | 65 | |
66 | - $router->attach('', '/module-maj/lineages', static function (Map $router): void { |
|
66 | + $router->attach('', '/module-maj/lineages', static function(Map $router): void { |
|
67 | 67 | |
68 | - $router->attach('', '/Page', static function (Map $router): void { |
|
68 | + $router->attach('', '/Page', static function(Map $router): void { |
|
69 | 69 | |
70 | 70 | $router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class); |
71 | 71 | $router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class); |
@@ -122,6 +122,6 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function headContent(): string |
124 | 124 | { |
125 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
125 | + return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">'; |
|
126 | 126 | } |
127 | 127 | } |
@@ -64,11 +64,11 @@ |
||
64 | 64 | $nb_visits_year = $nb_visits_today = null; |
65 | 65 | |
66 | 66 | if ($block_id !== false && $this->module->isMatomoEnabled($block_id)) { |
67 | - $nb_visits_today = (int) $this->matomo_service->visitsToday($this->module, $block_id); |
|
68 | - $nb_visits_year = (int) $this->matomo_service->visitsThisYear($this->module, $block_id) + $nb_visits_today; |
|
67 | + $nb_visits_today = (int)$this->matomo_service->visitsToday($this->module, $block_id); |
|
68 | + $nb_visits_year = (int)$this->matomo_service->visitsThisYear($this->module, $block_id) + $nb_visits_today; |
|
69 | 69 | } |
70 | 70 | |
71 | - return $this->viewResponse($this->module->name() . '::matomo-stats', [ |
|
71 | + return $this->viewResponse($this->module->name().'::matomo-stats', [ |
|
72 | 72 | 'visits_year' => $nb_visits_year, |
73 | 73 | 'visits_today' => $nb_visits_today |
74 | 74 | ]); |