Merged formats, from CMS_NODE_API and CMS_API, into CMS_API.formats: CMS_FORMATS.

This commit is contained in:
2015-07-09 13:41:42 +02:00
parent 16cae0047d
commit 31095b1b66
4 changed files with 66 additions and 68 deletions

View File

@@ -6,34 +6,56 @@ note
class
CMS_FORMATS
inherit
ITERABLE [CMS_FORMAT]
create
make
feature {NONE} -- Initialization
make (nb: INTEGER)
do
create items.make (nb)
end
feature -- Access
item (a_name: detachable READABLE_STRING_GENERAL): detachable CONTENT_FORMAT
item (a_name: detachable READABLE_STRING_GENERAL): detachable CMS_FORMAT
do
if a_name /= Void then
across
all_formats as c
items as c
until
Result /= Void
loop
if a_name.same_string (c.item.name) then
if a_name.is_case_insensitive_equal (c.item.name) then
Result := c.item
end
end
end
end
all_formats: LIST [CONTENT_FORMAT]
once
-- Can we provide an external file to read the
-- supported formats?
create {ARRAYED_LIST [CONTENT_FORMAT]} Result.make (4)
Result.force (plain_text)
Result.force (full_html)
Result.force (filtered_html)
Result.force (cms_html)
feature -- Element change
extend (f: CMS_FORMAT)
-- Add format `f' to available formats.
do
items.force (f)
ensure
has_format: item (f.name) = f
end
feature -- Access
new_cursor: ITERATION_CURSOR [CMS_FORMAT]
-- Fresh cursor associated with current structure
do
Result := items.new_cursor
end
feature -- Built-in formats
default_format: CONTENT_FORMAT
do
Result := plain_text --FIXME
@@ -44,23 +66,15 @@ feature -- Access
create Result
end
cms_html: CMS_EDITOR_CONTENT_FORMAT
once
create Result
end
feature {NONE} -- Implementation
full_html: FULL_HTML_CONTENT_FORMAT
once
create Result
end
items: ARRAYED_LIST [CMS_FORMAT]
filtered_html: FILTERED_HTML_CONTENT_FORMAT
once
create Result
end
invariant
items /= Void
note
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -35,13 +35,20 @@ feature {NONE} -- Initialize
local
l_module: CMS_MODULE
do
-- Initialize formats.
initialize_formats
-- Initialize storage.
if attached setup.storage (error_handler) as l_storage then
storage := l_storage
else
create {CMS_STORAGE_NULL} storage
end
-- Complete storage setup.
storage.set_api (Current)
-- Initialize enabled modules.
across
setup.enabled_modules as ic
loop
@@ -57,6 +64,23 @@ feature {NONE} -- Initialize
end
end
initialize_formats
-- Initialize content formats.
local
f: CMS_FORMAT
do
-- Initialize built-in formats
create formats.make (4)
create f.make_from_format (create {PLAIN_TEXT_CONTENT_FORMAT})
formats.extend (f)
create f.make_from_format (create {FILTERED_HTML_CONTENT_FORMAT})
formats.extend (f)
create f.make_from_format (create {FULL_HTML_CONTENT_FORMAT})
formats.extend (f)
create f.make ("cms_editor", "CMS HTML content")
formats.extend (f)
end
feature -- Access
setup: CMS_SETUP
@@ -72,9 +96,6 @@ feature -- Formats
formats: CMS_FORMATS
-- Available content formats.
once
create Result
end
format (a_format_name: detachable READABLE_STRING_GENERAL): detachable CONTENT_FORMAT
-- Content format name `a_format_name' if any.