mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 17:25:26 +02:00
#9073 added system system for edit images in edit tip
This commit is contained in:
parent
c92c355a3e
commit
8ea9a0fc7e
@ -88,8 +88,14 @@ if ($view === 'create' || $view === 'edit') {
|
|||||||
|
|
||||||
case 'edit':
|
case 'edit':
|
||||||
$idTip = get_parameter('idTip', '');
|
$idTip = get_parameter('idTip', '');
|
||||||
|
$imagesToDelete = get_parameter('images_to_delete', '');
|
||||||
if (empty($idTip) === false) {
|
if (empty($idTip) === false) {
|
||||||
if (count($errors) === 0) {
|
if (count($errors) === 0) {
|
||||||
|
if (empty($imagesToDelete) === false) {
|
||||||
|
$imagesToDelete = json_decode(io_safe_output($imagesToDelete), true);
|
||||||
|
$tipsWindow->deleteImagesFromTip($idTip, $imagesToDelete);
|
||||||
|
}
|
||||||
|
|
||||||
if (count($files) > 0) {
|
if (count($files) > 0) {
|
||||||
$uploadImages = $tipsWindow->uploadImages($files);
|
$uploadImages = $tipsWindow->uploadImages($files);
|
||||||
}
|
}
|
||||||
|
@ -251,13 +251,28 @@ class TipsWindow
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = sprintf('SELECT filename, path FROM twelcome_tip_file WHERE twelcome_tip_file = %s', $idTip);
|
$sql = sprintf('SELECT id, filename, path FROM twelcome_tip_file WHERE twelcome_tip_file = %s', $idTip);
|
||||||
|
|
||||||
return db_get_all_rows_sql($sql);
|
return db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function deleteImagesFromTip($idTip, $imagesToRemove)
|
||||||
|
{
|
||||||
|
foreach ($imagesToRemove as $id => $image) {
|
||||||
|
unlink($image);
|
||||||
|
db_process_sql_delete(
|
||||||
|
'twelcome_tip_file',
|
||||||
|
[
|
||||||
|
'id' => $id,
|
||||||
|
'twelcome_tip_file' => $idTip,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function setShowTipsAtStartup()
|
public function setShowTipsAtStartup()
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
@ -527,7 +542,6 @@ class TipsWindow
|
|||||||
|
|
||||||
$table->data = [];
|
$table->data = [];
|
||||||
$table->data[0][0] = __('Images');
|
$table->data[0][0] = __('Images');
|
||||||
$table->data[0][1] = html_print_input_hidden('number_images', 0, true);
|
|
||||||
$table->data[0][1] .= html_print_div(['id' => 'inputs_images'], true);
|
$table->data[0][1] .= html_print_div(['id' => 'inputs_images'], true);
|
||||||
$table->data[0][1] .= html_print_button(__('Add image'), 'button_add_image', false, '', '', true);
|
$table->data[0][1] .= html_print_button(__('Add image'), 'button_add_image', false, '', '', true);
|
||||||
$table->data[1][0] = __('Language');
|
$table->data[1][0] = __('Language');
|
||||||
@ -581,6 +595,29 @@ class TipsWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$outputImagesTip = '';
|
||||||
|
if (empty($files) === false) {
|
||||||
|
foreach ($files as $key => $value) {
|
||||||
|
$namePath = $value['path'].$value['filename'];
|
||||||
|
$imageTip = html_print_image($namePath, true);
|
||||||
|
$imageTip .= html_print_input_image(
|
||||||
|
'delete_image_tip',
|
||||||
|
'images/delete.png',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
true,
|
||||||
|
['onclick' => 'deleteImage(this, \''.$value['id'].'\', \''.$namePath.'\')']
|
||||||
|
);
|
||||||
|
$outputImagesTip .= html_print_div(
|
||||||
|
[
|
||||||
|
'class' => 'image-tip',
|
||||||
|
'content' => $imageTip,
|
||||||
|
],
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$table = new stdClass();
|
$table = new stdClass();
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
$table->class = 'databox filters';
|
$table->class = 'databox filters';
|
||||||
@ -589,8 +626,9 @@ class TipsWindow
|
|||||||
|
|
||||||
$table->data = [];
|
$table->data = [];
|
||||||
$table->data[0][0] = __('Images');
|
$table->data[0][0] = __('Images');
|
||||||
$table->data[0][1] = html_print_input_hidden('number_images', 0, true);
|
$table->data[0][1] .= $outputImagesTip;
|
||||||
$table->data[0][1] .= html_print_div(['id' => 'inputs_images'], true);
|
$table->data[0][1] .= html_print_div(['id' => 'inputs_images'], true);
|
||||||
|
$table->data[0][1] .= html_print_input_hidden('images_to_delete', '{}', true);
|
||||||
$table->data[0][1] .= html_print_button(__('Add image'), 'button_add_image', false, '', '', true);
|
$table->data[0][1] .= html_print_button(__('Add image'), 'button_add_image', false, '', '', true);
|
||||||
$table->data[1][0] = __('Language');
|
$table->data[1][0] = __('Language');
|
||||||
$table->data[1][1] = html_print_select_from_sql(
|
$table->data[1][1] = html_print_select_from_sql(
|
||||||
@ -744,8 +782,8 @@ class TipsWindow
|
|||||||
$imagesOk = [];
|
$imagesOk = [];
|
||||||
foreach ($files as $key => $file) {
|
foreach ($files as $key => $file) {
|
||||||
$name = str_replace(' ', '_', $file['name']);
|
$name = str_replace(' ', '_', $file['name']);
|
||||||
$name = str_replace('.', uniqid().'.', $file['name']);
|
$name = str_replace('.', uniqid().'.', $name);
|
||||||
$r = move_uploaded_file($file['tmp_name'], $dir.'/'.$name);
|
move_uploaded_file($file['tmp_name'], $dir.'/'.$name);
|
||||||
$imagesOk[] = $name;
|
$imagesOk[] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,9 @@ $(document).ready(function() {
|
|||||||
);
|
);
|
||||||
$("#inputs_images").append(div_image);
|
$("#inputs_images").append(div_image);
|
||||||
});
|
});
|
||||||
|
$("#image-delete_image_tip1").on("click", function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
$(".carousel .images").ready(function() {
|
$(".carousel .images").ready(function() {
|
||||||
activeCarousel();
|
activeCarousel();
|
||||||
@ -38,6 +41,15 @@ $("#checkbox_tips_startup").ready(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function deleteImage(e, id, path) {
|
||||||
|
var imagesToDelete = JSON.parse($("#hidden-images_to_delete").val());
|
||||||
|
imagesToDelete[id] = path;
|
||||||
|
$("#hidden-images_to_delete").val(JSON.stringify(imagesToDelete));
|
||||||
|
$(e)
|
||||||
|
.parent()
|
||||||
|
.remove();
|
||||||
|
}
|
||||||
function activeCarousel() {
|
function activeCarousel() {
|
||||||
if ($(".carousel .images img").length > 1) {
|
if ($(".carousel .images img").length > 1) {
|
||||||
$(".carousel .images").bxSlider({ controls: true });
|
$(".carousel .images").bxSlider({ controls: true });
|
||||||
|
@ -183,3 +183,10 @@ span.disable {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
.image-tip {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.image-tip img {
|
||||||
|
max-width: 350px;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user