Added notion of alias block, to provide a way to include a block content in mutiple regions.

This commit is contained in:
2015-10-16 23:02:47 +02:00
parent 05472abdd7
commit e90f82387f
9 changed files with 306 additions and 98 deletions

View File

@@ -0,0 +1,59 @@
note
description: "[
Block being an alias of other block.
Mainly to avoid multiple region for a block content.
]"
date: "$Date$"
revision: "$Revision$"
class
CMS_ALIAS_BLOCK
inherit
CMS_BLOCK
create
make_with_block
feature {NONE} -- Initialization
make_with_block (a_name: READABLE_STRING_8; a_block: CMS_BLOCK)
do
name := a_name
origin := a_block
title := a_block.title
end
feature -- Access
origin: CMS_BLOCK
name: READABLE_STRING_8
feature -- Status report
is_empty: BOOLEAN
-- <Precursor>
do
Result := origin.is_empty
end
is_raw: BOOLEAN
-- <Precursor>
do
Result := origin.is_raw
end
feature -- Conversion
to_html (a_theme: CMS_THEME): STRING_8
-- HTML representation of Current block.
do
Result := origin.to_html (a_theme)
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

View File

@@ -6,6 +6,11 @@ deferred class
CMS_BLOCK
inherit
CMS_BLOCK_SETUP
undefine
is_equal
end
COMPARABLE
DEBUG_OUTPUT
@@ -20,18 +25,9 @@ feature -- Access
deferred
end
title: detachable READABLE_STRING_32
-- Optional title.
deferred
end
html_options: detachable CMS_HTML_OPTIONS
-- Optional addition html options.
weight: INTEGER
-- Weight used to order blocks.
-- Default: 0;
feature -- Status report
is_empty: BOOLEAN
@@ -48,9 +44,6 @@ feature -- Status report
deferred
end
conditions: detachable LIST [CMS_BLOCK_CONDITION]
-- Optional block condition to be enabled.
feature -- Comparison
is_less alias "<" (other: like Current): BOOLEAN
@@ -87,25 +80,6 @@ feature -- Element change
opts.remove_css_class (a_class)
end
add_condition (a_condition: CMS_BLOCK_CONDITION)
-- Add condition `a_condition'.
local
l_conditions: like conditions
do
l_conditions := conditions
if l_conditions = Void then
create {ARRAYED_LIST [CMS_BLOCK_CONDITION]} l_conditions.make (1)
conditions := l_conditions
end
l_conditions.force (a_condition)
end
set_weight (w: like weight)
-- Set `weight' to `w'.
do
weight := w
end
feature -- Conversion
to_html (a_theme: CMS_THEME): STRING_8

View File

@@ -0,0 +1,55 @@
note
description: "Settings for CMS_BLOCK, that could be set and overwritten via CMS configuration."
date: "$Date$"
revision: "$Revision$"
class
CMS_BLOCK_SETUP
feature -- Access
title: detachable READABLE_STRING_32
-- Optional title.
weight: INTEGER
-- Weight used to order blocks.
-- Default: 0.
conditions: detachable LIST [CMS_BLOCK_CONDITION]
-- Optional block condition to be enabled.
feature -- Element change
set_title (a_title: detachable READABLE_STRING_GENERAL)
-- Set `title' with `a_title'.
do
if a_title = Void then
title := Void
else
title := a_title.as_string_32
end
end
set_weight (w: like weight)
-- Set `weight' to `w'.
do
weight := w
end
add_condition (a_condition: CMS_BLOCK_CONDITION)
-- Add condition `a_condition'.
local
l_conditions: like conditions
do
l_conditions := conditions
if l_conditions = Void then
create {ARRAYED_LIST [CMS_BLOCK_CONDITION]} l_conditions.make (1)
conditions := l_conditions
end
l_conditions.force (a_condition)
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

View File

@@ -32,9 +32,6 @@ feature -- Access
name: READABLE_STRING_8
-- <Precursor>
title: detachable READABLE_STRING_32
-- <Precursor>
cache: CMS_CACHE [READABLE_STRING_8]
-- Cache content.
@@ -65,12 +62,6 @@ feature -- Element change
name := n
end
set_title (a_title: like title)
-- Set `title' to `a_title'.
do
title := a_title
end
feature -- Conversion
to_html (a_theme: CMS_THEME): STRING_8

View File

@@ -39,9 +39,6 @@ feature -- Access
name: READABLE_STRING_8
-- <Precursor>
title: detachable READABLE_STRING_32
-- <Precursor>
content: READABLE_STRING_8
format: detachable CONTENT_FORMAT
@@ -74,12 +71,6 @@ feature -- Element change
name := n
end
set_title (a_title: like title)
-- Set `title' to `a_title'.
do
title := a_title
end
feature -- Conversion
to_html (a_theme: CMS_THEME): STRING_8

View File

@@ -27,8 +27,6 @@ feature -- Access
name: READABLE_STRING_8
title: detachable READABLE_STRING_32
feature -- Status report
is_empty: BOOLEAN
@@ -53,12 +51,6 @@ feature -- Element change
name := n
end
set_title (a_title: like title)
-- Set `title' to `a_title'.
do
title := a_title
end
set_is_horizontal (b: BOOLEAN)
-- Set `is_horizontal' to `b'.
do

View File

@@ -58,9 +58,6 @@ feature -- Access
name: READABLE_STRING_8
-- <Precursor>
title: detachable READABLE_STRING_32
-- <Precursor>
location: PATH
-- Location of template file.
@@ -94,12 +91,6 @@ feature -- Element change
name := n
end
set_title (a_title: like title)
-- Set `title' to `a_title'.
do
title := a_title
end
set_value (v: detachable ANY; k: READABLE_STRING_GENERAL)
-- Associate value `v' with key `k'.
do