note description: "Summary description for {WDOCS_MODULE_ADMINISTRATION}." date: "$Date$" revision: "$Revision$" class WDOCS_MODULE_ADMINISTRATION inherit CMS_MODULE_ADMINISTRATION [WDOCS_MODULE] redefine setup_hooks end CMS_HOOK_MENU_SYSTEM_ALTER CMS_HOOK_CACHE create make feature -- Module wdocs_api: detachable WDOCS_API do Result := module.wdocs_api end manager (a_version_id: detachable READABLE_STRING_GENERAL): WDOCS_MANAGER do Result := module.manager (a_version_id) end feature {NONE} -- Router/administration setup_administration_router (a_router: WSF_ROUTER; a_api: CMS_API) -- Setup url dispatching for Current module administration. -- (note: `a_router` is already based with admin path prefix). local h: WSF_URI_TEMPLATE_AGENT_HANDLER do create h.make (agent handle_admin (a_api, ?, ?)) a_router.handle ("/module/" + name, h, a_router.methods_get) create h.make (agent handle_clear_cache (a_api, ?, ?)) a_router.handle ("/module/" + name + "/clear-cache", h, a_router.methods_get) create h.make (agent handle_update_doc (a_api, ?, ?)) a_router.handle ("/module/" + name + "/update", h, a_router.methods_get) end feature -- Handler handle_admin (api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE) local s: STRING r: CMS_RESPONSE do create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) if req.is_get_request_method then if r.has_permissions (<<"admin wdocs">>) then create s.make_from_string ("") s.append ("
Now, you should clear the cache.
") else s := "Documentation not updated, contact the webmaster." end r.set_main_content (s) if attached {WSF_STRING} req.query_parameter ("destination") as p_dest then r.set_redirection (p_dest.url_encoded_value) end else create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api) end else create {BAD_REQUEST_ERROR_CMS_RESPONSE} r.make (req, res, api) end r.primary_tabs.extend (api.administration_link ("Docs-Administration", "module/" + name)) r.execute end feature -- Hooks configuration setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER) -- Module hooks configuration. do -- Module specific hook, if available. a_hooks.subscribe_to_cache_hook (Current) a_hooks.subscribe_to_menu_system_alter_hook (Current) end menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE) -- Hook execution on collection of menu contained by `a_menu_system' -- for related response `a_response'. local lnk: CMS_LOCAL_LINK do if a_response.has_permissions (<<"admin wdocs", "clear wdocs cache">>) then lnk := a_response.administration_link ("Docs", "module/" + name) a_menu_system.management_menu.extend (lnk) module.menu_system_alter (a_menu_system, a_response) end end clear_cache (a_cache_id_list: detachable ITERABLE [READABLE_STRING_GENERAL]; a_response: CMS_RESPONSE) --