Refactored and update CMS hooks design. (Move from CMS_RESPONSE to CMS_API).
Moved content_types and content_type_webform_managers from CMS_RESPONSE to CMS_API.
Updated the way to output content (node, ...) to html page.
See CMS_CONTENT_TYPE_WEBFORM_MANAGER.append_cointent_as_html_to (...).
Added notion of "teaser" (short version of the content), as opposed to full content.
One can use CMS_API.html_encoder ... when possible, same for `formats', ...
Added bridge from CMS_MODULE_API to CMS_API's encoders.
Added new CMS_TAXONOMY_HOOK used to retrieve list of content associated with a specific term.
Moved up to CMS_RESPONSE a few features which was available only in specific descendants.
Added /taxonomy/term/{termid} implementation.
This commit is contained in:
@@ -16,28 +16,25 @@ inherit
|
||||
|
||||
feature -- Hook
|
||||
|
||||
auto_subscribe_to_hooks (a_response: CMS_RESPONSE)
|
||||
local
|
||||
l_manager: CMS_HOOK_CORE_MANAGER
|
||||
auto_subscribe_to_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
do
|
||||
l_manager := a_response.hooks
|
||||
if attached {CMS_HOOK_MENU_SYSTEM_ALTER} Current as h_menu_system_alter then
|
||||
l_manager.subscribe_to_menu_system_alter_hook (h_menu_system_alter)
|
||||
a_hooks.subscribe_to_menu_system_alter_hook (h_menu_system_alter)
|
||||
end
|
||||
if attached {CMS_HOOK_MENU_ALTER} Current as h_menu_alter then
|
||||
l_manager.subscribe_to_menu_alter_hook (h_menu_alter)
|
||||
a_hooks.subscribe_to_menu_alter_hook (h_menu_alter)
|
||||
end
|
||||
if attached {CMS_HOOK_BLOCK} Current as h_block then
|
||||
l_manager.subscribe_to_block_hook (h_block)
|
||||
a_hooks.subscribe_to_block_hook (h_block)
|
||||
end
|
||||
if attached {CMS_HOOK_FORM_ALTER} Current as h_form then
|
||||
l_manager.subscribe_to_form_alter_hook (h_form)
|
||||
a_hooks.subscribe_to_form_alter_hook (h_form)
|
||||
end
|
||||
if attached {CMS_HOOK_VALUE_TABLE_ALTER} Current as h_value then
|
||||
l_manager.subscribe_to_value_table_alter_hook (h_value)
|
||||
a_hooks.subscribe_to_value_table_alter_hook (h_value)
|
||||
end
|
||||
if attached {CMS_HOOK_RESPONSE_ALTER} Current as h_resp then
|
||||
l_manager.subscribe_to_response_alter_hook (h_resp)
|
||||
a_hooks.subscribe_to_response_alter_hook (h_resp)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ feature -- Basic operation
|
||||
|
||||
prepare (a_response: CMS_RESPONSE)
|
||||
do
|
||||
a_response.hooks.invoke_form_alter (Current, Void, a_response)
|
||||
a_response.api.hooks.invoke_form_alter (Current, Void, a_response)
|
||||
end
|
||||
|
||||
process (a_response: CMS_RESPONSE)
|
||||
@@ -29,7 +29,7 @@ feature -- Basic operation
|
||||
|
||||
on_prepared (a_response: CMS_RESPONSE; fd: WSF_FORM_DATA)
|
||||
do
|
||||
a_response.hooks.invoke_form_alter (Current, fd, a_response)
|
||||
a_response.api.hooks.invoke_form_alter (Current, fd, a_response)
|
||||
end
|
||||
|
||||
on_processed (a_response: CMS_RESPONSE; fd: WSF_FORM_DATA)
|
||||
|
||||
@@ -9,7 +9,7 @@ class
|
||||
inherit
|
||||
CMS_MODULE
|
||||
redefine
|
||||
register_hooks
|
||||
setup_hooks
|
||||
end
|
||||
|
||||
CMS_HOOK_BLOCK
|
||||
@@ -47,11 +47,11 @@ feature -- Router
|
||||
|
||||
feature -- Hooks configuration
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- Module hooks configuration.
|
||||
do
|
||||
auto_subscribe_to_hooks (a_response)
|
||||
a_response.hooks.subscribe_to_block_hook (Current)
|
||||
auto_subscribe_to_hooks (a_hooks)
|
||||
a_hooks.subscribe_to_block_hook (Current)
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
@@ -71,7 +71,7 @@ feature -- Hooks
|
||||
create s.make_empty
|
||||
dbg.append_information_to (a_response.request, a_response.response, s)
|
||||
append_info_to ("Storage", a_response.api.storage.generator, a_response, s)
|
||||
create b.make ("debug-info", "Debug", s, a_response.formats.plain_text)
|
||||
create b.make ("debug-info", "Debug", s, a_response.api.formats.plain_text)
|
||||
b.add_condition (create {CMS_BLOCK_EXPRESSION_CONDITION}.make_none)
|
||||
a_response.add_block (b, "footer")
|
||||
end
|
||||
|
||||
@@ -28,6 +28,7 @@ feature {NONE} -- Initialize
|
||||
setup := a_setup
|
||||
create error_handler.make
|
||||
create {CMS_ENV_LOGGER} logger.make
|
||||
create hooks.make
|
||||
initialize
|
||||
ensure
|
||||
setup_set: setup = a_setup
|
||||
@@ -88,12 +89,15 @@ feature {NONE} -- Initialize
|
||||
l_enabled_modules.remove (ic.item)
|
||||
end
|
||||
end
|
||||
-- Initialize hooks system
|
||||
setup_hooks
|
||||
end
|
||||
|
||||
initialize_content_types
|
||||
-- Initialize content types.
|
||||
do
|
||||
create content_types.make (1)
|
||||
create content_type_webform_managers.make (1)
|
||||
end
|
||||
|
||||
initialize_formats
|
||||
@@ -190,6 +194,38 @@ feature -- Content
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Content type webform
|
||||
|
||||
content_type_webform_managers: ARRAYED_LIST [CMS_CONTENT_TYPE_WEBFORM_MANAGER [CMS_CONTENT]]
|
||||
-- Available content types
|
||||
|
||||
add_content_type_webform_manager (a_manager: CMS_CONTENT_TYPE_WEBFORM_MANAGER [CMS_CONTENT])
|
||||
-- Register webform manager `a_manager'.
|
||||
do
|
||||
content_type_webform_managers.force (a_manager)
|
||||
end
|
||||
|
||||
content_type_webform_manager (a_content_type: CMS_CONTENT_TYPE): detachable CMS_CONTENT_TYPE_WEBFORM_MANAGER [CMS_CONTENT]
|
||||
-- Web form manager for content type `a_content_type' if any.
|
||||
do
|
||||
Result := content_type_webform_manager_by_name (a_content_type.name)
|
||||
end
|
||||
|
||||
content_type_webform_manager_by_name (a_content_type_name: READABLE_STRING_GENERAL): detachable CMS_CONTENT_TYPE_WEBFORM_MANAGER [CMS_CONTENT]
|
||||
-- Web form manager for content type named `a_content_type_name' if any.
|
||||
do
|
||||
across
|
||||
content_type_webform_managers as ic
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
Result := ic.item
|
||||
if not a_content_type_name.is_case_insensitive_equal (Result.name) then
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Formats
|
||||
|
||||
formats: CMS_FORMATS
|
||||
@@ -356,9 +392,37 @@ feature -- Query: module
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
hooks: CMS_HOOK_CORE_MANAGER
|
||||
-- Manager handling hook subscriptions.
|
||||
|
||||
feature {NONE} -- Hooks
|
||||
|
||||
setup_hooks
|
||||
-- Set up CMS hooks.
|
||||
--| Each module has to opportunity to subscribe to various hooks.
|
||||
local
|
||||
l_module: CMS_MODULE
|
||||
l_hooks: like hooks
|
||||
do
|
||||
l_hooks := hooks
|
||||
register_hooks (l_hooks)
|
||||
across
|
||||
enabled_modules as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
if attached {CMS_HOOK_AUTO_REGISTER} l_module as l_auto then
|
||||
l_auto.auto_subscribe_to_hooks (l_hooks)
|
||||
end
|
||||
l_module.setup_hooks (l_hooks)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Query: API
|
||||
|
||||
user_api: CMS_USER_API
|
||||
-- API to access user related data.
|
||||
local
|
||||
l_api: like internal_user_api
|
||||
do
|
||||
|
||||
@@ -135,7 +135,7 @@ feature -- Router
|
||||
|
||||
feature -- Hooks configuration
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- Module hooks configuration.
|
||||
require
|
||||
is_enabled: is_enabled
|
||||
|
||||
@@ -46,6 +46,26 @@ feature {CMS_API_ACCESS, CMS_MODULE, CMS_API} -- Restricted access
|
||||
Result := cms_api.storage
|
||||
end
|
||||
|
||||
feature -- Bridge to CMS API
|
||||
|
||||
html_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
|
||||
-- `a_string' encoded for html output.
|
||||
do
|
||||
Result := cms_api.html_encoded (a_string)
|
||||
end
|
||||
|
||||
url_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
|
||||
-- `a_string' encoded with percent encoding, mainly used for url.
|
||||
do
|
||||
Result := cms_api.url_encoded (a_string)
|
||||
end
|
||||
|
||||
percent_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
|
||||
-- `a_string' encoded with percent encoding, mainly used for url.
|
||||
do
|
||||
Result := cms_api.percent_encoded (a_string)
|
||||
end
|
||||
|
||||
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)"
|
||||
|
||||
54
src/service/content/cms_content_type_webform_manager.e
Normal file
54
src/service/content/cms_content_type_webform_manager.e
Normal file
@@ -0,0 +1,54 @@
|
||||
note
|
||||
description: "[
|
||||
Html builder for content type `content_type'.
|
||||
This is used to build webform and html output for a specific node, or node content type.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_CONTENT_TYPE_WEBFORM_MANAGER [G -> CMS_CONTENT]
|
||||
|
||||
inherit
|
||||
CMS_API_ACCESS
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_type: like content_type)
|
||||
do
|
||||
content_type := a_type
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
content_type: CMS_CONTENT_TYPE
|
||||
-- Associated content type.
|
||||
|
||||
name: READABLE_STRING_8
|
||||
-- Associated content type name.
|
||||
do
|
||||
Result := content_type.name
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_content_as_html_to (a_content: G; is_teaser: BOOLEAN; a_output: STRING; a_response: detachable CMS_RESPONSE)
|
||||
-- Append `a_content' as html to `a_output', and adapt output according to `is_teaser' (full output, or teaser).
|
||||
-- In the context of optional `a_response'.
|
||||
deferred
|
||||
end
|
||||
|
||||
append_formatted_content_to (a_content: READABLE_STRING_GENERAL; a_format: CONTENT_FORMAT; a_output: STRING)
|
||||
-- Format string `a_content' with format `a_format', and append to `a_output'.
|
||||
do
|
||||
if a_content.is_valid_as_string_8 then
|
||||
a_output.append (a_format.formatted_output (a_content.to_string_8))
|
||||
else
|
||||
a_format.append_formatted_to (a_content, a_output)
|
||||
end
|
||||
end
|
||||
|
||||
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)"
|
||||
end
|
||||
@@ -188,4 +188,7 @@ feature -- Url
|
||||
Result := html_encoded (a_text)
|
||||
end
|
||||
|
||||
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)"
|
||||
end
|
||||
|
||||
@@ -33,8 +33,6 @@ feature {NONE} -- Initialization
|
||||
get_theme
|
||||
create menu_system.make
|
||||
initialize_block_region_settings
|
||||
create hooks.make
|
||||
register_hooks
|
||||
end
|
||||
|
||||
initialize_site_url
|
||||
@@ -66,24 +64,6 @@ feature {NONE} -- Initialization
|
||||
site_url_ends_with_slash: site_url.ends_with_general ("/")
|
||||
end
|
||||
|
||||
register_hooks
|
||||
local
|
||||
l_module: CMS_MODULE
|
||||
l_enabled_modules: CMS_MODULE_COLLECTION
|
||||
do
|
||||
api.register_hooks (hooks)
|
||||
l_enabled_modules := api.enabled_modules
|
||||
across
|
||||
l_enabled_modules as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
if attached {CMS_HOOK_AUTO_REGISTER} l_module as l_auto then
|
||||
l_auto.auto_subscribe_to_hooks (Current)
|
||||
end
|
||||
l_module.register_hooks (Current)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
request: WSF_REQUEST
|
||||
@@ -752,7 +732,7 @@ feature -- Blocks
|
||||
-- Get blocks provided by modules.
|
||||
do
|
||||
-- Get block from modules, and related alias.
|
||||
hooks.invoke_block (Current)
|
||||
api.hooks.invoke_block (Current)
|
||||
end
|
||||
|
||||
primary_menu_block: detachable CMS_MENU_BLOCK
|
||||
@@ -869,6 +849,11 @@ feature -- Hooks
|
||||
|
||||
hooks: CMS_HOOK_CORE_MANAGER
|
||||
-- Manager handling hook subscriptions.
|
||||
obsolete
|
||||
"Use api.hooks [dec/2015]"
|
||||
do
|
||||
Result := api.hooks
|
||||
end
|
||||
|
||||
feature -- Menu: change
|
||||
|
||||
@@ -1019,7 +1004,7 @@ feature -- Generation
|
||||
create {CMS_LOCAL_LINK} lnk.make ("Home", "")
|
||||
lnk.set_weight (-10)
|
||||
add_to_primary_menu (lnk)
|
||||
hooks.invoke_menu_system_alter (menu_system, Current)
|
||||
api.hooks.invoke_menu_system_alter (menu_system, Current)
|
||||
|
||||
if api.enabled_modules.count = 0 then
|
||||
add_to_primary_menu (create {CMS_LOCAL_LINK}.make ("Install", "admin/install"))
|
||||
@@ -1077,10 +1062,10 @@ feature -- Generation
|
||||
custom_prepare (page)
|
||||
|
||||
-- Cms response
|
||||
hooks.invoke_response_alter (Current)
|
||||
api.hooks.invoke_response_alter (Current)
|
||||
|
||||
-- Cms values
|
||||
hooks.invoke_value_table_alter (values, Current)
|
||||
api.hooks.invoke_value_table_alter (values, Current)
|
||||
|
||||
-- Predefined values
|
||||
page.register_variable (page, "page") -- DO NOT REMOVE
|
||||
@@ -1251,6 +1236,34 @@ feature -- Generation
|
||||
a_lnk.set_is_forbidden (not has_permission_on_link (a_lnk))
|
||||
end
|
||||
|
||||
feature -- Helpers: cms link
|
||||
|
||||
local_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK
|
||||
do
|
||||
create Result.make (a_title, a_location)
|
||||
end
|
||||
|
||||
user_local_link (u: CMS_USER; a_opt_title: detachable READABLE_STRING_GENERAL): CMS_LOCAL_LINK
|
||||
do
|
||||
if a_opt_title /= Void then
|
||||
create Result.make (a_opt_title, user_url (u))
|
||||
else
|
||||
create Result.make (u.name, user_url (u))
|
||||
end
|
||||
end
|
||||
|
||||
user_html_link (u: CMS_USER): like link
|
||||
do
|
||||
Result := link (u.name, "user/" + u.id.out, Void)
|
||||
end
|
||||
|
||||
user_url (u: CMS_USER): like url
|
||||
require
|
||||
u_with_id: u.has_id
|
||||
do
|
||||
Result := url ("user/" + u.id.out, Void)
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute
|
||||
|
||||
Reference in New Issue
Block a user