Merge branch 'master' into es17.01

This commit is contained in:
Jocelyn Fiat
2017-03-30 17:33:00 +02:00
8 changed files with 234 additions and 78 deletions

View File

@@ -88,6 +88,11 @@ feature -- Output
a_response.set_value (a_node, "node")
a_response.set_value (a_node.content_type, "optional_content_type")
create s.make_empty
if a_node.is_not_published then
a_response.add_warning_message ("This node is NOT published!")
elseif a_node.is_trashed then
a_response.add_warning_message ("This node is in the TRASH!")
end
append_content_as_html_to (a_node, False, s, a_response)
a_response.set_main_content (s)
end

View File

@@ -254,15 +254,25 @@ feature -- Form
edit_form_submit (fd: WSF_FORM_DATA; a_node: detachable CMS_NODE; a_type: CMS_NODE_TYPE [CMS_NODE]; b: STRING)
local
l_preview: BOOLEAN
l_preview, l_op_save, l_op_publish, l_op_unpublish: BOOLEAN
l_node: detachable CMS_NODE
s: STRING
l_node_path: READABLE_STRING_8
l_path_alias, l_existing_path_alias, l_auto_path_alias: detachable READABLE_STRING_8
do
fixme ("Refactor code per operacion: Preview, Save")
l_preview := attached {WSF_STRING} fd.item ("op") as l_op and then l_op.same_string ("Preview")
fixme ("Refactor code per operation: Preview, Save/Publish/UnPublish")
l_preview := attached {WSF_STRING} fd.item ("op") as l_op and then l_op.same_string (preview_submit_label)
if not l_preview then
l_op_save := True
if attached {WSF_STRING} fd.item ("op") as l_op then
if l_op.same_string (publish_submit_label) then
l_op_publish := True
elseif l_op.same_string (unpublish_submit_label) then
l_op_unpublish := True
else
check l_op.same_string (save_submit_label) end
end
end
debug ("cms")
across
fd as c
@@ -289,8 +299,13 @@ feature -- Form
end
fixme ("for now, publishing is not implemented, so let's assume any node saved is published.") -- FIXME
l_node.mark_published
if l_op_publish then
l_node.mark_published
elseif l_op_unpublish then
l_node.mark_not_published
else
-- Default status
end
node_api.save_node (l_node)
if attached user as u then
api.log ("node",
@@ -362,6 +377,7 @@ feature -- Form
f: CMS_FORM
ts: WSF_FORM_SUBMIT_INPUT
th: WSF_FORM_HIDDEN_INPUT
div: WSF_WIDGET_DIV
do
create f.make (a_url, a_name)
create th.make ("node-id")
@@ -375,18 +391,50 @@ feature -- Form
populate_form (a_node_type, f, a_node)
f.extend_html_text ("<br/>")
create ts.make ("op")
ts.set_default_value ("Save")
f.extend (ts)
create div.make
div.add_css_class ("css-editing-buttons")
f.extend (div)
create ts.make ("op")
ts.set_default_value ("Preview")
f.extend (ts)
ts.set_default_value (preview_submit_label)
ts.set_description ("Preview without saving.")
div.extend (ts)
if a_node = Void then
create ts.make ("op")
ts.set_default_value (save_submit_label)
div.extend (ts)
create ts.make ("op")
ts.set_default_value (publish_submit_label)
ts.set_description ("Save and mark published.")
div.extend (ts)
else
if a_node.is_published then
create ts.make ("op")
ts.set_default_value (save_submit_label)
ts.set_description ("Save and keep published.")
div.extend (ts)
create ts.make ("op")
ts.set_default_value (unpublish_submit_label)
ts.set_description ("Save and mark unpublished.")
div.extend (ts)
else
create ts.make ("op")
ts.set_default_value (save_submit_label)
div.extend (ts)
create ts.make ("op")
ts.set_default_value (publish_submit_label)
ts.set_description ("Save and mark published.")
div.extend (ts)
end
end
Result := f
end
new_delete_form (a_node: detachable CMS_NODE; a_url: READABLE_STRING_8; a_name: STRING; a_node_type: CMS_NODE_TYPE [CMS_NODE]): CMS_FORM
-- Create a web form named `a_name' for node `a_node' (if set), using form action url `a_url', and for type of node `a_node_type'.
require
@@ -487,4 +535,11 @@ feature -- Form
end
end
feature -- Labels
save_submit_label: STRING = "Save"
publish_submit_label: STRING = "Publish"
unpublish_submit_label: STRING = "Unpublish"
preview_submit_label: STRING = "Preview"
end

View File

@@ -84,6 +84,8 @@ feature -- HTTP Methods
l_nid, l_rev: INTEGER_64
edit_response: NODE_FORM_RESPONSE
view_response: NODE_VIEW_RESPONSE
l_is_published: BOOLEAN
l_is_denied: BOOLEAN
do
if req.percent_encoded_path_info.ends_with ("/edit") then
check valid_url: req.percent_encoded_path_info.starts_with ("/node/") end
@@ -119,19 +121,26 @@ feature -- HTTP Methods
l_rev := p_rev.value.to_integer_64
end
l_node := node_api.node (l_nid)
if
l_node /= Void and then
l_rev > 0 and then
l_rev < l_node.revision and then
node_api.has_permission_for_action_on_node ("view revisions", l_node, api.user)
then
l_node := node_api.revision_node (l_nid, l_rev)
if l_node /= Void then
l_is_published := l_node.is_published
if
l_rev > 0 and then
l_rev < l_node.revision
then
if node_api.has_permission_for_action_on_node ("view revisions", l_node, api.user) then
l_node := node_api.revision_node (l_nid, l_rev)
else
l_is_denied := True
end
end
end
if l_node = Void then
if l_is_denied then
send_access_denied (req, res)
elseif l_node = Void then
send_not_found (req, res)
else
if
l_rev > 0 or else l_node.is_published
l_rev > 0 and l_is_published
then
create view_response.make (req, res, api, node_api)
view_response.set_node (l_node)
@@ -148,7 +157,7 @@ feature -- HTTP Methods
view_response.set_revision (l_rev)
view_response.execute
else
send_access_denied (req, res)
send_access_denied_to_unpublished_node (req, res, l_node)
end
end
else
@@ -392,6 +401,17 @@ feature -- Error
l_page.execute
end
send_access_denied_to_unpublished_node (req: WSF_REQUEST; res: WSF_RESPONSE; a_node: CMS_NODE)
-- Forbidden response.
local
r: CMS_RESPONSE
do
create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
r.set_main_content ("This content is NOT published!")
r.execute
end
feature {NONE} -- Node
create_new_node (req: WSF_REQUEST; res: WSF_RESPONSE)