mirror of
https://github.com/Relintai/pandemonium_cms.git
synced 2024-11-14 09:37:19 +01:00
Implemented web interface for the WebPageEntryImage.
This commit is contained in:
parent
be1cabc9d2
commit
d6380afe34
@ -40,6 +40,78 @@ func _render(request : WebServerRequest):
|
||||
|
||||
request.body += '>'
|
||||
|
||||
func _handle_edit(request : WebServerRequest) -> void:
|
||||
if !request.can_edit():
|
||||
#should be ERR_FAIL_COND
|
||||
return
|
||||
|
||||
var b : HTMLBuilder = HTMLBuilder.new()
|
||||
|
||||
if request.get_method() == HTTPServerEnums.HTTP_METHOD_POST:
|
||||
image_url = request.get_parameter("image_url")
|
||||
alt = request.get_parameter("image_alt")
|
||||
|
||||
var imgssx : String = request.get_parameter("image_size_x")
|
||||
var imgssy : String = request.get_parameter("image_size_y")
|
||||
|
||||
image_size = Vector2i(imgssx.to_int(), imgssy.to_int())
|
||||
|
||||
if request.get_file_count() > 0:
|
||||
var fd : PoolByteArray = request.get_file_data(0)
|
||||
|
||||
if fd.size() > 0:
|
||||
var fn : String = request.get_file_file_name(0)
|
||||
var f : File = File.new()
|
||||
f.open("user://" + fn, File.WRITE)
|
||||
f.store_buffer(fd)
|
||||
f.close()
|
||||
|
||||
image_path = "user://" + fn
|
||||
|
||||
|
||||
#b.div().f().w("Save successful!").cdiv()
|
||||
request.send_redirect(request.get_url_root_parent(2))
|
||||
|
||||
b.div().f().a(request.get_url_root_parent(2)).f().w("<-- back").ca().cdiv()
|
||||
b.br()
|
||||
|
||||
b.h1().f().w("Editing: Image").ch1()
|
||||
b.br()
|
||||
|
||||
b.form_post(request.get_url_root()).enctype_multipart_form_data()
|
||||
b.csrf_tokenr(request)
|
||||
|
||||
b.label().fora("image_url").f().w("Image URL:").clabel().br()
|
||||
b.input_text("image_url", image_url, "", "", "image_url")
|
||||
b.br()
|
||||
|
||||
b.label().fora("image_alt").f().w("Image alt:").clabel().br()
|
||||
b.input_text("image_alt", alt, "", "", "image_alt")
|
||||
b.br()
|
||||
|
||||
b.label().fora("image_size_x").f().w("Image Width (Optional):").clabel().br()
|
||||
b.input_number("image_size_x", "0", "999990", "", "image_size_x").value(str(image_size.x))
|
||||
b.br()
|
||||
|
||||
b.label().fora("image_size_y").f().w("Image Heigth (Optional):").clabel().br()
|
||||
b.input_number("image_size_y", "0", "999990", "", "image_size_y").value(str(image_size.y))
|
||||
b.br()
|
||||
|
||||
b.label().fora("image").f().w("Add / Replace Image:").clabel().br()
|
||||
b.input_file("image", "image/png, image/jpeg", "", "image")
|
||||
b.br()
|
||||
|
||||
b.input_submit("Save")
|
||||
b.cform()
|
||||
b.br()
|
||||
|
||||
|
||||
|
||||
b.br()
|
||||
|
||||
request.body += b.result
|
||||
request.compile_and_send_body()
|
||||
|
||||
func _get_editor() -> Control:
|
||||
var WebPageEntryImageEditor : PackedScene = ResourceLoader.load("res://addons/web_pages/editor/post_entries/WebPageEntryImageEditor.tscn", "PackedScene")
|
||||
return WebPageEntryImageEditor.instance() as Control
|
||||
|
Loading…
Reference in New Issue
Block a user