Added recent_changes module.
Revisited hooks management, and added new CMS_HOOK_MANAGER. Added admin, and other link into navigation menu that goes into first sidebar. Fixed theme info, and template for sidebar ids. Better css class name for cms node content.
This commit is contained in:
@@ -236,28 +236,43 @@ feature -- Access: Node
|
||||
end
|
||||
|
||||
recent_nodes (params: CMS_DATA_QUERY_PARAMETERS): ITERABLE [CMS_NODE]
|
||||
-- List of the `a_rows' most recent nodes starting from `a_offset'.
|
||||
-- List of most recent nodes according to `params.offset' and `params.size'.
|
||||
do
|
||||
Result := node_storage.recent_nodes (params.offset.to_integer_32, params.size.to_integer_32)
|
||||
end
|
||||
|
||||
recent_node_changes_before (params: CMS_DATA_QUERY_PARAMETERS; a_date: DATE_TIME): ITERABLE [CMS_NODE]
|
||||
-- List of recent changes, before `a_date', according to `params' settings.
|
||||
do
|
||||
Result := node_storage.recent_node_changes_before (params.offset.to_integer_32, params.size.to_integer_32, a_date)
|
||||
end
|
||||
|
||||
node (a_id: INTEGER_64): detachable CMS_NODE
|
||||
-- Node by ID.
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Check preconditions")
|
||||
end
|
||||
Result := full_node (node_storage.node_by_id (a_id))
|
||||
Result := safe_full_node (node_storage.node_by_id (a_id))
|
||||
end
|
||||
|
||||
revision_node (a_node_id: INTEGER_64; a_revision_id: INTEGER_64): detachable CMS_NODE
|
||||
do
|
||||
Result := full_node (node_storage.node_by_id_and_revision (a_node_id, a_revision_id))
|
||||
Result := safe_full_node (node_storage.node_by_id_and_revision (a_node_id, a_revision_id))
|
||||
end
|
||||
|
||||
full_node (a_node: detachable CMS_NODE): detachable CMS_NODE
|
||||
safe_full_node (a_node: detachable CMS_NODE): detachable CMS_NODE
|
||||
do
|
||||
if a_node /= Void then
|
||||
Result := full_node (a_node)
|
||||
end
|
||||
end
|
||||
|
||||
full_node (a_node: CMS_NODE): CMS_NODE
|
||||
-- If `a_node' is partial, return the full node from `a_node',
|
||||
-- otherwise return directly `a_node'.
|
||||
require
|
||||
a_node_set: a_node /= Void
|
||||
do
|
||||
if attached {CMS_PARTIAL_NODE} a_node as l_partial_node then
|
||||
if attached node_type_for (l_partial_node) as ct then
|
||||
|
||||
@@ -23,6 +23,8 @@ inherit
|
||||
|
||||
CMS_HOOK_BLOCK
|
||||
|
||||
CMS_RECENT_CHANGES_HOOK
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
@@ -222,9 +224,12 @@ feature -- Hooks
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
-- <Precursor>
|
||||
do
|
||||
a_response.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_response.subscribe_to_block_hook (Current)
|
||||
a_response.subscribe_to_response_alter_hook (Current)
|
||||
a_response.hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_response.hooks.subscribe_to_block_hook (Current)
|
||||
a_response.hooks.subscribe_to_response_alter_hook (Current)
|
||||
|
||||
-- Module specific hook, if available.
|
||||
a_response.hooks.subscribe_to_hook (Current, {CMS_RECENT_CHANGES_HOOK})
|
||||
end
|
||||
|
||||
response_alter (a_response: CMS_RESPONSE)
|
||||
@@ -253,13 +258,63 @@ feature -- Hooks
|
||||
do
|
||||
debug
|
||||
create lnk.make ("List of nodes", "nodes")
|
||||
a_menu_system.primary_menu.extend (lnk)
|
||||
a_menu_system.navigation_menu.extend (lnk)
|
||||
end
|
||||
create lnk.make ("Trash", "trash")
|
||||
a_menu_system.primary_menu.extend (lnk)
|
||||
a_menu_system.navigation_menu.extend (lnk)
|
||||
|
||||
create lnk.make ("Create ..", "node")
|
||||
a_menu_system.primary_menu.extend (lnk)
|
||||
a_menu_system.navigation_menu.extend (lnk)
|
||||
end
|
||||
|
||||
populate_recent_changes (a_changes: CMS_RECENT_CHANGE_CONTAINER; a_sources: LIST [READABLE_STRING_8])
|
||||
local
|
||||
params: CMS_DATA_QUERY_PARAMETERS
|
||||
ch: CMS_RECENT_CHANGE_ITEM
|
||||
n: CMS_NODE
|
||||
l_info: STRING_8
|
||||
l_src: detachable READABLE_STRING_8
|
||||
l_nodes: ITERABLE [CMS_NODE]
|
||||
do
|
||||
create params.make (0, a_changes.limit)
|
||||
if attached node_api as l_node_api then
|
||||
across
|
||||
l_node_api.content_types as ic
|
||||
loop
|
||||
a_sources.force (ic.item.name)
|
||||
end
|
||||
l_src := a_changes.source
|
||||
if attached a_changes.date as l_date then
|
||||
l_nodes := l_node_api.recent_node_changes_before (params, l_date)
|
||||
else
|
||||
l_nodes := l_node_api.recent_node_changes_before (params, create {DATE_TIME}.make_now_utc)
|
||||
end
|
||||
across l_nodes as ic loop
|
||||
n := ic.item
|
||||
if l_src = Void or else l_src.is_case_insensitive_equal_general (n.content_type) then
|
||||
n := l_node_api.full_node (n)
|
||||
create ch.make (n.content_type, create {CMS_LOCAL_LINK}.make (n.title, "node/" + n.id.out), n.modification_date)
|
||||
if n.creation_date ~ n.modification_date then
|
||||
l_info := "new"
|
||||
if not n.is_published then
|
||||
l_info.append (" (unpublished)")
|
||||
end
|
||||
else
|
||||
if n.is_trashed then
|
||||
l_info := "trashed"
|
||||
else
|
||||
l_info := "updated"
|
||||
if not n.is_published then
|
||||
l_info.append (" (unpublished)")
|
||||
end
|
||||
end
|
||||
end
|
||||
ch.set_information (l_info)
|
||||
ch.set_author (n.author)
|
||||
a_changes.force (ch)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -300,6 +300,7 @@ feature -- Output
|
||||
end
|
||||
end
|
||||
create s.make_empty
|
||||
s.append ("<div class=%"cms-node node-" + a_node.content_type + "%">")
|
||||
s.append ("<div class=%"info%"> ")
|
||||
if attached a_node.author as l_author then
|
||||
s.append (" by ")
|
||||
@@ -339,6 +340,7 @@ feature -- Output
|
||||
|
||||
s.append ("</p>")
|
||||
end
|
||||
s.append ("</div>")
|
||||
|
||||
a_response.set_title (a_node.title)
|
||||
a_response.set_main_content (s)
|
||||
|
||||
@@ -274,7 +274,6 @@ feature {NONE} -- Trash:Restore
|
||||
r: GENERIC_VIEW_CMS_RESPONSE
|
||||
b: STRING
|
||||
n: CMS_NODE
|
||||
l_link: CMS_LOCAL_LINK
|
||||
do
|
||||
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
|
||||
if
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\..\cms-safe.ecf"/>
|
||||
<library name="cms_model" location="..\..\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||
<library name="cms_recent_changes_module" location="..\..\modules\recent_changes\recent_changes-safe.ecf" readonly="false"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\web\authentication\http_authorization\http_authorization-safe.ecf" readonly="false"/>
|
||||
|
||||
@@ -90,6 +90,11 @@ feature -- Access
|
||||
deferred
|
||||
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
|
||||
end
|
||||
|
||||
node_by_id (a_id: INTEGER_64): detachable CMS_NODE
|
||||
-- Retrieve node by id `a_id', if any.
|
||||
require
|
||||
|
||||
@@ -59,6 +59,12 @@ feature -- Access: node
|
||||
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
|
||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||
end
|
||||
|
||||
node_by_id (a_id: INTEGER_64): detachable CMS_NODE
|
||||
-- <Precursor>
|
||||
do
|
||||
|
||||
@@ -128,7 +128,7 @@ feature -- Access
|
||||
|
||||
from
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (a_count, "rows")
|
||||
l_parameters.put (a_count, "size")
|
||||
l_parameters.put (a_lower, "offset")
|
||||
sql_query (sql_select_recent_nodes, l_parameters)
|
||||
sql_start
|
||||
@@ -142,6 +142,34 @@ feature -- Access
|
||||
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.
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
do
|
||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||
|
||||
error_handler.reset
|
||||
write_information_log (generator + ".nodes")
|
||||
|
||||
from
|
||||
create l_parameters.make (3)
|
||||
l_parameters.put (a_count, "size")
|
||||
l_parameters.put (a_lower, "offset")
|
||||
l_parameters.put (a_date, "date")
|
||||
|
||||
sql_query (sql_select_recent_node_changes_before, 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
|
||||
|
||||
node_by_id (a_id: INTEGER_64): detachable CMS_NODE
|
||||
-- Retrieve node by id `a_id', if any.
|
||||
local
|
||||
@@ -402,7 +430,9 @@ feature {NONE} -- Queries
|
||||
|
||||
sql_select_node_by_id_and_revision: STRING = "SELECT nodes.nid, node_revisions.revision, nodes.type, node_revisions.title, node_revisions.summary, node_revisions.content, node_revisions.format, node_revisions.author, nodes.publish, nodes.created, node_revisions.changed, node_revisions.status FROM nodes INNER JOIN node_revisions ON nodes.nid = node_revisions.nid WHERE nodes.nid = :nid AND node_revisions.revision = :revision ORDER BY node_revisions.revision DESC;"
|
||||
|
||||
sql_select_recent_nodes: STRING = "SELECT nid, revision, type, title, summary, content, format, author, publish, created, changed, status FROM nodes ORDER BY nid DESC, publish DESC LIMIT :rows OFFSET :offset ;"
|
||||
sql_select_recent_nodes: STRING = "SELECT nid, revision, type, title, summary, content, format, author, publish, created, changed, status FROM nodes ORDER BY nid 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);"
|
||||
-- SQL Insert to add a new node.
|
||||
|
||||
Reference in New Issue
Block a user