Refactor directory structrue
This commit is contained in:
193
library/src/theme/cms_html_page.e
Normal file
193
library/src/theme/cms_html_page.e
Normal file
@@ -0,0 +1,193 @@
|
||||
note
|
||||
description: "Summary description for {CMS_HTML_PAGE}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-04 09:57:24 -0300 (ma. 04 de nov. de 2014) $"
|
||||
revision: "$Revision: 96034 $"
|
||||
|
||||
class
|
||||
CMS_HTML_PAGE
|
||||
|
||||
create
|
||||
make,
|
||||
make_typed
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_typed (a_type: like type)
|
||||
-- Make current page with optional page type `a_type'.
|
||||
do
|
||||
make
|
||||
type := a_type
|
||||
end
|
||||
|
||||
make
|
||||
do
|
||||
create regions.make (5)
|
||||
language := "en"
|
||||
|
||||
status_code := {HTTP_STATUS_CODE}.ok
|
||||
create header.make
|
||||
create {ARRAYED_LIST [STRING]} head_lines.make (5)
|
||||
header.put_content_type_text_html
|
||||
create variables.make (0)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
type: detachable READABLE_STRING_8
|
||||
-- Optional page type.
|
||||
-- such as "front", "about", ... that could be customized by themes.
|
||||
|
||||
is_front: BOOLEAN
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
|
||||
language: STRING
|
||||
|
||||
head_lines: LIST [STRING]
|
||||
|
||||
head_lines_to_string: STRING
|
||||
do
|
||||
create Result.make_empty
|
||||
across
|
||||
head_lines as h
|
||||
loop
|
||||
Result.append (h.item)
|
||||
Result.append_character ('%N')
|
||||
end
|
||||
end
|
||||
|
||||
variables: STRING_TABLE [detachable ANY]
|
||||
|
||||
feature -- Status
|
||||
|
||||
|
||||
status_code: INTEGER
|
||||
|
||||
feature -- Header
|
||||
|
||||
header: HTTP_HEADER
|
||||
|
||||
feature -- Region
|
||||
|
||||
regions: STRING_TABLE [STRING_8]
|
||||
-- header
|
||||
-- content
|
||||
-- footer
|
||||
-- could have sidebar first, sidebar second, ...
|
||||
|
||||
region (n: STRING_8): STRING_8
|
||||
do
|
||||
if attached regions.item (n) as r then
|
||||
Result := r
|
||||
else
|
||||
Result := ""
|
||||
debug
|
||||
Result := "{{" + n + "}}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_is_front (b: BOOLEAN)
|
||||
-- Set `is_front' to `b'.
|
||||
do
|
||||
is_front := b
|
||||
end
|
||||
|
||||
register_variable (a_value: detachable ANY; k: READABLE_STRING_GENERAL)
|
||||
do
|
||||
variables.force (a_value, k)
|
||||
end
|
||||
|
||||
add_to_region (s: STRING; k: STRING)
|
||||
local
|
||||
r: detachable STRING
|
||||
do
|
||||
r := regions.item (k)
|
||||
if r = Void then
|
||||
create r.make_from_string (s)
|
||||
set_region (r, k)
|
||||
else
|
||||
r.append (s)
|
||||
end
|
||||
end
|
||||
|
||||
set_region (s: STRING; k: STRING)
|
||||
do
|
||||
regions.force (s, k)
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_status_code (c: like status_code)
|
||||
do
|
||||
status_code := c
|
||||
end
|
||||
|
||||
set_language (s: like language)
|
||||
do
|
||||
language := s
|
||||
end
|
||||
|
||||
set_title (s: like title)
|
||||
do
|
||||
title := s
|
||||
end
|
||||
|
||||
add_meta_name_content (a_name: STRING; a_content: STRING)
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
s := "<meta name=%"" + a_name + "%" content=%"" + a_content + "%" />"
|
||||
head_lines.extend (s)
|
||||
end
|
||||
|
||||
add_meta_http_equiv (a_http_equiv: STRING; a_content: STRING)
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
s := "<meta http-equiv=%"" + a_http_equiv + "%" content=%"" + a_content + "%" />"
|
||||
head_lines.extend (s)
|
||||
end
|
||||
|
||||
add_style (a_href: STRING; a_media: detachable STRING)
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
s := "<link rel=%"stylesheet%" href=%""+ a_href + "%" type=%"text/css%""
|
||||
if a_media /= Void then
|
||||
s.append (" media=%""+ a_media + "%"")
|
||||
end
|
||||
s.append ("/>")
|
||||
head_lines.extend (s)
|
||||
end
|
||||
|
||||
add_javascript_url (a_src: STRING)
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
s := "<script type=%"text/javascript%" src=%"" + a_src + "%"></script>"
|
||||
head_lines.extend (s)
|
||||
end
|
||||
|
||||
add_javascript_content (a_script: STRING)
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
s := "<script type=%"text/javascript%">%N" + a_script + "%N</script>"
|
||||
head_lines.extend (s)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
77
library/src/theme/cms_html_page_response.e
Normal file
77
library/src/theme/cms_html_page_response.e
Normal file
@@ -0,0 +1,77 @@
|
||||
note
|
||||
description: "Summary description for {CMS_HTML_PAGE_RESPONSE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_HTML_PAGE_RESPONSE
|
||||
|
||||
inherit
|
||||
WSF_RESPONSE_MESSAGE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_html: like html)
|
||||
do
|
||||
html := a_html
|
||||
status_code := {HTTP_STATUS_CODE}.ok
|
||||
create header.make
|
||||
header.put_content_type_text_html
|
||||
end
|
||||
|
||||
feature -- Status
|
||||
|
||||
status_code: INTEGER
|
||||
|
||||
feature -- Header
|
||||
|
||||
header: HTTP_HEADER
|
||||
|
||||
feature -- Html access
|
||||
|
||||
html: STRING
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_status_code (c: like status_code)
|
||||
do
|
||||
status_code := c
|
||||
end
|
||||
|
||||
feature {WSF_RESPONSE} -- Output
|
||||
|
||||
send_to (res: WSF_RESPONSE)
|
||||
local
|
||||
h: like header
|
||||
s: STRING_8
|
||||
do
|
||||
h := header
|
||||
res.set_status_code (status_code)
|
||||
s := html
|
||||
|
||||
if not h.has_content_length then
|
||||
h.put_content_length (s.count)
|
||||
end
|
||||
if not h.has_content_type then
|
||||
h.put_content_type_text_html
|
||||
end
|
||||
res.put_header_text (h.string)
|
||||
res.put_string (s)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
|
||||
13
library/src/theme/cms_html_template.e
Normal file
13
library/src/theme/cms_html_template.e
Normal file
@@ -0,0 +1,13 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CMS_HTML_TEMPLATE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_HTML_TEMPLATE
|
||||
|
||||
inherit
|
||||
CMS_TEMPLATE
|
||||
|
||||
end
|
||||
12
library/src/theme/cms_page_template.e
Normal file
12
library/src/theme/cms_page_template.e
Normal file
@@ -0,0 +1,12 @@
|
||||
note
|
||||
description: "Summary description for {CMS_PAGE_TEMPLATE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_PAGE_TEMPLATE
|
||||
|
||||
inherit
|
||||
CMS_TEMPLATE
|
||||
end
|
||||
37
library/src/theme/cms_template.e
Normal file
37
library/src/theme/cms_template.e
Normal file
@@ -0,0 +1,37 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CMS_PAGE_TEMPLATE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_TEMPLATE
|
||||
|
||||
feature -- Access
|
||||
|
||||
theme: CMS_THEME
|
||||
deferred
|
||||
end
|
||||
|
||||
variables: STRING_TABLE [detachable ANY]
|
||||
deferred
|
||||
end
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
deferred
|
||||
end
|
||||
|
||||
to_html (page: CMS_HTML_PAGE): STRING
|
||||
deferred
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
138
library/src/theme/cms_theme.e
Normal file
138
library/src/theme/cms_theme.e
Normal file
@@ -0,0 +1,138 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CMS_THEME}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_THEME
|
||||
|
||||
inherit
|
||||
CMS_ENCODERS
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
|
||||
feature {NONE} -- Access
|
||||
|
||||
setup: CMS_SETUP
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING
|
||||
-- theme name.
|
||||
deferred
|
||||
end
|
||||
|
||||
regions: ARRAY [STRING]
|
||||
-- theme's regions.
|
||||
deferred
|
||||
end
|
||||
|
||||
page_template: CMS_TEMPLATE
|
||||
-- theme template page.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
menu_html (a_menu: CMS_MENU; is_horizontal: BOOLEAN): STRING_8
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Refactor HTML code to use the new Bootstrap theme template")
|
||||
end
|
||||
create Result.make_from_string ("<div id=%""+ a_menu.name +"%" class=%"menu%">")
|
||||
if is_horizontal then
|
||||
Result.append ("<ul class=%"horizontal%" >%N")
|
||||
else
|
||||
Result.append ("<ul class=%"vertical%" >%N")
|
||||
end
|
||||
across
|
||||
a_menu as c
|
||||
loop
|
||||
append_cms_link_to (c.item, Result)
|
||||
end
|
||||
Result.append ("</ul>%N")
|
||||
Result.append ("</div>")
|
||||
end
|
||||
|
||||
block_html (a_block: CMS_BLOCK): STRING_8
|
||||
local
|
||||
s: STRING
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Refactor HTML code to use the new Bootstrap theme template")
|
||||
end
|
||||
if attached {CMS_CONTENT_BLOCK} a_block as l_content_block and then l_content_block.is_raw then
|
||||
create s.make_empty
|
||||
if attached l_content_block.title as l_title then
|
||||
s.append ("<div class=%"title%">" + html_encoded (l_title) + "</div>")
|
||||
end
|
||||
s.append (l_content_block.to_html (Current))
|
||||
else
|
||||
create s.make_from_string ("<div class=%"block%" id=%"" + a_block.name + "%">")
|
||||
if attached a_block.title as l_title then
|
||||
s.append ("<div class=%"title%">" + html_encoded (l_title) + "</div>")
|
||||
end
|
||||
s.append ("<div class=%"inside%">")
|
||||
s.append (a_block.to_html (Current))
|
||||
s.append ("</div>")
|
||||
s.append ("</div>")
|
||||
end
|
||||
Result := s
|
||||
end
|
||||
page_html (page: CMS_HTML_PAGE): STRING_8
|
||||
-- Render `page' as html.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
append_cms_link_to (lnk: CMS_LINK; s: STRING_8)
|
||||
local
|
||||
cl: STRING
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Remove HTML from Eiffel")
|
||||
end
|
||||
create cl.make_empty
|
||||
if lnk.is_active then
|
||||
cl.append ("active ")
|
||||
end
|
||||
if lnk.is_expandable then
|
||||
cl.append ("expandable ")
|
||||
end
|
||||
if lnk.is_expanded then
|
||||
cl.append ("expanded ")
|
||||
end
|
||||
if cl.is_empty then
|
||||
s.append ("<li>")
|
||||
else
|
||||
s.append ("<li class=%""+ cl + "%">")
|
||||
end
|
||||
s.append ("<a href=%"" + (lnk.location) + "%">" + html_encoded (lnk.title) + "</a>")
|
||||
if
|
||||
(lnk.is_expanded or lnk.is_collapsed) and then
|
||||
attached lnk.children as l_children
|
||||
then
|
||||
s.append ("<ul>%N")
|
||||
across
|
||||
l_children as c
|
||||
loop
|
||||
append_cms_link_to (c.item, s)
|
||||
end
|
||||
s.append ("</ul>")
|
||||
end
|
||||
s.append ("</li>")
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
135
library/src/theme/cms_theme_information.e
Normal file
135
library/src/theme/cms_theme_information.e
Normal file
@@ -0,0 +1,135 @@
|
||||
note
|
||||
description: "Summary description for {CMS_THEME_INFORMATION}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_THEME_INFORMATION
|
||||
|
||||
create
|
||||
make,
|
||||
make_default
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_default
|
||||
do
|
||||
engine := {STRING_32} "default"
|
||||
create items.make_caseless (1)
|
||||
create regions.make (5)
|
||||
across
|
||||
(<<"top","header", "highlighted","help", "content", "footer", "first_sidebar", "second_sidebar", "bottom">>) as ic
|
||||
loop
|
||||
regions.force (ic.item, ic.item)
|
||||
end
|
||||
end
|
||||
|
||||
make (fn: PATH)
|
||||
local
|
||||
f: PLAIN_TEXT_FILE
|
||||
s: STRING_8
|
||||
h,k: STRING_8
|
||||
v: STRING_32
|
||||
i: INTEGER
|
||||
utf: UTF_CONVERTER
|
||||
l_engine: detachable READABLE_STRING_32
|
||||
done: BOOLEAN
|
||||
do
|
||||
make_default
|
||||
create f.make_with_path (fn)
|
||||
if f.exists and then f.is_access_readable then
|
||||
f.open_read
|
||||
from
|
||||
until
|
||||
done or f.exhausted or f.end_of_file
|
||||
loop
|
||||
f.read_line_thread_aware
|
||||
s := f.last_string
|
||||
s.left_adjust
|
||||
if
|
||||
s.is_empty
|
||||
or else s.starts_with_general (";")
|
||||
or else s.starts_with_general ("#")
|
||||
or else s.starts_with_general ("--")
|
||||
then
|
||||
-- Ignore
|
||||
else
|
||||
i := s.index_of ('=', 1)
|
||||
if i > 0 then
|
||||
h := s.substring (1, i - 1)
|
||||
h.left_adjust
|
||||
h.right_adjust
|
||||
if h.is_case_insensitive_equal_general ("engine") then
|
||||
s.remove_head (i)
|
||||
s.right_adjust
|
||||
v := utf.utf_8_string_8_to_string_32 (s)
|
||||
l_engine := v
|
||||
elseif h.starts_with_general ("regions[") and h[h.count] = ']' then
|
||||
s.remove_head (i)
|
||||
s.right_adjust
|
||||
v := utf.utf_8_string_8_to_string_32 (s)
|
||||
i := h.index_of ('[', 1)
|
||||
k := h.substring (i + 1, h.count - 1)
|
||||
k.left_adjust
|
||||
k.right_adjust
|
||||
if k.starts_with_general ("-") then
|
||||
--| If name is prefixed by "-"
|
||||
--| remove the related region
|
||||
--| If name is "-*", clear all regions.
|
||||
if k.is_case_insensitive_equal_general ("-*") then
|
||||
regions.wipe_out
|
||||
else
|
||||
k.remove_head (1)
|
||||
regions.remove (k)
|
||||
end
|
||||
else
|
||||
regions.force (v, k)
|
||||
end
|
||||
else
|
||||
s.remove_head (i)
|
||||
s.right_adjust
|
||||
v := utf.utf_8_string_8_to_string_32 (s)
|
||||
end
|
||||
items.force (v, h)
|
||||
end
|
||||
end
|
||||
end
|
||||
f.close
|
||||
end
|
||||
if l_engine /= Void and then not l_engine.is_empty then
|
||||
engine := l_engine
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
engine: STRING_32
|
||||
-- Template engine.
|
||||
--| Could be: default, smarty, ...
|
||||
|
||||
regions: STRING_TABLE [READABLE_STRING_GENERAL]
|
||||
-- Regions available in this theme
|
||||
|
||||
item (k: READABLE_STRING_GENERAL): detachable STRING_32
|
||||
-- Item associated with name `k' if any.
|
||||
do
|
||||
Result := items[k]
|
||||
end
|
||||
|
||||
items: STRING_TABLE [STRING_32]
|
||||
-- Items indexed by key name.
|
||||
|
||||
invariant
|
||||
engine_set: not engine.is_empty
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
75
library/src/theme/default_cms_template.e
Normal file
75
library/src/theme/default_cms_template.e
Normal file
@@ -0,0 +1,75 @@
|
||||
note
|
||||
description: "Summary description for {DEFAULT_CMS_TEMPLATE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
DEFAULT_CMS_TEMPLATE
|
||||
|
||||
inherit
|
||||
CMS_TEMPLATE
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
apply_template_engine (s: STRING_8)
|
||||
local
|
||||
p,n: INTEGER
|
||||
k: STRING
|
||||
sv: detachable STRING
|
||||
do
|
||||
from
|
||||
n := s.count
|
||||
p := 1
|
||||
until
|
||||
p = 0
|
||||
loop
|
||||
p := s.index_of ('$', p)
|
||||
if p > 0 then
|
||||
k := next_identifier (s, p + 1)
|
||||
s.remove_substring (p, p + k.count)
|
||||
sv := Void
|
||||
if attached variables.item (k) as l_value then
|
||||
|
||||
if attached {STRING_8} l_value as s8 then
|
||||
sv := s8
|
||||
elseif attached {STRING_32} l_value as s32 then
|
||||
sv := s32.as_string_8 -- FIXME: use html encoder
|
||||
else
|
||||
sv := l_value.out
|
||||
end
|
||||
s.insert_string (sv, p)
|
||||
p := p + sv.count
|
||||
else
|
||||
debug
|
||||
s.insert_string ("$" + k, p)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
next_identifier (s: STRING; a_index: INTEGER): STRING
|
||||
local
|
||||
i: INTEGER
|
||||
do
|
||||
from
|
||||
i := a_index
|
||||
until
|
||||
not (s[i].is_alpha_numeric or s[i] = '_' or s[i] = '.')
|
||||
loop
|
||||
i := i + 1
|
||||
end
|
||||
Result := s.substring (a_index, i - 1)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
100
library/src/theme/default_theme/default_cms_html_template.e
Normal file
100
library/src/theme/default_theme/default_cms_html_template.e
Normal file
@@ -0,0 +1,100 @@
|
||||
note
|
||||
description: "Summary description for {CMS_HTML_TEMPLATE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
DEFAULT_CMS_HTML_TEMPLATE
|
||||
|
||||
inherit
|
||||
CMS_HTML_TEMPLATE
|
||||
|
||||
DEFAULT_CMS_TEMPLATE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (t: DEFAULT_CMS_THEME)
|
||||
do
|
||||
theme := t
|
||||
create variables.make (0)
|
||||
end
|
||||
|
||||
variables: STRING_TABLE [detachable ANY]
|
||||
|
||||
feature -- Access
|
||||
|
||||
register (v: STRING_8; k: STRING_8)
|
||||
do
|
||||
variables.force (v, k)
|
||||
end
|
||||
|
||||
theme: DEFAULT_CMS_THEME
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
variables.make (10)
|
||||
|
||||
across
|
||||
page.variables as ic
|
||||
loop
|
||||
variables.force (ic.item, ic.key)
|
||||
end
|
||||
|
||||
if attached page.title as l_title then
|
||||
variables.force (l_title, "title")
|
||||
variables.force (l_title, "head_title")
|
||||
else
|
||||
variables.force ("", "title")
|
||||
variables.force ("", "head_title")
|
||||
end
|
||||
|
||||
variables.force (page.language, "language")
|
||||
variables.force (page.head_lines_to_string, "head_lines")
|
||||
end
|
||||
|
||||
to_html (page: CMS_HTML_PAGE): STRING
|
||||
do
|
||||
-- Process html generation
|
||||
create Result.make_from_string (template)
|
||||
apply_template_engine (Result)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
template: STRING
|
||||
once
|
||||
Result := "[
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$language" lang="$language" version="XHTML+RDFa 1.0" dir="ltr">
|
||||
<head>
|
||||
$head
|
||||
<title>$head_title</title>
|
||||
$styles
|
||||
$scripts
|
||||
$head_lines
|
||||
</head>
|
||||
<body class="$body_classes" $body_attributes>
|
||||
$page_top
|
||||
$page
|
||||
$page_bottom
|
||||
</body>
|
||||
</html>
|
||||
]"
|
||||
end
|
||||
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
102
library/src/theme/default_theme/default_cms_page_template.e
Normal file
102
library/src/theme/default_theme/default_cms_page_template.e
Normal file
@@ -0,0 +1,102 @@
|
||||
note
|
||||
description: "Summary description for {CMS_PAGE_TEMPLATE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
DEFAULT_CMS_PAGE_TEMPLATE
|
||||
|
||||
inherit
|
||||
CMS_PAGE_TEMPLATE
|
||||
|
||||
DEFAULT_CMS_TEMPLATE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (t: DEFAULT_CMS_THEME)
|
||||
do
|
||||
theme := t
|
||||
create variables.make (0)
|
||||
end
|
||||
|
||||
variables: STRING_TABLE [detachable ANY]
|
||||
|
||||
feature -- Access
|
||||
|
||||
theme: DEFAULT_CMS_THEME
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
variables.make (10)
|
||||
|
||||
across
|
||||
page.variables as ic
|
||||
loop
|
||||
variables.force (ic.item, ic.key)
|
||||
end
|
||||
|
||||
if attached page.title as l_title then
|
||||
variables.force (l_title, "title")
|
||||
else
|
||||
variables.force ("", "title")
|
||||
end
|
||||
across
|
||||
theme.regions as r
|
||||
loop
|
||||
variables.force (page.region (r.item), r.item)
|
||||
end
|
||||
end
|
||||
|
||||
to_html (page: CMS_HTML_PAGE): STRING
|
||||
do
|
||||
-- Process html generation
|
||||
create Result.make_from_string (template)
|
||||
apply_template_engine (Result)
|
||||
end
|
||||
|
||||
feature -- Registration
|
||||
|
||||
register (v: STRING_8; k: STRING_8)
|
||||
do
|
||||
variables.force (v, k)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
template: STRING
|
||||
once
|
||||
Result := "[
|
||||
<div id="page-wrapper">
|
||||
<div id="page">
|
||||
<div id="header">
|
||||
$header
|
||||
</div>
|
||||
<div id="main-wrapper">
|
||||
<div id="main">
|
||||
<div id="first_sidebar" class="sidebar $first_sidebar_css_class">$first_sidebar</div>
|
||||
<div id="content" class="$content_css_class">$content</div>
|
||||
<div id="second_sidebar" class="sidebar $second_sidebar_css_class">$second_sidebar</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">$footer</div>
|
||||
</div>
|
||||
</div>
|
||||
]"
|
||||
end
|
||||
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
100
library/src/theme/default_theme/default_cms_theme.e
Normal file
100
library/src/theme/default_theme/default_cms_theme.e
Normal file
@@ -0,0 +1,100 @@
|
||||
note
|
||||
description: "Summary description for {CMS_THEME}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
DEFAULT_CMS_THEME
|
||||
|
||||
inherit
|
||||
CMS_THEME
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_setup: like setup; a_info: like information)
|
||||
do
|
||||
setup := a_setup
|
||||
information := a_info
|
||||
end
|
||||
|
||||
information: CMS_THEME_INFORMATION
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING = "CMS"
|
||||
|
||||
regions: ARRAY [STRING]
|
||||
once
|
||||
Result := <<"header", "content", "footer", "first_sidebar", "second_sidebar">>
|
||||
end
|
||||
|
||||
html_template: DEFAULT_CMS_HTML_TEMPLATE
|
||||
local
|
||||
tpl: like internal_html_template
|
||||
do
|
||||
tpl := internal_html_template
|
||||
if tpl = Void then
|
||||
create tpl.make (Current)
|
||||
internal_html_template := tpl
|
||||
end
|
||||
Result := tpl
|
||||
end
|
||||
|
||||
page_template: DEFAULT_CMS_PAGE_TEMPLATE
|
||||
local
|
||||
tpl: like internal_page_template
|
||||
do
|
||||
tpl := internal_page_template
|
||||
if tpl = Void then
|
||||
create tpl.make (Current)
|
||||
internal_page_template := tpl
|
||||
end
|
||||
Result := tpl
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
end
|
||||
|
||||
page_html (page: CMS_HTML_PAGE): STRING_8
|
||||
local
|
||||
l_content: STRING_8
|
||||
do
|
||||
prepare (page)
|
||||
page_template.prepare (page)
|
||||
l_content := page_template.to_html (page)
|
||||
html_template.prepare (page)
|
||||
html_template.register (l_content, "page")
|
||||
Result := html_template.to_html (page)
|
||||
end
|
||||
|
||||
navigation_template: detachable READABLE_STRING_GENERAL
|
||||
-- navigation template name, if any.
|
||||
do
|
||||
end
|
||||
|
||||
feature {NONE} -- Internal
|
||||
|
||||
internal_page_template: detachable like page_template
|
||||
|
||||
internal_html_template: detachable like html_template
|
||||
|
||||
invariant
|
||||
attached internal_page_template as inv_p implies inv_p.theme = Current
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
@@ -0,0 +1,60 @@
|
||||
note
|
||||
description: "Summary description for {SMARTY_CMS_HTML_PAGE_INSPECTOR}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-07 04:58:41 -0300 (vi. 07 de nov. de 2014) $"
|
||||
revision: "$Revision: 96042 $"
|
||||
|
||||
class
|
||||
SMARTY_CMS_HTML_PAGE_INSPECTOR
|
||||
|
||||
inherit
|
||||
TEMPLATE_INSPECTOR
|
||||
redefine
|
||||
internal_data
|
||||
end
|
||||
|
||||
CMS_ENCODERS
|
||||
|
||||
create
|
||||
register
|
||||
|
||||
feature {TEMPLATE_ROUTINES}
|
||||
|
||||
internal_data (field_name: STRING; obj: detachable ANY): detachable CELL [detachable ANY]
|
||||
-- Return object in a cell
|
||||
-- If not handled by this inspector, return Void
|
||||
local
|
||||
l_fn: STRING
|
||||
do
|
||||
if attached {CMS_HTML_PAGE} obj as l_page then
|
||||
l_fn := field_name.as_lower
|
||||
if attached l_page.variables.item (l_fn) as v then
|
||||
Result := cell_of (v)
|
||||
elseif l_fn.is_case_insensitive_equal ("title") then
|
||||
if attached l_page.title as l_title then
|
||||
Result := cell_of (html_encoded (l_title))
|
||||
else
|
||||
Result := cell_of (Void)
|
||||
end
|
||||
elseif l_fn.is_case_insensitive_equal ("is_front") then
|
||||
Result := cell_of (l_page.is_front)
|
||||
elseif l_fn.starts_with_general ("region_") then
|
||||
l_fn.remove_head (7) -- remove "region_"
|
||||
Result := cell_of (l_page.region (l_fn))
|
||||
elseif l_fn.is_case_insensitive_equal ("regions") then
|
||||
Result := cell_of (l_page.regions)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
137
library/src/theme/smarty_theme/smarty_cms_page_template.e
Normal file
137
library/src/theme/smarty_theme/smarty_cms_page_template.e
Normal file
@@ -0,0 +1,137 @@
|
||||
note
|
||||
description: "Summary description for {CMS_PAGE_TEMPLATE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
SMARTY_CMS_PAGE_TEMPLATE
|
||||
|
||||
inherit
|
||||
CMS_PAGE_TEMPLATE
|
||||
|
||||
CMS_ENCODERS
|
||||
|
||||
SHARED_TEMPLATE_CONTEXT
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (tpl: READABLE_STRING_GENERAL; t: SMARTY_CMS_THEME)
|
||||
do
|
||||
theme := t
|
||||
create variables.make (0)
|
||||
template_name := tpl
|
||||
end
|
||||
|
||||
variables: STRING_TABLE [detachable ANY]
|
||||
|
||||
feature -- Access
|
||||
|
||||
template_name: READABLE_STRING_GENERAL
|
||||
|
||||
theme: SMARTY_CMS_THEME
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
variables.make (10)
|
||||
|
||||
across
|
||||
page.variables as ic
|
||||
loop
|
||||
variables.force (ic.item, ic.key)
|
||||
end
|
||||
|
||||
-- FIXME: review variables !
|
||||
if attached page.title as l_title then
|
||||
variables.force (html_encoded (l_title), "head_title")
|
||||
variables.force (html_encoded (l_title), "page_title")
|
||||
else
|
||||
variables.force ("CMS", "head_title")
|
||||
variables.force ("", "page_title")
|
||||
end
|
||||
|
||||
variables.force (page.language, "language")
|
||||
variables.force (page.head_lines_to_string, "head_lines")
|
||||
|
||||
across
|
||||
theme.regions as r
|
||||
loop
|
||||
variables.force (page.region (r.item), "region_" + r.item)
|
||||
end
|
||||
end
|
||||
|
||||
to_html (page: CMS_HTML_PAGE): STRING
|
||||
local
|
||||
tpl: detachable TEMPLATE_FILE
|
||||
ut: FILE_UTILITIES
|
||||
p: detachable PATH
|
||||
n: STRING_32
|
||||
do
|
||||
-- Process html generation
|
||||
template_context.set_template_folder (theme.templates_directory)
|
||||
template_context.disable_verbose
|
||||
debug ("smarty")
|
||||
template_context.enable_verbose
|
||||
end
|
||||
p := template_context.template_folder
|
||||
if p = Void then
|
||||
create p.make_current
|
||||
end
|
||||
if attached page.type as l_page_type then
|
||||
create n.make_from_string_general (l_page_type)
|
||||
n.append_character ('-')
|
||||
n.append_string_general (template_name)
|
||||
n.append_string_general (".tpl")
|
||||
if ut.file_path_exists (p.extended (n)) then
|
||||
create tpl.make_from_file (n)
|
||||
end
|
||||
end
|
||||
if tpl = Void then
|
||||
create n.make_from_string_general (template_name)
|
||||
n.append_string_general (".tpl")
|
||||
if ut.file_path_exists (p.extended (n)) then
|
||||
create tpl.make_from_file (n)
|
||||
end
|
||||
end
|
||||
if tpl /= Void then
|
||||
across
|
||||
variables as ic
|
||||
loop
|
||||
tpl.add_value (ic.item, ic.key)
|
||||
end
|
||||
|
||||
debug ("cms")
|
||||
template_context.enable_verbose
|
||||
end
|
||||
tpl.analyze
|
||||
tpl.get_output
|
||||
if attached tpl.output as l_output then
|
||||
Result := l_output
|
||||
else
|
||||
create Result.make_from_string ("ERROR: template issue.")
|
||||
end
|
||||
else
|
||||
create Result.make_from_string ("ERROR: template issue.")
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Registration
|
||||
|
||||
register (v: STRING_8; k: STRING_8)
|
||||
do
|
||||
variables.force (v, k)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
@@ -0,0 +1,47 @@
|
||||
note
|
||||
description: "Summary description for {SMARTY_CMS_REGIONS_INSPECTOR}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-06 17:59:12 -0300 (ju. 06 de nov. de 2014) $"
|
||||
revision: "$Revision: 96040 $"
|
||||
|
||||
class
|
||||
SMARTY_CMS_REGIONS_INSPECTOR
|
||||
|
||||
inherit
|
||||
TEMPLATE_INSPECTOR
|
||||
redefine
|
||||
internal_data
|
||||
end
|
||||
|
||||
create
|
||||
register
|
||||
|
||||
feature {TEMPLATE_ROUTINES}
|
||||
|
||||
internal_data (field_name: STRING; obj: detachable ANY): detachable CELL [detachable ANY]
|
||||
-- Return object in a cell
|
||||
-- If not handled by this inspector, return Void
|
||||
local
|
||||
l_fn: STRING
|
||||
do
|
||||
if attached {like {CMS_RESPONSE}.regions} obj as l_regions then
|
||||
l_fn := field_name.as_lower
|
||||
if l_fn.is_case_insensitive_equal ("count") then
|
||||
Result := cell_of (l_regions.count)
|
||||
elseif l_regions.has (l_fn) then
|
||||
Result := cell_of (l_regions.item (l_fn))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
137
library/src/theme/smarty_theme/smarty_cms_theme.e
Normal file
137
library/src/theme/smarty_theme/smarty_cms_theme.e
Normal file
@@ -0,0 +1,137 @@
|
||||
note
|
||||
description: "Summary description for {SMARTY_CMS_THEME}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
SMARTY_CMS_THEME
|
||||
|
||||
inherit
|
||||
CMS_THEME
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_setup: like setup; a_info: like information;)
|
||||
do
|
||||
setup := a_setup
|
||||
information := a_info
|
||||
if attached a_info.item ("template_dir") as s then
|
||||
templates_directory := a_setup.theme_location.extended (s)
|
||||
else
|
||||
templates_directory := a_setup.theme_location
|
||||
end
|
||||
ensure
|
||||
setup_set: setup = a_setup
|
||||
information_set: information = a_info
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING = "smarty-CMS"
|
||||
|
||||
templates_directory: PATH
|
||||
|
||||
information: CMS_THEME_INFORMATION
|
||||
|
||||
regions: ARRAY [STRING]
|
||||
local
|
||||
i: INTEGER
|
||||
utf: UTF_CONVERTER
|
||||
l_regions: like internal_regions
|
||||
do
|
||||
l_regions := internal_regions
|
||||
if l_regions = Void then
|
||||
if attached information.regions as tb and then not tb.is_empty then
|
||||
i := 1
|
||||
create l_regions.make_filled ("", i, i + tb.count - 1)
|
||||
across
|
||||
tb as ic
|
||||
loop
|
||||
l_regions.force (utf.utf_32_string_to_utf_8_string_8 (ic.key), i) -- NOTE: UTF-8 encoded !
|
||||
i := i + 1
|
||||
end
|
||||
else
|
||||
l_regions := <<"top","header", "content", "footer", "first_sidebar", "second_sidebar","bottom">>
|
||||
end
|
||||
internaL_regions := l_regions
|
||||
end
|
||||
Result := l_regions
|
||||
end
|
||||
|
||||
page_template: SMARTY_CMS_PAGE_TEMPLATE
|
||||
local
|
||||
tpl: like internal_page_template
|
||||
do
|
||||
tpl := internal_page_template
|
||||
if tpl = Void then
|
||||
create tpl.make ("page", Current)
|
||||
internal_page_template := tpl
|
||||
end
|
||||
Result := tpl
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
page.register_variable (page, "page")
|
||||
page.register_variable (page.regions, "regions")
|
||||
across
|
||||
page.regions as ic
|
||||
loop
|
||||
page.register_variable (ic.item, "region_" + ic.key)
|
||||
end
|
||||
end
|
||||
|
||||
page_html (page: CMS_HTML_PAGE): STRING_8
|
||||
local
|
||||
l_page_inspector: detachable SMARTY_CMS_HTML_PAGE_INSPECTOR
|
||||
l_regions_inspector: detachable SMARTY_CMS_REGIONS_INSPECTOR
|
||||
l_table_inspector: detachable STRING_TABLE_OF_STRING_INSPECTOR
|
||||
do
|
||||
prepare (page)
|
||||
create l_page_inspector.register (page.generating_type)
|
||||
|
||||
if attached {CMS_RESPONSE} page.variables.item ("cms") as l_cms then
|
||||
if attached l_cms.regions as l_regions then
|
||||
create l_regions_inspector.register (l_regions.generating_type)
|
||||
end
|
||||
end
|
||||
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [STRING]}).name)
|
||||
page_template.prepare (page)
|
||||
Result := page_template.to_html (page)
|
||||
|
||||
-- Clean template inspector.
|
||||
if l_regions_inspector /= Void then
|
||||
l_regions_inspector.unregister
|
||||
end
|
||||
if l_page_inspector /= Void then
|
||||
l_page_inspector.unregister
|
||||
end
|
||||
l_table_inspector.unregister
|
||||
end
|
||||
|
||||
feature {NONE} -- Internal
|
||||
|
||||
internal_regions: detachable like regions
|
||||
|
||||
internal_page_template: detachable like page_template
|
||||
|
||||
invariant
|
||||
attached internal_page_template as inv_p implies inv_p.theme = Current
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
@@ -0,0 +1,47 @@
|
||||
note
|
||||
description: "Summary description for {STRING_TABLE_OF_STRING_INSPECTOR}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-06 17:59:12 -0300 (ju. 06 de nov. de 2014) $"
|
||||
revision: "$Revision: 96040 $"
|
||||
|
||||
class
|
||||
STRING_TABLE_OF_STRING_INSPECTOR
|
||||
|
||||
inherit
|
||||
TEMPLATE_INSPECTOR
|
||||
redefine
|
||||
internal_data
|
||||
end
|
||||
|
||||
create
|
||||
register
|
||||
|
||||
feature {TEMPLATE_ROUTINES}
|
||||
|
||||
internal_data (field_name: STRING; obj: detachable ANY): detachable CELL [detachable ANY]
|
||||
-- Return object in a cell
|
||||
-- If not handled by this inspector, return Void
|
||||
local
|
||||
l_fn: STRING
|
||||
do
|
||||
if attached {STRING_TABLE [STRING]} obj as l_regions then
|
||||
l_fn := field_name.as_lower
|
||||
if l_fn.is_case_insensitive_equal ("count") then
|
||||
Result := cell_of (l_regions.count)
|
||||
elseif attached l_regions.item (l_fn) as v then
|
||||
Result := cell_of (v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
Reference in New Issue
Block a user