Fixed validation of node path alias field, for node creation.
Now,when installation a module, store the version (instead of just "yes")
This commit is contained in:
@@ -21,7 +21,6 @@ feature -- Forms ...
|
|||||||
tselect: WSF_FORM_SELECT
|
tselect: WSF_FORM_SELECT
|
||||||
opt: WSF_FORM_SELECT_OPTION
|
opt: WSF_FORM_SELECT_OPTION
|
||||||
cms_format: CMS_EDITOR_CONTENT_FORMAT
|
cms_format: CMS_EDITOR_CONTENT_FORMAT
|
||||||
l_uri: detachable READABLE_STRING_8
|
|
||||||
do
|
do
|
||||||
create cms_format
|
create cms_format
|
||||||
|
|
||||||
@@ -94,6 +93,15 @@ feature -- Forms ...
|
|||||||
|
|
||||||
f.extend (fset)
|
f.extend (fset)
|
||||||
|
|
||||||
|
-- Path alias
|
||||||
|
populate_form_with_path_alias (response, f, a_node)
|
||||||
|
end
|
||||||
|
|
||||||
|
populate_form_with_path_alias (response: NODE_RESPONSE; f: CMS_FORM; a_node: detachable CMS_NODE)
|
||||||
|
local
|
||||||
|
ti: WSF_FORM_TEXT_INPUT
|
||||||
|
l_uri: detachable READABLE_STRING_8
|
||||||
|
do
|
||||||
-- Path alias
|
-- Path alias
|
||||||
create ti.make ("path_alias")
|
create ti.make ("path_alias")
|
||||||
ti.set_label ("Path")
|
ti.set_label ("Path")
|
||||||
@@ -106,32 +114,32 @@ feature -- Forms ...
|
|||||||
end
|
end
|
||||||
ti.set_text_value (l_uri)
|
ti.set_text_value (l_uri)
|
||||||
ti.set_description ("Optionally specify an alternative URL path by which this content can be accessed. For example, type 'about' when writing an about page. Use a relative path or the URL alias won't work.")
|
ti.set_description ("Optionally specify an alternative URL path by which this content can be accessed. For example, type 'about' when writing an about page. Use a relative path or the URL alias won't work.")
|
||||||
ti.set_validation_action (agent (fd: WSF_FORM_DATA; ia_response: NODE_RESPONSE; ia_node: CMS_NODE)
|
|
||||||
do
|
|
||||||
if
|
|
||||||
attached fd.string_item ("path_alias") as f_path_alias
|
|
||||||
then
|
|
||||||
if ia_response.api.is_valid_path_alias (f_path_alias) then
|
|
||||||
-- Ok.
|
|
||||||
elseif f_path_alias.is_empty then
|
|
||||||
-- Ok
|
|
||||||
elseif f_path_alias.starts_with_general ("/") then
|
|
||||||
fd.report_invalid_field ("path_alias", "Path alias should not start with a slash '/' .")
|
|
||||||
elseif f_path_alias.has_substring ("://") then
|
|
||||||
fd.report_invalid_field ("path_alias", "Path alias should not be absolute url .")
|
|
||||||
else
|
|
||||||
-- TODO: implement full path alias validation
|
|
||||||
end
|
|
||||||
if
|
|
||||||
attached ia_response.api.source_of_path_alias (f_path_alias) as l_aliased_location and then
|
|
||||||
not l_aliased_location.same_string (ia_response.node_api.node_path (ia_node))
|
|
||||||
then
|
|
||||||
fd.report_invalid_field ("path_alias", "Path is already aliased to location %"" + ia_response.link (Void, l_aliased_location, Void) + "%" !")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end(?, response, a_node)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
ti.set_validation_action (agent (fd: WSF_FORM_DATA; ia_response: NODE_RESPONSE; ia_node: detachable CMS_NODE)
|
||||||
|
do
|
||||||
|
if
|
||||||
|
attached fd.string_item ("path_alias") as f_path_alias
|
||||||
|
then
|
||||||
|
if ia_response.api.is_valid_path_alias (f_path_alias) then
|
||||||
|
-- Ok.
|
||||||
|
elseif f_path_alias.is_empty then
|
||||||
|
-- Ok
|
||||||
|
elseif f_path_alias.starts_with_general ("/") then
|
||||||
|
fd.report_invalid_field ("path_alias", "Path alias should not start with a slash '/' .")
|
||||||
|
elseif f_path_alias.has_substring ("://") then
|
||||||
|
fd.report_invalid_field ("path_alias", "Path alias should not be absolute url .")
|
||||||
|
else
|
||||||
|
-- TODO: implement full path alias validation
|
||||||
|
end
|
||||||
|
if
|
||||||
|
attached ia_response.api.source_of_path_alias (f_path_alias) as l_aliased_location and then
|
||||||
|
((ia_node /= Void and then ia_node.has_id) implies not l_aliased_location.same_string (ia_response.node_api.node_path (ia_node)))
|
||||||
|
then
|
||||||
|
fd.report_invalid_field ("path_alias", "Path is already aliased to location %"" + ia_response.link (Void, l_aliased_location, Void) + "%" !")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end(?, response, a_node)
|
||||||
|
)
|
||||||
if
|
if
|
||||||
attached f.fields_by_name ("title") as l_title_fields and then
|
attached f.fields_by_name ("title") as l_title_fields and then
|
||||||
attached l_title_fields.first as l_title_field
|
attached l_title_fields.first as l_title_field
|
||||||
@@ -142,6 +150,7 @@ feature -- Forms ...
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
update_node (response: NODE_RESPONSE; fd: WSF_FORM_DATA; a_node: CMS_NODE)
|
update_node (response: NODE_RESPONSE; fd: WSF_FORM_DATA; a_node: CMS_NODE)
|
||||||
local
|
local
|
||||||
b,s: detachable READABLE_STRING_8
|
b,s: detachable READABLE_STRING_8
|
||||||
|
|||||||
@@ -79,14 +79,28 @@ feature {CMS_API} -- Module management
|
|||||||
is_installed (api: CMS_API): BOOLEAN
|
is_installed (api: CMS_API): BOOLEAN
|
||||||
-- Is Current module installed?
|
-- Is Current module installed?
|
||||||
do
|
do
|
||||||
Result := attached api.storage.custom_value ("is_initialized", "module-" + name) as v and then v.is_case_insensitive_equal_general ("yes")
|
if attached api.storage.custom_value ("is_initialized", "module-" + name) as v then
|
||||||
|
if v.is_case_insensitive_equal_general (version) then
|
||||||
|
Result := True
|
||||||
|
elseif v.is_case_insensitive_equal_general ("yes") then
|
||||||
|
-- Backward compatibility.
|
||||||
|
Result := True
|
||||||
|
elseif v.is_case_insensitive_equal_general ("no") then
|
||||||
|
-- Probably a module that was installed, but now uninstalled.
|
||||||
|
Result := False
|
||||||
|
else
|
||||||
|
-- Maybe a different version is installed.
|
||||||
|
-- For now, let's assume this is installed.
|
||||||
|
Result := True
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
install (api: CMS_API)
|
install (api: CMS_API)
|
||||||
require
|
require
|
||||||
is_not_installed: not is_installed (api)
|
is_not_installed: not is_installed (api)
|
||||||
do
|
do
|
||||||
api.storage.set_custom_value ("is_initialized", "yes", "module-" + name)
|
api.storage.set_custom_value ("is_initialized", version, "module-" + name)
|
||||||
end
|
end
|
||||||
|
|
||||||
uninstall (api: CMS_API)
|
uninstall (api: CMS_API)
|
||||||
@@ -151,6 +165,10 @@ feature -- Hooks
|
|||||||
create Result.make_empty
|
create Result.make_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
invariant
|
||||||
|
name_set: not name.is_whitespace
|
||||||
|
version_set: not version.is_whitespace
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
|||||||
Reference in New Issue
Block a user