Implemented view node by content type (no more hardcoded cases).

Added CMS_NODE_TYPE as descendant of CMS_CONTENT_TYPE,
  in case we have content which is not a node in the future.
  (probably useless, but for now, this extra abstraction is harmful)
Moved all node related code under node module cluster.
Applied comments from Javier Velilla.
Code cleaning.
This commit is contained in:
2015-04-29 17:28:33 +02:00
parent e8bb3790ba
commit c982f0ea9c
34 changed files with 756 additions and 521 deletions

View File

@@ -24,7 +24,7 @@ feature {NONE} -- Initialization
Precursor
end
feature {CMS_CONTENT_TYPE} -- Conversion
feature -- Conversion
import_node (a_node: CMS_NODE)
-- <Precursor>
@@ -39,7 +39,7 @@ feature -- Access
content_type: READABLE_STRING_8
once
Result := {CMS_BLOG_CONTENT_TYPE}.name
Result := {CMS_BLOG_NODE_TYPE}.name
end
feature -- Access: content

View File

@@ -1,75 +0,0 @@
note
description: "Summary description for {CMS_BLOG_CONTENT_TYPE_WEBFORM_MANAGER}."
date: "$Date$"
revision: "$Revision$"
class
CMS_BLOG_CONTENT_TYPE_WEBFORM_MANAGER
inherit
CMS_NODE_CONTENT_TYPE_WEBFORM_MANAGER [CMS_BLOG]
redefine
content_type,
fill_edit_form,
change_node,
new_node
end
create
make
feature -- Access
content_type: CMS_BLOG_CONTENT_TYPE
-- Associated content type.
feature -- form
fill_edit_form (response: NODE_RESPONSE; f: CMS_FORM; a_node: detachable like new_node)
local
ti: WSF_FORM_TEXT_INPUT
fset: WSF_FORM_FIELD_SET
ta: WSF_FORM_TEXTAREA
tselect: WSF_FORM_SELECT
opt: WSF_FORM_SELECT_OPTION
s: STRING_32
do
Precursor (response, f, a_node)
create ti.make ("tags")
ti.set_label ("Tags")
ti.set_size (70)
if a_node /= Void and then attached a_node.tags as l_tags then
create s.make_empty
across
l_tags as ic
loop
if not s.is_empty then
s.append_character (',')
end
s.append (ic.item)
end
ti.set_text_value (s)
end
ti.set_is_required (False)
f.extend (ti)
end
change_node (response: NODE_RESPONSE; fd: WSF_FORM_DATA; a_node: like new_node)
do
Precursor (response, fd, a_node)
if attached fd.string_item ("tags") as l_tags then
a_node.set_tags_from_string (l_tags)
end
end
new_node (response: NODE_RESPONSE; fd: WSF_FORM_DATA; a_node: detachable like new_node): like content_type.new_node
-- <Precursor>
do
Result := Precursor (response, fd, a_node)
if attached fd.string_item ("tags") as l_tags then
Result.set_tags_from_string (l_tags)
end
end
end

View File

@@ -35,14 +35,14 @@ feature {CMS_API} -- Module Initialization
initialize (api: CMS_API)
-- <Precursor>
local
ct: CMS_BLOG_CONTENT_TYPE
ct: CMS_BLOG_NODE_TYPE
do
Precursor (api)
if attached {CMS_NODE_API} api.module_api ({NODE_MODULE}) as l_node_api then
create ct
l_node_api.add_content_type (ct)
l_node_api.add_content_type_webform_manager (create {CMS_BLOG_CONTENT_TYPE_WEBFORM_MANAGER}.make (ct))
l_node_api.add_content_type_webform_manager (create {CMS_BLOG_NODE_TYPE_WEBFORM_MANAGER}.make (ct))
-- Add support for CMS_BLOG, which requires a storage extension to store the optional "tags" value
-- For now, we only have extension based on SQL statement.
if attached {CMS_NODE_STORAGE_SQL} l_node_api.node_storage as l_sql_node_storage then

View File

@@ -1,13 +1,13 @@
note
description: "Summary description for {CMS_BLOG_CONTENT_TYPE}."
description: "Summary description for {CMS_BLOG_NODE_TYPE}."
date: "$Date$"
revision: "$Revision$"
class
CMS_BLOG_CONTENT_TYPE
CMS_BLOG_NODE_TYPE
inherit
CMS_CONTENT_TYPE
CMS_NODE_TYPE
redefine
default_create
end
@@ -60,5 +60,4 @@ feature -- Factory
end
end
end

View File

@@ -0,0 +1,109 @@
note
description: "Summary description for {CMS_BLOG_NODE_TYPE_WEBFORM_MANAGER}."
date: "$Date$"
revision: "$Revision$"
class
CMS_BLOG_NODE_TYPE_WEBFORM_MANAGER
inherit
CMS_NODE_TYPE_WEBFORM_MANAGER [CMS_BLOG]
redefine
content_type,
populate_form,
update_node,
new_node,
append_html_output_to
end
create
make
feature -- Access
content_type: CMS_BLOG_NODE_TYPE
-- Associated content type.
feature -- form
populate_form (response: NODE_RESPONSE; f: CMS_FORM; a_node: detachable CMS_NODE)
local
ti: WSF_FORM_TEXT_INPUT
s: STRING_32
do
Precursor (response, f, a_node)
create ti.make ("tags")
ti.set_label ("Tags")
ti.set_size (70)
if
a_node /= Void and then
attached {CMS_BLOG} a_node as a_blog and then
attached a_blog.tags as l_tags
then
create s.make_empty
across
l_tags as ic
loop
if not s.is_empty then
s.append_character (',')
end
s.append (ic.item)
end
ti.set_text_value (s)
end
ti.set_is_required (False)
f.extend (ti)
end
update_node (response: NODE_RESPONSE; fd: WSF_FORM_DATA; a_node: CMS_NODE)
do
Precursor (response, fd, a_node)
if attached fd.string_item ("tags") as l_tags then
if attached {CMS_BLOG} a_node as l_blog then
l_blog.set_tags_from_string (l_tags)
end
end
end
new_node (response: NODE_RESPONSE; fd: WSF_FORM_DATA; a_node: detachable like new_node): like content_type.new_node
-- <Precursor>
do
Result := Precursor (response, fd, a_node)
if attached fd.string_item ("tags") as l_tags then
Result.set_tags_from_string (l_tags)
end
end
feature -- Output
append_html_output_to (a_node: CMS_NODE; a_response: NODE_RESPONSE)
-- <Precursor>
local
s: STRING
do
Precursor (a_node, a_response)
if attached a_response.main_content as l_main_content then
s := l_main_content
else
create s.make_empty
end
if attached {CMS_BLOG} a_node as l_blog_post then
if attached l_blog_post.tags as l_tags then
s.append ("<div><strong>Tags:</strong> ")
across
l_tags as ic
loop
s.append ("<span class=%"tag%">")
s.append (a_response.html_encoded (ic.item))
s.append ("</span> ")
end
s.append ("</div>")
end
end
a_response.set_main_content (s)
end
end

View File

@@ -28,7 +28,7 @@ feature -- Access
content_type: STRING
once
Result := {CMS_BLOG_CONTENT_TYPE}.name
Result := {CMS_BLOG_NODE_TYPE}.name
end
feature -- Persistence