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

@@ -52,11 +52,11 @@ feature {CMS_API} -- Module Initialization
node_api := l_node_api
-- Depends on {CMS_NODE_MODULE}
create ct
--| For now, add all available formats to content type `ct'.
across
l_node_api.available_content_formats as ic
api.formats as ic
loop
ct.extend_format (ic.item)
end

View File

@@ -38,26 +38,14 @@ feature {NONE} -- Initialization
-- Initialize content type system.
local
ct: CMS_PAGE_NODE_TYPE
f: CMS_FORMAT
do
-- Initialize built-in formats
create available_content_formats.make (4)
create f.make_from_format (create {PLAIN_TEXT_CONTENT_FORMAT})
add_content_format (f)
create f.make_from_format (create {FILTERED_HTML_CONTENT_FORMAT})
add_content_format (f)
create f.make_from_format (create {FULL_HTML_CONTENT_FORMAT})
add_content_format (f)
create f.make ("cms_editor", "CMS HTML content")
add_content_format (f)
-- Initialize content types.
create content_types.make (1)
create content_type_webform_managers.make (1)
create ct
--| For now, add all available formats to content type `ct'.
across
available_content_formats as ic
cms_api.formats as ic
loop
ct.extend_format (ic.item)
end
@@ -183,31 +171,6 @@ feature -- Content type webform
end
end
feature -- Content formats
available_content_formats: ARRAYED_LIST [CONTENT_FORMAT]
-- Available content formats.
add_content_format (f: CONTENT_FORMAT)
-- Add content format `f' to `available_content_formats'.
do
available_content_formats.extend (f)
end
content_format (a_name: READABLE_STRING_GENERAL): detachable CONTENT_FORMAT
-- Format named `a_name' if available.
do
across
available_content_formats as ic
until
Result = Void
loop
if a_name.is_case_insensitive_equal (ic.item.name) then
Result := ic.item
end
end
end
feature -- URL
new_content_path (ct: detachable CMS_CONTENT_TYPE): STRING

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.