First step toward more generic way to handle hook subscribers.
This commit is contained in:
@@ -29,6 +29,7 @@ feature {NONE} -- Initialization
|
|||||||
get_theme
|
get_theme
|
||||||
create menu_system.make
|
create menu_system.make
|
||||||
initialize_block_region_settings
|
initialize_block_region_settings
|
||||||
|
create hook_subscribers.make (0)
|
||||||
register_hooks
|
register_hooks
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -476,118 +477,111 @@ feature -- Blocks
|
|||||||
create Result.make ("made_with", Void, made_with_html, Void)
|
create Result.make ("made_with", Void, made_with_html, Void)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Hook: value alter
|
|
||||||
|
|
||||||
subscribe_to_value_table_alter_hook (h: like value_table_alter_hooks.item)
|
feature -- Hooks
|
||||||
|
|
||||||
|
hook_subscribers: HASH_TABLE [LIST [CMS_HOOK], TYPE [CMS_HOOK]]
|
||||||
|
-- Hook indexed by hook identifier.
|
||||||
|
|
||||||
|
subscribe_to_hook (h: CMS_HOOK; a_hook_type: TYPE [CMS_HOOK])
|
||||||
|
-- Subscribe `h' to hooks identified by `a_hook_type'.
|
||||||
local
|
local
|
||||||
lst: like value_table_alter_hooks
|
lst: detachable LIST [CMS_HOOK]
|
||||||
do
|
do
|
||||||
lst := value_table_alter_hooks
|
lst := hook_subscribers.item (a_hook_type)
|
||||||
if lst = Void then
|
if lst = Void then
|
||||||
create lst.make (1)
|
create {ARRAYED_LIST [CMS_HOOK]} lst.make (1)
|
||||||
value_table_alter_hooks := lst
|
hook_subscribers.force (lst, a_hook_type)
|
||||||
end
|
end
|
||||||
if not lst.has (h) then
|
if not lst.has (h) then
|
||||||
lst.force (h)
|
lst.force (h)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
value_table_alter_hooks: detachable ARRAYED_LIST [CMS_HOOK_VALUE_TABLE_ALTER]
|
feature -- Hook: value alter
|
||||||
|
|
||||||
invoke_value_table_alter (m: CMS_VALUE_TABLE)
|
subscribe_to_value_table_alter_hook (h: CMS_HOOK_VALUE_TABLE_ALTER)
|
||||||
|
-- Add `h' as subscriber of value table alter hooks CMS_HOOK_VALUE_TABLE_ALTER.
|
||||||
do
|
do
|
||||||
if attached value_table_alter_hooks as lst then
|
subscribe_to_hook (h, {CMS_HOOK_VALUE_TABLE_ALTER})
|
||||||
|
end
|
||||||
|
|
||||||
|
invoke_value_table_alter (a_table: CMS_VALUE_TABLE)
|
||||||
|
-- Invoke value table alter hook for table `a_table'.
|
||||||
|
do
|
||||||
|
if attached hook_subscribers.item ({CMS_HOOK_VALUE_TABLE_ALTER}) as lst then
|
||||||
across
|
across
|
||||||
lst as c
|
lst as c
|
||||||
loop
|
loop
|
||||||
c.item.value_table_alter (m, Current)
|
if attached {CMS_HOOK_VALUE_TABLE_ALTER} c.item as h then
|
||||||
|
h.value_table_alter (a_table, Current)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Hook: menu_system_alter
|
feature -- Hook: menu_system_alter
|
||||||
|
|
||||||
subscribe_to_menu_system_alter_hook (h: like menu_system_alter_hooks.item)
|
subscribe_to_menu_system_alter_hook (h: CMS_HOOK_MENU_SYSTEM_ALTER)
|
||||||
local
|
-- Add `h' as subscriber of menu system alter hooks CMS_HOOK_MENU_SYSTEM_ALTER.
|
||||||
lst: like menu_system_alter_hooks
|
|
||||||
do
|
do
|
||||||
lst := menu_system_alter_hooks
|
subscribe_to_hook (h, {CMS_HOOK_MENU_SYSTEM_ALTER})
|
||||||
if lst = Void then
|
|
||||||
create lst.make (1)
|
|
||||||
menu_system_alter_hooks := lst
|
|
||||||
end
|
|
||||||
if not lst.has (h) then
|
|
||||||
lst.force (h)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
menu_system_alter_hooks: detachable ARRAYED_LIST [CMS_HOOK_MENU_SYSTEM_ALTER]
|
invoke_menu_system_alter (a_menu_system: CMS_MENU_SYSTEM)
|
||||||
|
-- Invoke menu system alter hook for menu `a_menu_system'.
|
||||||
invoke_menu_system_alter (m: CMS_MENU_SYSTEM )
|
|
||||||
do
|
do
|
||||||
if attached menu_system_alter_hooks as lst then
|
if attached hook_subscribers.item ({CMS_HOOK_MENU_SYSTEM_ALTER}) as lst then
|
||||||
across
|
across
|
||||||
lst as c
|
lst as c
|
||||||
loop
|
loop
|
||||||
c.item.menu_system_alter (m, Current)
|
if attached {CMS_HOOK_MENU_SYSTEM_ALTER} c.item as h then
|
||||||
|
h.menu_system_alter (a_menu_system, Current)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Hook: menu_alter
|
feature -- Hook: menu_alter
|
||||||
|
|
||||||
subscribe_to_menu_alter_hook (h: like menu_alter_hooks.item)
|
subscribe_to_menu_alter_hook (h: CMS_HOOK_MENU_ALTER)
|
||||||
local
|
-- Add `h' as subscriber of menu alter hooks CMS_HOOK_MENU_ALTER.
|
||||||
lst: like menu_alter_hooks
|
|
||||||
do
|
do
|
||||||
lst := menu_alter_hooks
|
subscribe_to_hook (h, {CMS_HOOK_MENU_ALTER})
|
||||||
if lst = Void then
|
|
||||||
create lst.make (1)
|
|
||||||
menu_alter_hooks := lst
|
|
||||||
end
|
|
||||||
if not lst.has (h) then
|
|
||||||
lst.force (h)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
menu_alter_hooks: detachable ARRAYED_LIST [CMS_HOOK_MENU_ALTER]
|
invoke_menu_alter (a_menu: CMS_MENU)
|
||||||
|
-- Invoke menu alter hook for menu `a_menu'.
|
||||||
invoke_menu_alter (m: CMS_MENU)
|
|
||||||
do
|
do
|
||||||
if attached menu_alter_hooks as lst then
|
if attached hook_subscribers.item ({CMS_HOOK_MENU_ALTER}) as lst then
|
||||||
across
|
across
|
||||||
lst as c
|
lst as c
|
||||||
loop
|
loop
|
||||||
c.item.menu_alter (m, Current)
|
if attached {CMS_HOOK_MENU_ALTER} c.item as h then
|
||||||
|
h.menu_alter (a_menu, Current)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Hook: form_alter
|
feature -- Hook: form_alter
|
||||||
|
|
||||||
subscribe_to_form_alter_hook (h: like form_alter_hooks.item)
|
subscribe_to_form_alter_hook (h: CMS_HOOK_FORM_ALTER)
|
||||||
local
|
-- Add `h' as subscriber of form alter hooks CMS_HOOK_FORM_ALTER.
|
||||||
lst: like form_alter_hooks
|
|
||||||
do
|
do
|
||||||
lst := form_alter_hooks
|
subscribe_to_hook (h, {CMS_HOOK_MENU_ALTER})
|
||||||
if lst = Void then
|
|
||||||
create lst.make (1)
|
|
||||||
form_alter_hooks := lst
|
|
||||||
end
|
|
||||||
if not lst.has (h) then
|
|
||||||
lst.force (h)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
form_alter_hooks: detachable ARRAYED_LIST [CMS_HOOK_FORM_ALTER]
|
invoke_form_alter (a_form: CMS_FORM; a_form_data: detachable WSF_FORM_DATA)
|
||||||
|
-- Invoke form alter hook for form `a_form' and associated data `a_form_data'
|
||||||
invoke_form_alter (f: CMS_FORM; a_form_data: detachable WSF_FORM_DATA)
|
|
||||||
do
|
do
|
||||||
if attached form_alter_hooks as lst then
|
if attached hook_subscribers.item ({CMS_HOOK_FORM_ALTER}) as lst then
|
||||||
across
|
across
|
||||||
lst as c
|
lst as c
|
||||||
loop
|
loop
|
||||||
c.item.form_alter (f, a_form_data, Current)
|
if attached {CMS_HOOK_FORM_ALTER} c.item as h then
|
||||||
|
h.form_alter (a_form, a_form_data, Current)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -595,31 +589,24 @@ feature -- Hook: form_alter
|
|||||||
feature -- Hook: block
|
feature -- Hook: block
|
||||||
|
|
||||||
subscribe_to_block_hook (h: CMS_HOOK_BLOCK)
|
subscribe_to_block_hook (h: CMS_HOOK_BLOCK)
|
||||||
local
|
-- Add `h' as subscriber of hooks CMS_HOOK_BLOCK.
|
||||||
lst: like block_hooks
|
|
||||||
do
|
do
|
||||||
lst := block_hooks
|
subscribe_to_hook (h, {CMS_HOOK_BLOCK})
|
||||||
if lst = Void then
|
|
||||||
create lst.make (1)
|
|
||||||
block_hooks := lst
|
|
||||||
end
|
|
||||||
if not lst.has (h) then
|
|
||||||
lst.force (h)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
block_hooks: detachable ARRAYED_LIST [CMS_HOOK_BLOCK]
|
|
||||||
|
|
||||||
invoke_block
|
invoke_block
|
||||||
|
-- Invoke block hook in order to get block from modules.
|
||||||
do
|
do
|
||||||
if attached block_hooks as lst then
|
if attached hook_subscribers.item ({CMS_HOOK_BLOCK}) as lst then
|
||||||
across
|
across
|
||||||
lst as c
|
lst as c
|
||||||
loop
|
loop
|
||||||
across
|
if attached {CMS_HOOK_BLOCK} c.item as h then
|
||||||
c.item.block_list as blst
|
across
|
||||||
loop
|
h.block_list as blst
|
||||||
c.item.get_block_view (blst.item, Current)
|
loop
|
||||||
|
h.get_block_view (blst.item, Current)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user