diff --git a/modules/node/handler/cms_node_type_webform_manager.e b/modules/node/handler/cms_node_type_webform_manager.e index 1b0fc94..69c9496 100644 --- a/modules/node/handler/cms_node_type_webform_manager.e +++ b/modules/node/handler/cms_node_type_webform_manager.e @@ -21,7 +21,6 @@ feature -- Forms ... tselect: WSF_FORM_SELECT opt: WSF_FORM_SELECT_OPTION cms_format: CMS_EDITOR_CONTENT_FORMAT - l_uri: detachable READABLE_STRING_8 do create cms_format @@ -94,6 +93,15 @@ feature -- Forms ... 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 create ti.make ("path_alias") ti.set_label ("Path") @@ -106,32 +114,32 @@ feature -- Forms ... end 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_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 + 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 attached f.fields_by_name ("title") as l_title_fields and then attached l_title_fields.first as l_title_field @@ -142,6 +150,7 @@ feature -- Forms ... end end + update_node (response: NODE_RESPONSE; fd: WSF_FORM_DATA; a_node: CMS_NODE) local b,s: detachable READABLE_STRING_8 diff --git a/src/service/cms_module.e b/src/service/cms_module.e index 1791353..fcb3574 100644 --- a/src/service/cms_module.e +++ b/src/service/cms_module.e @@ -79,14 +79,28 @@ feature {CMS_API} -- Module management is_installed (api: CMS_API): BOOLEAN -- Is Current module installed? 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 install (api: CMS_API) require is_not_installed: not is_installed (api) do - api.storage.set_custom_value ("is_initialized", "yes", "module-" + name) + api.storage.set_custom_value ("is_initialized", version, "module-" + name) end uninstall (api: CMS_API) @@ -151,6 +165,10 @@ feature -- Hooks create Result.make_empty end +invariant + name_set: not name.is_whitespace + version_set: not version.is_whitespace + note copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"