Added exportation solution via CMS_HOOK_EXPORT.
Updated blocks settings for demo example project.
This commit is contained in:
@@ -9,30 +9,17 @@ management.conditions[]=is_front
|
|||||||
feed.news.weight=3
|
feed.news.weight=3
|
||||||
feed.news.region=feed_news
|
feed.news.region=feed_news
|
||||||
feed.news.region=content
|
feed.news.region=content
|
||||||
feed.news.condition=<none>
|
feed.news.condition=is_front
|
||||||
|
|
||||||
feed.forum.weight=2
|
feed.forum.weight=2
|
||||||
feed.forum.region=feed_forum
|
feed.forum.region=feed_forum
|
||||||
feed.forum.region=<none>
|
feed.forum.region=content
|
||||||
feed.forum.condition=<none>
|
feed.forum.condition=is_front
|
||||||
feed.forum.options[size]=15
|
feed.forum.options[size]=5
|
||||||
|
|
||||||
#Updates
|
#Updates
|
||||||
recent_changes.region=content
|
recent_changes.region=content
|
||||||
recent_changes.condition=is_front
|
recent_changes.condition=is_front
|
||||||
recent_changes.title=Updates
|
recent_changes.title=Updates
|
||||||
recent_changes.options[size]=3
|
recent_changes.options[size]=4
|
||||||
|
|
||||||
#Aliases
|
|
||||||
&aliases[foo]=management
|
|
||||||
&aliases[bar]=feed.forum
|
|
||||||
|
|
||||||
foo.region=content
|
|
||||||
foo.condition=is_front
|
|
||||||
foo.weight=-10
|
|
||||||
|
|
||||||
bar.region=content
|
|
||||||
bar.condition=is_front
|
|
||||||
bar.title=Bar
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ feature -- Access: router
|
|||||||
l_role_handler: CMS_ROLE_HANDLER
|
l_role_handler: CMS_ROLE_HANDLER
|
||||||
|
|
||||||
l_admin_cache_handler: CMS_ADMIN_CACHE_HANDLER
|
l_admin_cache_handler: CMS_ADMIN_CACHE_HANDLER
|
||||||
|
l_admin_export_handler: CMS_ADMIN_EXPORT_HANDLER
|
||||||
|
|
||||||
l_uri_mapping: WSF_URI_MAPPING
|
l_uri_mapping: WSF_URI_MAPPING
|
||||||
do
|
do
|
||||||
@@ -73,6 +74,10 @@ feature -- Access: router
|
|||||||
create l_uri_mapping.make_trailing_slash_ignored ("/admin/cache", l_admin_cache_handler)
|
create l_uri_mapping.make_trailing_slash_ignored ("/admin/cache", l_admin_cache_handler)
|
||||||
a_router.map (l_uri_mapping, a_router.methods_get_post)
|
a_router.map (l_uri_mapping, a_router.methods_get_post)
|
||||||
|
|
||||||
|
create l_admin_export_handler.make (a_api)
|
||||||
|
create l_uri_mapping.make_trailing_slash_ignored ("/admin/export", l_admin_export_handler)
|
||||||
|
a_router.map (l_uri_mapping, a_router.methods_get_post)
|
||||||
|
|
||||||
create l_user_handler.make (a_api)
|
create l_user_handler.make (a_api)
|
||||||
a_router.handle ("/admin/add/user", l_user_handler, a_router.methods_get_post)
|
a_router.handle ("/admin/add/user", l_user_handler, a_router.methods_get_post)
|
||||||
a_router.handle ("/admin/user/{id}", l_user_handler, a_router.methods_get)
|
a_router.handle ("/admin/user/{id}", l_user_handler, a_router.methods_get)
|
||||||
@@ -84,8 +89,6 @@ feature -- Access: router
|
|||||||
a_router.handle ("/admin/role/{id}", l_role_handler, a_router.methods_get)
|
a_router.handle ("/admin/role/{id}", l_role_handler, a_router.methods_get)
|
||||||
a_router.handle ("/admin/role/{id}/edit", l_role_handler, a_router.methods_get_post)
|
a_router.handle ("/admin/role/{id}/edit", l_role_handler, a_router.methods_get_post)
|
||||||
a_router.handle ("/admin/role/{id}/delete", l_role_handler, a_router.methods_get_post)
|
a_router.handle ("/admin/role/{id}/delete", l_role_handler, a_router.methods_get_post)
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Security
|
feature -- Security
|
||||||
@@ -101,6 +104,7 @@ feature -- Security
|
|||||||
Result.force ("install modules")
|
Result.force ("install modules")
|
||||||
Result.force ("admin core caches")
|
Result.force ("admin core caches")
|
||||||
Result.force ("clear blocks cache")
|
Result.force ("clear blocks cache")
|
||||||
|
Result.force ("admin export")
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Hooks
|
feature -- Hooks
|
||||||
@@ -132,6 +136,10 @@ feature -- Hooks
|
|||||||
end
|
end
|
||||||
-- Per module cache permission!
|
-- Per module cache permission!
|
||||||
create lnk.make ("Cache", "admin/cache")
|
create lnk.make ("Cache", "admin/cache")
|
||||||
|
a_menu_system.management_menu.extend (lnk)
|
||||||
|
|
||||||
|
-- Per module export permission!
|
||||||
|
create lnk.make ("Export", "admin/export")
|
||||||
a_menu_system.management_menu.extend (lnk)
|
a_menu_system.management_menu.extend (lnk)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
104
modules/admin/handler/cms_admin_export_handler.e
Normal file
104
modules/admin/handler/cms_admin_export_handler.e
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
Administrate export functionality.
|
||||||
|
]"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
CMS_ADMIN_EXPORT_HANDLER
|
||||||
|
|
||||||
|
inherit
|
||||||
|
CMS_HANDLER
|
||||||
|
|
||||||
|
WSF_URI_HANDLER
|
||||||
|
rename
|
||||||
|
new_mapping as new_uri_mapping
|
||||||
|
end
|
||||||
|
|
||||||
|
WSF_RESOURCE_HANDLER_HELPER
|
||||||
|
redefine
|
||||||
|
do_get,
|
||||||
|
do_post
|
||||||
|
end
|
||||||
|
|
||||||
|
REFACTORING_HELPER
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature -- Execution
|
||||||
|
|
||||||
|
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
-- Execute request handler
|
||||||
|
do
|
||||||
|
execute_methods (req, res)
|
||||||
|
end
|
||||||
|
|
||||||
|
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
local
|
||||||
|
l_response: CMS_RESPONSE
|
||||||
|
s: STRING
|
||||||
|
f: CMS_FORM
|
||||||
|
do
|
||||||
|
create {GENERIC_VIEW_CMS_RESPONSE} l_response.make (req, res, api)
|
||||||
|
f := exportation_web_form (l_response)
|
||||||
|
create s.make_empty
|
||||||
|
f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s)
|
||||||
|
l_response.set_main_content (s)
|
||||||
|
l_response.execute
|
||||||
|
end
|
||||||
|
|
||||||
|
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
local
|
||||||
|
l_response: CMS_RESPONSE
|
||||||
|
s: STRING
|
||||||
|
f: CMS_FORM
|
||||||
|
l_exportation_parameters: CMS_EXPORT_PARAMETERS
|
||||||
|
do
|
||||||
|
create {GENERIC_VIEW_CMS_RESPONSE} l_response.make (req, res, api)
|
||||||
|
f := exportation_web_form (l_response)
|
||||||
|
f.process (l_response)
|
||||||
|
if
|
||||||
|
attached f.last_data as fd and then
|
||||||
|
fd.is_valid
|
||||||
|
then
|
||||||
|
if attached fd.string_item ("op") as l_op and then l_op.same_string (text_export_all_data) then
|
||||||
|
create l_exportation_parameters.make (api.site_location.extended ("export").extended ((create {DATE_TIME}.make_now_utc).formatted_out ("yyyy-[0]mm-[0]dd_hh12-[0]mi-[0]ss")))
|
||||||
|
l_response.hooks.invoke_export_to (Void, l_exportation_parameters, l_response)
|
||||||
|
l_response.add_notice_message ("All data exported (if allowed)!")
|
||||||
|
create s.make_empty
|
||||||
|
across
|
||||||
|
l_exportation_parameters.logs as ic
|
||||||
|
loop
|
||||||
|
s.append (ic.item)
|
||||||
|
s.append ("<br/>")
|
||||||
|
s.append_character ('%N')
|
||||||
|
end
|
||||||
|
l_response.add_notice_message (s)
|
||||||
|
else
|
||||||
|
fd.report_error ("Invalid form data!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
create s.make_empty
|
||||||
|
f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s)
|
||||||
|
l_response.set_main_content (s)
|
||||||
|
l_response.execute
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Widget
|
||||||
|
|
||||||
|
exportation_web_form (a_response: CMS_RESPONSE): CMS_FORM
|
||||||
|
local
|
||||||
|
but: WSF_FORM_SUBMIT_INPUT
|
||||||
|
do
|
||||||
|
create Result.make (a_response.url (a_response.location, Void), "export_all_data")
|
||||||
|
create but.make_with_text ("op", text_export_all_data)
|
||||||
|
Result.extend (but)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Interface text.
|
||||||
|
|
||||||
|
text_export_all_data: STRING_32 = "Export all data"
|
||||||
|
|
||||||
|
end
|
||||||
@@ -97,6 +97,21 @@ feature -- Access node
|
|||||||
Result := nodes_to_blogs (blog_storage.blogs_from_user_limited (a_user, a_limit, a_offset))
|
Result := nodes_to_blogs (blog_storage.blogs_from_user_limited (a_user, a_limit, a_offset))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Conversion
|
||||||
|
|
||||||
|
full_blog_node (a_blog: CMS_BLOG): CMS_BLOG
|
||||||
|
-- If `a_blog' is partial, return the full blog node from `a_blog',
|
||||||
|
-- otherwise return directly `a_blog'.
|
||||||
|
require
|
||||||
|
a_blog_set: a_blog /= Void
|
||||||
|
do
|
||||||
|
if attached {CMS_BLOG} node_api.full_node (a_blog) as l_full_blog then
|
||||||
|
Result := l_full_blog
|
||||||
|
else
|
||||||
|
Result := a_blog
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
feature {NONE} -- Helpers
|
feature {NONE} -- Helpers
|
||||||
|
|
||||||
nodes_to_blogs (a_nodes: LIST [CMS_NODE]): ARRAYED_LIST [CMS_BLOG]
|
nodes_to_blogs (a_nodes: LIST [CMS_NODE]): ARRAYED_LIST [CMS_BLOG]
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
<library name="cms" location="..\..\cms-safe.ecf" readonly="false"/>
|
<library name="cms" location="..\..\cms-safe.ecf" readonly="false"/>
|
||||||
<library name="cms_model" location="..\..\library\model\cms_model-safe.ecf" readonly="false"/>
|
<library name="cms_model" location="..\..\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||||
<library name="cms_node_module" location="..\..\modules\node\node-safe.ecf" readonly="false"/>
|
<library name="cms_node_module" location="..\..\modules\node\node-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" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
|
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ inherit
|
|||||||
|
|
||||||
CMS_HOOK_RESPONSE_ALTER
|
CMS_HOOK_RESPONSE_ALTER
|
||||||
|
|
||||||
|
CMS_HOOK_EXPORT
|
||||||
|
|
||||||
|
CMS_EXPORT_NODE_UTILITIES
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|
||||||
@@ -153,6 +157,7 @@ feature -- Hooks
|
|||||||
do
|
do
|
||||||
a_response.hooks.subscribe_to_menu_system_alter_hook (Current)
|
a_response.hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||||
a_response.hooks.subscribe_to_response_alter_hook (Current)
|
a_response.hooks.subscribe_to_response_alter_hook (Current)
|
||||||
|
a_response.hooks.subscribe_to_export_hook (Current)
|
||||||
end
|
end
|
||||||
|
|
||||||
response_alter (a_response: CMS_RESPONSE)
|
response_alter (a_response: CMS_RESPONSE)
|
||||||
@@ -168,4 +173,47 @@ feature -- Hooks
|
|||||||
create lnk.make ("Blogs", "blogs/")
|
create lnk.make ("Blogs", "blogs/")
|
||||||
a_menu_system.primary_menu.extend (lnk)
|
a_menu_system.primary_menu.extend (lnk)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
export_to (a_export_id_list: detachable ITERABLE [READABLE_STRING_GENERAL]; a_export_parameters: CMS_EXPORT_PARAMETERS; a_response: CMS_RESPONSE)
|
||||||
|
-- Export data identified by `a_export_id_list',
|
||||||
|
-- or export all data if `a_export_id_list' is Void.
|
||||||
|
local
|
||||||
|
n: CMS_BLOG
|
||||||
|
p: PATH
|
||||||
|
d: DIRECTORY
|
||||||
|
f: PLAIN_TEXT_FILE
|
||||||
|
lst: LIST [CMS_BLOG]
|
||||||
|
do
|
||||||
|
if
|
||||||
|
a_export_id_list = Void
|
||||||
|
or else across a_export_id_list as ic some ic.item.same_string ("blog") end
|
||||||
|
then
|
||||||
|
if attached blog_api as l_blog_api then
|
||||||
|
lst := l_blog_api.blogs_order_created_desc
|
||||||
|
a_export_parameters.log ("Exporting " + lst.count.out + " blogs")
|
||||||
|
across
|
||||||
|
lst as ic
|
||||||
|
loop
|
||||||
|
n := l_blog_api.full_blog_node (ic.item)
|
||||||
|
a_export_parameters.log (n.content_type + " #" + n.id.out)
|
||||||
|
p := a_export_parameters.location.extended ("nodes").extended (n.content_type).extended (n.id.out)
|
||||||
|
create d.make_with_path (p.parent)
|
||||||
|
if not d.exists then
|
||||||
|
d.recursive_create_dir
|
||||||
|
end
|
||||||
|
create f.make_with_path (p)
|
||||||
|
if not f.exists or else f.is_access_writable then
|
||||||
|
f.open_write
|
||||||
|
f.put_string (json_to_string (blog_node_to_json (n)))
|
||||||
|
f.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
blog_node_to_json (a_blog: CMS_BLOG): JSON_OBJECT
|
||||||
|
do
|
||||||
|
Result := node_to_json (a_blog)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,8 +6,12 @@ note
|
|||||||
deferred class
|
deferred class
|
||||||
CMS_BLOG_STORAGE_I
|
CMS_BLOG_STORAGE_I
|
||||||
|
|
||||||
inherit
|
feature -- Error Handling
|
||||||
CMS_NODE_STORAGE_I
|
|
||||||
|
error_handler: ERROR_HANDLER
|
||||||
|
-- Error handler.
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
|
|||||||
@@ -330,6 +330,14 @@ feature -- Access: Node
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
nodes_of_type (a_node_type: CMS_CONTENT_TYPE): LIST [CMS_NODE]
|
||||||
|
-- List of nodes of type `a_node_type'.
|
||||||
|
do
|
||||||
|
Result := node_storage.nodes_of_type (a_node_type)
|
||||||
|
ensure
|
||||||
|
expected_type: across Result as ic all ic.item.content_type.same_string (a_node_type.name) end
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Access: page/book outline
|
feature -- Access: page/book outline
|
||||||
|
|
||||||
children (a_node: CMS_NODE): detachable LIST [CMS_NODE]
|
children (a_node: CMS_NODE): detachable LIST [CMS_NODE]
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ inherit
|
|||||||
|
|
||||||
CMS_RECENT_CHANGES_HOOK
|
CMS_RECENT_CHANGES_HOOK
|
||||||
|
|
||||||
|
CMS_HOOK_EXPORT
|
||||||
|
|
||||||
|
CMS_EXPORT_NODE_UTILITIES
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|
||||||
@@ -230,6 +234,7 @@ feature -- Hooks
|
|||||||
a_response.hooks.subscribe_to_menu_system_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_block_hook (Current)
|
||||||
a_response.hooks.subscribe_to_response_alter_hook (Current)
|
a_response.hooks.subscribe_to_response_alter_hook (Current)
|
||||||
|
a_response.hooks.subscribe_to_export_hook (Current)
|
||||||
|
|
||||||
-- Module specific hook, if available.
|
-- Module specific hook, if available.
|
||||||
a_response.hooks.subscribe_to_hook (Current, {CMS_RECENT_CHANGES_HOOK})
|
a_response.hooks.subscribe_to_hook (Current, {CMS_RECENT_CHANGES_HOOK})
|
||||||
@@ -353,4 +358,69 @@ feature -- Hooks
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
export_to (a_export_id_list: detachable ITERABLE [READABLE_STRING_GENERAL]; a_export_parameters: CMS_EXPORT_PARAMETERS; a_response: CMS_RESPONSE)
|
||||||
|
-- Export data identified by `a_export_id_list',
|
||||||
|
-- or export all data if `a_export_id_list' is Void.
|
||||||
|
local
|
||||||
|
l_node_type: CMS_CONTENT_TYPE
|
||||||
|
n: CMS_NODE
|
||||||
|
p: PATH
|
||||||
|
d: DIRECTORY
|
||||||
|
f: PLAIN_TEXT_FILE
|
||||||
|
lst: LIST [CMS_NODE]
|
||||||
|
do
|
||||||
|
if attached node_api as l_node_api then
|
||||||
|
across
|
||||||
|
l_node_api.node_types as types_ic
|
||||||
|
loop
|
||||||
|
l_node_type := types_ic.item
|
||||||
|
if
|
||||||
|
l_node_type.name.same_string_general ("page") and then
|
||||||
|
( a_export_id_list = Void
|
||||||
|
or else across a_export_id_list as ic some ic.item.same_string (l_node_type.name) end
|
||||||
|
)
|
||||||
|
then
|
||||||
|
|
||||||
|
-- For now, handle only page from this node module.
|
||||||
|
lst := l_node_api.nodes_of_type (l_node_type)
|
||||||
|
a_export_parameters.log ("Exporting " + lst.count.out + " nodes of type " + l_node_type.name)
|
||||||
|
across
|
||||||
|
lst as ic
|
||||||
|
loop
|
||||||
|
n := l_node_api.full_node (ic.item)
|
||||||
|
a_export_parameters.log (l_node_type.name + " #" + n.id.out)
|
||||||
|
p := a_export_parameters.location.extended ("nodes").extended (l_node_type.name).extended (n.id.out)
|
||||||
|
create d.make_with_path (p.parent)
|
||||||
|
if not d.exists then
|
||||||
|
d.recursive_create_dir
|
||||||
|
end
|
||||||
|
create f.make_with_path (p)
|
||||||
|
if not f.exists or else f.is_access_writable then
|
||||||
|
f.open_write
|
||||||
|
if attached {CMS_PAGE} n as l_page then
|
||||||
|
f.put_string (json_to_string (page_node_to_json (l_page)))
|
||||||
|
else
|
||||||
|
f.put_string (json_to_string (node_to_json (n)))
|
||||||
|
end
|
||||||
|
f.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
page_node_to_json (a_page: CMS_PAGE): JSON_OBJECT
|
||||||
|
local
|
||||||
|
j: JSON_OBJECT
|
||||||
|
do
|
||||||
|
Result := node_to_json (a_page)
|
||||||
|
if attached a_page.parent as l_parent_page then
|
||||||
|
create j.make_empty
|
||||||
|
j.put_string (l_parent_page.content_type, "type")
|
||||||
|
j.put_integer (l_parent_page.id, "nid")
|
||||||
|
Result.put (j, "parent")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
55
modules/node/export/cms_export_node_utilities.e
Normal file
55
modules/node/export/cms_export_node_utilities.e
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
Routines usefull during node exportation (see {CMS_HOOK_EXPORT}).
|
||||||
|
]"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
CMS_EXPORT_NODE_UTILITIES
|
||||||
|
|
||||||
|
inherit
|
||||||
|
CMS_EXPORT_JSON_UTILITIES
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
node_to_json (n: CMS_NODE): JSON_OBJECT
|
||||||
|
local
|
||||||
|
jo,j_author: JSON_OBJECT
|
||||||
|
do
|
||||||
|
create Result.make_empty
|
||||||
|
Result.put_string (n.content_type, "type")
|
||||||
|
Result.put_integer (n.id, "nid")
|
||||||
|
Result.put_integer (n.revision, "revision")
|
||||||
|
Result.put_string (n.title, "title")
|
||||||
|
put_date_into_json (n.creation_date, "creation_date", Result)
|
||||||
|
put_date_into_json (n.modification_date, "modification_date", Result)
|
||||||
|
put_date_into_json (n.publication_date, "publication_date", Result)
|
||||||
|
Result.put_integer (n.status, "status")
|
||||||
|
if attached n.author as u then
|
||||||
|
create j_author.make
|
||||||
|
j_author.put_integer (u.id, "uid")
|
||||||
|
j_author.put_string (u.name, "name")
|
||||||
|
Result.put (j_author, "author")
|
||||||
|
end
|
||||||
|
create jo.make_empty
|
||||||
|
if attached n.format as l_format then
|
||||||
|
jo.put_string (l_format, "format")
|
||||||
|
end
|
||||||
|
if attached n.summary as s then
|
||||||
|
jo.put_string (s, "summary")
|
||||||
|
end
|
||||||
|
if attached n.content as s then
|
||||||
|
jo.put_string (s, "content")
|
||||||
|
end
|
||||||
|
Result.put (jo, "data")
|
||||||
|
if attached n.link as lnk then
|
||||||
|
create jo.make_empty
|
||||||
|
jo.put_string (lnk.title, "title")
|
||||||
|
jo.put_string (lnk.location, "location")
|
||||||
|
jo.put_integer (lnk.weight, "weight")
|
||||||
|
Result.put (jo, "link")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="node" uuid="C7114DD4-FA92-4AE5-A209-0FFC45E44257" library_target="node">
|
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="node" uuid="C7114DD4-FA92-4AE5-A209-0FFC45E44257" library_target="node">
|
||||||
<target name="node">
|
<target name="node">
|
||||||
<root all_classes="true"/>
|
<root all_classes="true"/>
|
||||||
<file_rule>
|
<file_rule>
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<exclude>/CVS$</exclude>
|
<exclude>/CVS$</exclude>
|
||||||
<exclude>/.svn$</exclude>
|
<exclude>/.svn$</exclude>
|
||||||
</file_rule>
|
</file_rule>
|
||||||
<option warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="all" syntax="transitional">
|
<option warning="true" full_class_checking="false" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="all" syntax="transitional">
|
||||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||||
</option>
|
</option>
|
||||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
<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" 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"/>
|
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\web\authentication\http_authorization\http_authorization-safe.ecf" readonly="false"/>
|
||||||
|
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf"/>
|
||||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
|
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
|
||||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error.ecf"/>
|
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error.ecf"/>
|
||||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http.ecf"/>
|
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http.ecf"/>
|
||||||
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\network\authentication\http_authorization\http_authorization.ecf" readonly="false"/>
|
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\network\authentication\http_authorization\http_authorization.ecf" readonly="false"/>
|
||||||
|
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf"/>
|
||||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter.ecf"/>
|
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter.ecf"/>
|
||||||
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
||||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
|
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
|
||||||
|
|||||||
@@ -127,6 +127,26 @@ feature -- Access
|
|||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
nodes_of_type (a_node_type: CMS_CONTENT_TYPE): LIST [CMS_NODE]
|
||||||
|
-- List of nodes of type `a_node_type'.
|
||||||
|
--| Redefine to optimize!
|
||||||
|
do
|
||||||
|
Result := nodes
|
||||||
|
from
|
||||||
|
Result.start
|
||||||
|
until
|
||||||
|
Result.after
|
||||||
|
loop
|
||||||
|
if Result.item.content_type.same_string (a_node_type.name) then
|
||||||
|
Result.forth
|
||||||
|
else
|
||||||
|
Result.remove
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
expected_type: across Result as ic all ic.item.content_type.same_string (a_node_type.name) end
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Access: outline
|
feature -- Access: outline
|
||||||
|
|
||||||
children (a_node: CMS_NODE): detachable LIST [CMS_NODE]
|
children (a_node: CMS_NODE): detachable LIST [CMS_NODE]
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ inherit
|
|||||||
CMS_PROXY_STORAGE_SQL
|
CMS_PROXY_STORAGE_SQL
|
||||||
|
|
||||||
CMS_NODE_STORAGE_I
|
CMS_NODE_STORAGE_I
|
||||||
|
redefine
|
||||||
|
nodes_of_type
|
||||||
|
end
|
||||||
|
|
||||||
CMS_STORAGE_SQL_I
|
CMS_STORAGE_SQL_I
|
||||||
|
|
||||||
@@ -264,6 +267,33 @@ feature -- Access
|
|||||||
-- end
|
-- end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
nodes_of_type (a_node_type: CMS_CONTENT_TYPE): 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 + ".nodes_of_type")
|
||||||
|
create l_parameters.make (1)
|
||||||
|
l_parameters.put (a_node_type.name, "node_type")
|
||||||
|
|
||||||
|
from
|
||||||
|
sql_query (sql_select_nodes_of_type, l_parameters)
|
||||||
|
sql_start
|
||||||
|
until
|
||||||
|
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
|
||||||
|
Result.force (l_node)
|
||||||
|
end
|
||||||
|
sql_forth
|
||||||
|
end
|
||||||
|
sql_finalize
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Access: outline
|
feature -- Access: outline
|
||||||
|
|
||||||
children (a_node: CMS_NODE): detachable LIST [CMS_NODE]
|
children (a_node: CMS_NODE): detachable LIST [CMS_NODE]
|
||||||
@@ -495,6 +525,10 @@ feature {NONE} -- Queries
|
|||||||
-- SQL Query to retrieve all nodes.
|
-- SQL Query to retrieve all nodes.
|
||||||
--| note: {CMS_NODE_API}.trashed = -1
|
--| note: {CMS_NODE_API}.trashed = -1
|
||||||
|
|
||||||
|
sql_select_nodes_of_type: STRING = "SELECT nid, revision, type, title, summary, content, format, author, publish, created, changed, status FROM nodes WHERE status != -1 AND type=:node_type ;"
|
||||||
|
-- SQL Query to retrieve all nodes of type :node_type.
|
||||||
|
--| note: {CMS_NODE_API}.trashed = -1
|
||||||
|
|
||||||
sql_select_node_revisions: 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_node_revisions: 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 query to get node revisions (missing the latest one).
|
-- SQL query to get node revisions (missing the latest one).
|
||||||
|
|
||||||
|
|||||||
@@ -223,6 +223,34 @@ feature -- Hook: cache
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Hook: export
|
||||||
|
|
||||||
|
subscribe_to_export_hook (h: CMS_HOOK_EXPORT)
|
||||||
|
-- Add `h' as subscriber of export hooks CMS_HOOK_EXPORT.
|
||||||
|
do
|
||||||
|
subscribe_to_hook (h, {CMS_HOOK_EXPORT})
|
||||||
|
end
|
||||||
|
|
||||||
|
invoke_export_to (a_export_id_list: detachable ITERABLE [READABLE_STRING_GENERAL]; a_export_parameters: CMS_EXPORT_PARAMETERS; a_response: CMS_RESPONSE)
|
||||||
|
-- Invoke response alter hook for response `a_response'.
|
||||||
|
local
|
||||||
|
d: DIRECTORY
|
||||||
|
do
|
||||||
|
if attached subscribers ({CMS_HOOK_EXPORT}) as lst then
|
||||||
|
create d.make_with_path (a_export_parameters.location)
|
||||||
|
if not d.exists then
|
||||||
|
d.recursive_create_dir
|
||||||
|
end
|
||||||
|
across
|
||||||
|
lst as ic
|
||||||
|
loop
|
||||||
|
if attached {CMS_HOOK_EXPORT} ic.item as h then
|
||||||
|
h.export_to (a_export_id_list, a_export_parameters, a_response)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
|||||||
35
src/hooks/export/cms_export_json_utilities.e
Normal file
35
src/hooks/export/cms_export_json_utilities.e
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
Usefull routines to export to JSON.
|
||||||
|
]"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
CMS_EXPORT_JSON_UTILITIES
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
put_date_into_json (dt: detachable DATE_TIME; a_key: JSON_STRING; j: JSON_OBJECT)
|
||||||
|
local
|
||||||
|
hd: HTTP_DATE
|
||||||
|
do
|
||||||
|
if dt /= Void then
|
||||||
|
create hd.make_from_date_time (dt)
|
||||||
|
j.put_integer (hd.timestamp, a_key)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
json_to_string (j: JSON_OBJECT): STRING
|
||||||
|
local
|
||||||
|
pp: JSON_PRETTY_STRING_VISITOR
|
||||||
|
do
|
||||||
|
create Result.make_empty
|
||||||
|
create pp.make (Result)
|
||||||
|
j.accept (pp)
|
||||||
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
end
|
||||||
43
src/hooks/export/cms_export_parameters.e
Normal file
43
src/hooks/export/cms_export_parameters.e
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
Parameters used by CMS_HOOK_EXPORT subscribers.
|
||||||
|
]"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
CMS_EXPORT_PARAMETERS
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make (a_location: PATH)
|
||||||
|
do
|
||||||
|
location := a_location
|
||||||
|
create logs.make (10)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
location: PATH
|
||||||
|
-- Location of export folder.
|
||||||
|
|
||||||
|
feature -- Logs
|
||||||
|
|
||||||
|
logs: ARRAYED_LIST [READABLE_STRING_8]
|
||||||
|
-- Associated exportation logs.
|
||||||
|
|
||||||
|
log (m: READABLE_STRING_8)
|
||||||
|
-- Add message `m' into `logs'.
|
||||||
|
do
|
||||||
|
logs.force (m)
|
||||||
|
end
|
||||||
|
|
||||||
|
invariant
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
end
|
||||||
31
src/hooks/export/cms_hook_export.e
Normal file
31
src/hooks/export/cms_hook_export.e
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
CMS HOOK providing a way to export module data according to specific export parameters.
|
||||||
|
]"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
deferred class
|
||||||
|
CMS_HOOK_EXPORT
|
||||||
|
|
||||||
|
inherit
|
||||||
|
CMS_HOOK
|
||||||
|
|
||||||
|
feature -- Hook
|
||||||
|
|
||||||
|
export_to (a_export_id_list: detachable ITERABLE [READABLE_STRING_GENERAL]; a_export_parameters: CMS_EXPORT_PARAMETERS; a_response: CMS_RESPONSE)
|
||||||
|
-- Export data identified by `a_export_id_list',
|
||||||
|
-- or export all data if `a_export_id_list' is Void.
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
|
-- export_identifiers: detachable ITERABLE [READABLE_STRING_32]
|
||||||
|
-- -- Optional list of exportation ids, if any.
|
||||||
|
-- do
|
||||||
|
-- -- To redefine if needed.
|
||||||
|
-- end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user