Skip to content

Commit

Permalink
Merge pull request #945 from Hlavtox/fix-date
Browse files Browse the repository at this point in the history
Fix date formatting
  • Loading branch information
Hlavtox committed Nov 14, 2023
2 parents 8d34c26 + e44e2f2 commit a46852f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions ps_facetedsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,13 @@ private function getExistingFiltersOverview()
$tmp[] = (isset($supportedControllers[$c]) ? $supportedControllers[$c]['name'] : $c);
}
$filters_templates[$k]['controllers'] = implode(', ', $tmp);

// Format date for different core versions. Since 8.0, it has only two arguments.
if (version_compare(_PS_VERSION_, '8.0.0', '>=')) {
$filters_templates[$k]['date_add'] = Tools::displayDate($v['date_add'], true);
} else {
$filters_templates[$k]['date_add'] = Tools::displayDate($v['date_add'], null, true);
}
}

return $filters_templates;
Expand Down
1 change: 1 addition & 0 deletions tests/php/phpstan/phpstan-1.7.6.neon
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ parameters:
- '~^Parameter #1 \$string of method PrestaShop\\Module\\FacetedSearch\\URLSerializer::unserialize\(\) expects string, array given\.$~'
- '~^Call to an undefined static method Search::findClosestWeightestWord\(\)\.$~'
- '~^Parameter #1 \$master of static method DbCore::getInstance\(\) expects bool, int given\.$~'
- '~^Parameter #2 \$id_lang of static method ToolsCore::displayDate\(\) expects int|null, true given\.$~'
1 change: 1 addition & 0 deletions tests/php/phpstan/phpstan-1.7.7.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ parameters:
- '~^Access to an undefined property Cookie::\$id_lang\.$~'
- '~^Parameter #1 \$string of method PrestaShop\\Module\\FacetedSearch\\URLSerializer::unserialize\(\) expects string, array given\.$~'
- '~^Parameter #1 \$master of static method DbCore::getInstance\(\) expects bool, int given\.$~'
- '~^Parameter #2 \$id_lang of static method ToolsCore::displayDate\(\) expects int|null, true given\.$~'
1 change: 1 addition & 0 deletions tests/php/phpstan/phpstan-1.7.8.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ parameters:
- '~^Parameter #\d+ \$\w+ of static method ProductCore::priceCalculation\(\) expects \w+, \w+ given\.$~'
- '~^Access to an undefined property Cookie::\$id_lang\.$~'
- '~^Parameter #1 \$master of static method DbCore::getInstance\(\) expects bool, int given\.$~'
- '~^Parameter #2 \$id_lang of static method ToolsCore::displayDate\(\) expects int|null, true given\.$~'
2 changes: 2 additions & 0 deletions tests/php/phpstan/phpstan-latest.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ parameters:
- '~^Parameter #2 \$active of static method CurrencyCore::getCurrencies\(\) expects bool, int given\.$~'
- '~^Parameter #3 \$groupBy of static method CurrencyCore::getCurrencies\(\) expects bool, Shop given\.$~'
- '~^Parameter #\d+ \$\w+ of static method ProductCore::priceCalculation\(\) expects \w+, \w+ given\.$~'
- '~^Parameter #2 \$full of static method ToolsCore::displayDate\(\) expects bool, null given\.$~'
- '~^Static method ToolsCore::displayDate\(\) invoked with 3 parameters, 1-2 required\.$~'
6 changes: 3 additions & 3 deletions views/templates/admin/manage.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
<tbody>
{foreach $filters_templates as $template}
<tr>
<td class="center">{(int)$template['id_layered_filter']}</td>
<td class="center">{$template['id_layered_filter']}</td>
<td class="text-left">{$template['name']}</td>
<td>{$template['controllers']}</td>
<td class="center">{(int)$template['n_categories']}</td>
<td>{Tools::displayDate($template['date_add'],null , true)}</td>
<td class="center">{$template['n_categories']}</td>
<td>{$template['date_add']}</td>
<td>
{if empty($limit_warning)}
<div class="btn-group-action">
Expand Down

0 comments on commit a46852f

Please sign in to comment.