From b48b8aed9769e88fbf557a59201751b5529d7454 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Gomez Date: Fri, 18 Oct 2024 18:29:33 +0200 Subject: [PATCH 1/2] - Solucionado bug al marcar como seleccionados valores como el 0. - Actualizadas las traducciones. --- Core/Lib/Widget/WidgetSelect.php | 4 ++-- Core/Translation/cs_CZ.json | 2 +- Core/Translation/es_ES.json | 2 +- Core/Translation/eu_ES.json | 4 ++-- Core/Translation/pt_BR.json | 4 ++-- Core/Translation/pt_PT.json | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Core/Lib/Widget/WidgetSelect.php b/Core/Lib/Widget/WidgetSelect.php index 37f06d01e..2acd261c3 100644 --- a/Core/Lib/Widget/WidgetSelect.php +++ b/Core/Lib/Widget/WidgetSelect.php @@ -28,7 +28,7 @@ * * @author Carlos García Gómez * @author Jose Antonio Cuello Principal - * @author Daniel Fernández Giménez + * @author Daniel Fernández Giménez */ class WidgetSelect extends BaseWidget { @@ -293,7 +293,7 @@ protected function inputHtml($type = 'text', $extraClass = '') $title = empty($option['title']) ? $option['value'] : $option['title']; // don't use strict comparison (===) - if (!empty($this->value) && in_array($option['value'], explode(',', $this->value))) { + if ($option['value'] == $this->value && (!$found || $this->multiple)) { $found = true; $html .= ''; continue; diff --git a/Core/Translation/cs_CZ.json b/Core/Translation/cs_CZ.json index 948240983..497f6b1e3 100644 --- a/Core/Translation/cs_CZ.json +++ b/Core/Translation/cs_CZ.json @@ -1138,7 +1138,7 @@ "percentage-vat": "% Impuesto", "period": "Periodo", "personalized": "Personalizované", - "pgsql-endpoint": "Bezpečnostní brána PostgreSQL", + "pgsql-endpoint": "Konečný bod PostgreSQL", "pgsql-ssl-mode": "Režim SSL PostgreSQL", "phase": "Fase", "phone": "Teléfono", diff --git a/Core/Translation/es_ES.json b/Core/Translation/es_ES.json index 3839647f8..d6a120782 100644 --- a/Core/Translation/es_ES.json +++ b/Core/Translation/es_ES.json @@ -1015,7 +1015,7 @@ "new-supplier": "Nuevo proveedor", "news": "Noticias", "next": "Siguiente", - "nick": "Apodo", + "nick": "Usuario", "no": "No", "no-data": "Sin datos", "no-data-received-form": "Ningún dato recibido por formulario", diff --git a/Core/Translation/eu_ES.json b/Core/Translation/eu_ES.json index 535ba7020..a87444111 100644 --- a/Core/Translation/eu_ES.json +++ b/Core/Translation/eu_ES.json @@ -940,7 +940,7 @@ "maximum-amount-without-cifnif": "Gehieneko zenbatekoa IFK\/IFZ gabe", "maximum-stock": "Stock maximoa", "may": "Maiatza", - "media-whatsapp-not-upload": "Errorea multimedia fitxategia WhatsApp zerbitzarira igoan: %file%", + "media-whatsapp-not-upload": "Errorea multimedia fitxategia WhatsApp zerbitzarian igoan: %file%", "mega-search": "MegaBilaketa", "memcache": "Memcache", "memcache-clear": "Memcache garbituta.", @@ -1342,7 +1342,7 @@ "second-trimester": "Bigarren hiruhilekoa", "select": "Aukeratu", "select-all": "Guztiak hautatu", - "select-content-for": "%content%-rako edukia hautatu", + "select-content-for": "%content%-erako edukia hautatu", "select-none": "Bat ere ez hautatu", "select-plugin-zip-file": "Hautatu plugin zip fitxategia:", "select-user": "Aukeratu erabiltzailea", diff --git a/Core/Translation/pt_BR.json b/Core/Translation/pt_BR.json index 7c209367b..c780f0c74 100644 --- a/Core/Translation/pt_BR.json +++ b/Core/Translation/pt_BR.json @@ -1078,7 +1078,7 @@ "optional": "opcional", "options": "Opções", "options-button-header": "Maquetação e permissões", - "order": "Ordem", + "order": "Pedido", "order-email-subject": "O seu pedido %code%", "order-email-text": "Olá, vai anexo a sua Nota de Encomenda\/Pedido %code%", "orders": "Pedidos", @@ -1587,7 +1587,7 @@ "unit-profit": "lucro unitário", "unit-purchase-price": "Preço de compra por unidade", "unit-sale-price": "Preço de venda unit.", - "unlimited": "Ilimitado", + "unlimited": "Sem limites", "unlink": "Desvincular", "unlink-file": "Desvincular arquivo", "unlink-install-ok": "Instalação excluída do registro corretamente.", diff --git a/Core/Translation/pt_PT.json b/Core/Translation/pt_PT.json index 8da58eed7..bdb19affa 100644 --- a/Core/Translation/pt_PT.json +++ b/Core/Translation/pt_PT.json @@ -1587,7 +1587,7 @@ "unit-profit": "Lucro unitário", "unit-purchase-price": "Preço de compra unitário", "unit-sale-price": "Preço de venda unit.", - "unlimited": "Ilimitado", + "unlimited": "Sem limites", "unlink": "Desvincular", "unlink-file": "Desvincular arquivo", "unlink-install-ok": "Instalação removida do registro corretamente.", From 1bb461ffb89597132eb11c2c8fb7519ed07a1565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Fern=C3=A1ndez?= Date: Tue, 12 Nov 2024 13:59:25 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Permite=20a=C3=B1adir=20bloques=20en=20las?= =?UTF-8?q?=20notificaciones=20de=20email?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/Lib/Email/MailNotifier.php | 49 +++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/Core/Lib/Email/MailNotifier.php b/Core/Lib/Email/MailNotifier.php index 0f609ef87..0123db0a4 100644 --- a/Core/Lib/Email/MailNotifier.php +++ b/Core/Lib/Email/MailNotifier.php @@ -37,7 +37,9 @@ class MailNotifier public static function getText(string $text, array $params): string { foreach ($params as $key => $value) { - $text = str_replace('{' . $key . '}', $value, $text); + if (is_string($value)) { + $text = str_replace('{' . $key . '}', $value, $text); + } } return $text; @@ -81,6 +83,7 @@ public static function send(string $notificationName, string $email, string $nam $newMail->to($email, $name); $newMail->title = static::getText($notification->subject, $params); $newMail->text = static::getText($notification->body, $params); + static::replaceTextToBlock($newMail, $params); foreach ($mainBlocks as $block) { $newMail->addMainBlock($block); @@ -96,4 +99,46 @@ public static function send(string $notificationName, string $email, string $nam return $newMail->send(); } -} + + protected static function replaceTextToBlock(DinNewMail &$newMail, array $params): void + { + // si no hay parámetros o texto, no hacemos nada + if (empty($params) || empty($newMail->text)) { + return; + } + + // obtenemos las coincidencias de {block1}, {block2}, ... sobre el texto + preg_match_all('/{block(\d+)}/', $newMail->text, $matches); + + // si no hay coincidencias, no hacemos nada + if (empty($matches[1])) { + return; + } + + // obtenemos el texto hasta el primer bloque, y entre los bloques + // para añadir un TextBlock con el texto encontrado + $text = $newMail->text; + $newMail->text = ''; + $lastPos = 0; + + // recorremos los bloques encontrados + foreach ($matches[1] as $index => $blockIndex) { + $substr = substr($text, $lastPos, strpos($text, '{block' . $blockIndex . '}') - $lastPos); + $lastPos = strpos($text, '{block' . $blockIndex . '}') + strlen('{block' . $blockIndex . '}'); + if (empty($substr) && isset($params['block' . $blockIndex]) && $params['block' . $blockIndex] instanceof BaseBlock) { + $newMail->addMainBlock($params['block' . $blockIndex]); + continue; + } + + $newMail->addMainBlock(new TextBlock($substr)); + if (isset($params['block' . $blockIndex]) && $params['block' . $blockIndex] instanceof BaseBlock) { + $newMail->addMainBlock($params['block' . $blockIndex]); + } + } + + $substr = substr($text, $lastPos); + if (false === empty($substr)) { + $newMail->addMainBlock(new TextBlock($substr)); + } + } +} \ No newline at end of file