Refactored add child feature, to have all the page specific code in CMS_PAGE_NODE_TYPE_WEBFORM_MANAGER (and not in the general node code).

Note that ideally PAGE could be a separated page node module (as it is for blog).
Added listing of children for each "page".
This commit is contained in:
2015-09-09 21:58:16 +02:00
parent eb70af6f19
commit 32a409b7e9
11 changed files with 261 additions and 276 deletions

View File

@@ -117,9 +117,19 @@ feature -- Access
deferred
end
feature -- Access: outline
children (a_node: CMS_NODE): detachable LIST [CMS_NODE]
-- Children of node `a_node'.
-- note: this is the partial version of the nodes.
deferred
end
available_parents_for_node (a_node: CMS_NODE): LIST [CMS_NODE]
-- Given the node `a_node', return the list of possible parent nodes id
deferred
ensure
a_node_excluded: across Result as ic all not a_node.same_node (ic.item) end
end
feature -- Change: Node

View File

@@ -86,6 +86,13 @@ feature -- Access: node
create {ARRAYED_LIST [CMS_USER]} Result.make (0)
end
feature -- Access: outline
children (a_node: CMS_NODE): detachable LIST [CMS_NODE]
-- <Precursor>
do
end
available_parents_for_node (a_node: CMS_NODE): LIST [CMS_NODE]
-- <Precursor>
do

View File

@@ -255,6 +255,32 @@ feature -- Access
-- end
end
feature -- Access: outline
children (a_node: CMS_NODE): detachable LIST [CMS_NODE]
-- <Precursor>
local
l_parameters: STRING_TABLE [detachable ANY]
do
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
error_handler.reset
write_information_log (generator + ".children")
from
create l_parameters.make (1)
l_parameters.put (a_node.id, "nid")
sql_query (sql_select_children_of_node, l_parameters)
sql_start
until
sql_after
loop
if attached fetch_node as l_node then
Result.force (l_node)
end
sql_forth
end
end
available_parents_for_node (a_node: CMS_NODE): LIST [CMS_NODE]
-- <Precursor>
@@ -482,7 +508,17 @@ feature {NONE} -- Queries
Sql_last_insert_node_revision: STRING = "SELECT MAX(revision) FROM node_revisions;"
Sql_last_insert_node_revision_for_nid: STRING = "SELECT MAX(revision) FROM node_revisions WHERE nid=:nid;"
sql_select_available_parents_for_node : STRING = "SELECT pn_1.nid, pn_1.revision, pn_1.type, title, summary, content, format, author, publish, created, changed, status FROM nodes pn_1 LEFT JOIN page_nodes pn_2 ON pn_1.nid = pn_2.nid AND pn_1.nid != :nid WHERE pn_2.parent != :nid AND pn_1.status != -1 GROUP BY pn_1.nid, pn_1.revision;"
sql_select_available_parents_for_node : STRING = "[
SELECT node.nid, node.revision, node.type, title, summary, content, format, author, publish, created, changed, status
FROM nodes node LEFT JOIN page_nodes pn ON node.nid = pn.nid AND node.nid != :nid
WHERE node.nid != :nid AND pn.parent != :nid AND node.status != -1 GROUP BY node.nid, node.revision;
]"
sql_select_children_of_node: STRING = "[
SELECT node.nid, node.revision, node.type, title, summary, content, format, author, publish, created, changed, status
FROM nodes node LEFT JOIN page_nodes pn ON node.nid = pn.nid
WHERE pn.parent = :nid AND node.status != -1 GROUP BY node.nid, node.revision;
]"
feature {NONE} -- Sql Queries: USER_ROLES collaborators, author