Added permission arguments to "trash" and "Create" links.

Added blocks configuration settings via the cms.ini and "blocks" section
   ex: [blocks]
       navigation.region=sidebar_first
   This enables the site to change default block location, and even hides it easily, if the theme does not include associated region name.
This commit is contained in:
2015-08-13 00:44:16 +02:00
parent 0061afcbe8
commit e1bdcb965c
3 changed files with 38 additions and 12 deletions

View File

@@ -31,6 +31,9 @@ node=on
oauth20=on
openid=on
[blocks]
#navigation.region=sidebar_first
[admin]
# CMS Installation, are accessible by "all", "none" or uppon "permission". (default is none)
installation_access=permission

View File

@@ -173,6 +173,7 @@ feature -- Access
Result.force ("view revisions own " + l_type_name)
end
end
Result.force ("view trash")
end
end
@@ -255,6 +256,7 @@ feature -- Hooks
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
local
lnk: CMS_LOCAL_LINK
perms: ARRAYED_LIST [READABLE_STRING_8]
do
debug
create lnk.make ("List of nodes", "nodes")
@@ -262,9 +264,20 @@ feature -- Hooks
end
create lnk.make ("Trash", "trash")
a_menu_system.navigation_menu.extend (lnk)
lnk.set_permission_arguments (<<"view trash">>)
create lnk.make ("Create ..", "node")
a_menu_system.navigation_menu.extend (lnk)
if attached node_api as l_node_api then
create perms.make (2)
perms.force ("create any node")
across
l_node_api.content_types as ic
loop
perms.force ("create " + ic.item.name)
end
lnk.set_permission_arguments (perms)
end
end
populate_recent_changes (a_changes: CMS_RECENT_CHANGE_CONTAINER; a_sources: LIST [READABLE_STRING_8])

View File

@@ -403,19 +403,26 @@ feature -- Blocks initialization
create regions.make_caseless (5)
create l_table.make_caseless (10)
l_table["top"] := "top"
l_table["header"] := "header"
l_table["highlighted"] := "highlighted"
l_table["help"] := "help"
l_table["content"] := "content"
l_table["footer"] := "footer"
l_table["management"] := "sidebar_first"
l_table["navigation"] := "sidebar_first"
l_table["user"] := "sidebar_first"
l_table["bottom"] := "page_bottom"
l_table["top"] := block_region_preference ("top", "top")
l_table["header"] := block_region_preference ("header", "header")
l_table["highlighted"] := block_region_preference ("highlighted", "highlighted")
l_table["help"] := block_region_preference ("help", "help")
l_table["content"] := block_region_preference ("content", "content")
l_table["footer"] := block_region_preference ("footer", "footer")
l_table["management"] := block_region_preference ("management", "sidebar_first")
l_table["navigation"] := block_region_preference ("navigation", "sidebar_first")
l_table["user"] := block_region_preference ("user", "sidebar_first")
l_table["bottom"] := block_region_preference ("bottom", "page_bottom")
block_region_settings := l_table
end
block_region_preference (a_block_id: READABLE_STRING_8; a_default_region: READABLE_STRING_8): READABLE_STRING_8
-- Region associated with `a_block_id' in configuration, if any.
do
Result := setup.text_item_or_default ("blocks." + a_block_id + ".region", a_default_region)
end
feature -- Blocks regions
regions: STRING_TABLE [CMS_BLOCK_REGION]
@@ -430,12 +437,15 @@ feature -- Blocks regions
do
l_region_name := block_region_settings.item (b.name)
if l_region_name = Void then
if a_default_region /= Void then
if attached setup.text_item ("blocks." + b.name + ".region") as l_setup_name then
l_region_name := l_setup_name.as_string_8 -- FIXME: potential truncated string 32.
-- Remember for later.
block_region_settings.force (l_region_name, b.name)
elseif a_default_region /= Void then
l_region_name := a_default_region
else
-- Default .. put it in same named region
-- Maybe a bad idea
l_region_name := b.name.as_lower
end
end