Files
ROC/modules/node/content/cms_node.e
Jocelyn Fiat 9514f1de9c Updated SQLITE builder using GLOBAL_SETTINGS to map 0 to 0, by default 0 -> NULL
Updated CMS_NODE_API, with status, not_published, published and trashed.
Updated Form response to use permission scopes.
Updated sqlquery to retrieve user author.
Added logger info in cms_response
Updated CMS_NODE with a new status attribute.
Updated table nodes to support trashing (or soft deletes) of node using the new status field
Updated Sqlite builder to test different scenarios for users and roles.
Updated NODE_FORM_RESPONSE.edit_form feature to add a delete operation
  if there is a node ie node id >0 and the current user has delete permission on it.
Updated NODE_HANDLER.do_post to handle the operation "DELETE".
Updated queries to retrieve nodes filter by no logical deleted rows (ie. status is trashed).


Signed-off-by: jvelilla <javier.hector@gmail.com>
2015-05-12 22:02:23 +02:00

253 lines
5.6 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)
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 -- 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
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
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