diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 2cce339..793693f 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -11,6 +11,6 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.2 - name: Check style uses: wilkware/action-ips-style@main \ No newline at end of file diff --git a/.style b/.style index fe04d92..c3da0b4 160000 --- a/.style +++ b/.style @@ -1 +1 @@ -Subproject commit fe04d922f53d36e19d91a7f8dfe4ca7c66ed62a4 +Subproject commit c3da0b498e05763595d29a223dbad7e9c12ce556 diff --git a/Abfall_IO/module.php b/Abfall_IO/module.php index 1161edc..8101c46 100644 --- a/Abfall_IO/module.php +++ b/Abfall_IO/module.php @@ -478,7 +478,8 @@ public function Update() } // CSV format else { - $csv = array_map(function ($v) { + $csv = array_map(function ($v) + { $data = str_getcsv($v, ';'); return $data; }, explode("\n", $res)); diff --git a/libs/ServiceHelper.php b/libs/ServiceHelper.php index 6b042a6..6f77849 100644 --- a/libs/ServiceHelper.php +++ b/libs/ServiceHelper.php @@ -134,7 +134,8 @@ private function OrderData(array $arr, string $key = null, string $direction = ' } } // Sort by passed keys - usort($arr, function ($a, $b) use ($props) { + usort($arr, function ($a, $b) use ($props) + { foreach ($props as $key => $val) { if ($a[$key] == $b[$key]) { continue; diff --git a/libs/VisualisationHelper.php b/libs/VisualisationHelper.php index c6f21ed..c93ef74 100644 --- a/libs/VisualisationHelper.php +++ b/libs/VisualisationHelper.php @@ -30,18 +30,19 @@ protected function BuildWidget(array $waste, string $skin) // (0) tabel with all infos $table = []; // (1) build new data array - foreach($waste as $key => $value) { + foreach ($waste as $key => $value) { $id = @$this->GetIDForIdent($value['ident']); if ($id !== false) { $name = IPS_GetName($id); $type = $this->RecognizeWaste($name); $date = $value['date']; $days = $this->CalcDaysToDate($date); - $table[] = ['name' => $name, 'type' => $type, 'date' => $date, 'days' => $days ]; + $table[] = ['name' => $name, 'type' => $type, 'date' => $date, 'days' => $days]; } } // (2) sort waste by date - usort($table, function ($a, $b) { + usort($table, function ($a, $b) + { return strtotime($a['date']) - strtotime($b['date']); }); // (3) build html texts @@ -57,7 +58,7 @@ protected function BuildWidget(array $waste, string $skin) // generate widget for tile visu if ($next == '') { $next = date('d.m.', strtotime($table[0]['date'])); - $next = $this->Translate(date('D', strtotime($table[0]['date']))) . '. ' . $next; + $next = $this->Translate(date('D', strtotime($table[0]['date']))) . '. ' . $next; } $textS = ''; $textM = ''; @@ -65,10 +66,10 @@ protected function BuildWidget(array $waste, string $skin) // date infos $days = $table[0]['days']; $day = strtotime($table[0]['date']); - $wd = $this->Translate (date('l')); + $wd = $this->Translate(date('l')); $sd = date('d.m.', $day); $wn = $table[0]['name']; - if($days > 1) { + if ($days > 1) { $textS = "in $days " . $this->Translate('days'); $textM = "$wn

" . $this->Translate('Next pickup:') . "
in $days " . $this->Translate('days') . '
' . $this->Translate('on') . " $wd $sd"; } else { @@ -77,10 +78,10 @@ protected function BuildWidget(array $waste, string $skin) } // table rows $textL = ''; - foreach($table as $row) { + foreach ($table as $row) { if ($row['days'] == 0) $text = $this->Translate('Today'); if ($row['days'] == 1) $text = $this->Translate('Tomorrow'); - if ($row['days'] >= 2) $text = $row['days'] . ' ' . $this->Translate('days'); + if ($row['days'] >= 2) $text = $row['days'] . ' ' . $this->Translate('days'); $textL .= ''; $textL .= ''; $textL .= '' . $row['name'] . ''; @@ -135,15 +136,15 @@ protected function BuildWidget(array $waste, string $skin)
- -
' . $textS. '
+ +
' . $textS . '
- -
' . $textM. '
+ +
' . $textM . '
@@ -152,7 +153,7 @@ protected function BuildWidget(array $waste, string $skin) ' . $removal . '' . $date . '' . $pickup . ' ' . - $textL .' + $textL . ' @@ -187,16 +188,16 @@ private function CalcDaysToDate($startDate, $endDate = null) */ private function RecognizeWaste($name) { - if(preg_match("/(papier|pappe|zeitung)/i", $name)){ + if (preg_match('/(papier|pappe|zeitung)/i', $name)) { return 'blue'; } - if(preg_match("/(bio|grün|garten|baum|schnittgut)/i", $name)){ + if (preg_match('/(bio|grün|garten|baum|schnittgut)/i', $name)) { return 'green'; } - if(preg_match("/(gelb|plast|pvc)/i", $name)){ + if (preg_match('/(gelb|plast|pvc)/i', $name)) { return 'yellow'; } - if(preg_match("/(schadstoff|sonder|sperr)/i", $name)){ + if (preg_match('/(schadstoff|sonder|sperr)/i', $name)) { return 'red'; } // Rest or all others diff --git a/libs/_traits.php b/libs/_traits.php index a114d82..a5dfb02 100644 --- a/libs/_traits.php +++ b/libs/_traits.php @@ -171,7 +171,7 @@ define('IS_ACTIVE', IS_SBASE + 2); //module created and running define('IS_DELETING', IS_SBASE + 3); //module us being deleted define('IS_INACTIVE', IS_SBASE + 4); //module is not beeing used -// --- ERROR CODES + // --- ERROR CODES define('IS_EBASE', 200); //default errorcode define('IS_NOTCREATED', IS_EBASE + 1); //instance could not be created }