From e99c19b7fa5f0ac1776658f09df8b719284e0163 Mon Sep 17 00:00:00 2001 From: Chee Hau Lee Date: Wed, 21 Jul 2021 14:43:52 +0800 Subject: [PATCH 1/3] Update Supplier.php --- .../Service/Provider/Decorator/Supplier.php | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php b/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php index 83b12250fa..fb23c01313 100644 --- a/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php +++ b/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php @@ -21,6 +21,18 @@ class Supplier extends \Aimeos\MShop\Service\Provider\Decorator\Base implements \Aimeos\MShop\Service\Provider\Decorator\Iface { + private $beConfig = array( + 'supplier.addressformat' => array( + 'code' => 'supplier.addressformat', + 'internalcode' => 'supplier.addressformat', + 'label' => 'Change how supplier address display.', + 'type' => 'string', + 'internaltype' => 'string', + 'default' => 'short', + 'required' => false, + ), + ); + private $feConfig = array( 'supplier.code' => array( 'code' => 'supplier.code', @@ -64,12 +76,7 @@ public function __construct( \Aimeos\MShop\Service\Provider\Iface $provider, { $addrId = ( count( $addresses ) > 1 ) ? $item->getCode() . '-' . $id : $item->getCode(); - $this->feConfig['supplier.code']['default'][$addrId] = trim( preg_replace( "/\n+/m", "\n", sprintf( - /// Supplier address format with label (%1$s), company (%2$s), - /// address part one (%3$s, e.g street), address part two (%4$s, e.g house number), address part three (%5$s, e.g additional information), - /// postal/zip code (%6$s), city (%7$s), state (%8$s), country ID (%9$s), - /// e-mail (%10$s), phone (%11$s), facsimile/telefax (%12$s), web site (%13$s) - $context->getI18n()->dt( 'mshop', '%1$s + $format = $this->getConfigValue( 'supplier.addressformat', '%1$s %2$s %3$s %4$s %5$s @@ -79,7 +86,14 @@ public function __construct( \Aimeos\MShop\Service\Provider\Iface $provider, %11$s %12$s %13$s' - ), + ); + + $this->feConfig['supplier.code']['default'][$addrId] = trim( preg_replace( "/\n+/m", "\n", sprintf( + /// Supplier address format with label (%1$s), company (%2$s), + /// address part one (%3$s, e.g street), address part two (%4$s, e.g house number), address part three (%5$s, e.g additional information), + /// postal/zip code (%6$s), city (%7$s), state (%8$s), country ID (%9$s), + /// e-mail (%10$s), phone (%11$s), facsimile/telefax (%12$s), web site (%13$s) + $context->getI18n()->dt( 'mshop', $format ), $item->getLabel(), $addr->getCompany(), $addr->getAddress1(), @@ -179,7 +193,7 @@ public function setConfigFE( \Aimeos\MShop\Order\Item\Base\Service\Iface $orderS if( ( $code = $attributes['supplier.code'] ) != '' ) { // add short address as attribute for summary page / customer email - $attributes['supplier.address'] = $this->feConfig['supplier.code']['short'][$code]; + $attributes['supplier.address'] = $this->feConfig['supplier.code']['default'][$code]; // remove code attribute for summary page / customer email $this->setAttributes( $orderServiceItem, ['supplier.code' => $attributes['supplier.code']], 'hidden' ); From e8334ca5c7d0313d0b2bdc9e0cd183f177de2b30 Mon Sep 17 00:00:00 2001 From: Chee Hau Lee Date: Wed, 21 Jul 2021 17:49:39 +0800 Subject: [PATCH 2/3] Update Supplier.php --- .../Service/Provider/Decorator/Supplier.php | 67 ++++++++++++------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php b/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php index fb23c01313..4116ef4bfb 100644 --- a/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php +++ b/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php @@ -25,10 +25,19 @@ class Supplier 'supplier.addressformat' => array( 'code' => 'supplier.addressformat', 'internalcode' => 'supplier.addressformat', - 'label' => 'Change how supplier address display.', + 'label' => 'Change supplier address format.', 'type' => 'string', 'internaltype' => 'string', - 'default' => 'short', + 'default' => '%1$s +%2$s +%3$s %4$s +%5$s +%6$s %7$s +%8$s %9$s +%10$s +%11$s +%12$s +%13$s', 'required' => false, ), ); @@ -76,6 +85,10 @@ public function __construct( \Aimeos\MShop\Service\Provider\Iface $provider, { $addrId = ( count( $addresses ) > 1 ) ? $item->getCode() . '-' . $id : $item->getCode(); + /// Supplier address format with label (%1$s), company (%2$s), + /// address part one (%3$s, e.g street), address part two (%4$s, e.g house number), address part three (%5$s, e.g additional information), + /// postal/zip code (%6$s), city (%7$s), state (%8$s), country ID (%9$s), + /// e-mail (%10$s), phone (%11$s), facsimile/telefax (%12$s), web site (%13$s) $format = $this->getConfigValue( 'supplier.addressformat', '%1$s %2$s %3$s %4$s @@ -89,10 +102,6 @@ public function __construct( \Aimeos\MShop\Service\Provider\Iface $provider, ); $this->feConfig['supplier.code']['default'][$addrId] = trim( preg_replace( "/\n+/m", "\n", sprintf( - /// Supplier address format with label (%1$s), company (%2$s), - /// address part one (%3$s, e.g street), address part two (%4$s, e.g house number), address part three (%5$s, e.g additional information), - /// postal/zip code (%6$s), city (%7$s), state (%8$s), country ID (%9$s), - /// e-mail (%10$s), phone (%11$s), facsimile/telefax (%12$s), web site (%13$s) $context->getI18n()->dt( 'mshop', $format ), $item->getLabel(), $addr->getCompany(), @@ -109,30 +118,36 @@ public function __construct( \Aimeos\MShop\Service\Provider\Iface $provider, $addr->getWebsite() ) ) ); - $this->feConfig['supplier.code']['short'][$addrId] = trim( preg_replace( "/\n+/m", "\n", sprintf( - /// Supplier address format with label (%1$s), company (%2$s), - /// address part one (%3$s, e.g street), address part two (%4$s, e.g house number), address part three (%5$s, e.g additional information), - /// postal/zip code (%6$s), city (%7$s), state (%8$s), country ID (%9$s), - /// e-mail (%10$s), phone (%11$s), facsimile/telefax (%12$s), web site (%13$s) - $context->getI18n()->dt( 'mshop', '%1$s, %2$s, %3$s %4$s, %6$s %7$s' ), - $item->getLabel(), - $addr->getCompany(), - $addr->getAddress1(), - $addr->getAddress2(), - $addr->getAddress3(), - $addr->getPostal(), - $addr->getCity(), - $addr->getState(), - $addr->getCountryId(), - $addr->getEmail(), - $addr->getTelephone(), - $addr->getTelefax(), - $addr->getWebsite() - ) ) ); } } } + /** + * Checks the backend configuration attributes for validity. + * + * @param array $attributes Attributes added by the shop owner in the administraton interface + * @return array An array with the attribute keys as key and an error message as values for all attributes that are + * known by the provider but aren't valid + */ + public function checkConfigBE( array $attributes ) : array + { + $error = $this->getProvider()->checkConfigBE( $attributes ); + $error += $this->checkConfig( $this->beConfig, $attributes ); + + return $error; + } + + + /** + * Returns the configuration attribute definitions of the provider to generate a list of available fields and + * rules for the value of each field in the administration interface. + * + * @return array List of attribute definitions implementing \Aimeos\MW\Common\Critera\Attribute\Iface + */ + public function getConfigBE() : array + { + return array_merge( $this->getProvider()->getConfigBE(), $this->getConfigItems( $this->beConfig ) ); + } /** * Checks the frontend configuration attributes for validity. From e9e049db51fd341da0d15317783f0461818a9640 Mon Sep 17 00:00:00 2001 From: Chee Hau Lee Date: Wed, 21 Jul 2021 18:32:37 +0800 Subject: [PATCH 3/3] Update Supplier.php --- .../src/MShop/Service/Provider/Decorator/Supplier.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php b/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php index 4116ef4bfb..aab3545e81 100644 --- a/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php +++ b/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php @@ -26,8 +26,8 @@ class Supplier 'code' => 'supplier.addressformat', 'internalcode' => 'supplier.addressformat', 'label' => 'Change supplier address format.', - 'type' => 'string', - 'internaltype' => 'string', + 'type' => 'text', + 'internaltype' => 'text', 'default' => '%1$s %2$s %3$s %4$s