diff --git a/.gitignore b/.gitignore index 16f1349e2..d23cf16a8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ client/html/tests/tmp *.junit.xml *.log *.ser + +.idea +vendor diff --git a/client/html/src/Client/Html/Basket/Standard/Standard.php b/client/html/src/Client/Html/Basket/Standard/Standard.php index 9ab8659fb..1e864549b 100644 --- a/client/html/src/Client/Html/Basket/Standard/Standard.php +++ b/client/html/src/Client/Html/Basket/Standard/Standard.php @@ -12,6 +12,9 @@ namespace Aimeos\Client\Html\Basket\Standard; +use Illuminate\Support\Facades\Log; +use Illuminate\Http\UploadedFile; + /** * Default implementation of standard basket HTML client. * @@ -458,8 +461,18 @@ protected function addCoupon( \Aimeos\MW\View\Iface $view ) */ protected function addProducts( \Aimeos\MW\View\Iface $view ) { + $attrIds[] = \Aimeos\MShop::create( $this->getContext(), 'attribute' )->find( 'custom', [], 'product', 'upload' )->getId(); + + $attrIds[] = \Aimeos\MShop::create( $this->getContext(), 'attribute' )->find( 'file', [], 'product', 'upload' )->getId(); + + $fs = $this->getContext()->fs( 'fs' ); + + if( !$fs->has('basket-upload' ) ) { + $fs->mkdir( 'basket-upload' ); + } + $context = $this->getContext(); - $domains = ['attribute', 'media', 'price', 'product', 'text']; + $domains = ['attribute', 'media', 'price', 'product', 'text', 'custom']; $basketCntl = \Aimeos\Controller\Frontend::create( $context, 'basket' ); $productCntl = \Aimeos\Controller\Frontend::create( $context, 'product' )->uses( $domains ); @@ -482,12 +495,29 @@ protected function addProducts( \Aimeos\MW\View\Iface $view ) $list = []; $entries = (array) $view->param( 'b_prod', [] ); - foreach( $entries as $values ) - { - if( isset( $values['prodid'] ) ) { - $list[] = $values['prodid']; + for($i = 0; $i < count($entries); ++$i) { + $paths = []; + foreach ($attrIds as $attrId) { + if (isset($entries[$i]['attrcustid'][$attrId]) && is_array($entries[$i]['attrcustid'][$attrId])) { + /** @var UploadedFile $file */ + foreach ($entries[$i]['attrcustid'][$attrId] as $file) { + $filepath = 'basket-upload/' . md5($file->getFilename() . microtime(true)) . '.' . $file->extension(); + try { + $stream = fopen($file->getRealPath(), 'r+'); + $fs->writes($filepath, $stream); + fclose($stream); + } catch (\Exception $ex) { + Log::error($ex->getMessage()); + } + $paths[] = $filepath; + } + $entries[$i]['attrcustid'][$attrId] = $paths; + } + if (isset($entries[$i]['prodid'])) { + $list[] = $entries[$i]['prodid']; + } } - } + } foreach( $entries as $values ) { diff --git a/client/html/templates/basket/standard/body-standard.php b/client/html/templates/basket/standard/body-standard.php index 06f5eca2a..2269e8d90 100644 --- a/client/html/templates/basket/standard/body-standard.php +++ b/client/html/templates/basket/standard/body-standard.php @@ -40,7 +40,7 @@ standardBasket ) ) : ?>

html( $this->translate( 'client', 'Basket' ), $enc::TRUST ) ?>

-
+ csrf()->formfield() ?> diff --git a/client/html/templates/catalog/detail/body-standard.php b/client/html/templates/catalog/detail/body-standard.php index 179dd012e..30e371da1 100644 --- a/client/html/templates/catalog/detail/body-standard.php +++ b/client/html/templates/catalog/detail/body-standard.php @@ -170,8 +170,11 @@ block()->get( 'catalog/detail/service' ) ?> - - + + csrf()->formfield() ?> diff --git a/client/html/templates/common/partials/attribute-standard.php b/client/html/templates/common/partials/attribute-standard.php index 3d0b6898b..043e18cc1 100644 --- a/client/html/templates/common/partials/attribute-standard.php +++ b/client/html/templates/common/partials/attribute-standard.php @@ -87,6 +87,36 @@ ?> +