Improved node management.

- List node by node types
- fixed the trash/restore/delete workflow
Added messaging module to send message to cms users (by email for now).
Added early protection for cache, export and import functionalities.
This commit is contained in:
2017-02-28 11:24:48 +01:00
parent dc84e79952
commit a341bd98eb
35 changed files with 1055 additions and 212 deletions

View File

@@ -100,6 +100,13 @@ feature -- Access
deferred
end
recent_nodes_of_type (a_node_type: CMS_CONTENT_TYPE; a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
-- Recent `a_count` nodes of type `a_node_type` with an offset of `lower`.
deferred
ensure
across Result as ic all ic.item.is_typed_as (a_node_type.name) end
end
recent_node_changes_before (a_lower: INTEGER; a_count: INTEGER; a_date: DATE_TIME): LIST [CMS_NODE]
-- List of recent changes, before `a_date', according to `params' settings.
deferred
@@ -120,6 +127,12 @@ feature -- Access
deferred
end
nodes_of_type_count (a_node_type: CMS_CONTENT_TYPE): NATURAL_64
-- Count of nodes of type `a_node_type`.
do
Result := nodes_of_type (a_node_type).count.to_natural_64
end
nodes_of_type (a_node_type: CMS_CONTENT_TYPE): LIST [CMS_NODE]
-- List of nodes of type `a_node_type'.
--| Redefine to optimize!
@@ -137,7 +150,7 @@ feature -- Access
end
end
ensure
expected_type: across Result as ic all ic.item.content_type.same_string (a_node_type.name) end
expected_type: across Result as ic all ic.item.is_typed_as (a_node_type.name) end
end
nodes_of_type_with_title (a_node_type: CMS_CONTENT_TYPE; a_title: READABLE_STRING_GENERAL): LIST [CMS_NODE]

View File

@@ -59,6 +59,12 @@ feature -- Access: node
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
end
recent_nodes_of_type (a_node_type: CMS_CONTENT_TYPE; a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
-- Recent `a_count` nodes of type `a_node_type` with an offset of `lower`.
do
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
end
recent_node_changes_before (a_lower: INTEGER; a_count: INTEGER; a_date: DATE_TIME): LIST [CMS_NODE]
-- List of recent changes, before `a_date', according to `params' settings.
do

View File

@@ -13,6 +13,7 @@ inherit
CMS_NODE_STORAGE_I
redefine
nodes_of_type_count,
nodes_of_type,
nodes_of_type_with_title
end
@@ -38,6 +39,22 @@ feature -- Access
sql_finalize
end
nodes_of_type_count (a_node_type: CMS_CONTENT_TYPE): NATURAL_64
-- Count of nodes of type `a_node_type`.
local
l_parameters: STRING_TABLE [ANY]
do
error_handler.reset
create l_parameters.make (1)
l_parameters.force (a_node_type.name, "node_type")
sql_query (sql_select_nodes_of_type_count, l_parameters)
if not has_error and not sql_after then
Result := sql_read_natural_64 (1)
end
sql_finalize
end
nodes: LIST [CMS_NODE]
-- List of nodes.
do
@@ -145,6 +162,31 @@ feature -- Access
sql_finalize
end
recent_nodes_of_type (a_node_type: CMS_CONTENT_TYPE; a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
-- Recent `a_count` nodes of type `a_node_type` with an offset of `lower`.
local
l_parameters: STRING_TABLE [detachable ANY]
do
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
error_handler.reset
from
create l_parameters.make (3)
l_parameters.put (a_node_type.name, "node_type")
l_parameters.put (a_count, "size")
l_parameters.put (a_lower, "offset")
sql_query (sql_select_recent_nodes_of_type, l_parameters)
sql_start
until
sql_after
loop
if attached fetch_node as l_node then
Result.force (l_node)
end
sql_forth
end
sql_finalize
end
recent_node_changes_before (a_lower: INTEGER; a_count: INTEGER; a_date: DATE_TIME): LIST [CMS_NODE]
-- List of recent changes, before `a_date', according to `params' settings.
local
@@ -270,7 +312,7 @@ feature -- Access
sql_after
loop
if attached fetch_node as l_node then
check expected_node_type: l_node.content_type.same_string (a_node_type.name) end
check expected_node_type: l_node.is_typed_as (a_node_type.name) end
Result.force (l_node)
end
sql_forth
@@ -474,6 +516,10 @@ feature {NONE} -- Queries
-- Nodes count (Published and not Published)
--| note: {CMS_NODE_API}.trashed = -1
sql_select_nodes_of_type_count: STRING = "SELECT count(*) FROM nodes WHERE type=:node_type AND status != -1 ;"
-- Nodes of type `:node_type` count (Published and not Published)
--| note: {CMS_NODE_API}.trashed = -1
sql_select_nodes: STRING = "SELECT nid, revision, type, title, summary, content, format, author, publish, created, changed, status FROM nodes WHERE status != -1 ;"
-- SQL Query to retrieve all nodes.
--| note: {CMS_NODE_API}.trashed = -1
@@ -503,6 +549,8 @@ feature {NONE} -- Queries
sql_select_recent_nodes: STRING = "SELECT nid, revision, type, title, summary, content, format, author, publish, created, changed, status FROM nodes ORDER BY changed DESC, publish DESC LIMIT :size OFFSET :offset ;"
sql_select_recent_nodes_of_type: STRING = "SELECT nid, revision, type, title, summary, content, format, author, publish, created, changed, status FROM nodes WHERE type=:node_type ORDER BY changed DESC, publish DESC LIMIT :size OFFSET :offset ;"
sql_select_recent_node_changes_before: STRING = "SELECT nid, revision, type, title, summary, content, format, author, publish, created, changed, status FROM nodes WHERE changed <= :date ORDER BY changed DESC, nid DESC LIMIT :size OFFSET :offset ;"
sql_insert_node: STRING = "INSERT INTO nodes (revision, type, title, summary, content, format, publish, created, changed, status, author) VALUES (:revision, :type, :title, :summary, :content, :format, :publish, :created, :changed, :status, :author);"