Skip to content

Commit

Permalink
Major Release v4.0.2023120
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilkware committed Nov 20, 2023
1 parent 2b9538e commit 62e7f11
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .style
Submodule .style updated 1 files
+27 −33 .php-cs-fixer.php
3 changes: 2 additions & 1 deletion Abfall_IO/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion libs/ServiceHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
35 changes: 18 additions & 17 deletions libs/VisualisationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -57,18 +58,18 @@ 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 = '';
$textL = '';
// 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<br /><br />" . $this->Translate('Next pickup:') . "<br />in $days " . $this->Translate('days') . '<br />' . $this->Translate('on') . " $wd $sd";
} else {
Expand All @@ -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 .= '<tr>';
$textL .= '<td><svg class="icon icon--' . $row['type'] . '" aria-hidden="true"><use xlink:href="#icon-waste" href="#icon-waste" /></svg></td>';
$textL .= '<td>' . $row['name'] . '</td>';
Expand Down Expand Up @@ -135,15 +136,15 @@ protected function BuildWidget(array $waste, string $skin)
<!-- Small Cards -->
<div class="cardS">
<div id="grid">
<svg class="icon icon--' . $table[0]['type'] .'" aria-hidden="true"><use xlink:href="#icon-waste" href="#icon-waste" /></svg>
<div class="text">' . $textS. '</div>
<svg class="icon icon--' . $table[0]['type'] . '" aria-hidden="true"><use xlink:href="#icon-waste" href="#icon-waste" /></svg>
<div class="text">' . $textS . '</div>
</div>
</div>
<!-- Medium Cards -->
<div class="cardM">
<div id="grid">
<svg class="icon icon--' . $table[0]['type'] .'" aria-hidden="true"><use xlink:href="#icon-waste" href="#icon-waste" /></svg>
<div class="text">' . $textM. '</div>
<svg class="icon icon--' . $table[0]['type'] . '" aria-hidden="true"><use xlink:href="#icon-waste" href="#icon-waste" /></svg>
<div class="text">' . $textM . '</div>
</div>
</div>
<!-- Large Cards -->
Expand All @@ -152,7 +153,7 @@ protected function BuildWidget(array $waste, string $skin)
<thead >
<tr><th></th><th>' . $removal . '</th><th>' . $date . '</th><th>' . $pickup . '</th></tr>
</thead>' .
$textL .'
$textL . '
</table>
</div>
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libs/_traits.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 62e7f11

Please sign in to comment.