Initial CMS API commmit.

This commit is contained in:
jvelilla
2014-10-01 12:17:39 -03:00
parent 588827b495
commit 27a11f2eea
170 changed files with 12459 additions and 14 deletions

View File

@@ -0,0 +1,183 @@
note
description: "Summary description for {CMS_HTML_PAGE}."
date: "$Date$"
revision: "$Revision$"
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.
title: detachable STRING
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: HASH_TABLE [STRING_8, 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
header_region: STRING_8
do
Result := region ("header")
end
content_region: STRING_8
do
Result := region ("content")
end
footer_region: STRING_8
do
Result := region ("content")
end
feature -- Element change
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
add_to_header_region (s: STRING)
do
add_to_region (s, "header")
end
add_to_content_region (s: STRING)
do
add_to_region (s, "content")
end
add_to_footer_region (s: STRING)
do
add_to_region (s, "footer")
end
set_region (s: STRING; k: STRING)
do
regions.force (s, k)
end
set_header_region (s: STRING)
do
set_region (s, "header")
end
set_content_region (s: STRING)
do
set_region (s, "content")
end
set_footer_region (s: STRING)
do
set_region (s, "footer")
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
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