forked from Cavemanon/cavepaintings
Fixed issues with next/prev post functionality not working with certin URL setups, as the query was not making it back to the server, or was being lost on redirect
This commit is contained in:
@ -9,11 +9,11 @@ class ImageIOTheme extends Themelet
|
|||||||
*/
|
*/
|
||||||
public function get_deleter_html(int $image_id): string
|
public function get_deleter_html(int $image_id): string
|
||||||
{
|
{
|
||||||
return (string)SHM_SIMPLE_FORM(
|
return (string)"<span id='image_delete_form'>".SHM_SIMPLE_FORM(
|
||||||
"image/delete",
|
"image/delete",
|
||||||
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]),
|
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]),
|
||||||
INPUT(["type"=>'submit', "value"=>'Delete', "onclick"=>'return confirm("Delete the image?");']),
|
INPUT(["type"=>'submit', "value"=>'Delete', "onclick"=>'return confirm("Delete the image?");', "id"=>"image_delete_button"]),
|
||||||
);
|
)."</span>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,7 +77,13 @@ class ViewImage extends Extension
|
|||||||
if (!$image->is_locked() || $user->can(Permissions::EDIT_IMAGE_LOCK)) {
|
if (!$image->is_locked() || $user->can(Permissions::EDIT_IMAGE_LOCK)) {
|
||||||
send_event(new ImageInfoSetEvent($image));
|
send_event(new ImageInfoSetEvent($image));
|
||||||
$page->set_mode(PageMode::REDIRECT);
|
$page->set_mode(PageMode::REDIRECT);
|
||||||
$page->set_redirect(make_link("post/view/$image_id", url_escape(@$_POST['query'])));
|
|
||||||
|
if (isset($_GET['search'])) {
|
||||||
|
$query = "search=" . url_escape($_GET['search']);
|
||||||
|
} else {
|
||||||
|
$query = null;
|
||||||
|
}
|
||||||
|
$page->set_redirect(make_link("post/view/$image_id", null, $query));
|
||||||
} else {
|
} else {
|
||||||
$this->theme->display_error(403, "Post Locked", "An admin has locked this post");
|
$this->theme->display_error(403, "Post Locked", "An admin has locked this post");
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,29 @@
|
|||||||
|
function joinUrlSegments(base, query) {
|
||||||
|
let separatorChar = "?";
|
||||||
|
if(base.includes("?")) {
|
||||||
|
separatorChar = "&";
|
||||||
|
}
|
||||||
|
return base + separatorChar + query;
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
if(document.location.hash.length > 3) {
|
if(document.location.hash.length > 3) {
|
||||||
var query = document.location.hash.substring(1);
|
var query = document.location.hash.substring(1);
|
||||||
|
|
||||||
$('LINK#prevlink').attr('href', function(i, attr) {
|
$('LINK#prevlink').attr('href', function(i, attr) {
|
||||||
return attr + '?' + query;
|
return joinUrlSegments(attr,query);
|
||||||
});
|
});
|
||||||
$('LINK#nextlink').attr('href', function(i, attr) {
|
$('LINK#nextlink').attr('href', function(i, attr) {
|
||||||
return attr + '?' + query;
|
return joinUrlSegments(attr,query);
|
||||||
});
|
});
|
||||||
$('A#prevlink').attr('href', function(i, attr) {
|
$('A#prevlink').attr('href', function(i, attr) {
|
||||||
return attr + '?' + query;
|
return joinUrlSegments(attr,query);
|
||||||
});
|
});
|
||||||
$('A#nextlink').attr('href', function(i, attr) {
|
$('A#nextlink').attr('href', function(i, attr) {
|
||||||
return attr + '?' + query;
|
return joinUrlSegments(attr,query);
|
||||||
|
});
|
||||||
|
$('span#image_delete_form form').attr('action', function(i, attr) {
|
||||||
|
return joinUrlSegments(attr,query);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user