Dodanie obsługi dodatkowych danych producenta oraz informacji o bezpieczeństwie w klasach ShopProducer i ShopProduct

This commit is contained in:
2026-01-04 21:22:28 +01:00
parent f955fdbd54
commit 56fab94f47
10 changed files with 158 additions and 104 deletions

View File

@@ -14,28 +14,30 @@ class ShopProducer
return $mdb -> delete( 'pp_shop_producer', [ 'id' => $producer_id ] );
}
static public function save( $producer_id, $name, int $status, $img, $description, $meta_title )
static public function save( $producer_id, $name, int $status, $img, $description, $data, $meta_title )
{
global $mdb;
if ( !$producer_id )
{
$mdb -> insert( 'pp_shop_producer', [
'name' => $name,
'status' => $status,
'img' => $img
] );
'name' => $name,
'status' => $status,
'img' => $img
] );
$id = $mdb -> id();
foreach ( $description as $key => $val )
$langs = \admin\factory\Languages::languages_list( true );
foreach ( $langs as $lg )
{
$mdb -> insert( 'pp_shop_producer_lang', [
'producer_id' => $id,
'lang_id' => $key,
'description' => $val,
'meta_title' => $meta_title[$key]
] );
'producer_id' => $id,
'lang_id' => $lg['id'],
'description' => $description[ $lg['id'] ] ?? null,
'data' => $data[ $lg['id'] ] ?? null,
'meta_title' => $meta_title[ $lg['id'] ] ?? null
] );
}
\S::htacces();
@@ -46,29 +48,36 @@ class ShopProducer
else
{
$mdb -> update( 'pp_shop_producer', [
'name' => $name,
'status' => $status,
'img' => $img
], [
'id' => (int) $producer_id
] );
'name' => $name,
'status' => $status,
'img' => $img
], [
'id' => (int) $producer_id
] );
foreach ( $description as $key => $val )
$langs = \admin\factory\Languages::languages_list( true );
foreach ( $langs as $lg )
{
if ( $translation_id = $mdb -> get( 'pp_shop_producer_lang', 'id', [ 'AND' => [ 'producer_id' => $producer_id, 'lang_id' => $key ] ] ) )
if ( $translation_id = $mdb -> get( 'pp_shop_producer_lang', 'id', [ 'AND' => [ 'producer_id' => $producer_id, 'lang_id' => $lg['id'] ] ] ) )
{
$mdb -> update( 'pp_shop_producer_lang', [
'description' => $val,
'meta_title' => $meta_title[$key]
'description' => $description[ $lg['id'] ] ?? null,
'meta_title' => $meta_title[ $lg['id'] ] ?? null,
'data' => $data[ $lg['id'] ] ?? null
], [
'id' => $translation_id
] );
}
else
{
$mdb -> insert( 'pp_shop_producer_lang', [
'producer_id' => $producer_id,
'lang_id' => $key,
'description' => $val,
'meta_title' => $meta_title[$key]
'lang_id' => $lg['id'],
'description' => $description[ $lg['id'] ] ?? null,
'data' => $data[ $lg['id'] ] ?? null,
'meta_title' => $meta_title[ $lg['id'] ] ?? null
] );
}
}
\S::htacces();