Skip to content

Commit

Permalink
Merge pull request from GHSA-fhhq-4x46-qx77
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Borowicz committed Mar 22, 2021
2 parents 57f144f + fa80051 commit aaaba81
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 45 deletions.
20 changes: 1 addition & 19 deletions src/Core/Currency/CurrencyGridDataFactory.php
Expand Up @@ -103,24 +103,6 @@ private function getModifiedRecords(RecordCollectionInterface $records)
*/
private function buildCurrencyName(array $currency)
{
$currencyName = mb_ucfirst($currency['name']);

if (!empty($currency['unofficial'])) {
return sprintf(
'%s %s',
$currencyName,
'<i class="material-icons unofficial">person</i>'
);
}

if (!empty($currency['modified'])) {
return sprintf(
'%s (%s)',
$currencyName,
$this->translator->trans('Edited', [], 'Admin.International.Feature')
);
}

return $currencyName;
return mb_ucfirst($currency['name']);
}
}
63 changes: 63 additions & 0 deletions src/Core/Grid/Column/Type/Currency/NameColumn.php
@@ -0,0 +1,63 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Currency;

use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* Class NameColumn displays currency name with unofficial icon if needed.
*/
final class NameColumn extends AbstractColumn
{
/**
* {@inheritdoc}
*/
public function getType()
{
return 'currency_name';
}

/**
* {@inheritdoc}
*/
protected function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);

$resolver
->setRequired([
'field',
])
->setDefaults([
'clickable' => true,
])
->setAllowedTypes('field', 'string')
->setAllowedTypes('clickable', 'bool')
;
}
}
Expand Up @@ -34,6 +34,7 @@
use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Currency\NameColumn;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn;
use PrestaShop\PrestaShop\Core\Grid\Filter\Filter;
use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection;
Expand Down Expand Up @@ -71,7 +72,7 @@ protected function getName()
protected function getColumns()
{
return (new ColumnCollection())
->add((new DataColumn('currency'))
->add((new NameColumn('currency'))
->setName($this->trans('Currency', [], 'Admin.Global'))
->setOptions([
'field' => 'currency',
Expand Down
@@ -0,0 +1,32 @@
{#**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*#}

{{ record[column.options.field] }}

{% if record.unofficial %}
<i class="material-icons unofficial">person</i>
{% elseif record.modified %}
({{ 'Edited' | trans({}, 'Admin.International.Feature') }})
{% endif %}
@@ -1,26 +1,26 @@
{#**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*#}
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*#}

{{ record[column.options.field]|raw }}
{{ record[column.options.field] }}
Expand Up @@ -58,7 +58,7 @@
</div>
<div class="col-xs-12">
{if $conditions}
<p>{$conditions nofilter}</p>
<p>{$conditions}</p>
{/if}
{if $msg}
<p class="alert {if $nw_error}alert-danger{else}alert-success{/if}">
Expand Down

0 comments on commit aaaba81

Please sign in to comment.