Skip to content

Commit 8735000

Browse files
committed
Fixed component content saving
1 parent f7e2fe1 commit 8735000

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

app/component/post.php

+11-5
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ static function editorSave($id, $fields, $type = 'post') {
111111
$posts = new PostSQL();
112112
$publicPath = \Vvveb\publicUrlPath() . 'media/';
113113

114+
$post = [];
114115
$post_content = [];
115116

116117
foreach ($fields as $field) {
@@ -134,11 +135,16 @@ static function editorSave($id, $fields, $type = 'post') {
134135
}
135136
}
136137
}
137-
//$post['post_content']['post_id'] = $id;
138-
$post_content['language_id'] = 1;
139-
$post['post_content'][] = $post_content;
140-
$post['post_id'] = $id;
141138

142-
$result = $posts->edit(['post' => $post, 'post_id' => $id]);
139+
if ($post) {
140+
//$post['post_id'] = $id;
141+
$result = $posts->edit(['post' => $post, 'post_id' => $id]);
142+
}
143+
144+
if ($post_content) {
145+
$post_content['language_id'] = self :: $global['language_id'];
146+
//$post['post_content']['post_id'] = $id;
147+
$result = $posts->editContent(['post_content' => $post_content, 'post_id' => $id, 'language_id' => self :: $global['language_id']]);
148+
}
143149
}
144150
}

app/component/product.php

+21-9
Original file line numberDiff line numberDiff line change
@@ -125,27 +125,39 @@ static function editorSave($id, $fields, $type = 'product') {
125125
$product_content = [];
126126
$publicPath = \Vvveb\publicUrlPath() . 'media/';
127127

128+
$product = [];
129+
$product_content = [];
130+
128131
foreach ($fields as $field) {
129132
$name = $field['name'];
130133
$value = $field['value'];
131134

132135
if ($name == 'name') {
133136
$product_content[$name] = strip_tags($value);
134137
} else {
135-
if ($name == 'content' || $name == 'excerpt') {
136-
$product_content[$name] = sanitizeHTML($value);
138+
if ($name == 'images') {
137139
} else {
138-
if ($name == 'image') {
139-
$value = str_replace($publicPath,'', $value);
140+
if ($name == 'content' || $name == 'excerpt') {
141+
$product_content[$name] = sanitizeHTML($value);
142+
} else {
143+
if ($name == 'image') {
144+
$value = str_replace($publicPath,'', $value);
145+
}
146+
$product[$name] = $value;
140147
}
141-
$product[$name] = $value;
142148
}
143149
}
144150
}
145151

146-
$product_content['language_id'] = 1;
147-
$product['product_content'][] = $product_content;
148-
$product['product_id'] = $id;
149-
$result = $products->edit(['product' => $product, 'product_id' => $id]);
152+
if ($product) {
153+
//$product['product_id'] = $id;
154+
$result = $products->edit(['product' => $product, 'product_id' => $id]);
155+
}
156+
157+
if ($product_content) {
158+
$product_content['language_id'] = self :: $global['language_id'];
159+
//$product['product_content']['post_id'] = $id;
160+
$result = $products->editContent(['product_content' => $product_content, 'product_id' => $id, 'language_id' => self :: $global['language_id']]);
161+
}
150162
}
151163
}

0 commit comments

Comments
 (0)