mirror of
https://github.com/Relintai/pandemonium_cms.git
synced 2024-11-14 09:37:19 +01:00
Restructured some of the logic and methods to make theming easier.
This commit is contained in:
parent
fbf751c28d
commit
35448d019a
@ -9,8 +9,6 @@ export(Array, Resource) var entries : Array
|
||||
|
||||
signal entries_changed()
|
||||
|
||||
#TODO fix webperm assign
|
||||
|
||||
func _handle_request(request : WebServerRequest):
|
||||
if request.get_remaining_segment_count() > 0:
|
||||
if allow_web_interface_editing:
|
||||
@ -264,6 +262,24 @@ func web_editor_handle_delete(request : WebServerRequest) -> bool:
|
||||
|
||||
return true
|
||||
|
||||
func create_entry(cls_name : String) -> WebPageEntry:
|
||||
return _create_entry(cls_name)
|
||||
|
||||
func _create_entry(cls_name : String) -> WebPageEntry:
|
||||
var entry : WebPageEntry = null
|
||||
|
||||
if cls_name == "WebPageEntryTitleText":
|
||||
entry = WebPageEntryTitleText.new()
|
||||
elif cls_name == "WebPageEntryText":
|
||||
entry = WebPageEntryText.new()
|
||||
elif cls_name == "WebPageEntryImage":
|
||||
entry = WebPageEntryImage.new()
|
||||
|
||||
if !entry:
|
||||
PLogger.log_error("PageEditor: Couldn't create entry for: " + cls_name)
|
||||
|
||||
return entry
|
||||
|
||||
func get_next_id() -> int:
|
||||
var id : int = 0
|
||||
for i in range(entries.size()):
|
||||
|
@ -48,5 +48,11 @@ func _render_edit_bar(request : WebServerRequest) -> void:
|
||||
|
||||
request.body += hb.result
|
||||
|
||||
func get_editor() -> Control:
|
||||
return _get_editor()
|
||||
|
||||
func _get_editor() -> Control:
|
||||
return null
|
||||
|
||||
func get_page_entry_class_name() -> String:
|
||||
return "WebPageEntry"
|
||||
|
@ -40,6 +40,10 @@ func _render(request : WebServerRequest):
|
||||
|
||||
request.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
|
||||
|
||||
func get_page_entry_class_name() -> String:
|
||||
return "WebPageEntryImage"
|
||||
|
||||
|
@ -16,5 +16,9 @@ func set_text(t : String) -> void:
|
||||
func _render(request : WebServerRequest):
|
||||
request.body += compiled_text
|
||||
|
||||
func _get_editor() -> Control:
|
||||
var WebPageEntryTextEditor : PackedScene = ResourceLoader.load("res://addons/web_pages/editor/post_entries/WebPageEntryTextEditor.tscn", "PackedScene")
|
||||
return WebPageEntryTextEditor.instance() as Control
|
||||
|
||||
func get_page_entry_class_name() -> String:
|
||||
return "WebPageEntryText"
|
||||
|
@ -39,3 +39,7 @@ func _handle_edit(request : WebServerRequest) -> void:
|
||||
|
||||
request.body += b.result
|
||||
request.compile_and_send_body()
|
||||
|
||||
func _get_editor() -> Control:
|
||||
var WebPageEntryTitleTextEditor : PackedScene = ResourceLoader.load("res://addons/web_pages/editor/post_entries/WebPageEntryTitleTextEditor.tscn", "PackedScene")
|
||||
return WebPageEntryTitleTextEditor.instance() as Control
|
||||
|
@ -173,18 +173,7 @@ func on_page_entries_changed() -> void:
|
||||
recreate()
|
||||
|
||||
func _on_add_entry_class_selected(cls_name : String) -> void:
|
||||
var entry : WebPageEntry = null
|
||||
|
||||
if cls_name == "WebPageEntryTitleText":
|
||||
entry = WebPageEntryTitleText.new()
|
||||
elif cls_name == "WebPageEntryText":
|
||||
entry = WebPageEntryText.new()
|
||||
elif cls_name == "WebPageEntryImage":
|
||||
entry = WebPageEntryImage.new()
|
||||
|
||||
if !entry:
|
||||
PLogger.log_error("PageEditor: Couldn't create entry for: " + cls_name)
|
||||
return
|
||||
var entry : WebPageEntry = _page.create_entry(cls_name)
|
||||
|
||||
add_entry(entry, _entry_add_after)
|
||||
|
||||
|
@ -8,10 +8,6 @@ var _main_container : Control = null
|
||||
|
||||
var _editor : Control = null
|
||||
|
||||
var WebPageEntryTitleTextEditor : PackedScene = null
|
||||
var WebPageEntryTextEditor : PackedScene = null
|
||||
var WebPageEntryImageEditor : PackedScene = null
|
||||
|
||||
signal entry_add_requested_after(entry)
|
||||
signal entry_move_up_requested(entry)
|
||||
signal entry_move_down_requested(entry)
|
||||
@ -20,16 +16,11 @@ signal entry_delete_requested(entry)
|
||||
func set_entry(entry : WebPageEntry, undo_redo : UndoRedo) -> void:
|
||||
_entry = entry
|
||||
|
||||
_editor = entry.get_editor()
|
||||
|
||||
var cls : String = entry.get_page_entry_class_name()
|
||||
_entry_type_label.text = cls
|
||||
|
||||
if cls == "WebPageEntryTitleText":
|
||||
_editor = WebPageEntryTitleTextEditor.instance()
|
||||
elif cls == "WebPageEntryText":
|
||||
_editor = WebPageEntryTextEditor.instance()
|
||||
elif cls == "WebPageEntryImage":
|
||||
_editor = WebPageEntryImageEditor.instance()
|
||||
|
||||
if _editor:
|
||||
_editor.set_entry(entry, undo_redo)
|
||||
_main_container.add_child(_editor)
|
||||
@ -48,10 +39,6 @@ func _on_delete_button_pressed():
|
||||
|
||||
func _notification(what):
|
||||
if what == NOTIFICATION_INSTANCED:
|
||||
WebPageEntryTitleTextEditor = ResourceLoader.load("res://addons/web_pages/editor/post_entries/WebPageEntryTitleTextEditor.tscn", "PackedScene")
|
||||
WebPageEntryTextEditor = ResourceLoader.load("res://addons/web_pages/editor/post_entries/WebPageEntryTextEditor.tscn", "PackedScene")
|
||||
WebPageEntryImageEditor = ResourceLoader.load("res://addons/web_pages/editor/post_entries/WebPageEntryImageEditor.tscn", "PackedScene")
|
||||
|
||||
_entry_type_label = get_node("PC/VBC/TopBar/EntryTypeLabel")
|
||||
_main_container = get_node("PC/VBC/MainContainer")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user