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

@@ -56,7 +56,7 @@ feature {CMS_API} -- Module Initialization
create ct create ct
--| For now, add all available formats to content type `ct'. --| For now, add all available formats to content type `ct'.
across across
l_node_api.available_content_formats as ic api.formats as ic
loop loop
ct.extend_format (ic.item) ct.extend_format (ic.item)
end end

View File

@@ -38,26 +38,14 @@ feature {NONE} -- Initialization
-- Initialize content type system. -- Initialize content type system.
local local
ct: CMS_PAGE_NODE_TYPE ct: CMS_PAGE_NODE_TYPE
f: CMS_FORMAT
do 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. -- Initialize content types.
create content_types.make (1) create content_types.make (1)
create content_type_webform_managers.make (1) create content_type_webform_managers.make (1)
create ct create ct
--| For now, add all available formats to content type `ct'. --| For now, add all available formats to content type `ct'.
across across
available_content_formats as ic cms_api.formats as ic
loop loop
ct.extend_format (ic.item) ct.extend_format (ic.item)
end end
@@ -183,31 +171,6 @@ feature -- Content type webform
end end
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 feature -- URL
new_content_path (ct: detachable CMS_CONTENT_TYPE): STRING new_content_path (ct: detachable CMS_CONTENT_TYPE): STRING

View File

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

View File

@@ -35,13 +35,20 @@ feature {NONE} -- Initialize
local local
l_module: CMS_MODULE l_module: CMS_MODULE
do do
-- Initialize formats.
initialize_formats
-- Initialize storage.
if attached setup.storage (error_handler) as l_storage then if attached setup.storage (error_handler) as l_storage then
storage := l_storage storage := l_storage
else else
create {CMS_STORAGE_NULL} storage create {CMS_STORAGE_NULL} storage
end end
-- Complete storage setup.
storage.set_api (Current) storage.set_api (Current)
-- Initialize enabled modules.
across across
setup.enabled_modules as ic setup.enabled_modules as ic
loop loop
@@ -57,6 +64,23 @@ feature {NONE} -- Initialize
end end
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 feature -- Access
setup: CMS_SETUP setup: CMS_SETUP
@@ -72,9 +96,6 @@ feature -- Formats
formats: CMS_FORMATS formats: CMS_FORMATS
-- Available content formats. -- Available content formats.
once
create Result
end
format (a_format_name: detachable READABLE_STRING_GENERAL): detachable CONTENT_FORMAT format (a_format_name: detachable READABLE_STRING_GENERAL): detachable CONTENT_FORMAT
-- Content format name `a_format_name' if any. -- Content format name `a_format_name' if any.