Refactored CMS_MODULE.router (..): WSF_ROUTER design, to create only one router object of type CMS_ROUTER. Added optional CMS_NODE.link: CMS_LOCAL_LINK Reviewed permissions related to node module. Refactor and add CMS_STORAGE_SQL(_BUILDER) abstractions for implementation relying only on SQL statements. Factorized sql builder initialization (to work for sqlite and mysql storage builders). Added CMS_RESPONSE.formatted_string (a_text: READABLE_STRING_GENERAL; args: TUPLE): STRING_32 Added function "translation", but not implemented for now. Updated indexing notes and comments. Code cleaning.
269 lines
5.9 KiB
Plaintext
269 lines
5.9 KiB
Plaintext
note
|
|
description: "[
|
|
CMS abstraction for CMS content entity, named "node".
|
|
]"
|
|
status: "draft"
|
|
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
|
revision: "$Revision: 96542 $"
|
|
|
|
deferred class
|
|
CMS_NODE
|
|
|
|
inherit
|
|
|
|
REFACTORING_HELPER
|
|
|
|
feature{NONE} -- Initialization
|
|
|
|
make_empty
|
|
-- Create empty node.
|
|
do
|
|
make ({STRING_32} "")
|
|
end
|
|
|
|
make (a_title: READABLE_STRING_32)
|
|
-- Create current node with `a_title'.
|
|
local
|
|
l_time: DATE_TIME
|
|
do
|
|
create l_time.make_now_utc
|
|
set_title (a_title)
|
|
set_creation_date (l_time)
|
|
set_modification_date (l_time)
|
|
set_publication_date (l_time)
|
|
mark_not_published
|
|
ensure
|
|
title_set: title = a_title
|
|
end
|
|
|
|
feature -- Conversion
|
|
|
|
import_node (a_node: CMS_NODE)
|
|
-- Import `a_node' into current node.
|
|
do
|
|
set_id (a_node.id)
|
|
set_revision (a_node.revision)
|
|
set_title (a_node.title)
|
|
set_creation_date (a_node.creation_date)
|
|
set_modification_date (a_node.modification_date)
|
|
set_publication_date (a_node.publication_date)
|
|
set_author (a_node.author)
|
|
set_content (
|
|
a_node.content,
|
|
a_node.summary,
|
|
a_node.format
|
|
)
|
|
set_status (a_node.status)
|
|
set_link (a_node.link)
|
|
end
|
|
|
|
feature -- Access
|
|
|
|
id: INTEGER_64 assign set_id
|
|
-- Unique id.
|
|
--| Should we use NATURAL_64 instead?
|
|
|
|
revision: INTEGER_64 assign set_revision
|
|
-- Revision value.
|
|
--| Note: for now version is not supported.
|
|
|
|
content_type: READABLE_STRING_8
|
|
-- Associated content type name.
|
|
-- Page, Article, Blog, News, etc.
|
|
deferred
|
|
end
|
|
|
|
status: INTEGER
|
|
-- Associated status for the current node.
|
|
-- default: {CMS_NODE_API}.Not_Published}
|
|
-- {CMS_NODE_API}.Published
|
|
-- {CMS_NODE_API}.Trashed
|
|
|
|
feature -- Access
|
|
|
|
title: READABLE_STRING_32
|
|
-- Full title of the node.
|
|
-- Required!
|
|
|
|
summary: detachable READABLE_STRING_8
|
|
-- A short summary of the node.
|
|
deferred
|
|
end
|
|
|
|
content: detachable READABLE_STRING_8
|
|
-- Content of the node.
|
|
deferred
|
|
end
|
|
|
|
format: detachable READABLE_STRING_8
|
|
-- Format associated with `content' and `summary'.
|
|
-- For example: text, mediawiki, html, etc
|
|
deferred
|
|
end
|
|
|
|
feature -- Access: date
|
|
|
|
modification_date: DATE_TIME
|
|
-- When the node was updated.
|
|
|
|
creation_date: DATE_TIME
|
|
-- When the node was created.
|
|
|
|
publication_date: DATE_TIME
|
|
-- When the node was published.
|
|
|
|
publication_date_output: READABLE_STRING_32
|
|
-- Formatted output.
|
|
|
|
feature -- Access: author
|
|
|
|
author: detachable CMS_USER
|
|
-- Author of current node.
|
|
|
|
feature -- status report
|
|
|
|
has_id: BOOLEAN
|
|
-- Has unique identifier?
|
|
do
|
|
Result := id > 0
|
|
end
|
|
|
|
same_node (a_node: CMS_NODE): BOOLEAN
|
|
-- Is `a_node' same node as Current?
|
|
do
|
|
-- FIXME: if we introduce notion of revision, update this part!
|
|
Result := Current = a_node or id = a_node.id
|
|
ensure
|
|
valid_result: Result implies a_node.id = id
|
|
end
|
|
|
|
is_typed_as (a_content_type: READABLE_STRING_GENERAL): BOOLEAN
|
|
-- Is current node of type `a_content_type' ?
|
|
do
|
|
Result := a_content_type.is_case_insensitive_equal (content_type)
|
|
end
|
|
|
|
feature -- Access: menu
|
|
|
|
link: detachable CMS_LOCAL_LINK
|
|
-- Associated menu link.
|
|
|
|
feature -- Element change
|
|
|
|
set_content (a_content: like content; a_summary: like summary; a_format: like format)
|
|
-- Set `content', `summary' and `format' to `a_content', `a_summary' and `a_format'.
|
|
-- The `format' is associated with both `content' and `summary'
|
|
deferred
|
|
ensure
|
|
content_assigned: content = a_content
|
|
summary_assigned: summary = a_summary
|
|
format_assigned: format = a_format
|
|
end
|
|
|
|
set_title (a_title: like title)
|
|
-- Assign `title' with `a_title'.
|
|
do
|
|
title := a_title
|
|
if attached link as lnk then
|
|
lnk.set_title (a_title)
|
|
end
|
|
ensure
|
|
title_assigned: title = a_title
|
|
end
|
|
|
|
set_modification_date (a_modification_date: like modification_date)
|
|
-- Assign `modification_date' with `a_modification_date'.
|
|
do
|
|
modification_date := a_modification_date
|
|
ensure
|
|
modification_date_assigned: modification_date = a_modification_date
|
|
end
|
|
|
|
set_creation_date (a_creation_date: like creation_date)
|
|
-- Assign `creation_date' with `a_creation_date'.
|
|
do
|
|
creation_date := a_creation_date
|
|
ensure
|
|
creation_date_assigned: creation_date = a_creation_date
|
|
end
|
|
|
|
set_publication_date (a_publication_date: like publication_date)
|
|
-- Assign `publication_date' with `a_publication_date'.
|
|
do
|
|
publication_date := a_publication_date
|
|
publication_date_output := publication_date.formatted_out ("yyyy/[0]mm/[0]dd")
|
|
ensure
|
|
publication_date_assigned: publication_date = a_publication_date
|
|
end
|
|
|
|
set_id (a_id: like id)
|
|
-- Assign `id' with `a_id'.
|
|
do
|
|
id := a_id
|
|
ensure
|
|
id_assigned: id = a_id
|
|
end
|
|
|
|
set_revision (a_revision: like revision)
|
|
-- Assign `revision' with `a_revision'.
|
|
do
|
|
revision := a_revision
|
|
ensure
|
|
revision_assigned: revision = a_revision
|
|
end
|
|
|
|
set_author (u: like author)
|
|
-- Assign 'author' with `u'
|
|
do
|
|
author := u
|
|
ensure
|
|
auther_set: author = u
|
|
end
|
|
|
|
set_link (a_link: like link)
|
|
-- Set `link' to `a_link'.
|
|
do
|
|
link := a_link
|
|
end
|
|
|
|
feature -- Status change
|
|
|
|
mark_not_published
|
|
-- Set status to not_published.
|
|
do
|
|
set_status ({CMS_NODE_API}.not_published)
|
|
ensure
|
|
status_not_published: status = {CMS_NODE_API}.not_published
|
|
end
|
|
|
|
mark_published
|
|
-- Set status to published.
|
|
do
|
|
set_status ({CMS_NODE_API}.published)
|
|
ensure
|
|
status_published: status = {CMS_NODE_API}.published
|
|
end
|
|
|
|
mark_trashed
|
|
-- Set status to trashed.
|
|
do
|
|
set_status ({CMS_NODE_API}.trashed)
|
|
ensure
|
|
status_trash: status = {CMS_NODE_API}.trashed
|
|
end
|
|
|
|
feature {CMS_NODE_STORAGE_I} -- Access: status change.
|
|
|
|
set_status (a_status: like status)
|
|
-- Assign `status' with `a_status'.
|
|
do
|
|
status := a_status
|
|
ensure
|
|
status_set: status = a_status
|
|
end
|
|
|
|
note
|
|
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
|
end
|