Compare commits
6 Commits
taxonomy_c
...
es_rev9823
| Author | SHA1 | Date | |
|---|---|---|---|
| 23d266497b | |||
| ce8de442e9 | |||
| e3ae564746 | |||
| b0626d5250 | |||
| 276dcc6fcd | |||
| 6313007fbf |
@@ -10,7 +10,7 @@ class
|
||||
inherit
|
||||
CMS_MODULE
|
||||
redefine
|
||||
register_hooks,
|
||||
setup_hooks,
|
||||
initialize,
|
||||
install
|
||||
end
|
||||
@@ -85,10 +85,10 @@ feature -- Access: router
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
do
|
||||
a_response.hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_response.hooks.subscribe_to_block_hook (Current)
|
||||
a_hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_hooks.subscribe_to_block_hook (Current)
|
||||
end
|
||||
|
||||
block_list: ITERABLE [like {CMS_BLOCK}.name]
|
||||
|
||||
@@ -11,7 +11,7 @@ ROC_AUTH.login = function() {
|
||||
var username = form.username.value;
|
||||
var password = form.password.value;
|
||||
//var host = form.host.value;
|
||||
var origin = window.location.origin.concat(window.location.pathname);
|
||||
var origin = window.location.origin + window.location.pathname;
|
||||
var _login = function(){
|
||||
|
||||
|
||||
@@ -322,4 +322,4 @@ ROC_AUTH.validatePassword =function(){
|
||||
if ((password != null) && (confirm_password != null)) {
|
||||
password.onchange = ROC_AUTH.validatePassword();
|
||||
confirm_password.onkeyup = ROC_AUTH.validatePassword;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,3 +19,8 @@ ul.taxonomy li:hover {
|
||||
border-bottom: solid 1px #66f;
|
||||
background-color: #ddf;
|
||||
}
|
||||
|
||||
table.taxonomy td {
|
||||
border: solid 1px #ccc;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
@@ -19,3 +19,9 @@ ul.taxonomy {
|
||||
}
|
||||
}
|
||||
}
|
||||
table.taxonomy {
|
||||
td {
|
||||
border: solid 1px #ccc;
|
||||
padding: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,3 +90,11 @@ ul.horizontal li {
|
||||
border: solid 1px red;
|
||||
padding: 5px 2px 5px 2px;
|
||||
}
|
||||
|
||||
table.with_border thead td {
|
||||
font-weight: bold;
|
||||
}
|
||||
table.with_border td {
|
||||
border: solid 1px #ccc;
|
||||
padding: 2px 5px 2px 5px;
|
||||
}
|
||||
|
||||
@@ -95,3 +95,13 @@ ul.horizontal {
|
||||
border: solid 1px red;
|
||||
padding: 5px 2px 5px 2px;
|
||||
}
|
||||
|
||||
table.with_border {
|
||||
thead td {
|
||||
font-weight: bold;
|
||||
}
|
||||
td {
|
||||
border: solid 1px #ccc;
|
||||
padding: 2px 5px 2px 5px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +152,7 @@ feature -- Query
|
||||
-- Retrieved value at `a_index' position in `item'.
|
||||
local
|
||||
l_item: like sql_item
|
||||
i64: INTEGER_64
|
||||
do
|
||||
l_item := sql_item (a_index)
|
||||
if attached {INTEGER_32} l_item as i then
|
||||
@@ -159,7 +160,18 @@ feature -- Query
|
||||
elseif attached {INTEGER_32_REF} l_item as l_value then
|
||||
Result := l_value.item
|
||||
else
|
||||
check is_integer_32: False end
|
||||
if attached {INTEGER_64} l_item as i then
|
||||
i64 := i
|
||||
elseif attached {INTEGER_64_REF} l_item as l_value then
|
||||
i64 := l_value.item
|
||||
else
|
||||
check is_integer_32: False end
|
||||
end
|
||||
if i64 <= {INTEGER_32}.max_value then
|
||||
Result := i64.to_integer_32
|
||||
else
|
||||
check is_integer_32: False end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class
|
||||
inherit
|
||||
CMS_MODULE
|
||||
redefine
|
||||
register_hooks,
|
||||
setup_hooks,
|
||||
permissions
|
||||
end
|
||||
|
||||
@@ -116,11 +116,11 @@ feature -- Security
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- <Precursor>
|
||||
do
|
||||
a_response.hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_response.hooks.subscribe_to_response_alter_hook (Current)
|
||||
a_hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_hooks.subscribe_to_response_alter_hook (Current)
|
||||
end
|
||||
|
||||
response_alter (a_response: CMS_RESPONSE)
|
||||
|
||||
@@ -44,7 +44,7 @@ feature -- Execution
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_response.make (req, res, api)
|
||||
f := clear_cache_web_form (l_response)
|
||||
create s.make_empty
|
||||
f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s)
|
||||
f.append_to_html (l_response.wsf_theme, s)
|
||||
l_response.set_main_content (s)
|
||||
l_response.execute
|
||||
end
|
||||
@@ -63,14 +63,14 @@ feature -- Execution
|
||||
fd.is_valid
|
||||
then
|
||||
if attached fd.string_item ("op") as l_op and then l_op.same_string (text_clear_all_caches) then
|
||||
l_response.hooks.invoke_clear_cache (Void, l_response)
|
||||
api.hooks.invoke_clear_cache (Void, l_response)
|
||||
l_response.add_notice_message ("Caches cleared (if allowed)!")
|
||||
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)
|
||||
f.append_to_html (l_response.wsf_theme, s)
|
||||
l_response.set_main_content (s)
|
||||
l_response.execute
|
||||
end
|
||||
|
||||
@@ -44,7 +44,7 @@ feature -- Execution
|
||||
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)
|
||||
f.append_to_html (l_response.wsf_theme, s)
|
||||
l_response.set_main_content (s)
|
||||
l_response.execute
|
||||
end
|
||||
@@ -69,8 +69,7 @@ feature -- Execution
|
||||
else
|
||||
create l_exportation_parameters.make (api.site_location.extended ("export").extended ((create {DATE_TIME}.make_now_utc).formatted_out ("yyyy-[0]mm-[0]dd---hh24-[0]mi-[0]ss")))
|
||||
end
|
||||
|
||||
l_response.hooks.invoke_export_to (Void, l_exportation_parameters, l_response)
|
||||
api.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
|
||||
@@ -86,7 +85,7 @@ feature -- Execution
|
||||
end
|
||||
end
|
||||
create s.make_empty
|
||||
f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s)
|
||||
f.append_to_html (l_response.wsf_theme, s)
|
||||
l_response.set_main_content (s)
|
||||
l_response.execute
|
||||
end
|
||||
|
||||
@@ -88,7 +88,7 @@ feature -- Execution
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
|
||||
f := modules_collection_web_form (r)
|
||||
create s.make_empty
|
||||
f.append_to_html (create {CMS_TO_WSF_THEME}.make (r, r.theme), s)
|
||||
f.append_to_html (r.wsf_theme, s)
|
||||
r.set_page_title ("Modules")
|
||||
r.set_main_content (s)
|
||||
r.execute
|
||||
@@ -133,7 +133,7 @@ feature -- Execution
|
||||
then
|
||||
r.add_error_message ("Error occurred.")
|
||||
create s.make_empty
|
||||
f.append_to_html (create {CMS_TO_WSF_THEME}.make (r, r.theme), s)
|
||||
f.append_to_html (r.wsf_theme, s)
|
||||
r.set_page_title ("Modules")
|
||||
r.set_main_content (s)
|
||||
else
|
||||
|
||||
@@ -8,30 +8,10 @@ class
|
||||
|
||||
inherit
|
||||
CMS_RESPONSE
|
||||
redefine
|
||||
make,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: like api)
|
||||
do
|
||||
create {WSF_NULL_THEME} wsf_theme.make
|
||||
Precursor (req, res, a_api)
|
||||
end
|
||||
|
||||
initialize
|
||||
do
|
||||
Precursor
|
||||
create {CMS_TO_WSF_THEME} wsf_theme.make (Current, theme)
|
||||
end
|
||||
|
||||
wsf_theme: WSF_THEME
|
||||
|
||||
feature -- Process
|
||||
|
||||
process
|
||||
|
||||
@@ -8,32 +8,12 @@ class
|
||||
|
||||
inherit
|
||||
CMS_RESPONSE
|
||||
redefine
|
||||
make,
|
||||
initialize
|
||||
end
|
||||
|
||||
CMS_SHARED_SORTING_UTILITIES
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: like api)
|
||||
do
|
||||
create {WSF_NULL_THEME} wsf_theme.make
|
||||
Precursor (req, res, a_api)
|
||||
end
|
||||
|
||||
initialize
|
||||
do
|
||||
Precursor
|
||||
create {CMS_TO_WSF_THEME} wsf_theme.make (Current, theme)
|
||||
end
|
||||
|
||||
wsf_theme: WSF_THEME
|
||||
|
||||
feature -- Query
|
||||
|
||||
role_id_path_parameter (req: WSF_REQUEST): INTEGER_64
|
||||
@@ -84,7 +64,7 @@ feature -- Process Edit
|
||||
do
|
||||
create b.make_empty
|
||||
f := new_edit_form (a_role, url (request.percent_encoded_path_info, Void), "edit-user")
|
||||
hooks.invoke_form_alter (f, fd, Current)
|
||||
api.hooks.invoke_form_alter (f, fd, Current)
|
||||
if request.is_post_request_method then
|
||||
f.validation_actions.extend (agent edit_form_validate(?,a_role, b))
|
||||
f.submit_actions.extend (agent edit_form_submit(?, a_role, b))
|
||||
@@ -117,7 +97,7 @@ feature -- Process Delete
|
||||
do
|
||||
create b.make_empty
|
||||
f := new_delete_form (a_role, url (request.percent_encoded_path_info, Void), "edit-user")
|
||||
hooks.invoke_form_alter (f, fd, Current)
|
||||
api.hooks.invoke_form_alter (f, fd, Current)
|
||||
if request.is_post_request_method then
|
||||
f.process (Current)
|
||||
fd := f.last_data
|
||||
@@ -149,7 +129,7 @@ feature -- Process New
|
||||
do
|
||||
create b.make_empty
|
||||
f := new_edit_form (l_role, url (request.percent_encoded_path_info, Void), "create-role")
|
||||
hooks.invoke_form_alter (f, fd, Current)
|
||||
api.hooks.invoke_form_alter (f, fd, Current)
|
||||
if request.is_post_request_method then
|
||||
f.validation_actions.extend (agent new_form_validate(?, b))
|
||||
f.submit_actions.extend (agent edit_form_submit(?, l_role, b))
|
||||
|
||||
@@ -8,31 +8,10 @@ class
|
||||
|
||||
inherit
|
||||
CMS_RESPONSE
|
||||
redefine
|
||||
make,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: like api;)
|
||||
do
|
||||
create {WSF_NULL_THEME} wsf_theme.make
|
||||
Precursor (req, res, a_api)
|
||||
end
|
||||
|
||||
initialize
|
||||
do
|
||||
Precursor
|
||||
create {CMS_TO_WSF_THEME} wsf_theme.make (Current, theme)
|
||||
end
|
||||
|
||||
wsf_theme: WSF_THEME
|
||||
|
||||
feature -- Query
|
||||
|
||||
role_id_path_parameter (req: WSF_REQUEST): INTEGER_64
|
||||
|
||||
@@ -7,32 +7,11 @@ class
|
||||
CMS_USER_FORM_RESPONSE
|
||||
|
||||
inherit
|
||||
|
||||
CMS_RESPONSE
|
||||
redefine
|
||||
make,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: like api)
|
||||
do
|
||||
create {WSF_NULL_THEME} wsf_theme.make
|
||||
Precursor (req, res, a_api)
|
||||
end
|
||||
|
||||
initialize
|
||||
do
|
||||
Precursor
|
||||
create {CMS_TO_WSF_THEME} wsf_theme.make (Current, theme)
|
||||
end
|
||||
|
||||
wsf_theme: WSF_THEME
|
||||
|
||||
feature -- Query
|
||||
|
||||
user_id_path_parameter (req: WSF_REQUEST): INTEGER_64
|
||||
@@ -86,7 +65,7 @@ feature -- Process Edit
|
||||
do
|
||||
create b.make_empty
|
||||
f := new_edit_form (a_user, url (location, Void), "edit-user")
|
||||
hooks.invoke_form_alter (f, fd, Current)
|
||||
api.hooks.invoke_form_alter (f, fd, Current)
|
||||
if request.is_post_request_method then
|
||||
f.submit_actions.extend (agent edit_form_submit (?, a_user, b))
|
||||
f.process (Current)
|
||||
@@ -118,7 +97,7 @@ feature -- Process Delete
|
||||
do
|
||||
create b.make_empty
|
||||
f := new_delete_form (a_user, url (location, Void), "edit-user")
|
||||
hooks.invoke_form_alter (f, fd, Current)
|
||||
api.hooks.invoke_form_alter (f, fd, Current)
|
||||
if request.is_post_request_method then
|
||||
f.process (Current)
|
||||
fd := f.last_data
|
||||
@@ -151,7 +130,7 @@ feature -- Process New
|
||||
do
|
||||
create b.make_empty
|
||||
f := new_edit_form (l_user, url (location, Void), "create-user")
|
||||
hooks.invoke_form_alter (f, fd, Current)
|
||||
api.hooks.invoke_form_alter (f, fd, Current)
|
||||
if request.is_post_request_method then
|
||||
f.validation_actions.extend (agent new_form_validate (?, b))
|
||||
f.submit_actions.extend (agent edit_form_submit (?, l_user, b))
|
||||
|
||||
@@ -8,31 +8,10 @@ class
|
||||
|
||||
inherit
|
||||
CMS_RESPONSE
|
||||
redefine
|
||||
make,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: like api;)
|
||||
do
|
||||
create {WSF_NULL_THEME} wsf_theme.make
|
||||
Precursor (req, res, a_api)
|
||||
end
|
||||
|
||||
initialize
|
||||
do
|
||||
Precursor
|
||||
create {CMS_TO_WSF_THEME} wsf_theme.make (Current, theme)
|
||||
end
|
||||
|
||||
wsf_theme: WSF_THEME
|
||||
|
||||
feature -- Query
|
||||
|
||||
user_id_path_parameter (req: WSF_REQUEST): INTEGER_64
|
||||
|
||||
@@ -9,7 +9,7 @@ class
|
||||
inherit
|
||||
CMS_MODULE
|
||||
redefine
|
||||
register_hooks
|
||||
setup_hooks
|
||||
end
|
||||
|
||||
|
||||
@@ -91,12 +91,12 @@ feature -- Router
|
||||
|
||||
feature -- Hooks configuration
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- Module hooks configuration.
|
||||
do
|
||||
auto_subscribe_to_hooks (a_response)
|
||||
a_response.hooks.subscribe_to_block_hook (Current)
|
||||
a_response.hooks.subscribe_to_value_table_alter_hook (Current)
|
||||
auto_subscribe_to_hooks (a_hooks)
|
||||
a_hooks.subscribe_to_block_hook (Current)
|
||||
a_hooks.subscribe_to_value_table_alter_hook (Current)
|
||||
end
|
||||
|
||||
value_table_alter (a_value: CMS_VALUE_TABLE; a_response: CMS_RESPONSE)
|
||||
|
||||
@@ -13,7 +13,7 @@ inherit
|
||||
CMS_MODULE
|
||||
redefine
|
||||
filters,
|
||||
register_hooks
|
||||
setup_hooks
|
||||
end
|
||||
|
||||
CMS_HOOK_AUTO_REGISTER
|
||||
@@ -101,12 +101,12 @@ feature {NONE} -- Implementation: routes
|
||||
|
||||
feature -- Hooks configuration
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- Module hooks configuration.
|
||||
do
|
||||
auto_subscribe_to_hooks (a_response)
|
||||
a_response.hooks.subscribe_to_block_hook (Current)
|
||||
a_response.hooks.subscribe_to_value_table_alter_hook (Current)
|
||||
auto_subscribe_to_hooks (a_hooks)
|
||||
a_hooks.subscribe_to_block_hook (Current)
|
||||
a_hooks.subscribe_to_value_table_alter_hook (Current)
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
@@ -11,7 +11,7 @@ ROC_AUTH.login = function() {
|
||||
var username = form.username.value;
|
||||
var password = form.password.value;
|
||||
//var host = form.host.value;
|
||||
var origin = window.location.origin.concat(window.location.pathname);
|
||||
var origin = window.location.origin + window.location.pathname;
|
||||
var _login = function(){
|
||||
|
||||
|
||||
@@ -322,4 +322,4 @@ ROC_AUTH.validatePassword =function(){
|
||||
if ((password != null) && (confirm_password != null)) {
|
||||
password.onchange = ROC_AUTH.validatePassword();
|
||||
confirm_password.onkeyup = ROC_AUTH.validatePassword;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ inherit
|
||||
rename
|
||||
module_api as blog_api
|
||||
redefine
|
||||
register_hooks,
|
||||
setup_hooks,
|
||||
initialize,
|
||||
install,
|
||||
blog_api
|
||||
@@ -66,7 +66,7 @@ feature {CMS_API} -- Module Initialization
|
||||
ct.extend_format (ic.item)
|
||||
end
|
||||
l_node_api.add_node_type (ct)
|
||||
l_node_api.add_content_type_webform_manager (create {CMS_BLOG_NODE_TYPE_WEBFORM_MANAGER}.make (ct))
|
||||
l_node_api.add_node_type_webform_manager (create {CMS_BLOG_NODE_TYPE_WEBFORM_MANAGER}.make (ct, l_node_api))
|
||||
|
||||
-- Add support for CMS_BLOG, which requires a storage extension to store the optional "tags" value
|
||||
-- For now, we only have extension based on SQL statement.
|
||||
@@ -153,11 +153,11 @@ feature -- Access: router
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
do
|
||||
a_response.hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_response.hooks.subscribe_to_response_alter_hook (Current)
|
||||
a_response.hooks.subscribe_to_export_hook (Current)
|
||||
a_hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_hooks.subscribe_to_response_alter_hook (Current)
|
||||
a_hooks.subscribe_to_export_hook (Current)
|
||||
end
|
||||
|
||||
response_alter (a_response: CMS_RESPONSE)
|
||||
|
||||
@@ -13,7 +13,7 @@ inherit
|
||||
populate_form,
|
||||
update_node,
|
||||
new_node,
|
||||
append_html_output_to
|
||||
append_content_as_html_to
|
||||
end
|
||||
|
||||
create
|
||||
@@ -76,34 +76,24 @@ feature -- form
|
||||
|
||||
feature -- Output
|
||||
|
||||
append_html_output_to (a_node: CMS_NODE; a_response: NODE_RESPONSE)
|
||||
append_content_as_html_to (a_node: CMS_BLOG; is_teaser: BOOLEAN; a_output: STRING; a_response: detachable CMS_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
s: STRING
|
||||
do
|
||||
Precursor (a_node, a_response)
|
||||
if attached a_response.main_content as l_main_content then
|
||||
s := l_main_content
|
||||
else
|
||||
create s.make_empty
|
||||
end
|
||||
Precursor (a_node, is_teaser, a_output, a_response)
|
||||
|
||||
if attached {CMS_BLOG} a_node as l_blog_post then
|
||||
if attached l_blog_post.tags as l_tags then
|
||||
s.append ("<div><strong>Tags:</strong> ")
|
||||
a_output.append ("<div><strong>Tags:</strong> ")
|
||||
across
|
||||
l_tags as ic
|
||||
loop
|
||||
s.append ("<span class=%"tag%">")
|
||||
s.append (a_response.html_encoded (ic.item))
|
||||
s.append ("</span> ")
|
||||
a_output.append ("<span class=%"tag%">")
|
||||
a_output.append (cms_api.html_encoded (ic.item))
|
||||
a_output.append ("</span> ")
|
||||
end
|
||||
s.append ("</div>")
|
||||
a_output.append ("</div>")
|
||||
end
|
||||
end
|
||||
a_response.set_main_content (s)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -232,7 +232,7 @@ feature -- HTML Output
|
||||
if attached api.format (n.format) as f then
|
||||
f.append_formatted_to (l_summary, a_output)
|
||||
else
|
||||
page.formats.default_format.append_formatted_to (l_summary, a_output)
|
||||
api.formats.default_format.append_formatted_to (l_summary, a_output)
|
||||
end
|
||||
a_output.append ("<br />")
|
||||
a_output.append (page.link ("See more...", lnk.location, Void))
|
||||
|
||||
@@ -12,7 +12,7 @@ inherit
|
||||
module_api as feed_aggregator_api
|
||||
redefine
|
||||
initialize,
|
||||
register_hooks,
|
||||
setup_hooks,
|
||||
permissions,
|
||||
feed_aggregator_api
|
||||
end
|
||||
@@ -181,13 +181,13 @@ feature -- Handle
|
||||
|
||||
feature -- Hooks configuration
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- Module hooks configuration.
|
||||
do
|
||||
a_response.hooks.subscribe_to_block_hook (Current)
|
||||
a_response.hooks.subscribe_to_response_alter_hook (Current)
|
||||
a_response.hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_response.hooks.subscribe_to_cache_hook (Current)
|
||||
a_hooks.subscribe_to_block_hook (Current)
|
||||
a_hooks.subscribe_to_response_alter_hook (Current)
|
||||
a_hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_hooks.subscribe_to_cache_hook (Current)
|
||||
end
|
||||
|
||||
feature -- Hook
|
||||
|
||||
@@ -41,7 +41,6 @@ feature {NONE} -- Initialization
|
||||
ct: CMS_PAGE_NODE_TYPE
|
||||
do
|
||||
-- Initialize node content types.
|
||||
create content_type_webform_managers.make (1)
|
||||
create ct
|
||||
--| For now, add all available formats to content type `ct'.
|
||||
across
|
||||
@@ -50,7 +49,7 @@ feature {NONE} -- Initialization
|
||||
ct.extend_format (ic.item)
|
||||
end
|
||||
add_node_type (ct)
|
||||
add_content_type_webform_manager (create {CMS_PAGE_NODE_TYPE_WEBFORM_MANAGER}.make (ct))
|
||||
add_node_type_webform_manager (create {CMS_PAGE_NODE_TYPE_WEBFORM_MANAGER}.make (ct, Current))
|
||||
end
|
||||
|
||||
feature {CMS_MODULE} -- Access nodes storage.
|
||||
@@ -106,31 +105,16 @@ feature -- Content type
|
||||
|
||||
feature -- Content type webform
|
||||
|
||||
content_type_webform_managers: ARRAYED_LIST [CMS_CONTENT_TYPE_WEBFORM_MANAGER]
|
||||
content_type_webform_managers: ARRAYED_LIST [CMS_CONTENT_TYPE_WEBFORM_MANAGER [CMS_CONTENT]]
|
||||
-- Available content types
|
||||
|
||||
add_content_type_webform_manager (a_manager: CMS_CONTENT_TYPE_WEBFORM_MANAGER)
|
||||
-- Register webform manager `a_manager'.
|
||||
do
|
||||
content_type_webform_managers.force (a_manager)
|
||||
Result := cms_api.content_type_webform_managers
|
||||
end
|
||||
|
||||
content_type_webform_manager (a_content_type: CMS_CONTENT_TYPE): detachable CMS_CONTENT_TYPE_WEBFORM_MANAGER
|
||||
-- Web form manager for content type `a_content_type' if any.
|
||||
local
|
||||
l_type_name: READABLE_STRING_GENERAL
|
||||
add_node_type_webform_manager (a_manager: CMS_NODE_TYPE_WEBFORM_MANAGER [CMS_NODE])
|
||||
-- Register webform manager `a_manager'.
|
||||
do
|
||||
l_type_name := a_content_type.name
|
||||
across
|
||||
content_type_webform_managers as ic
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
Result := ic.item
|
||||
if not l_type_name.is_case_insensitive_equal (Result.name) then
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
cms_api.add_content_type_webform_manager (a_manager)
|
||||
end
|
||||
|
||||
node_type_webform_manager (a_node_type: CMS_CONTENT_TYPE): detachable CMS_NODE_TYPE_WEBFORM_MANAGER_I [CMS_NODE]
|
||||
|
||||
@@ -9,7 +9,7 @@ class
|
||||
inherit
|
||||
CMS_MODULE
|
||||
redefine
|
||||
register_hooks,
|
||||
setup_hooks,
|
||||
initialize,
|
||||
is_installed,
|
||||
install,
|
||||
@@ -25,6 +25,8 @@ inherit
|
||||
|
||||
CMS_RECENT_CHANGES_HOOK
|
||||
|
||||
CMS_TAXONOMY_HOOK
|
||||
|
||||
CMS_HOOK_EXPORT
|
||||
|
||||
CMS_EXPORT_NODE_UTILITIES
|
||||
@@ -234,16 +236,17 @@ feature -- Access: router
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- <Precursor>
|
||||
do
|
||||
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)
|
||||
a_response.hooks.subscribe_to_export_hook (Current)
|
||||
a_hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_hooks.subscribe_to_block_hook (Current)
|
||||
a_hooks.subscribe_to_response_alter_hook (Current)
|
||||
a_hooks.subscribe_to_export_hook (Current)
|
||||
|
||||
-- Module specific hook, if available.
|
||||
a_response.hooks.subscribe_to_hook (Current, {CMS_RECENT_CHANGES_HOOK})
|
||||
a_hooks.subscribe_to_hook (Current, {CMS_RECENT_CHANGES_HOOK})
|
||||
a_hooks.subscribe_to_hook (Current, {CMS_TAXONOMY_HOOK})
|
||||
end
|
||||
|
||||
response_alter (a_response: CMS_RESPONSE)
|
||||
@@ -364,6 +367,51 @@ feature -- Hooks
|
||||
end
|
||||
end
|
||||
|
||||
populate_content_associated_with_term (t: CMS_TERM; a_contents: CMS_TAXONOMY_ENTITY_CONTAINER)
|
||||
local
|
||||
l_node_typenames: ARRAYED_LIST [READABLE_STRING_8]
|
||||
nid: INTEGER_64
|
||||
l_info_to_remove: ARRAYED_LIST [TUPLE [entity: READABLE_STRING_32; typename: detachable READABLE_STRING_32]]
|
||||
do
|
||||
if
|
||||
attached node_api as l_node_api and then
|
||||
attached l_node_api.node_types as l_node_types and then
|
||||
not l_node_types.is_empty
|
||||
then
|
||||
create l_node_typenames.make (l_node_types.count)
|
||||
across
|
||||
l_node_types as ic
|
||||
loop
|
||||
l_node_typenames.force (ic.item.name)
|
||||
end
|
||||
create l_info_to_remove.make (0)
|
||||
across
|
||||
a_contents.taxonomy_info as ic
|
||||
loop
|
||||
if
|
||||
attached ic.item.typename as l_typename and then
|
||||
across l_node_typenames as t_ic some t_ic.item.same_string (l_typename) end
|
||||
then
|
||||
if ic.item.entity.is_integer then
|
||||
nid := ic.item.entity.to_integer_64
|
||||
if nid > 0 and then attached l_node_api.node (nid) as l_node then
|
||||
if l_node.link = Void then
|
||||
l_node.set_link (l_node_api.node_link (l_node))
|
||||
end
|
||||
a_contents.force (create {CMS_TAXONOMY_ENTITY}.make (l_node, l_node.modification_date))
|
||||
l_info_to_remove.force (ic.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
across
|
||||
l_info_to_remove as ic
|
||||
loop
|
||||
a_contents.taxonomy_info.prune_all (ic.item)
|
||||
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.
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Html builder for content type `content_type'.
|
||||
This is used to build webform and html output for a specific node, or node content type.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_CONTENT_TYPE_WEBFORM_MANAGER
|
||||
|
||||
inherit
|
||||
CMS_API_ACCESS
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_type: like content_type)
|
||||
do
|
||||
content_type := a_type
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
content_type: CMS_CONTENT_TYPE
|
||||
-- Associated content type.
|
||||
|
||||
name: READABLE_STRING_8
|
||||
-- Associated content type name.
|
||||
do
|
||||
Result := content_type.name
|
||||
end
|
||||
|
||||
end
|
||||
@@ -100,6 +100,7 @@ feature -- Forms ...
|
||||
populate_form_with_taxonomy (response: NODE_RESPONSE; f: CMS_FORM; a_node: detachable CMS_NODE)
|
||||
local
|
||||
ti: detachable WSF_FORM_TEXT_INPUT
|
||||
th: WSF_FORM_HIDDEN_INPUT
|
||||
w_set: WSF_FORM_FIELD_SET
|
||||
w_select: WSF_FORM_SELECT
|
||||
w_opt: WSF_FORM_SELECT_OPTION
|
||||
@@ -126,6 +127,9 @@ feature -- Forms ...
|
||||
l_vocs as vocs_ic
|
||||
loop
|
||||
voc := vocs_ic.item
|
||||
create th.make_with_text ({STRING_32} "taxonomy_vocabularies[" + voc.id.out + "]", voc.name)
|
||||
w_set.extend (th)
|
||||
|
||||
l_terms := Void
|
||||
if a_node /= Void and then a_node.has_id then
|
||||
l_terms := l_taxonomy_api.terms_of_entity (a_node.content_type, a_node.id.out, voc)
|
||||
@@ -139,7 +143,7 @@ feature -- Forms ...
|
||||
if voc.is_tags then
|
||||
w_voc_set.set_legend (response.translation (voc.name, Void))
|
||||
|
||||
create ti.make ({STRING_32} "taxonomy_terms[" + voc.name + "]")
|
||||
create ti.make ({STRING_32} "taxonomy_" + voc.id.out)
|
||||
w_voc_set.extend (ti)
|
||||
if voc.is_term_required then
|
||||
ti.enable_required
|
||||
@@ -186,7 +190,8 @@ feature -- Forms ...
|
||||
voc as voc_terms_ic
|
||||
loop
|
||||
t := voc_terms_ic.item
|
||||
create w_cb.make_with_value ({STRING_32} "taxonomy_terms[" + voc.name + "]", t.text)
|
||||
create w_cb.make_with_value ({STRING_32} "taxonomy_" + voc.id.out + "[]", t.text)
|
||||
w_cb.set_title (t.text)
|
||||
w_voc_set.extend (w_cb)
|
||||
if l_terms /= Void and then across l_terms as ic some ic.item.text.same_string (t.text) end then
|
||||
w_cb.set_checked (True)
|
||||
@@ -196,7 +201,7 @@ feature -- Forms ...
|
||||
end
|
||||
end
|
||||
else
|
||||
create w_select.make ({STRING_32} "taxonomy_terms[" + voc.name + "]")
|
||||
create w_select.make ({STRING_32} "taxonomy_" + voc.id.out)
|
||||
w_voc_set.extend (w_select)
|
||||
|
||||
if attached voc.description as l_desc then
|
||||
@@ -248,68 +253,81 @@ feature -- Forms ...
|
||||
l_text: READABLE_STRING_GENERAL
|
||||
l_found: BOOLEAN
|
||||
t: detachable CMS_TERM
|
||||
vid: INTEGER_64
|
||||
do
|
||||
if
|
||||
a_node /= Void and then a_node.has_id and then
|
||||
attached fd.table_item ("taxonomy_terms") as fd_terms
|
||||
attached fd.table_item ("taxonomy_vocabularies") as fd_vocs
|
||||
then
|
||||
across
|
||||
fd_terms.values as ic
|
||||
loop
|
||||
if attached {WSF_STRING} ic.item as l_string then
|
||||
l_voc_name := ic.key
|
||||
l_new_terms := a_taxonomy_api.splitted_string (l_string.value, ',')
|
||||
if attached a_vocs.item_by_name (l_voc_name) as voc then
|
||||
if a_response.has_permissions (<<{STRING_32} "update any taxonomy", {STRING_32} "update " + content_type.name + " taxonomy">>) then
|
||||
create l_terms_to_remove.make (0)
|
||||
if attached a_taxonomy_api.terms_of_entity (content_type.name, a_node.id.out, voc) as l_existing_terms then
|
||||
across
|
||||
l_existing_terms as t_ic
|
||||
if a_response.has_permissions (<<{STRING_32} "update any taxonomy", {STRING_32} "update " + content_type.name + " taxonomy">>) then
|
||||
across
|
||||
fd_vocs.values as ic
|
||||
loop
|
||||
vid := ic.key.to_integer_64
|
||||
l_voc_name := ic.item.string_representation
|
||||
|
||||
if attached a_vocs.item_by_id (vid) as voc then
|
||||
if attached fd.string_item ("taxonomy_" + vid.out) as l_string then
|
||||
l_new_terms := a_taxonomy_api.splitted_string (l_string, ',')
|
||||
elseif attached fd.table_item ("taxonomy_" + vid.out) as fd_terms then
|
||||
create {ARRAYED_LIST [READABLE_STRING_32]} l_new_terms.make (fd_terms.count)
|
||||
across
|
||||
fd_terms as t_ic
|
||||
loop
|
||||
l_new_terms.force (t_ic.item.string_representation)
|
||||
end
|
||||
else
|
||||
create {ARRAYED_LIST [READABLE_STRING_32]} l_new_terms.make (0)
|
||||
end
|
||||
|
||||
create l_terms_to_remove.make (0)
|
||||
if attached a_taxonomy_api.terms_of_entity (content_type.name, a_node.id.out, voc) as l_existing_terms then
|
||||
across
|
||||
l_existing_terms as t_ic
|
||||
loop
|
||||
l_text := t_ic.item.text
|
||||
from
|
||||
l_found := False
|
||||
l_new_terms.start
|
||||
until
|
||||
l_new_terms.after
|
||||
loop
|
||||
l_text := t_ic.item.text
|
||||
from
|
||||
l_found := False
|
||||
l_new_terms.start
|
||||
until
|
||||
l_new_terms.after
|
||||
loop
|
||||
if l_new_terms.item.same_string_general (l_text) then
|
||||
-- Already associated with term `t_ic.text'.
|
||||
l_found := True
|
||||
l_new_terms.remove
|
||||
else
|
||||
l_new_terms.forth
|
||||
end
|
||||
end
|
||||
if not l_found then
|
||||
-- Remove term
|
||||
l_terms_to_remove.force (t_ic.item)
|
||||
if l_new_terms.item.same_string_general (l_text) then
|
||||
-- Already associated with term `t_ic.text'.
|
||||
l_found := True
|
||||
l_new_terms.remove
|
||||
else
|
||||
l_new_terms.forth
|
||||
end
|
||||
end
|
||||
across
|
||||
l_terms_to_remove as t_ic
|
||||
loop
|
||||
a_taxonomy_api.unassociate_term_from_entity (t_ic.item, content_type.name, a_node.id.out)
|
||||
if not l_found then
|
||||
-- Remove term
|
||||
l_terms_to_remove.force (t_ic.item)
|
||||
end
|
||||
end
|
||||
across
|
||||
l_new_terms as t_ic
|
||||
l_terms_to_remove as t_ic
|
||||
loop
|
||||
t := a_taxonomy_api.term_by_text (t_ic.item, voc)
|
||||
if
|
||||
t = Void and voc.is_tags
|
||||
then
|
||||
-- Create new term!
|
||||
create t.make (t_ic.item)
|
||||
a_taxonomy_api.save_term (t, voc)
|
||||
if a_taxonomy_api.has_error then
|
||||
t := Void
|
||||
end
|
||||
end
|
||||
if t /= Void then
|
||||
a_taxonomy_api.associate_term_with_entity (t, content_type.name, a_node.id.out)
|
||||
a_taxonomy_api.unassociate_term_from_entity (t_ic.item, content_type.name, a_node.id.out)
|
||||
end
|
||||
end
|
||||
across
|
||||
l_new_terms as t_ic
|
||||
loop
|
||||
t := a_taxonomy_api.term_by_text (t_ic.item, voc)
|
||||
if
|
||||
t = Void and voc.is_tags
|
||||
then
|
||||
-- Create new term!
|
||||
create t.make (t_ic.item)
|
||||
a_taxonomy_api.save_term (t, voc)
|
||||
if a_taxonomy_api.has_error then
|
||||
t := Void
|
||||
end
|
||||
end
|
||||
if t /= Void then
|
||||
a_taxonomy_api.associate_term_with_entity (t, content_type.name, a_node.id.out)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -400,7 +418,7 @@ feature -- Forms ...
|
||||
elseif a_node /= Void and then attached a_node.format as s_format and then attached response.api.format (s_format) as f_format then
|
||||
f := f_format
|
||||
else
|
||||
f := response.formats.default_format
|
||||
f := cms_api.formats.default_format
|
||||
end
|
||||
|
||||
-- Update node with summary and body content
|
||||
@@ -464,7 +482,7 @@ feature -- Forms ...
|
||||
elseif a_node /= Void and then attached a_node.format as s_format and then attached response.api.format (s_format) as f_format then
|
||||
f := f_format
|
||||
else
|
||||
f := response.formats.default_format
|
||||
f := cms_api.formats.default_format
|
||||
end
|
||||
|
||||
-- Update node with summary and content
|
||||
@@ -476,69 +494,78 @@ feature -- Forms ...
|
||||
|
||||
feature -- Output
|
||||
|
||||
append_html_output_to (a_node: CMS_NODE; a_response: NODE_RESPONSE)
|
||||
append_content_as_html_to (a_node: G; is_teaser: BOOLEAN; a_output: STRING; a_response: detachable CMS_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
lnk: CMS_LOCAL_LINK
|
||||
lnk: detachable CMS_LOCAL_LINK
|
||||
hdate: HTTP_DATE
|
||||
s: STRING
|
||||
node_api: CMS_NODE_API
|
||||
l_node_api: CMS_NODE_API
|
||||
do
|
||||
node_api := a_response.node_api
|
||||
|
||||
a_response.set_value (a_node, "node")
|
||||
l_node_api := node_api
|
||||
|
||||
-- Show tabs only if a user is authenticated.
|
||||
if attached a_response.user as l_user then
|
||||
lnk := a_response.node_local_link (a_node, a_response.translation ("View", Void))
|
||||
if
|
||||
not is_teaser and then
|
||||
a_response /= Void and then
|
||||
attached a_response.user as l_user
|
||||
then
|
||||
lnk := a_node.link
|
||||
if lnk /= Void then
|
||||
lnk := a_response.local_link (a_response.translation ("View", Void), lnk.location)
|
||||
else
|
||||
lnk := a_response.local_link (a_response.translation ("View", Void), l_node_api.node_path (a_node))
|
||||
end
|
||||
lnk.set_weight (1)
|
||||
a_response.add_to_primary_tabs (lnk)
|
||||
|
||||
|
||||
if a_node.status = {CMS_NODE_API}.trashed then
|
||||
create lnk.make ("Delete", node_api.node_path (a_node) + "/delete")
|
||||
create lnk.make ("Delete", l_node_api.node_path (a_node) + "/delete")
|
||||
lnk.set_weight (2)
|
||||
a_response.add_to_primary_tabs (lnk)
|
||||
elseif a_node.has_id then
|
||||
-- Node in {{CMS_NODE_API}.published} or {CMS_NODE_API}.not_published} status.
|
||||
create lnk.make ("Edit", node_api.node_path (a_node) + "/edit")
|
||||
create lnk.make ("Edit", l_node_api.node_path (a_node) + "/edit")
|
||||
lnk.set_weight (2)
|
||||
a_response.add_to_primary_tabs (lnk)
|
||||
if
|
||||
node_api.has_permission_for_action_on_node ("view revisions", a_node, l_user)
|
||||
l_node_api.has_permission_for_action_on_node ("view revisions", a_node, l_user)
|
||||
then
|
||||
create lnk.make ("Revisions", node_api.node_path (a_node) + "/revision")
|
||||
create lnk.make ("Revisions", l_node_api.node_path (a_node) + "/revision")
|
||||
lnk.set_weight (3)
|
||||
a_response.add_to_primary_tabs (lnk)
|
||||
end
|
||||
|
||||
if
|
||||
node_api.has_permission_for_action_on_node ("trash", a_node, l_user)
|
||||
l_node_api.has_permission_for_action_on_node ("trash", a_node, l_user)
|
||||
then
|
||||
create lnk.make ("Move to trash", node_api.node_path (a_node) + "/trash")
|
||||
create lnk.make ("Move to trash", l_node_api.node_path (a_node) + "/trash")
|
||||
lnk.set_weight (3)
|
||||
a_response.add_to_primary_tabs (lnk)
|
||||
end
|
||||
end
|
||||
end
|
||||
create s.make_empty
|
||||
s.append ("<div class=%"cms-node node-" + a_node.content_type + "%">")
|
||||
s.append ("<div class=%"info%"> ")
|
||||
a_output.append ("<div class=%"")
|
||||
if is_teaser then
|
||||
a_output.append (" cms-teaser")
|
||||
end
|
||||
a_output.append ("cms-node node-" + a_node.content_type + "%">")
|
||||
|
||||
a_output.append ("<div class=%"info%"> ")
|
||||
if attached a_node.author as l_author then
|
||||
s.append (" by ")
|
||||
s.append (a_response.html_encoded (l_author.name))
|
||||
a_output.append (" by ")
|
||||
a_output.append (l_node_api.html_encoded (l_author.name))
|
||||
end
|
||||
if attached a_node.modification_date as l_modified then
|
||||
s.append (" (modified: ")
|
||||
a_output.append (" (modified: ")
|
||||
create hdate.make_from_date_time (l_modified)
|
||||
s.append (hdate.yyyy_mmm_dd_string)
|
||||
s.append (")")
|
||||
a_output.append (hdate.yyyy_mmm_dd_string)
|
||||
a_output.append (")")
|
||||
end
|
||||
s.append ("</div>")
|
||||
|
||||
a_output.append ("</div>")
|
||||
|
||||
if
|
||||
attached {CMS_TAXONOMY_API} a_response.api.module_api ({CMS_TAXONOMY_MODULE}) as l_taxonomy_api and then
|
||||
a_response /= Void and then
|
||||
attached {CMS_TAXONOMY_API} cms_api.module_api ({CMS_TAXONOMY_MODULE}) as l_taxonomy_api and then
|
||||
attached l_taxonomy_api.vocabularies_for_type (content_type.name) as vocs and then not vocs.is_empty
|
||||
then
|
||||
vocs.sort
|
||||
@@ -549,60 +576,43 @@ feature -- Output
|
||||
attached l_taxonomy_api.terms_of_entity (content_type.name, a_node.id.out, ic.item) as l_terms and then
|
||||
not l_terms.is_empty
|
||||
then
|
||||
s.append ("<ul class=%"taxonomy term-" + ic.item.id.out + "%">")
|
||||
s.append (a_response.html_encoded (ic.item.name))
|
||||
s.append (": ")
|
||||
a_output.append ("<ul class=%"taxonomy term-" + ic.item.id.out + "%">")
|
||||
a_output.append (l_node_api.html_encoded (ic.item.name))
|
||||
a_output.append (": ")
|
||||
across
|
||||
l_terms as t_ic
|
||||
loop
|
||||
s.append ("<li>")
|
||||
a_response.append_link_to_html (t_ic.item.text, "taxonomy/term/" + t_ic.item.id.out, Void, s)
|
||||
s.append ("</li>")
|
||||
a_output.append ("<li>")
|
||||
a_response.append_link_to_html (t_ic.item.text, "taxonomy/term/" + t_ic.item.id.out, Void, a_output)
|
||||
a_output.append ("</li>")
|
||||
end
|
||||
s.append ("</ul>%N")
|
||||
a_output.append ("</ul>%N")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- We don't show the summary on the detail page, since its just a short view of the full content. Otherwise we would write the same thing twice.
|
||||
-- The usage of the summary is to give a short overview in the list of nodes or for the meta tag "description"
|
||||
|
||||
-- if attached a_node.summary as l_summary then
|
||||
-- s.append ("<p class=%"summary%">")
|
||||
-- if attached node_api.cms_api.format (a_node.format) as f then
|
||||
-- append_formatted_output (l_content, f, s)
|
||||
-- else
|
||||
-- append_formatted_output (l_content, a_response.formats.default_format, s)
|
||||
-- end
|
||||
|
||||
-- s.append ("</p>")
|
||||
|
||||
-- end
|
||||
|
||||
if attached a_node.content as l_content then
|
||||
s.append ("<p class=%"content%">")
|
||||
if attached node_api.cms_api.format (a_node.format) as f then
|
||||
append_formatted_output (l_content, f, s)
|
||||
else
|
||||
append_formatted_output (l_content, a_response.formats.default_format, s)
|
||||
if is_teaser then
|
||||
if attached a_node.summary as l_summary then
|
||||
a_output.append ("<p class=%"summary%">")
|
||||
if attached cms_api.format (a_node.format) as f then
|
||||
append_formatted_content_to (l_summary, f, a_output)
|
||||
else
|
||||
append_formatted_content_to (l_summary, cms_api.formats.default_format, a_output)
|
||||
end
|
||||
a_output.append ("</p>")
|
||||
end
|
||||
|
||||
s.append ("</p>")
|
||||
end
|
||||
s.append ("</div>")
|
||||
|
||||
a_response.set_title (a_node.title)
|
||||
a_response.set_main_content (s)
|
||||
end
|
||||
|
||||
append_formatted_output (a_content: READABLE_STRING_GENERAL; a_format: CONTENT_FORMAT; a_output: STRING_8)
|
||||
-- Format `a_content' with format `a_format'.
|
||||
do
|
||||
if a_content.is_valid_as_string_8 then
|
||||
a_output.append (a_format.formatted_output (a_content.to_string_8))
|
||||
else
|
||||
a_format.append_formatted_to (a_content, a_output)
|
||||
elseif attached a_node.content as l_content then
|
||||
a_output.append ("<p class=%"content%">")
|
||||
if attached cms_api.format (a_node.format) as f then
|
||||
append_formatted_content_to (l_content, f, a_output)
|
||||
else
|
||||
append_formatted_content_to (l_content, cms_api.formats.default_format, a_output)
|
||||
end
|
||||
a_output.append ("</p>")
|
||||
end
|
||||
a_output.append ("</div>")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -10,16 +10,35 @@ deferred class
|
||||
CMS_NODE_TYPE_WEBFORM_MANAGER_I [G -> CMS_NODE]
|
||||
|
||||
inherit
|
||||
CMS_CONTENT_TYPE_WEBFORM_MANAGER
|
||||
CMS_CONTENT_TYPE_WEBFORM_MANAGER [CMS_NODE]
|
||||
rename
|
||||
make as old_make
|
||||
redefine
|
||||
content_type
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_type: like content_type; a_node_api: CMS_NODE_API)
|
||||
do
|
||||
node_api := a_node_api
|
||||
old_make (a_type)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
content_type: CMS_NODE_TYPE [G]
|
||||
-- Associated content type.
|
||||
|
||||
cms_api: CMS_API
|
||||
-- API for current instance of CMS.
|
||||
do
|
||||
Result := node_api.cms_api
|
||||
end
|
||||
|
||||
node_api: CMS_NODE_API
|
||||
-- Associated node API.
|
||||
|
||||
feature -- Query
|
||||
|
||||
has_valid_node_type (a_node: CMS_NODE): BOOLEAN
|
||||
@@ -57,11 +76,18 @@ feature -- Node ...
|
||||
|
||||
feature -- Output
|
||||
|
||||
append_html_output_to (a_node: CMS_NODE; a_response: NODE_RESPONSE)
|
||||
append_content_as_html_to_page (a_node: G; a_response: NODE_RESPONSE)
|
||||
-- Append an html representation of `a_node' to response `a_response'.
|
||||
require
|
||||
has_valid_node_type (a_node)
|
||||
deferred
|
||||
local
|
||||
s: STRING
|
||||
do
|
||||
create s.make_empty
|
||||
a_response.set_value (a_node, "node")
|
||||
a_response.set_title (a_node.title)
|
||||
append_content_as_html_to (a_node, False, s, a_response)
|
||||
a_response.set_main_content (s)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ inherit
|
||||
CMS_NODE_TYPE_WEBFORM_MANAGER [CMS_PAGE]
|
||||
redefine
|
||||
content_type,
|
||||
append_html_output_to,
|
||||
append_content_as_html_to,
|
||||
populate_form,
|
||||
new_node,
|
||||
update_node
|
||||
@@ -102,27 +102,27 @@ feature -- Forms ...
|
||||
|
||||
parent_validation (a_response: NODE_RESPONSE; fd: WSF_FORM_DATA)
|
||||
local
|
||||
node_api: CMS_NODE_API
|
||||
l_node_api: CMS_NODE_API
|
||||
l_parent_id: INTEGER_64
|
||||
nid: INTEGER_64
|
||||
l_parent_node: detachable CMS_NODE
|
||||
do
|
||||
node_api := a_response.node_api
|
||||
l_node_api := node_api
|
||||
if attached fd.integer_item ("select_parent_node") as s_parent_node then
|
||||
l_parent_id := s_parent_node.to_integer_64
|
||||
else
|
||||
l_parent_id := 0
|
||||
end
|
||||
if l_parent_id > 0 then
|
||||
l_parent_node := node_api.node (l_parent_id)
|
||||
l_parent_node := l_node_api.node (l_parent_id)
|
||||
if l_parent_node = Void then
|
||||
fd.report_invalid_field ("select_parent_node", "Invalid parent, not found id #" + l_parent_id.out)
|
||||
else
|
||||
nid := a_response.node_id_path_parameter
|
||||
if
|
||||
nid > 0 and then
|
||||
attached node_api.node (nid) as l_node and then
|
||||
node_api.is_node_a_parent_of (l_node, l_parent_node)
|
||||
attached l_node_api.node (nid) as l_node and then
|
||||
l_node_api.is_node_a_parent_of (l_node, l_parent_node)
|
||||
then
|
||||
fd.report_invalid_field ("select_parent_node", "Invalid parent due to cycle (node #" + nid.out + " is already a parent of node #" + l_parent_id.out)
|
||||
end
|
||||
@@ -137,50 +137,51 @@ feature -- Forms ...
|
||||
|
||||
feature -- Output
|
||||
|
||||
append_html_output_to (a_node: CMS_NODE; a_response: NODE_RESPONSE)
|
||||
append_content_as_html_to (a_node: CMS_PAGE; is_teaser: BOOLEAN; a_output: STRING; a_response: detachable CMS_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
s: STRING
|
||||
node_api: CMS_NODE_API
|
||||
l_node_api: CMS_NODE_API
|
||||
lnk: CMS_LOCAL_LINK
|
||||
do
|
||||
node_api := a_response.node_api
|
||||
Precursor (a_node, a_response)
|
||||
|
||||
if a_node.has_id and then not a_node.is_trashed then
|
||||
if node_api.has_permission_for_action_on_node ("create", a_node, a_response.user) then
|
||||
create lnk.make ("Add Child", "node/add/page?parent=" + a_node.id.out)
|
||||
lnk.set_weight (3)
|
||||
a_response.add_to_primary_tabs (lnk)
|
||||
end
|
||||
end
|
||||
|
||||
if attached a_response.main_content as l_main_content then
|
||||
s := l_main_content
|
||||
else
|
||||
create s.make_empty
|
||||
end
|
||||
|
||||
if attached {CMS_PAGE} a_node as l_node_page then
|
||||
s.append ("<ul class=%"page-navigation%">")
|
||||
if attached l_node_page.parent as l_parent_node then
|
||||
s.append ("<li class=%"page-parent%">Go to parent page ")
|
||||
s.append (a_response.link (l_parent_node.title, a_response.node_api.node_path (l_parent_node), Void))
|
||||
s.append ("</li>")
|
||||
end
|
||||
if attached node_api.children (a_node) as l_children then
|
||||
across
|
||||
l_children as ic
|
||||
loop
|
||||
s.append ("<li>")
|
||||
s.append (a_response.link (ic.item.title, a_response.node_api.node_path (ic.item), Void))
|
||||
s.append ("</li>")
|
||||
Precursor (a_node, is_teaser, a_output, a_response)
|
||||
|
||||
if not is_teaser then
|
||||
l_node_api := node_api
|
||||
if
|
||||
a_response /= Void and then
|
||||
a_node.has_id and then not a_node.is_trashed
|
||||
then
|
||||
if
|
||||
l_node_api.has_permission_for_action_on_node ("create", a_node, a_response.user)
|
||||
then
|
||||
create lnk.make ("Add Child", "node/add/page?parent=" + a_node.id.out)
|
||||
lnk.set_weight (3)
|
||||
a_response.add_to_primary_tabs (lnk)
|
||||
end
|
||||
end
|
||||
s.append ("</ul>")
|
||||
end
|
||||
|
||||
a_response.set_main_content (s)
|
||||
if
|
||||
a_response /= Void and then
|
||||
attached {CMS_PAGE} a_node as l_node_page
|
||||
then
|
||||
a_output.append ("<ul class=%"page-navigation%">")
|
||||
if attached l_node_page.parent as l_parent_node then
|
||||
a_output.append ("<li class=%"page-parent%">Go to parent page ")
|
||||
a_output.append (a_response.link (l_parent_node.title, l_node_api.node_path (l_parent_node), Void))
|
||||
a_output.append ("</li>")
|
||||
end
|
||||
if attached l_node_api.children (a_node) as l_children then
|
||||
across
|
||||
l_children as ic
|
||||
loop
|
||||
a_output.append ("<li>")
|
||||
a_output.append (a_response.link (ic.item.title, l_node_api.node_path (ic.item), Void))
|
||||
a_output.append ("</li>")
|
||||
end
|
||||
end
|
||||
a_output.append ("</ul>")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -7,30 +7,10 @@ class
|
||||
|
||||
inherit
|
||||
NODE_RESPONSE
|
||||
redefine
|
||||
make,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: like api; a_node_api: like node_api)
|
||||
do
|
||||
create {WSF_NULL_THEME} wsf_theme.make
|
||||
Precursor (req, res, a_api, a_node_api)
|
||||
end
|
||||
|
||||
initialize
|
||||
do
|
||||
Precursor
|
||||
create {CMS_TO_WSF_THEME} wsf_theme.make (Current, theme)
|
||||
end
|
||||
|
||||
wsf_theme: WSF_THEME
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
@@ -114,7 +94,7 @@ feature {NONE} -- Create a new node
|
||||
if attached a_type.new_node (Void) as l_node then
|
||||
-- create new node
|
||||
f := new_edit_form (l_node, url (location, Void), "edit-" + a_type.name, a_type)
|
||||
hooks.invoke_form_alter (f, fd, Current)
|
||||
api.hooks.invoke_form_alter (f, fd, Current)
|
||||
if request.is_post_request_method then
|
||||
f.validation_actions.extend (agent edit_form_validate (?, b))
|
||||
f.submit_actions.put_front (agent edit_form_submit (?, l_node, a_type, b))
|
||||
@@ -144,7 +124,7 @@ feature {NONE} -- Create a new node
|
||||
fd: detachable WSF_FORM_DATA
|
||||
do
|
||||
f := new_edit_form (A_node, url (location, Void), "edit-" + a_type.name, a_type)
|
||||
hooks.invoke_form_alter (f, fd, Current)
|
||||
api.hooks.invoke_form_alter (f, fd, Current)
|
||||
if request.is_post_request_method then
|
||||
f.validation_actions.extend (agent edit_form_validate (?, b))
|
||||
f.submit_actions.put_front (agent edit_form_submit (?, a_node, a_type, b))
|
||||
@@ -175,7 +155,7 @@ feature {NONE} -- Create a new node
|
||||
do
|
||||
if a_node.is_trashed then
|
||||
f := new_delete_form (a_node, url (location, Void), "delete-" + a_type.name, a_type)
|
||||
hooks.invoke_form_alter (f, fd, Current)
|
||||
api.hooks.invoke_form_alter (f, fd, Current)
|
||||
if request.is_post_request_method then
|
||||
f.process (Current)
|
||||
fd := f.last_data
|
||||
@@ -206,7 +186,7 @@ feature {NONE} -- Create a new node
|
||||
fd: detachable WSF_FORM_DATA
|
||||
do
|
||||
f := new_trash_form (a_node, url (location, Void), "trash-" + a_type.name, a_type)
|
||||
hooks.invoke_form_alter (f, fd, Current)
|
||||
api.hooks.invoke_form_alter (f, fd, Current)
|
||||
if request.is_post_request_method then
|
||||
f.process (Current)
|
||||
fd := f.last_data
|
||||
|
||||
@@ -42,15 +42,6 @@ feature -- Helpers
|
||||
|
||||
feature -- Helpers: cms link
|
||||
|
||||
user_local_link (u: CMS_USER; a_opt_title: detachable READABLE_STRING_GENERAL): CMS_LOCAL_LINK
|
||||
do
|
||||
if a_opt_title /= Void then
|
||||
create Result.make (a_opt_title, user_url (u))
|
||||
else
|
||||
create Result.make (u.name, user_url (u))
|
||||
end
|
||||
end
|
||||
|
||||
node_local_link (n: CMS_NODE; a_opt_title: detachable READABLE_STRING_GENERAL): CMS_LOCAL_LINK
|
||||
do
|
||||
if attached n.link as lnk then
|
||||
@@ -59,17 +50,12 @@ feature -- Helpers: cms link
|
||||
Result := node_api.node_link (n)
|
||||
end
|
||||
if a_opt_title /= Void and then not Result.title.same_string_general (a_opt_title) then
|
||||
create Result.make (a_opt_title, Result.location)
|
||||
Result := local_link (a_opt_title, Result.location)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Helpers: html link
|
||||
|
||||
user_html_link (u: CMS_USER): like link
|
||||
do
|
||||
Result := link (u.name, "user/" + u.id.out, Void)
|
||||
end
|
||||
|
||||
node_html_link (n: CMS_NODE; a_opt_title: detachable READABLE_STRING_GENERAL): like link
|
||||
local
|
||||
l_title: detachable READABLE_STRING_GENERAL
|
||||
@@ -80,18 +66,10 @@ feature -- Helpers: html link
|
||||
l_title := n.title
|
||||
end
|
||||
Result := link (l_title, node_api.node_path (n), Void)
|
||||
|
||||
end
|
||||
|
||||
feature -- Helpers: URL
|
||||
|
||||
user_url (u: CMS_USER): like url
|
||||
require
|
||||
u_with_id: u.has_id
|
||||
do
|
||||
Result := url ("user/" + u.id.out, Void)
|
||||
end
|
||||
|
||||
node_url (n: CMS_NODE): like url
|
||||
require
|
||||
n_with_id: n.has_id
|
||||
|
||||
@@ -8,30 +8,10 @@ class
|
||||
|
||||
inherit
|
||||
NODE_RESPONSE
|
||||
redefine
|
||||
make,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: like api; a_node_api: like node_api)
|
||||
do
|
||||
create {WSF_NULL_THEME} wsf_theme.make
|
||||
Precursor (req, res, a_api, a_node_api)
|
||||
end
|
||||
|
||||
initialize
|
||||
do
|
||||
Precursor
|
||||
create {CMS_TO_WSF_THEME} wsf_theme.make (Current, theme)
|
||||
end
|
||||
|
||||
wsf_theme: WSF_THEME
|
||||
|
||||
feature -- Access
|
||||
|
||||
node: detachable CMS_NODE
|
||||
@@ -71,7 +51,7 @@ feature -- Execution
|
||||
attached node_api.node_type_for (l_node) as l_content_type and then
|
||||
attached node_api.node_type_webform_manager (l_content_type) as l_manager
|
||||
then
|
||||
l_manager.append_html_output_to (l_node, Current)
|
||||
l_manager.append_content_as_html_to_page (l_node, Current)
|
||||
end
|
||||
elseif revision > 0 then
|
||||
set_main_content ("Missing revision node!")
|
||||
|
||||
@@ -12,7 +12,7 @@ inherit
|
||||
module_api as user_oauth_api
|
||||
redefine
|
||||
filters,
|
||||
register_hooks,
|
||||
setup_hooks,
|
||||
initialize,
|
||||
install,
|
||||
user_oauth_api
|
||||
@@ -190,12 +190,12 @@ feature -- Router
|
||||
|
||||
feature -- Hooks configuration
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- Module hooks configuration.
|
||||
do
|
||||
auto_subscribe_to_hooks (a_response)
|
||||
a_response.hooks.subscribe_to_block_hook (Current)
|
||||
a_response.hooks.subscribe_to_value_table_alter_hook (Current)
|
||||
auto_subscribe_to_hooks (a_hooks)
|
||||
a_hooks.subscribe_to_block_hook (Current)
|
||||
a_hooks.subscribe_to_value_table_alter_hook (Current)
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
@@ -14,7 +14,7 @@ inherit
|
||||
module_api as user_openid_api
|
||||
redefine
|
||||
filters,
|
||||
register_hooks,
|
||||
setup_hooks,
|
||||
initialize,
|
||||
install,
|
||||
user_openid_api
|
||||
@@ -166,12 +166,12 @@ feature -- Router
|
||||
|
||||
feature -- Hooks configuration
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- Module hooks configuration.
|
||||
do
|
||||
auto_subscribe_to_hooks (a_response)
|
||||
a_response.hooks.subscribe_to_block_hook (Current)
|
||||
a_response.hooks.subscribe_to_value_table_alter_hook (Current)
|
||||
auto_subscribe_to_hooks (a_hooks)
|
||||
a_hooks.subscribe_to_block_hook (Current)
|
||||
a_hooks.subscribe_to_value_table_alter_hook (Current)
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
@@ -11,7 +11,7 @@ inherit
|
||||
rename
|
||||
module_api as recent_changes_api
|
||||
redefine
|
||||
register_hooks,
|
||||
setup_hooks,
|
||||
permissions
|
||||
end
|
||||
|
||||
@@ -110,7 +110,7 @@ feature -- Hook
|
||||
do
|
||||
l_user := Void -- Public access for the feed!
|
||||
create l_changes.make (a_size, create {DATE_TIME}.make_now_utc, a_source)
|
||||
if attached a_response.hooks.subscribers ({CMS_RECENT_CHANGES_HOOK}) as lst then
|
||||
if attached a_response.api.hooks.subscribers ({CMS_RECENT_CHANGES_HOOK}) as lst then
|
||||
across
|
||||
lst as ic
|
||||
loop
|
||||
@@ -236,7 +236,7 @@ feature -- Handler
|
||||
create l_changes.make (l_size, l_until_date, l_filter_source)
|
||||
|
||||
create l_content.make (1024)
|
||||
if attached r.hooks.subscribers ({CMS_RECENT_CHANGES_HOOK}) as lst then
|
||||
if attached api.hooks.subscribers ({CMS_RECENT_CHANGES_HOOK}) as lst then
|
||||
create l_sources.make (lst.count)
|
||||
|
||||
across
|
||||
@@ -284,7 +284,7 @@ feature -- Handler
|
||||
create l_submit.make_with_text ("op", "Filter")
|
||||
l_form.extend (l_submit)
|
||||
l_form.extend_html_text ("<br/>")
|
||||
l_form.append_to_html (create {CMS_TO_WSF_THEME}.make (r, r.theme), l_content)
|
||||
l_form.append_to_html (r.wsf_theme, l_content)
|
||||
end
|
||||
|
||||
l_changes.reverse_sort
|
||||
@@ -397,12 +397,12 @@ feature -- Handler
|
||||
|
||||
feature -- Hooks configuration
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- Module hooks configuration.
|
||||
do
|
||||
a_response.hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_response.hooks.subscribe_to_response_alter_hook (Current)
|
||||
a_response.hooks.subscribe_to_block_hook (Current)
|
||||
a_hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_hooks.subscribe_to_response_alter_hook (Current)
|
||||
a_hooks.subscribe_to_block_hook (Current)
|
||||
end
|
||||
|
||||
feature -- Hook
|
||||
|
||||
@@ -52,7 +52,7 @@ feature -- Access node
|
||||
Result := taxonomy_storage.vocabularies (a_limit, a_offset)
|
||||
end
|
||||
|
||||
vocabulary (a_id: INTEGER): detachable CMS_VOCABULARY
|
||||
vocabulary (a_id: INTEGER_64): detachable CMS_VOCABULARY
|
||||
-- Vocabulary associated with id `a_id'.
|
||||
require
|
||||
valid_id: a_id > 0
|
||||
@@ -66,6 +66,27 @@ feature -- Access node
|
||||
Result := taxonomy_storage.vocabularies_for_type (a_type_name)
|
||||
end
|
||||
|
||||
types_associated_with_vocabulary (a_vocab: CMS_VOCABULARY): detachable LIST [READABLE_STRING_32]
|
||||
-- Type names associated with `a_vocab'.
|
||||
do
|
||||
Result := taxonomy_storage.types_associated_with_vocabulary (a_vocab)
|
||||
end
|
||||
|
||||
vocabularies_for_term (a_term: CMS_TERM): detachable CMS_VOCABULARY_COLLECTION
|
||||
-- Vocabularies including `a_term'.
|
||||
do
|
||||
Result := taxonomy_storage.vocabularies_for_term (a_term)
|
||||
end
|
||||
|
||||
is_term_inside_vocabulary (a_term: CMS_TERM; a_vocab: CMS_VOCABULARY): BOOLEAN
|
||||
-- Is `a_term' inside `a_vocab' ?
|
||||
require
|
||||
valid_term: a_term.has_id
|
||||
valid_vocabulary: a_vocab.has_id
|
||||
do
|
||||
Result := taxonomy_storage.is_term_inside_vocabulary (a_term, a_vocab)
|
||||
end
|
||||
|
||||
fill_vocabularies_with_terms (a_vocab: CMS_VOCABULARY)
|
||||
-- Fill `a_vocab' with associated terms.
|
||||
do
|
||||
@@ -114,7 +135,7 @@ feature -- Access node
|
||||
Result := taxonomy_storage.term_by_text (a_term_text, a_vocabulary)
|
||||
end
|
||||
|
||||
entities_associated_with_term (a_term: CMS_TERM): detachable LIST [TUPLE [entity: READABLE_STRING_32; type: detachable READABLE_STRING_32]]
|
||||
entities_associated_with_term (a_term: CMS_TERM): detachable LIST [TUPLE [entity: READABLE_STRING_32; typename: detachable READABLE_STRING_32]]
|
||||
-- Entities and related typename associated with `a_term'.
|
||||
require
|
||||
a_term_exists: a_term.has_id
|
||||
@@ -125,19 +146,39 @@ feature -- Access node
|
||||
feature -- Write
|
||||
|
||||
save_vocabulary (a_voc: CMS_VOCABULARY)
|
||||
-- Insert or update vocabulary `a_voc'
|
||||
-- and also save {CMS_VOCABULARY}.terms if `a_with_terms' is True.
|
||||
do
|
||||
reset_error
|
||||
taxonomy_storage.save_vocabulary (a_voc)
|
||||
taxonomy_storage.save_vocabulary (a_voc, False)
|
||||
error_handler.append (taxonomy_storage.error_handler)
|
||||
end
|
||||
|
||||
save_term (a_term: CMS_TERM; voc: CMS_VOCABULARY)
|
||||
save_vocabulary_and_terms (a_voc: CMS_VOCABULARY)
|
||||
-- Insert or update vocabulary `a_voc'
|
||||
-- and also save {CMS_VOCABULARY}.terms.
|
||||
do
|
||||
reset_error
|
||||
taxonomy_storage.save_vocabulary (a_voc, True)
|
||||
error_handler.append (taxonomy_storage.error_handler)
|
||||
end
|
||||
|
||||
save_term (a_term: CMS_TERM; voc: detachable CMS_VOCABULARY)
|
||||
-- Save `a_term' inside `voc' if set.
|
||||
do
|
||||
reset_error
|
||||
taxonomy_storage.save_term (a_term, voc)
|
||||
error_handler.append (taxonomy_storage.error_handler)
|
||||
end
|
||||
|
||||
remove_term_from_vocabulary (t: CMS_TERM; voc: CMS_VOCABULARY)
|
||||
-- Remove term `t' from vocabulary `voc'.
|
||||
do
|
||||
reset_error
|
||||
taxonomy_storage.remove_term_from_vocabulary (t, voc)
|
||||
error_handler.append (taxonomy_storage.error_handler)
|
||||
end
|
||||
|
||||
associate_term_with_entity (a_term: CMS_TERM; a_type_name: READABLE_STRING_GENERAL; a_entity: READABLE_STRING_GENERAL)
|
||||
-- Associate term `a_term' with `(a_type_name, a_entity)'.
|
||||
do
|
||||
|
||||
19
modules/taxonomy/cms_taxonomy_hook.e
Normal file
19
modules/taxonomy/cms_taxonomy_hook.e
Normal file
@@ -0,0 +1,19 @@
|
||||
note
|
||||
description: "Hook provided by module {CMS_TAXONOMY_MODULE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_TAXONOMY_HOOK
|
||||
|
||||
inherit
|
||||
CMS_HOOK
|
||||
|
||||
feature -- Hook
|
||||
|
||||
populate_content_associated_with_term (t: CMS_TERM; a_contents: CMS_TAXONOMY_ENTITY_CONTAINER)
|
||||
-- Populate `a_contents' with taxonomy entity associated with term `t'.
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
||||
@@ -13,7 +13,7 @@ inherit
|
||||
rename
|
||||
module_api as taxonomy_api
|
||||
redefine
|
||||
register_hooks,
|
||||
setup_hooks,
|
||||
initialize,
|
||||
install,
|
||||
uninstall,
|
||||
@@ -109,6 +109,7 @@ feature -- Access: router
|
||||
do
|
||||
if attached taxonomy_api as l_taxonomy_api then
|
||||
configure_web (a_api, l_taxonomy_api, a_router)
|
||||
configure_web_amin (a_api, l_taxonomy_api, a_router)
|
||||
else
|
||||
-- Issue with api/dependencies,
|
||||
-- thus Current module should not be used!
|
||||
@@ -120,17 +121,56 @@ feature -- Access: router
|
||||
-- Configure router mapping for web interface.
|
||||
local
|
||||
l_taxonomy_handler: TAXONOMY_HANDLER
|
||||
l_voc_handler: TAXONOMY_VOCABULARY_HANDLER
|
||||
do
|
||||
create l_taxonomy_handler.make (a_api, a_taxonomy_api)
|
||||
a_router.handle ("/taxonomy/term/{termid}", l_taxonomy_handler, a_router.methods_get)
|
||||
|
||||
create l_voc_handler.make (a_api, a_taxonomy_api)
|
||||
a_router.handle ("/taxonomy/vocabulary/", l_voc_handler, a_router.methods_get)
|
||||
a_router.handle ("/taxonomy/vocabulary/{vocid}", l_voc_handler, a_router.methods_get)
|
||||
end
|
||||
|
||||
configure_web_amin (a_api: CMS_API; a_taxonomy_api: CMS_TAXONOMY_API; a_router: WSF_ROUTER)
|
||||
-- Configure router mapping for web interface.
|
||||
local
|
||||
l_taxonomy_handler: TAXONOMY_TERM_ADMIN_HANDLER
|
||||
l_voc_handler: TAXONOMY_VOCABULARY_ADMIN_HANDLER
|
||||
do
|
||||
a_router.handle ("/admin/taxonomy/", create {WSF_URI_AGENT_HANDLER}.make (agent handle_admin_taxonomy (?, ?, a_api)), a_router.methods_get)
|
||||
|
||||
create l_taxonomy_handler.make (a_api, a_taxonomy_api)
|
||||
a_router.handle ("/admin/taxonomy/term/", l_taxonomy_handler, a_router.methods_get_post)
|
||||
a_router.handle ("/admin/taxonomy/term/{termid}", l_taxonomy_handler, a_router.methods_get_post)
|
||||
|
||||
create l_voc_handler.make (a_api, a_taxonomy_api)
|
||||
a_router.handle ("/admin/taxonomy/vocabulary/", l_voc_handler, a_router.methods_get_post)
|
||||
a_router.handle ("/admin/taxonomy/vocabulary/{vocid}", l_voc_handler, a_router.methods_get_post)
|
||||
end
|
||||
|
||||
feature -- Handler
|
||||
|
||||
handle_admin_taxonomy (req: WSF_REQUEST; res: WSF_RESPONSE; api: CMS_API)
|
||||
local
|
||||
l_page: CMS_RESPONSE
|
||||
lnk: CMS_LOCAL_LINK
|
||||
do
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
create lnk.make ("Admin Vocabularies", "admin/taxonomy/vocabulary/")
|
||||
l_page.add_to_primary_tabs (lnk)
|
||||
|
||||
create lnk.make ("Create terms", "admin/taxonomy/term/")
|
||||
l_page.add_to_primary_tabs (lnk)
|
||||
|
||||
l_page.execute
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
do
|
||||
a_response.hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_response.hooks.subscribe_to_response_alter_hook (Current)
|
||||
a_hooks.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_hooks.subscribe_to_response_alter_hook (Current)
|
||||
end
|
||||
|
||||
response_alter (a_response: CMS_RESPONSE)
|
||||
@@ -139,10 +179,14 @@ feature -- Hooks
|
||||
end
|
||||
|
||||
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
|
||||
local
|
||||
lnk: CMS_LOCAL_LINK
|
||||
do
|
||||
-- Add the link to the taxonomy to the main menu
|
||||
-- create lnk.make ("Taxonomy", "taxonomy/")
|
||||
-- a_menu_system.primary_menu.extend (lnk)
|
||||
-- Add the link to the taxonomy to the main menu
|
||||
if a_response.has_permission ("admin taxonomy") then
|
||||
create lnk.make ("Taxonomy", "admin/taxonomy/")
|
||||
a_menu_system.management_menu.extend (lnk)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -19,6 +19,7 @@ feature {NONE} -- Initialization
|
||||
make (nb: INTEGER)
|
||||
do
|
||||
create items.make (nb)
|
||||
items.compare_objects
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
@@ -48,6 +49,21 @@ feature -- Status report
|
||||
Result := items.has (a_term)
|
||||
end
|
||||
|
||||
term_by_id (tid: INTEGER_64): detachable CMS_TERM
|
||||
-- Term of id `tid' contained in Current, if any.
|
||||
do
|
||||
across
|
||||
items as ic
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
Result := ic.item
|
||||
if Result.id /= tid then
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
wipe_out
|
||||
|
||||
@@ -19,6 +19,7 @@ feature {NONE} -- Initialization
|
||||
make (nb: INTEGER)
|
||||
do
|
||||
create items.make (nb)
|
||||
items.compare_objects
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
@@ -37,6 +38,21 @@ feature -- Access
|
||||
end
|
||||
end
|
||||
|
||||
item_by_id (a_id: INTEGER_64): detachable CMS_VOCABULARY
|
||||
-- Vocabulary of id `a_id' contained in Current, if any.
|
||||
do
|
||||
across
|
||||
items as ic
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
Result := ic.item
|
||||
if Result.id /= a_id then
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
new_cursor: INDEXABLE_ITERATION_CURSOR [CMS_VOCABULARY]
|
||||
-- <Precursor>
|
||||
do
|
||||
|
||||
44
modules/taxonomy/handler/cms_taxonomy_entity.e
Normal file
44
modules/taxonomy/handler/cms_taxonomy_entity.e
Normal file
@@ -0,0 +1,44 @@
|
||||
note
|
||||
description: "[
|
||||
Information related to content or taxonomy entity in a taxonomy container.
|
||||
|
||||
Mainly used to build list of contents/entities associated with a term.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_TAXONOMY_ENTITY
|
||||
|
||||
inherit
|
||||
COMPARABLE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_content: CMS_CONTENT; a_date: DATE_TIME)
|
||||
-- Build Current information from `a_content' dated by `a_date'.
|
||||
do
|
||||
content := a_content
|
||||
date := a_date
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
content: CMS_CONTENT
|
||||
-- Content of the entity.
|
||||
|
||||
date: DATE_TIME
|
||||
-- Date, usually related to last modification.
|
||||
|
||||
feature -- Comparison
|
||||
|
||||
is_less alias "<" (other: like Current): BOOLEAN
|
||||
-- Is current object less than `other'?
|
||||
do
|
||||
Result := date < other.date
|
||||
end
|
||||
|
||||
end
|
||||
89
modules/taxonomy/handler/cms_taxonomy_entity_container.e
Normal file
89
modules/taxonomy/handler/cms_taxonomy_entity_container.e
Normal file
@@ -0,0 +1,89 @@
|
||||
note
|
||||
description: "Container of entity associated with taxonomy term."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_TAXONOMY_ENTITY_CONTAINER
|
||||
|
||||
inherit
|
||||
ITERABLE [CMS_TAXONOMY_ENTITY]
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make (a_taxo_info: like taxonomy_info; a_limit: NATURAL_32; a_date: detachable DATE_TIME; a_type: detachable READABLE_STRING_8)
|
||||
do
|
||||
taxonomy_info := a_taxo_info
|
||||
limit := a_limit
|
||||
date := a_date
|
||||
content_type := a_type
|
||||
create items.make (a_limit.to_integer_32)
|
||||
end
|
||||
|
||||
feature -- Settings
|
||||
|
||||
limit: NATURAL_32
|
||||
-- Maximum container size.
|
||||
|
||||
date: detachable DATE_TIME
|
||||
-- Contents related to entities listed on `taxonomy_info'.
|
||||
|
||||
content_type: detachable READABLE_STRING_8
|
||||
-- Filter by content type if not Void.
|
||||
|
||||
feature -- Access
|
||||
|
||||
taxonomy_info: LIST [TUPLE [entity: READABLE_STRING_32; typename: detachable READABLE_STRING_32]]
|
||||
-- Associated information.
|
||||
|
||||
items: ARRAYED_LIST [CMS_TAXONOMY_ENTITY]
|
||||
-- List of recent events.
|
||||
|
||||
count: INTEGER
|
||||
-- Number of change items.
|
||||
do
|
||||
Result := items.count
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: ITERATION_CURSOR [CMS_TAXONOMY_ENTITY]
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := items.new_cursor
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
force (a_item: CMS_TAXONOMY_ENTITY)
|
||||
-- Add `a_item'.
|
||||
do
|
||||
items.force (a_item)
|
||||
end
|
||||
|
||||
feature -- Sorting
|
||||
|
||||
sort
|
||||
-- Sort `items' from older, to newer.
|
||||
do
|
||||
item_sorter.sort (items)
|
||||
end
|
||||
|
||||
reverse_sort
|
||||
-- Sort `items' from newer to older.
|
||||
do
|
||||
item_sorter.reverse_sort (items)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
item_sorter: QUICK_SORTER [CMS_TAXONOMY_ENTITY]
|
||||
-- New change item sorter.
|
||||
once
|
||||
create Result.make (create {COMPARABLE_COMPARATOR [CMS_TAXONOMY_ENTITY]})
|
||||
end
|
||||
|
||||
end
|
||||
@@ -68,9 +68,10 @@ feature -- HTTP Methods
|
||||
local
|
||||
l_page: CMS_RESPONSE
|
||||
tid: INTEGER_64
|
||||
l_typename: detachable READABLE_STRING_8
|
||||
l_entity: detachable READABLE_STRING_32
|
||||
s: STRING
|
||||
l_contents: CMS_TAXONOMY_ENTITY_CONTAINER
|
||||
ct: CMS_CONTENT
|
||||
do
|
||||
if
|
||||
attached {WSF_STRING} req.path_parameter ("termid") as p_termid and then
|
||||
@@ -83,38 +84,58 @@ feature -- HTTP Methods
|
||||
if attached taxonomy_api.term_by_id (tid) as t then
|
||||
-- Responding with `main_content_html (l_page)'.
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
l_page.set_title (t.text)
|
||||
create s.make_empty
|
||||
l_page.set_page_title ("Entities associated with term %"" + l_page.html_encoded (t.text) + "%":")
|
||||
|
||||
if
|
||||
attached taxonomy_api.entities_associated_with_term (t) as l_entity_type_lst and then
|
||||
not l_entity_type_lst.is_empty
|
||||
then
|
||||
s.append ("<ul class=%"taxonomy-entities%">")
|
||||
across
|
||||
l_entity_type_lst as ic
|
||||
loop
|
||||
-- FIXME: for now basic implementation .. to be replaced by specific hook !
|
||||
if attached ic.item.entity as e and then e.is_valid_as_string_8 then
|
||||
l_entity := e.to_string_8
|
||||
if attached ic.item.type as l_type and then l_type.is_valid_as_string_8 then
|
||||
l_typename := l_type.to_string_8
|
||||
else
|
||||
l_typename := Void
|
||||
end
|
||||
if l_typename /= Void then
|
||||
s.append ("<li class=%""+ l_typename +"%">")
|
||||
if
|
||||
l_typename.is_case_insensitive_equal_general ("page")
|
||||
or l_typename.is_case_insensitive_equal_general ("blog")
|
||||
then
|
||||
s.append (l_page.link ({STRING_32} "" + l_typename + "/" + l_entity, "node/" + l_entity.to_string_8, Void))
|
||||
end
|
||||
s.append ("</li>%N")
|
||||
create l_contents.make (l_entity_type_lst, 25, create {DATE_TIME}.make_now_utc, Void)
|
||||
if attached api.hooks.subscribers ({CMS_TAXONOMY_HOOK}) as lst then
|
||||
across
|
||||
lst as ic
|
||||
loop
|
||||
if attached {CMS_TAXONOMY_HOOK} ic.item as h then
|
||||
h.populate_content_associated_with_term (t, l_contents)
|
||||
end
|
||||
end
|
||||
l_contents.sort
|
||||
s.append ("<ul class=%"taxonomy-entities%">")
|
||||
across
|
||||
l_contents as ic
|
||||
loop
|
||||
ct := ic.item.content
|
||||
s.append ("<li class=%""+ ct.content_type +"%">")
|
||||
if attached ct.link as lnk then
|
||||
l_page.append_link_to_html (lnk.title, lnk.location, Void, s)
|
||||
end
|
||||
if attached api.content_type_webform_manager_by_name (ct.content_type) as l_wfm then
|
||||
l_wfm.append_content_as_html_to (ct, True, s, l_page)
|
||||
end
|
||||
s.append ("</li>%N")
|
||||
end
|
||||
s.append ("</ul>%N")
|
||||
end
|
||||
if not l_contents.taxonomy_info.is_empty then
|
||||
check all_taxo_handled: False end
|
||||
s.append ("<ul class=%"error%">Item(s) with unknown content type!")
|
||||
across
|
||||
l_contents.taxonomy_info as ic
|
||||
loop
|
||||
-- FIXME: for now basic implementation .. to be replaced by specific hook !
|
||||
if attached ic.item.entity as e and then e.is_valid_as_string_8 then
|
||||
l_entity := e
|
||||
s.append ("<li>Entity %"")
|
||||
s.append (api.html_encoded (e))
|
||||
s.append ("%"")
|
||||
if attached ic.item.typename as l_type and then l_type.is_valid_as_string_8 then
|
||||
s.append (" {" + api.html_encoded (l_type) + "}")
|
||||
end
|
||||
s.append ("</li>")
|
||||
end
|
||||
end
|
||||
s.append ("</ul>%N")
|
||||
end
|
||||
s.append ("</ul>%N")
|
||||
else
|
||||
s.append ("No entity found.")
|
||||
end
|
||||
|
||||
269
modules/taxonomy/handler/taxonomy_term_admin_handler.e
Normal file
269
modules/taxonomy/handler/taxonomy_term_admin_handler.e
Normal file
@@ -0,0 +1,269 @@
|
||||
note
|
||||
description: "[
|
||||
Request handler related to
|
||||
/admin/taxonomy/term/{termid}
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$revision$"
|
||||
|
||||
class
|
||||
TAXONOMY_TERM_ADMIN_HANDLER
|
||||
|
||||
inherit
|
||||
CMS_MODULE_HANDLER [CMS_TAXONOMY_API]
|
||||
rename
|
||||
module_api as taxonomy_api
|
||||
end
|
||||
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as uri_execute,
|
||||
new_mapping as new_uri_mapping
|
||||
end
|
||||
|
||||
WSF_URI_TEMPLATE_HANDLER
|
||||
rename
|
||||
execute as uri_template_execute,
|
||||
new_mapping as new_uri_template_mapping
|
||||
select
|
||||
new_uri_template_mapping
|
||||
end
|
||||
|
||||
WSF_RESOURCE_HANDLER_HELPER
|
||||
redefine
|
||||
do_get,
|
||||
do_post
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
CMS_API_ACCESS
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- execute
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler for any kind of mapping.
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler for URI mapping.
|
||||
do
|
||||
execute (req, res)
|
||||
end
|
||||
|
||||
uri_template_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler for URI-template mapping.
|
||||
do
|
||||
execute (req, res)
|
||||
end
|
||||
|
||||
feature -- HTTP Methods
|
||||
|
||||
|
||||
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
l_page: CMS_RESPONSE
|
||||
tid: INTEGER_64
|
||||
s: STRING
|
||||
f: CMS_FORM
|
||||
t: detachable CMS_TERM
|
||||
l_parents: detachable CMS_VOCABULARY_COLLECTION
|
||||
do
|
||||
if
|
||||
attached {WSF_STRING} req.path_parameter ("termid") as p_termid and then
|
||||
p_termid.is_integer
|
||||
then
|
||||
tid := p_termid.value.to_integer_64
|
||||
if tid > 0 then
|
||||
t := taxonomy_api.term_by_id (tid)
|
||||
end
|
||||
end
|
||||
|
||||
-- Responding with `main_content_html (l_page)'.
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
if l_page.has_permission ("admin taxonomy") then
|
||||
|
||||
if t = Void then
|
||||
l_page.set_title ("New term ...")
|
||||
create t.make ("")
|
||||
else
|
||||
l_page.set_title (t.text)
|
||||
end
|
||||
create s.make_empty
|
||||
f := edit_form (t, l_page, req)
|
||||
f.process (l_page)
|
||||
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 ("Save changes") then
|
||||
if attached fd.string_item ("text") as l_text then
|
||||
t.set_text (l_text)
|
||||
l_page.set_title (t.text)
|
||||
end
|
||||
if attached fd.string_item ("description") as l_description then
|
||||
t.set_description (l_description)
|
||||
end
|
||||
if attached fd.string_item ("weight") as l_weight and then l_weight.is_integer then
|
||||
t.set_weight (l_weight.to_integer)
|
||||
end
|
||||
taxonomy_api.save_term (t, Void)
|
||||
if taxonomy_api.has_error then
|
||||
fd.report_error ("Term creation failed!")
|
||||
else
|
||||
l_page.add_success_message ("Term creation succeed.")
|
||||
s.append ("<div>View term: ")
|
||||
s.append (l_page.link (t.text, "admin/taxonomy/term/" + t.id.out, Void))
|
||||
s.append ("</div>")
|
||||
|
||||
if
|
||||
attached fd.table_item ("vocabularies") as voc_tb and then
|
||||
attached taxonomy_api.vocabularies (0, 0) as l_vocabularies
|
||||
then
|
||||
l_parents := taxonomy_api.vocabularies_for_term (t)
|
||||
across
|
||||
voc_tb as vid_ic
|
||||
until
|
||||
taxonomy_api.has_error
|
||||
loop
|
||||
if attached l_vocabularies.item_by_id (vid_ic.item.string_representation.to_integer_64) as v then
|
||||
if l_parents /= Void and then attached l_parents.item_by_id (v.id) as l_v then
|
||||
-- Already as parent!
|
||||
l_parents.remove (l_v)
|
||||
else
|
||||
taxonomy_api.save_term (t, v)
|
||||
l_vocabularies.remove (v)
|
||||
end
|
||||
end
|
||||
end
|
||||
if l_parents /= Void then
|
||||
across
|
||||
l_parents as v_ic
|
||||
until
|
||||
taxonomy_api.has_error
|
||||
loop
|
||||
taxonomy_api.remove_term_from_vocabulary (t, v_ic.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- l_page.set_redirection (l_page.location)
|
||||
end
|
||||
else
|
||||
fd.report_error ("Invalid form data!")
|
||||
end
|
||||
end
|
||||
f.append_to_html (l_page.wsf_theme, s)
|
||||
l_page.set_main_content (s)
|
||||
l_page.execute
|
||||
else
|
||||
send_access_denied (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: CMS_RESPONSE
|
||||
tid: INTEGER_64
|
||||
s: STRING
|
||||
f: CMS_FORM
|
||||
t: detachable CMS_TERM
|
||||
do
|
||||
if
|
||||
attached {WSF_STRING} req.path_parameter ("termid") as p_termid and then
|
||||
p_termid.is_integer
|
||||
then
|
||||
tid := p_termid.value.to_integer_64
|
||||
if tid > 0 then
|
||||
t := taxonomy_api.term_by_id (tid)
|
||||
end
|
||||
end
|
||||
-- Responding with `main_content_html (l_page)'.
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
if l_page.has_permission ("admin taxonomy") then
|
||||
if t = Void then
|
||||
l_page.set_title ("Create term ...")
|
||||
create t.make ("")
|
||||
else
|
||||
l_page.set_title (t.text)
|
||||
end
|
||||
create s.make_empty
|
||||
f := edit_form (t, l_page, req)
|
||||
f.append_to_html (l_page.wsf_theme, s)
|
||||
l_page.set_main_content (s)
|
||||
l_page.execute
|
||||
else
|
||||
send_access_denied (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
edit_form (t: CMS_TERM; a_page: CMS_RESPONSE; req: WSF_REQUEST): CMS_FORM
|
||||
local
|
||||
f: CMS_FORM
|
||||
voc: detachable CMS_VOCABULARY
|
||||
w_tf: WSF_FORM_TEXT_INPUT
|
||||
w_txt: WSF_FORM_TEXTAREA
|
||||
w_set: WSF_FORM_FIELD_SET
|
||||
w_cb: WSF_FORM_CHECKBOX_INPUT
|
||||
l_parents: detachable CMS_VOCABULARY_COLLECTION
|
||||
do
|
||||
create f.make (req.percent_encoded_path_info, "taxonomy")
|
||||
if t.has_id then
|
||||
f.extend_html_text (a_page.link ("View associated entities", "taxonomy/term/" + t.id.out, Void))
|
||||
end
|
||||
create w_tf.make_with_text ("text", t.text)
|
||||
w_tf.set_is_required (True)
|
||||
w_tf.set_label ("Text")
|
||||
f.extend (w_tf)
|
||||
|
||||
create w_txt.make ("description")
|
||||
w_txt.set_label ("Description")
|
||||
w_txt.set_rows (3)
|
||||
w_txt.set_cols (60)
|
||||
if attached t.description as l_desc then
|
||||
w_txt.set_text_value (api.html_encoded (l_desc))
|
||||
end
|
||||
w_txt.set_description ("Description of the terms; can be used by modules or administration.")
|
||||
f.extend (w_txt)
|
||||
|
||||
create w_tf.make_with_text ("weight", t.weight.out)
|
||||
w_tf.set_label ("Weight")
|
||||
w_tf.set_description ("Terms are sorted in ascending order by weight.")
|
||||
f.extend (w_tf)
|
||||
|
||||
if attached taxonomy_api.vocabularies (0, 0) as vocs then
|
||||
if t.has_id then
|
||||
l_parents := taxonomy_api.vocabularies_for_term (t)
|
||||
end
|
||||
create w_set.make
|
||||
w_set.set_legend ("Associated vocabularies")
|
||||
across
|
||||
vocs as ic
|
||||
loop
|
||||
voc := ic.item
|
||||
create w_cb.make_with_value ("vocabularies[]", ic.item.id.out)
|
||||
w_cb.set_title (voc.name)
|
||||
if
|
||||
l_parents /= Void and then
|
||||
across l_parents as p_ic some p_ic.item.id = ic.item.id end
|
||||
then
|
||||
w_cb.set_checked (True)
|
||||
end
|
||||
w_set.extend (w_cb)
|
||||
end
|
||||
if w_set.count > 0 then
|
||||
f.extend (w_set)
|
||||
end
|
||||
end
|
||||
|
||||
f.extend (create {WSF_FORM_SUBMIT_INPUT}.make_with_text ("op", "Save changes"))
|
||||
Result := f
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
414
modules/taxonomy/handler/taxonomy_vocabulary_admin_handler.e
Normal file
414
modules/taxonomy/handler/taxonomy_vocabulary_admin_handler.e
Normal file
@@ -0,0 +1,414 @@
|
||||
note
|
||||
description: "[
|
||||
Request handler related to
|
||||
/admin/taxonomy/vocabulary/
|
||||
/admin/taxonomy/vocabulary/{vocid}
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$revision$"
|
||||
|
||||
class
|
||||
TAXONOMY_VOCABULARY_ADMIN_HANDLER
|
||||
|
||||
inherit
|
||||
CMS_MODULE_HANDLER [CMS_TAXONOMY_API]
|
||||
rename
|
||||
module_api as taxonomy_api
|
||||
end
|
||||
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as uri_execute,
|
||||
new_mapping as new_uri_mapping
|
||||
end
|
||||
|
||||
WSF_URI_TEMPLATE_HANDLER
|
||||
rename
|
||||
execute as uri_template_execute,
|
||||
new_mapping as new_uri_template_mapping
|
||||
select
|
||||
new_uri_template_mapping
|
||||
end
|
||||
|
||||
WSF_RESOURCE_HANDLER_HELPER
|
||||
redefine
|
||||
do_get,
|
||||
do_post
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
CMS_API_ACCESS
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- execute
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler for any kind of mapping.
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler for URI mapping.
|
||||
do
|
||||
execute (req, res)
|
||||
end
|
||||
|
||||
uri_template_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler for URI-template mapping.
|
||||
do
|
||||
execute (req, res)
|
||||
end
|
||||
|
||||
feature -- HTTP Methods
|
||||
|
||||
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
l_page: CMS_RESPONSE
|
||||
voc: CMS_VOCABULARY
|
||||
l_typename: READABLE_STRING_GENERAL
|
||||
s: STRING
|
||||
do
|
||||
if not api.user_has_permission (current_user (req), "admin taxonomy") then
|
||||
send_access_denied (req, res)
|
||||
else
|
||||
if attached {WSF_STRING} req.form_parameter ("op") as p_op then
|
||||
if p_op.same_string ("New Vocabulary") then
|
||||
if
|
||||
attached {WSF_STRING} req.form_parameter ("vocabulary_name") as p_name and then
|
||||
not p_name.is_empty
|
||||
then
|
||||
create voc.make (p_name.value)
|
||||
taxonomy_api.save_vocabulary (voc)
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
if taxonomy_api.has_error then
|
||||
l_page.add_error_message ("Vocabulary creation failed!")
|
||||
else
|
||||
l_page.add_success_message ("Vocabulary creation succeed!")
|
||||
l_page.set_redirection ("admin/taxonomy/vocabulary/" + voc.id.out)
|
||||
end
|
||||
else
|
||||
create {BAD_REQUEST_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
end
|
||||
elseif
|
||||
p_op.same_string ("Save changes") and then
|
||||
attached {WSF_STRING} req.path_parameter ("vocid") as p_vocid and then p_vocid.is_integer and then
|
||||
attached taxonomy_api.vocabulary (p_vocid.value.to_integer_64) as l_vocabulary
|
||||
then
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
create s.make_empty
|
||||
l_page.add_notice_message ("Vocabulary " + l_vocabulary.id.out)
|
||||
if attached {WSF_STRING} req.form_parameter ("name") as p_name then
|
||||
l_vocabulary.set_name (p_name.value)
|
||||
end
|
||||
if attached {WSF_STRING} req.form_parameter ("description") as p_desc then
|
||||
l_vocabulary.set_description (p_desc.value)
|
||||
end
|
||||
if attached {WSF_STRING} req.form_parameter ("weight") as p_weight and then p_weight.is_integer then
|
||||
l_vocabulary.set_weight (p_weight.integer_value)
|
||||
end
|
||||
taxonomy_api.save_vocabulary (l_vocabulary)
|
||||
if taxonomy_api.has_error then
|
||||
l_page.add_error_message ("Could not save vocabulary")
|
||||
elseif
|
||||
attached {WSF_TABLE} req.form_parameter ("typenames") as typenames_table
|
||||
then
|
||||
across
|
||||
typenames_table as ic
|
||||
loop
|
||||
l_typename := ic.item.string_representation
|
||||
create voc.make_from_term (l_vocabulary)
|
||||
voc.set_associated_content_type (l_typename, False, False, False)
|
||||
l_page.add_notice_message ("Content type :" + api.html_encoded (l_typename))
|
||||
if attached {WSF_TABLE} req.form_parameter ({STRING_32} "vocabulary_" + l_typename.as_string_32) as opts then
|
||||
across
|
||||
opts as o_ic
|
||||
loop
|
||||
if o_ic.item.same_string ("tags") then
|
||||
voc.set_is_tags (True)
|
||||
elseif o_ic.item.same_string ("multiple") then
|
||||
voc.allow_multiple_term (True)
|
||||
elseif o_ic.item.same_string ("required") then
|
||||
voc.set_is_term_required (True)
|
||||
end
|
||||
end
|
||||
end
|
||||
taxonomy_api.associate_vocabulary_with_type (voc, l_typename)
|
||||
if taxonomy_api.has_error then
|
||||
l_page.add_error_message ("Could not save vocabulary content type associations.")
|
||||
end
|
||||
end
|
||||
end
|
||||
if not taxonomy_api.has_error then
|
||||
l_page.add_notice_message (l_page.link ({STRING_32} "Back to vocabulary %"" + l_vocabulary.name + "%"", "admin/taxonomy/vocabulary/" + l_vocabulary.id.out, Void))
|
||||
end
|
||||
l_page.set_main_content (s)
|
||||
else
|
||||
create {NOT_IMPLEMENTED_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
end
|
||||
else
|
||||
create {BAD_REQUEST_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
end
|
||||
l_page.execute
|
||||
end
|
||||
end
|
||||
|
||||
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
tid: INTEGER_64
|
||||
do
|
||||
if not api.user_has_permission (current_user (req), "admin taxonomy") then
|
||||
send_access_denied (req, res)
|
||||
else
|
||||
if attached {WSF_STRING} req.path_parameter ("vocid") as p_vocid then
|
||||
if p_vocid.is_integer then
|
||||
tid := p_vocid.value.to_integer_64
|
||||
end
|
||||
end
|
||||
if tid > 0 then
|
||||
do_get_vocabulary (tid, req, res)
|
||||
else
|
||||
do_get_vocabularies (req, res)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
do_get_vocabulary (tid: INTEGER_64; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
require
|
||||
valid_tid: tid > 0
|
||||
local
|
||||
l_page: CMS_RESPONSE
|
||||
s: STRING
|
||||
l_typename: detachable READABLE_STRING_8
|
||||
v: detachable CMS_VOCABULARY
|
||||
l_typenames: detachable LIST [READABLE_STRING_32]
|
||||
f: CMS_FORM
|
||||
wtb: WSF_WIDGET_TABLE
|
||||
wtb_row: WSF_WIDGET_TABLE_ROW
|
||||
wtb_item: WSF_WIDGET_TABLE_ITEM
|
||||
voc: detachable CMS_VOCABULARY
|
||||
l_term: detachable CMS_TERM
|
||||
tf_input: WSF_FORM_TEXT_INPUT
|
||||
tf_text: WSF_FORM_TEXTAREA
|
||||
tf_num: WSF_FORM_NUMBER_INPUT
|
||||
w_set: WSF_FORM_FIELD_SET
|
||||
w_cb: WSF_FORM_CHECKBOX_INPUT
|
||||
sub: WSF_FORM_SUBMIT_INPUT
|
||||
do
|
||||
voc := taxonomy_api.vocabulary (tid)
|
||||
if voc /= Void then
|
||||
-- Responding with `main_content_html (l_page)'.
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
l_page.set_title (voc.name)
|
||||
taxonomy_api.fill_vocabularies_with_terms (voc)
|
||||
|
||||
create f.make (req.percent_encoded_path_info, "taxonomy")
|
||||
|
||||
create tf_input.make_with_text ("name", voc.name)
|
||||
f.extend (tf_input)
|
||||
|
||||
create tf_text.make ("description")
|
||||
tf_text.set_text_value (voc.description)
|
||||
tf_text.set_description ("Description of the vocabulary; also used as intructions to present to the user when selecting terms.")
|
||||
tf_text.set_rows (3)
|
||||
f.extend (tf_text)
|
||||
|
||||
create tf_num.make_with_text ("weight", voc.weight.out)
|
||||
tf_num.set_label ("weight")
|
||||
tf_num.set_description ("Items are displayed in ascending order by weight.")
|
||||
f.extend (tf_num)
|
||||
|
||||
create wtb.make
|
||||
wtb.add_css_class ("with_border")
|
||||
create wtb_row.make (2)
|
||||
create wtb_item.make_with_text ("Text")
|
||||
wtb_row.set_item (wtb_item, 1)
|
||||
create wtb_item.make_with_text ("Description")
|
||||
wtb_row.set_item (wtb_item, 2)
|
||||
wtb.add_head_row (wtb_row)
|
||||
across
|
||||
voc as ic
|
||||
loop
|
||||
l_term := ic.item
|
||||
|
||||
create wtb_row.make (3)
|
||||
wtb.add_row (wtb_row)
|
||||
|
||||
create wtb_item.make_with_text (l_page.link (ic.item.text, "admin/taxonomy/term/" + l_term.id.out, Void))
|
||||
wtb_row.set_item (wtb_item, 1)
|
||||
if attached ic.item.description as l_desc then
|
||||
create wtb_item.make_with_text (api.html_encoded (l_desc))
|
||||
else
|
||||
create wtb_item.make_with_text ("")
|
||||
end
|
||||
wtb_row.set_item (wtb_item, 2)
|
||||
end
|
||||
if wtb.body_row_count > 0 then
|
||||
f.extend (wtb)
|
||||
else
|
||||
f.extend_raw_text ("No terms.")
|
||||
end
|
||||
|
||||
create w_set.make
|
||||
w_set.set_legend ("Content types")
|
||||
f.extend (w_set)
|
||||
|
||||
|
||||
l_typenames := taxonomy_api.types_associated_with_vocabulary (voc)
|
||||
create wtb.make
|
||||
wtb.add_css_class ("with_border")
|
||||
create wtb_row.make (5)
|
||||
wtb_row.set_item (create {WSF_WIDGET_TABLE_ITEM}.make_with_text ("Type"), 1)
|
||||
create wtb_item.make_with_text ("Settings ...")
|
||||
wtb_item.add_html_attribute ("colspan", "3")
|
||||
wtb_row.set_item (wtb_item, 2)
|
||||
wtb.add_head_row (wtb_row)
|
||||
|
||||
across
|
||||
api.content_types as ic
|
||||
loop
|
||||
create wtb_row.make (4)
|
||||
wtb.add_row (wtb_row)
|
||||
|
||||
l_typename := ic.item.name
|
||||
create w_cb.make_with_value ("typenames[]", api.html_encoded (l_typename))
|
||||
w_cb.set_title (ic.item.name)
|
||||
wtb_row.set_item (create {WSF_WIDGET_TABLE_ITEM}.make_with_content (w_cb), 1)
|
||||
|
||||
v := Void
|
||||
if
|
||||
l_typenames /= Void and then
|
||||
across l_typenames as tn_ic some l_typename.is_case_insensitive_equal (tn_ic.item) end
|
||||
then
|
||||
w_cb.set_checked (True)
|
||||
if attached taxonomy_api.vocabularies_for_type (l_typename) as v_list then
|
||||
across v_list as v_ic until v /= Void loop
|
||||
if v_ic.item.id = voc.id then
|
||||
v := v_ic.item
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
create w_cb.make_with_value ("vocabulary_" + l_typename +"[]", "tags")
|
||||
w_cb.set_title ("Tags")
|
||||
w_cb.set_checked (v /= Void and then v.is_tags)
|
||||
wtb_row.set_item (create {WSF_WIDGET_TABLE_ITEM}.make_with_content (w_cb), 2)
|
||||
|
||||
create w_cb.make_with_value ("vocabulary_" + l_typename +"[]", "multiple")
|
||||
w_cb.set_title ("Multiple Select")
|
||||
w_cb.set_checked (v /= Void and then v.multiple_terms_allowed)
|
||||
wtb_row.set_item (create {WSF_WIDGET_TABLE_ITEM}.make_with_content (w_cb), 3)
|
||||
|
||||
create w_cb.make_with_value ("vocabulary_" + l_typename +"[]", "required")
|
||||
w_cb.set_title ("Required")
|
||||
w_cb.set_checked (v /= Void and then v.is_term_required)
|
||||
wtb_row.set_item (create {WSF_WIDGET_TABLE_ITEM}.make_with_content (w_cb), 4)
|
||||
end
|
||||
if wtb.body_row_count > 0 then
|
||||
w_set.extend (wtb)
|
||||
end
|
||||
|
||||
create sub.make_with_text ("op", "Save changes")
|
||||
f.extend (sub)
|
||||
|
||||
create s.make_empty
|
||||
f.append_to_html (l_page.wsf_theme, s)
|
||||
l_page.set_main_content (s)
|
||||
else
|
||||
-- Responding with `main_content_html (l_page)'.
|
||||
create {NOT_FOUND_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
end
|
||||
l_page.execute
|
||||
end
|
||||
|
||||
do_get_vocabularies (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: CMS_RESPONSE
|
||||
s: STRING
|
||||
l_typenames: detachable LIST [READABLE_STRING_32]
|
||||
f: CMS_FORM
|
||||
wtb: WSF_WIDGET_TABLE
|
||||
wtb_row: WSF_WIDGET_TABLE_ROW
|
||||
wtb_item: WSF_WIDGET_TABLE_ITEM
|
||||
voc: detachable CMS_VOCABULARY
|
||||
tf_input: WSF_FORM_TEXT_INPUT
|
||||
w_set: WSF_FORM_FIELD_SET
|
||||
sub: WSF_FORM_SUBMIT_INPUT
|
||||
do
|
||||
-- Responding with `main_content_html (l_page)'.
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
create wtb.make
|
||||
wtb.add_css_class ("with_border")
|
||||
create wtb_row.make (3)
|
||||
create wtb_item.make_with_text ("Name")
|
||||
wtb_row.set_item (wtb_item, 1)
|
||||
create wtb_item.make_with_text ("Type")
|
||||
wtb_row.set_item (wtb_item, 2)
|
||||
create wtb_item.make_with_text ("Operations")
|
||||
wtb_row.set_item (wtb_item, 3)
|
||||
wtb.add_head_row (wtb_row)
|
||||
|
||||
if attached taxonomy_api.vocabularies (0, 0) as lst then
|
||||
across
|
||||
lst as ic
|
||||
loop
|
||||
voc := ic.item
|
||||
create wtb_row.make (3)
|
||||
wtb.add_row (wtb_row)
|
||||
|
||||
create wtb_item.make_with_text (l_page.link (ic.item.name, "admin/taxonomy/vocabulary/" + ic.item.id.out, Void))
|
||||
-- if attached ic.item.description as l_desc then
|
||||
-- s.append (" : <em>")
|
||||
-- s.append (api.html_encoded (l_desc))
|
||||
-- s.append ("</em>")
|
||||
-- end
|
||||
wtb_row.set_item (wtb_item, 1)
|
||||
l_typenames := taxonomy_api.types_associated_with_vocabulary (voc)
|
||||
if l_typenames /= Void then
|
||||
create s.make_empty
|
||||
across
|
||||
l_typenames as types_ic
|
||||
loop
|
||||
if not s.is_empty then
|
||||
s.append_character (',')
|
||||
s.append_character (' ')
|
||||
end
|
||||
s.append (api.html_encoded (types_ic.item))
|
||||
end
|
||||
create wtb_item.make_with_text (s)
|
||||
wtb_row.set_item (wtb_item, 2)
|
||||
end
|
||||
|
||||
s := l_page.link ("edit", "admin/taxonomy/vocabulary/" + voc.id.out, Void)
|
||||
create wtb_item.make_with_text (s)
|
||||
wtb_row.set_item (wtb_item, 3)
|
||||
end
|
||||
end
|
||||
create f.make (req.percent_encoded_path_info, "taxonomy")
|
||||
f.set_method_post
|
||||
|
||||
f.extend (wtb)
|
||||
|
||||
create w_set.make
|
||||
w_set.set_legend ("Create a new vocabulary")
|
||||
create tf_input.make_with_text ("vocabulary_name", "")
|
||||
tf_input.set_label ("Vocabulary name")
|
||||
w_set.extend (tf_input)
|
||||
create sub.make_with_text ("op", "New Vocabulary")
|
||||
w_set.extend (sub)
|
||||
f.extend (w_set)
|
||||
|
||||
create s.make_empty
|
||||
f.append_to_html (l_page.wsf_theme, s)
|
||||
l_page.set_title ("Vocabularies")
|
||||
l_page.set_main_content (s)
|
||||
l_page.execute
|
||||
end
|
||||
|
||||
end
|
||||
129
modules/taxonomy/handler/taxonomy_vocabulary_handler.e
Normal file
129
modules/taxonomy/handler/taxonomy_vocabulary_handler.e
Normal file
@@ -0,0 +1,129 @@
|
||||
note
|
||||
description: "[
|
||||
Request handler related to
|
||||
/taxonomy/vocabulary/
|
||||
/taxonomy/vocabulary/{vocid}
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$revision$"
|
||||
|
||||
class
|
||||
TAXONOMY_VOCABULARY_HANDLER
|
||||
|
||||
inherit
|
||||
CMS_MODULE_HANDLER [CMS_TAXONOMY_API]
|
||||
rename
|
||||
module_api as taxonomy_api
|
||||
end
|
||||
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as uri_execute,
|
||||
new_mapping as new_uri_mapping
|
||||
end
|
||||
|
||||
WSF_URI_TEMPLATE_HANDLER
|
||||
rename
|
||||
execute as uri_template_execute,
|
||||
new_mapping as new_uri_template_mapping
|
||||
select
|
||||
new_uri_template_mapping
|
||||
end
|
||||
|
||||
WSF_RESOURCE_HANDLER_HELPER
|
||||
redefine
|
||||
do_get
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
CMS_API_ACCESS
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- execute
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler for any kind of mapping.
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler for URI mapping.
|
||||
do
|
||||
execute (req, res)
|
||||
end
|
||||
|
||||
uri_template_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler for URI-template mapping.
|
||||
do
|
||||
execute (req, res)
|
||||
end
|
||||
|
||||
feature -- HTTP Methods
|
||||
|
||||
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: CMS_RESPONSE
|
||||
tid: INTEGER_64
|
||||
s: STRING
|
||||
do
|
||||
if attached {WSF_STRING} req.path_parameter ("vocid") as p_vocid then
|
||||
if p_vocid.is_integer then
|
||||
tid := p_vocid.value.to_integer_64
|
||||
end
|
||||
end
|
||||
if tid > 0 then
|
||||
if attached taxonomy_api.vocabulary (tid) as voc then
|
||||
-- Responding with `main_content_html (l_page)'.
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
l_page.set_title (voc.name)
|
||||
taxonomy_api.fill_vocabularies_with_terms (voc)
|
||||
|
||||
create s.make_empty
|
||||
s.append ("<ul class=%"taxonomy-terms%">")
|
||||
across
|
||||
voc as ic
|
||||
loop
|
||||
s.append ("<li>")
|
||||
s.append (l_page.link (ic.item.text, "taxonomy/term/" + ic.item.id.out, Void))
|
||||
if attached ic.item.description as l_desc then
|
||||
s.append (" : <em>")
|
||||
s.append (api.html_encoded (l_desc))
|
||||
s.append ("</em>")
|
||||
end
|
||||
s.append ("</li>")
|
||||
end
|
||||
s.append ("</ul>")
|
||||
l_page.set_main_content (s)
|
||||
else
|
||||
-- Responding with `main_content_html (l_page)'.
|
||||
create {NOT_FOUND_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
end
|
||||
l_page.execute
|
||||
else
|
||||
-- Responding with `main_content_html (l_page)'.
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
create s.make_empty
|
||||
if attached taxonomy_api.vocabularies (0, 0) as lst then
|
||||
s.append ("<ul class=%"taxonomy-vocabularies%">")
|
||||
across
|
||||
lst as ic
|
||||
loop
|
||||
s.append ("<li>")
|
||||
s.append (l_page.link (ic.item.name, "taxonomy/vocabulary/" + ic.item.id.out, Void))
|
||||
s.append ("</li>")
|
||||
end
|
||||
s.append ("</ul>")
|
||||
else
|
||||
s.append ("No vocabulary!")
|
||||
end
|
||||
l_page.set_main_content (s)
|
||||
l_page.execute
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -41,6 +41,24 @@ feature -- Access
|
||||
deferred
|
||||
end
|
||||
|
||||
vocabularies_for_term (a_term: CMS_TERM): detachable CMS_VOCABULARY_COLLECTION
|
||||
-- Vocabularies including `a_term'.
|
||||
deferred
|
||||
end
|
||||
|
||||
is_term_inside_vocabulary (a_term: CMS_TERM; a_vocab: CMS_VOCABULARY): BOOLEAN
|
||||
-- Is `a_term' inside `a_vocab' ?
|
||||
require
|
||||
valid_term: a_term.has_id
|
||||
valid_vocabulary: a_vocab.has_id
|
||||
deferred
|
||||
end
|
||||
|
||||
types_associated_with_vocabulary (a_vocab: CMS_VOCABULARY): detachable LIST [READABLE_STRING_32]
|
||||
-- Type names associated with `a_vocab'.
|
||||
deferred
|
||||
end
|
||||
|
||||
terms_count: INTEGER_64
|
||||
-- Number of terms.
|
||||
deferred
|
||||
@@ -80,7 +98,7 @@ feature -- Access
|
||||
deferred
|
||||
end
|
||||
|
||||
entities_associated_with_term (a_term: CMS_TERM): detachable LIST [TUPLE [entity: READABLE_STRING_32; type: detachable READABLE_STRING_32]]
|
||||
entities_associated_with_term (a_term: CMS_TERM): detachable LIST [TUPLE [entity: READABLE_STRING_32; typename: detachable READABLE_STRING_32]]
|
||||
-- Entities and related typename associated with `a_term'.
|
||||
require
|
||||
a_term_exists: a_term.has_id
|
||||
@@ -89,20 +107,28 @@ feature -- Access
|
||||
|
||||
feature -- Store
|
||||
|
||||
save_vocabulary (a_voc: CMS_VOCABULARY)
|
||||
-- Insert or update vocabulary `a_voc'.
|
||||
save_vocabulary (a_voc: CMS_VOCABULARY; a_with_terms: BOOLEAN)
|
||||
-- Insert or update vocabulary `a_voc'
|
||||
-- and also save {CMS_VOCABULARY}.terms if `a_with_terms' is True.
|
||||
deferred
|
||||
ensure
|
||||
not error_handler.has_error implies a_voc.has_id and then vocabulary (a_voc.id) /= Void
|
||||
end
|
||||
|
||||
save_term (t: CMS_TERM; voc: CMS_VOCABULARY)
|
||||
-- Insert or update term `t' as part of vocabulary `voc'.
|
||||
save_term (t: CMS_TERM; voc: detachable CMS_VOCABULARY)
|
||||
-- Insert or update term `t' as part of vocabulary `voc' if set.
|
||||
deferred
|
||||
ensure
|
||||
not error_handler.has_error implies t.has_id and then term_by_id (t.id) /= Void
|
||||
end
|
||||
|
||||
remove_term_from_vocabulary (t: CMS_TERM; voc: CMS_VOCABULARY)
|
||||
-- Remove term `t' from vocabulary `voc'.
|
||||
require
|
||||
t_has_id: t.has_id
|
||||
deferred
|
||||
end
|
||||
|
||||
associate_term_with_entity (a_term: CMS_TERM; a_type_name: READABLE_STRING_GENERAL; a_entity: READABLE_STRING_GENERAL)
|
||||
-- Associate term `a_term' with `(a_type_name, a_entity)'.
|
||||
require
|
||||
|
||||
@@ -53,6 +53,21 @@ feature -- Access
|
||||
do
|
||||
end
|
||||
|
||||
vocabularies_for_term (a_term: CMS_TERM): detachable CMS_VOCABULARY_COLLECTION
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
is_term_inside_vocabulary (a_term: CMS_TERM; a_vocab: CMS_VOCABULARY): BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
types_associated_with_vocabulary (a_vocab: CMS_VOCABULARY): detachable LIST [READABLE_STRING_32]
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
terms_count: INTEGER_64
|
||||
-- Number of terms.
|
||||
do
|
||||
@@ -78,25 +93,32 @@ feature -- Access
|
||||
do
|
||||
end
|
||||
|
||||
entities_associated_with_term (a_term: CMS_TERM): detachable LIST [TUPLE [entity: READABLE_STRING_32; type: detachable READABLE_STRING_32]]
|
||||
entities_associated_with_term (a_term: CMS_TERM): detachable LIST [TUPLE [entity: READABLE_STRING_32; typename: detachable READABLE_STRING_32]]
|
||||
-- Entities and related typename associated with `a_term'.
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Store
|
||||
|
||||
save_vocabulary (a_voc: CMS_VOCABULARY)
|
||||
-- Insert or update vocabulary `a_voc'.
|
||||
save_vocabulary (a_voc: CMS_VOCABULARY; a_with_terms: BOOLEAN)
|
||||
-- Insert or update vocabulary `a_voc'
|
||||
-- and also save {CMS_VOCABULARY}.terms if `a_with_terms' is True.
|
||||
do
|
||||
error_handler.add_custom_error (-1, "not implemented", "save_vocabulary")
|
||||
end
|
||||
|
||||
save_term (t: CMS_TERM; voc: CMS_VOCABULARY)
|
||||
save_term (t: CMS_TERM; voc: detachable CMS_VOCABULARY)
|
||||
-- <Precursor>
|
||||
do
|
||||
error_handler.add_custom_error (-1, "not implemented", "save_term")
|
||||
end
|
||||
|
||||
remove_term_from_vocabulary (t: CMS_TERM; voc: CMS_VOCABULARY)
|
||||
-- Remove term `t' from vocabulary `voc'.
|
||||
do
|
||||
error_handler.add_custom_error (-1, "not implemented", "remove_term_from_vocabulary")
|
||||
end
|
||||
|
||||
associate_term_with_entity (a_term: CMS_TERM; a_type_name: READABLE_STRING_GENERAL; a_entity: READABLE_STRING_GENERAL)
|
||||
do
|
||||
error_handler.add_custom_error (-1, "not implemented", "associate_term_with_entity")
|
||||
|
||||
@@ -198,7 +198,7 @@ feature -- Access
|
||||
end
|
||||
end
|
||||
|
||||
entities_associated_with_term (a_term: CMS_TERM): detachable LIST [TUPLE [entity: READABLE_STRING_32; type: detachable READABLE_STRING_32]]
|
||||
entities_associated_with_term (a_term: CMS_TERM): detachable LIST [TUPLE [entity: READABLE_STRING_32; typename: detachable READABLE_STRING_32]]
|
||||
-- Entities and related typename associated with `a_term'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
@@ -211,7 +211,7 @@ feature -- Access
|
||||
sql_query (sql_select_entity_and_type_by_term, l_parameters)
|
||||
|
||||
if not has_error then
|
||||
create {ARRAYED_LIST [TUPLE [entity: READABLE_STRING_32; type: detachable READABLE_STRING_32]]} Result.make (0)
|
||||
create {ARRAYED_LIST [TUPLE [entity: READABLE_STRING_32; typename: detachable READABLE_STRING_32]]} Result.make (0)
|
||||
from
|
||||
sql_start
|
||||
until
|
||||
@@ -232,21 +232,41 @@ feature -- Access
|
||||
|
||||
feature -- Store
|
||||
|
||||
save_vocabulary (voc: CMS_VOCABULARY)
|
||||
save_vocabulary (voc: CMS_VOCABULARY; a_with_terms: BOOLEAN)
|
||||
local
|
||||
l_terms: CMS_TERM_COLLECTION
|
||||
do
|
||||
save_term (voc, create {CMS_VOCABULARY}.make_none)
|
||||
across
|
||||
voc.terms as ic
|
||||
until
|
||||
has_error
|
||||
loop
|
||||
save_term (ic.item, voc)
|
||||
|
||||
if a_with_terms then
|
||||
l_terms := terms (voc, 0, 0)
|
||||
across
|
||||
voc.terms as ic
|
||||
until
|
||||
has_error
|
||||
loop
|
||||
if attached l_terms.term_by_id (ic.item.id) as t then
|
||||
-- Already contained.
|
||||
-- Remove from `l_terms' to leave only terms to remove.
|
||||
l_terms.remove (t)
|
||||
else
|
||||
save_term (ic.item, voc)
|
||||
end
|
||||
end
|
||||
across
|
||||
l_terms as ic
|
||||
until
|
||||
has_error
|
||||
loop
|
||||
remove_term_from_vocabulary (ic.item, voc)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
save_term (t: CMS_TERM; voc: CMS_VOCABULARY)
|
||||
save_term (t: CMS_TERM; voc: detachable CMS_VOCABULARY)
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
l_insert_voc: BOOLEAN
|
||||
do
|
||||
error_handler.reset
|
||||
|
||||
@@ -255,6 +275,8 @@ feature -- Store
|
||||
l_parameters.put (t.description, "description")
|
||||
l_parameters.put (t.weight, "weight")
|
||||
|
||||
l_insert_voc := voc /= Void and then is_term_inside_vocabulary (t, voc)
|
||||
|
||||
sql_begin_transaction
|
||||
if t.has_id then
|
||||
l_parameters.put (t.id, "tid")
|
||||
@@ -263,9 +285,18 @@ feature -- Store
|
||||
sql_insert (sql_insert_term, l_parameters)
|
||||
t.set_id (last_inserted_term_id)
|
||||
end
|
||||
if not has_error then
|
||||
if
|
||||
not has_error and
|
||||
voc /= Void and then
|
||||
not l_insert_voc
|
||||
then
|
||||
l_parameters.wipe_out
|
||||
l_parameters.put (t.id, "tid")
|
||||
l_parameters.put (voc.id, "parent_tid")
|
||||
if voc.has_id then
|
||||
l_parameters.put (voc.id, "parent_tid")
|
||||
else
|
||||
l_parameters.put (0, "parent_tid")
|
||||
end
|
||||
sql_insert (sql_insert_term_in_vocabulary, l_parameters)
|
||||
end
|
||||
if has_error then
|
||||
@@ -276,6 +307,19 @@ feature -- Store
|
||||
sql_finalize
|
||||
end
|
||||
|
||||
remove_term_from_vocabulary (t: CMS_TERM; voc: CMS_VOCABULARY)
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (t.id, "tid")
|
||||
l_parameters.put (voc.id, "parent_tid")
|
||||
sql_modify (sql_remove_term_from_vocabulary, l_parameters)
|
||||
sql_finalize
|
||||
end
|
||||
|
||||
associate_term_with_entity (a_term: CMS_TERM; a_type_name: READABLE_STRING_GENERAL; a_entity: READABLE_STRING_GENERAL)
|
||||
-- Associate term `a_term' with `(a_type_name, a_entity)'.
|
||||
local
|
||||
@@ -376,6 +420,90 @@ feature -- Vocabulary and types
|
||||
end
|
||||
end
|
||||
|
||||
is_term_inside_vocabulary (a_term: CMS_TERM; a_voc: CMS_VOCABULARY): BOOLEAN
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (a_term.id, "tid")
|
||||
l_parameters.put (a_voc.id, "parent_tid")
|
||||
sql_query (sql_select_term_in_vocabulary, l_parameters)
|
||||
sql_start
|
||||
if not has_error or sql_after then
|
||||
Result := sql_read_integer_64 (1) > 0
|
||||
end
|
||||
sql_finalize
|
||||
end
|
||||
|
||||
vocabularies_for_term (a_term: CMS_TERM): detachable CMS_VOCABULARY_COLLECTION
|
||||
-- <Precursor>
|
||||
local
|
||||
voc: detachable CMS_VOCABULARY
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
l_parent_id: INTEGER_64
|
||||
l_ids: ARRAYED_LIST [INTEGER_64]
|
||||
do
|
||||
error_handler.reset
|
||||
|
||||
create l_parameters.make (3)
|
||||
l_parameters.put (a_term.id, "tid")
|
||||
sql_query (sql_select_vocabularies_for_term, l_parameters)
|
||||
|
||||
create l_ids.make (1)
|
||||
from
|
||||
sql_start
|
||||
until
|
||||
sql_after or has_error
|
||||
loop
|
||||
l_parent_id := sql_read_integer_64 (1)
|
||||
l_ids.force (l_parent_id)
|
||||
sql_forth
|
||||
end
|
||||
sql_finalize
|
||||
|
||||
if l_ids.count > 0 then
|
||||
create Result.make (1)
|
||||
across
|
||||
l_ids as ic
|
||||
loop
|
||||
voc := vocabulary (ic.item)
|
||||
if voc /= Void then
|
||||
Result.force (voc)
|
||||
end
|
||||
end
|
||||
if Result.count = 0 then
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
types_associated_with_vocabulary (a_vocab: CMS_VOCABULARY): detachable LIST [READABLE_STRING_32]
|
||||
-- Type names associated with `a_vocab'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_vocab.id, "tid")
|
||||
sql_query (sql_select_type_associated_with_vocabulary, l_parameters)
|
||||
|
||||
create {ARRAYED_LIST [READABLE_STRING_32]} Result.make (3)
|
||||
from
|
||||
sql_start
|
||||
until
|
||||
sql_after or has_error
|
||||
loop
|
||||
if attached sql_read_string_32 (1) as l_typename then
|
||||
Result.force (l_typename)
|
||||
end
|
||||
sql_forth
|
||||
end
|
||||
sql_finalize
|
||||
end
|
||||
|
||||
associate_vocabulary_with_type (a_voc: CMS_VOCABULARY; a_type_name: READABLE_STRING_GENERAL)
|
||||
-- <Precursor>
|
||||
local
|
||||
@@ -396,10 +524,17 @@ feature -- Vocabulary and types
|
||||
i := i | mask_is_required
|
||||
end
|
||||
l_parameters.put ((- i).out, "entity")
|
||||
|
||||
l_parameters.put (a_type_name, "type")
|
||||
|
||||
sql_insert (sql_insert_term_index, l_parameters)
|
||||
if
|
||||
attached vocabularies_for_type (a_type_name) as lst and then
|
||||
across lst as ic some a_voc.id = ic.item.id end
|
||||
then
|
||||
sql_modify (sql_update_term_index, l_parameters)
|
||||
else
|
||||
sql_insert (sql_insert_term_index, l_parameters)
|
||||
end
|
||||
|
||||
sql_finalize
|
||||
end
|
||||
|
||||
@@ -464,6 +599,20 @@ feature {NONE} -- Queries
|
||||
]"
|
||||
-- Terms under :parent_tid.
|
||||
|
||||
sql_select_vocabularies_for_term: STRING = "[
|
||||
SELECT parent
|
||||
FROM taxonomy_hierarchy
|
||||
WHERE tid = :tid
|
||||
;
|
||||
]"
|
||||
|
||||
sql_select_term_in_vocabulary: STRING = "[
|
||||
SELECT count(*)
|
||||
FROM taxonomy_hierarchy
|
||||
WHERE tid = :tid and parent = :parent_tid
|
||||
;
|
||||
]"
|
||||
|
||||
sql_select_terms_with_range: STRING = "[
|
||||
SELECT taxonomy_term.tid, taxonomy_term.text, taxonomy_term.weight, taxonomy_term.description
|
||||
FROM taxonomy_term INNER JOIN taxonomy_hierarchy ON taxonomy_term.tid = taxonomy_hierarchy.tid
|
||||
@@ -505,6 +654,10 @@ feature {NONE} -- Queries
|
||||
VALUES (:tid, :parent_tid);
|
||||
]"
|
||||
|
||||
sql_remove_term_from_vocabulary: STRING = "[
|
||||
DELETE FROM taxonomy_hierarchy WHERE tid=:tid AND parent=:parent_tid;
|
||||
]"
|
||||
|
||||
sql_select_terms_of_entity: STRING = "[
|
||||
SELECT tid FROM taxonomy_index WHERE type=:type AND entity=:entity;
|
||||
]"
|
||||
@@ -527,6 +680,19 @@ feature {NONE} -- Queries
|
||||
WHERE type=:type AND entity <= 0;
|
||||
]"
|
||||
|
||||
sql_select_type_associated_with_vocabulary: STRING = "[
|
||||
SELECT type
|
||||
FROM taxonomy_index
|
||||
WHERE tid=:tid AND entity <= 0;
|
||||
]"
|
||||
|
||||
sql_update_term_index: STRING = "[
|
||||
UPDATE taxonomy_index
|
||||
SET entity=:entity
|
||||
WHERE tid=:tid and type=:type
|
||||
;
|
||||
]"
|
||||
|
||||
sql_insert_term_index: STRING = "[
|
||||
INSERT INTO taxonomy_index (tid, entity, type)
|
||||
VALUES (:tid, :entity, :type);
|
||||
|
||||
@@ -19,3 +19,8 @@ ul.taxonomy li:hover {
|
||||
border-bottom: solid 1px #66f;
|
||||
background-color: #ddf;
|
||||
}
|
||||
|
||||
table.taxonomy td {
|
||||
border: solid 1px #ccc;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
@@ -19,3 +19,9 @@ ul.taxonomy {
|
||||
}
|
||||
}
|
||||
}
|
||||
table.taxonomy {
|
||||
td {
|
||||
border: solid 1px #ccc;
|
||||
padding: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-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_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<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="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_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension.ecf" readonly="false"/>
|
||||
|
||||
@@ -16,28 +16,25 @@ inherit
|
||||
|
||||
feature -- Hook
|
||||
|
||||
auto_subscribe_to_hooks (a_response: CMS_RESPONSE)
|
||||
local
|
||||
l_manager: CMS_HOOK_CORE_MANAGER
|
||||
auto_subscribe_to_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
do
|
||||
l_manager := a_response.hooks
|
||||
if attached {CMS_HOOK_MENU_SYSTEM_ALTER} Current as h_menu_system_alter then
|
||||
l_manager.subscribe_to_menu_system_alter_hook (h_menu_system_alter)
|
||||
a_hooks.subscribe_to_menu_system_alter_hook (h_menu_system_alter)
|
||||
end
|
||||
if attached {CMS_HOOK_MENU_ALTER} Current as h_menu_alter then
|
||||
l_manager.subscribe_to_menu_alter_hook (h_menu_alter)
|
||||
a_hooks.subscribe_to_menu_alter_hook (h_menu_alter)
|
||||
end
|
||||
if attached {CMS_HOOK_BLOCK} Current as h_block then
|
||||
l_manager.subscribe_to_block_hook (h_block)
|
||||
a_hooks.subscribe_to_block_hook (h_block)
|
||||
end
|
||||
if attached {CMS_HOOK_FORM_ALTER} Current as h_form then
|
||||
l_manager.subscribe_to_form_alter_hook (h_form)
|
||||
a_hooks.subscribe_to_form_alter_hook (h_form)
|
||||
end
|
||||
if attached {CMS_HOOK_VALUE_TABLE_ALTER} Current as h_value then
|
||||
l_manager.subscribe_to_value_table_alter_hook (h_value)
|
||||
a_hooks.subscribe_to_value_table_alter_hook (h_value)
|
||||
end
|
||||
if attached {CMS_HOOK_RESPONSE_ALTER} Current as h_resp then
|
||||
l_manager.subscribe_to_response_alter_hook (h_resp)
|
||||
a_hooks.subscribe_to_response_alter_hook (h_resp)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ feature -- Basic operation
|
||||
|
||||
prepare (a_response: CMS_RESPONSE)
|
||||
do
|
||||
a_response.hooks.invoke_form_alter (Current, Void, a_response)
|
||||
a_response.api.hooks.invoke_form_alter (Current, Void, a_response)
|
||||
end
|
||||
|
||||
process (a_response: CMS_RESPONSE)
|
||||
@@ -29,7 +29,7 @@ feature -- Basic operation
|
||||
|
||||
on_prepared (a_response: CMS_RESPONSE; fd: WSF_FORM_DATA)
|
||||
do
|
||||
a_response.hooks.invoke_form_alter (Current, fd, a_response)
|
||||
a_response.api.hooks.invoke_form_alter (Current, fd, a_response)
|
||||
end
|
||||
|
||||
on_processed (a_response: CMS_RESPONSE; fd: WSF_FORM_DATA)
|
||||
|
||||
@@ -9,7 +9,7 @@ class
|
||||
inherit
|
||||
CMS_MODULE
|
||||
redefine
|
||||
register_hooks
|
||||
setup_hooks
|
||||
end
|
||||
|
||||
CMS_HOOK_BLOCK
|
||||
@@ -47,11 +47,11 @@ feature -- Router
|
||||
|
||||
feature -- Hooks configuration
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- Module hooks configuration.
|
||||
do
|
||||
auto_subscribe_to_hooks (a_response)
|
||||
a_response.hooks.subscribe_to_block_hook (Current)
|
||||
auto_subscribe_to_hooks (a_hooks)
|
||||
a_hooks.subscribe_to_block_hook (Current)
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
@@ -71,7 +71,7 @@ feature -- Hooks
|
||||
create s.make_empty
|
||||
dbg.append_information_to (a_response.request, a_response.response, s)
|
||||
append_info_to ("Storage", a_response.api.storage.generator, a_response, s)
|
||||
create b.make ("debug-info", "Debug", s, a_response.formats.plain_text)
|
||||
create b.make ("debug-info", "Debug", s, a_response.api.formats.plain_text)
|
||||
b.add_condition (create {CMS_BLOCK_EXPRESSION_CONDITION}.make_none)
|
||||
a_response.add_block (b, "footer")
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ inherit
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
CMS_ENCODERS
|
||||
CMS_REQUEST_UTIL
|
||||
|
||||
create
|
||||
make
|
||||
@@ -28,6 +28,7 @@ feature {NONE} -- Initialize
|
||||
setup := a_setup
|
||||
create error_handler.make
|
||||
create {CMS_ENV_LOGGER} logger.make
|
||||
create hooks.make
|
||||
initialize
|
||||
ensure
|
||||
setup_set: setup = a_setup
|
||||
@@ -88,12 +89,15 @@ feature {NONE} -- Initialize
|
||||
l_enabled_modules.remove (ic.item)
|
||||
end
|
||||
end
|
||||
-- Initialize hooks system
|
||||
setup_hooks
|
||||
end
|
||||
|
||||
initialize_content_types
|
||||
-- Initialize content types.
|
||||
do
|
||||
create content_types.make (1)
|
||||
create content_type_webform_managers.make (1)
|
||||
end
|
||||
|
||||
initialize_formats
|
||||
@@ -190,6 +194,38 @@ feature -- Content
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Content type webform
|
||||
|
||||
content_type_webform_managers: ARRAYED_LIST [CMS_CONTENT_TYPE_WEBFORM_MANAGER [CMS_CONTENT]]
|
||||
-- Available content types
|
||||
|
||||
add_content_type_webform_manager (a_manager: CMS_CONTENT_TYPE_WEBFORM_MANAGER [CMS_CONTENT])
|
||||
-- Register webform manager `a_manager'.
|
||||
do
|
||||
content_type_webform_managers.force (a_manager)
|
||||
end
|
||||
|
||||
content_type_webform_manager (a_content_type: CMS_CONTENT_TYPE): detachable CMS_CONTENT_TYPE_WEBFORM_MANAGER [CMS_CONTENT]
|
||||
-- Web form manager for content type `a_content_type' if any.
|
||||
do
|
||||
Result := content_type_webform_manager_by_name (a_content_type.name)
|
||||
end
|
||||
|
||||
content_type_webform_manager_by_name (a_content_type_name: READABLE_STRING_GENERAL): detachable CMS_CONTENT_TYPE_WEBFORM_MANAGER [CMS_CONTENT]
|
||||
-- Web form manager for content type named `a_content_type_name' if any.
|
||||
do
|
||||
across
|
||||
content_type_webform_managers as ic
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
Result := ic.item
|
||||
if not a_content_type_name.is_case_insensitive_equal (Result.name) then
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Formats
|
||||
|
||||
formats: CMS_FORMATS
|
||||
@@ -356,9 +392,37 @@ feature -- Query: module
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
hooks: CMS_HOOK_CORE_MANAGER
|
||||
-- Manager handling hook subscriptions.
|
||||
|
||||
feature {NONE} -- Hooks
|
||||
|
||||
setup_hooks
|
||||
-- Set up CMS hooks.
|
||||
--| Each module has to opportunity to subscribe to various hooks.
|
||||
local
|
||||
l_module: CMS_MODULE
|
||||
l_hooks: like hooks
|
||||
do
|
||||
l_hooks := hooks
|
||||
setup_core_hooks (l_hooks)
|
||||
across
|
||||
enabled_modules as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
if attached {CMS_HOOK_AUTO_REGISTER} l_module as l_auto then
|
||||
l_auto.auto_subscribe_to_hooks (l_hooks)
|
||||
end
|
||||
l_module.setup_hooks (l_hooks)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Query: API
|
||||
|
||||
user_api: CMS_USER_API
|
||||
-- API to access user related data.
|
||||
local
|
||||
l_api: like internal_user_api
|
||||
do
|
||||
@@ -372,7 +436,7 @@ feature -- Query: API
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
register_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
setup_core_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- Register hooks associated with the cms core.
|
||||
do
|
||||
a_hooks.subscribe_to_export_hook (Current)
|
||||
|
||||
@@ -136,6 +136,15 @@ feature -- Router
|
||||
feature -- Hooks configuration
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
obsolete
|
||||
"!UNSAFE!: it is highly recommended to update this module and use setup_hooks [Dec/2015]."
|
||||
require
|
||||
is_enabled: is_enabled
|
||||
do
|
||||
setup_hooks (a_response.api.hooks)
|
||||
end
|
||||
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- Module hooks configuration.
|
||||
require
|
||||
is_enabled: is_enabled
|
||||
|
||||
@@ -46,6 +46,26 @@ feature {CMS_API_ACCESS, CMS_MODULE, CMS_API} -- Restricted access
|
||||
Result := cms_api.storage
|
||||
end
|
||||
|
||||
feature -- Bridge to CMS API
|
||||
|
||||
html_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
|
||||
-- `a_string' encoded for html output.
|
||||
do
|
||||
Result := cms_api.html_encoded (a_string)
|
||||
end
|
||||
|
||||
url_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
|
||||
-- `a_string' encoded with percent encoding, mainly used for url.
|
||||
do
|
||||
Result := cms_api.url_encoded (a_string)
|
||||
end
|
||||
|
||||
percent_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
|
||||
-- `a_string' encoded with percent encoding, mainly used for url.
|
||||
do
|
||||
Result := cms_api.percent_encoded (a_string)
|
||||
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)"
|
||||
|
||||
54
src/service/content/cms_content_type_webform_manager.e
Normal file
54
src/service/content/cms_content_type_webform_manager.e
Normal file
@@ -0,0 +1,54 @@
|
||||
note
|
||||
description: "[
|
||||
Html builder for content type `content_type'.
|
||||
This is used to build webform and html output for a specific node, or node content type.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_CONTENT_TYPE_WEBFORM_MANAGER [G -> CMS_CONTENT]
|
||||
|
||||
inherit
|
||||
CMS_API_ACCESS
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_type: like content_type)
|
||||
do
|
||||
content_type := a_type
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
content_type: CMS_CONTENT_TYPE
|
||||
-- Associated content type.
|
||||
|
||||
name: READABLE_STRING_8
|
||||
-- Associated content type name.
|
||||
do
|
||||
Result := content_type.name
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_content_as_html_to (a_content: G; is_teaser: BOOLEAN; a_output: STRING; a_response: detachable CMS_RESPONSE)
|
||||
-- Append `a_content' as html to `a_output', and adapt output according to `is_teaser' (full output, or teaser).
|
||||
-- In the context of optional `a_response'.
|
||||
deferred
|
||||
end
|
||||
|
||||
append_formatted_content_to (a_content: READABLE_STRING_GENERAL; a_format: CONTENT_FORMAT; a_output: STRING)
|
||||
-- Format string `a_content' with format `a_format', and append to `a_output'.
|
||||
do
|
||||
if a_content.is_valid_as_string_8 then
|
||||
a_output.append (a_format.formatted_output (a_content.to_string_8))
|
||||
else
|
||||
a_format.append_formatted_to (a_content, a_output)
|
||||
end
|
||||
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
|
||||
@@ -188,4 +188,7 @@ feature -- Url
|
||||
Result := html_encoded (a_text)
|
||||
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
|
||||
|
||||
@@ -33,8 +33,7 @@ feature {NONE} -- Initialization
|
||||
get_theme
|
||||
create menu_system.make
|
||||
initialize_block_region_settings
|
||||
create hooks.make
|
||||
register_hooks
|
||||
obsolete_register_hooks
|
||||
end
|
||||
|
||||
initialize_site_url
|
||||
@@ -66,20 +65,18 @@ feature {NONE} -- Initialization
|
||||
site_url_ends_with_slash: site_url.ends_with_general ("/")
|
||||
end
|
||||
|
||||
register_hooks
|
||||
obsolete_register_hooks
|
||||
-- Obsolete code to initialize hooks.
|
||||
-- Dangerous, since those hooks would be available only under CMS_RESPONSE context.
|
||||
local
|
||||
l_module: CMS_MODULE
|
||||
l_enabled_modules: CMS_MODULE_COLLECTION
|
||||
do
|
||||
api.register_hooks (hooks)
|
||||
l_enabled_modules := api.enabled_modules
|
||||
across
|
||||
l_enabled_modules as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
if attached {CMS_HOOK_AUTO_REGISTER} l_module as l_auto then
|
||||
l_auto.auto_subscribe_to_hooks (Current)
|
||||
end
|
||||
l_module.register_hooks (Current)
|
||||
end
|
||||
end
|
||||
@@ -752,7 +749,7 @@ feature -- Blocks
|
||||
-- Get blocks provided by modules.
|
||||
do
|
||||
-- Get block from modules, and related alias.
|
||||
hooks.invoke_block (Current)
|
||||
api.hooks.invoke_block (Current)
|
||||
end
|
||||
|
||||
primary_menu_block: detachable CMS_MENU_BLOCK
|
||||
@@ -869,6 +866,11 @@ feature -- Hooks
|
||||
|
||||
hooks: CMS_HOOK_CORE_MANAGER
|
||||
-- Manager handling hook subscriptions.
|
||||
obsolete
|
||||
"Use api.hooks [dec/2015]"
|
||||
do
|
||||
Result := api.hooks
|
||||
end
|
||||
|
||||
feature -- Menu: change
|
||||
|
||||
@@ -981,6 +983,26 @@ feature -- Theme
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Theme helpers
|
||||
|
||||
wsf_theme: WSF_THEME
|
||||
-- WSF Theme from CMS `theme' for Current response.
|
||||
local
|
||||
t: like internal_wsf_theme
|
||||
do
|
||||
t := internal_wsf_theme
|
||||
if t = Void then
|
||||
create {CMS_TO_WSF_THEME} t.make (Current, theme)
|
||||
internal_wsf_theme := t
|
||||
end
|
||||
Result := t
|
||||
end
|
||||
|
||||
feature {NONE} -- Theme helpers
|
||||
|
||||
internal_wsf_theme: detachable WSF_THEME
|
||||
-- Once per object for `wsf_theme'.
|
||||
|
||||
feature -- Element Change
|
||||
|
||||
set_status_code (a_status: INTEGER)
|
||||
@@ -1019,7 +1041,7 @@ feature -- Generation
|
||||
create {CMS_LOCAL_LINK} lnk.make ("Home", "")
|
||||
lnk.set_weight (-10)
|
||||
add_to_primary_menu (lnk)
|
||||
hooks.invoke_menu_system_alter (menu_system, Current)
|
||||
api.hooks.invoke_menu_system_alter (menu_system, Current)
|
||||
|
||||
if api.enabled_modules.count = 0 then
|
||||
add_to_primary_menu (create {CMS_LOCAL_LINK}.make ("Install", "admin/install"))
|
||||
@@ -1077,10 +1099,10 @@ feature -- Generation
|
||||
custom_prepare (page)
|
||||
|
||||
-- Cms response
|
||||
hooks.invoke_response_alter (Current)
|
||||
api.hooks.invoke_response_alter (Current)
|
||||
|
||||
-- Cms values
|
||||
hooks.invoke_value_table_alter (values, Current)
|
||||
api.hooks.invoke_value_table_alter (values, Current)
|
||||
|
||||
-- Predefined values
|
||||
page.register_variable (page, "page") -- DO NOT REMOVE
|
||||
@@ -1251,6 +1273,34 @@ feature -- Generation
|
||||
a_lnk.set_is_forbidden (not has_permission_on_link (a_lnk))
|
||||
end
|
||||
|
||||
feature -- Helpers: cms link
|
||||
|
||||
local_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK
|
||||
do
|
||||
create Result.make (a_title, a_location)
|
||||
end
|
||||
|
||||
user_local_link (u: CMS_USER; a_opt_title: detachable READABLE_STRING_GENERAL): CMS_LOCAL_LINK
|
||||
do
|
||||
if a_opt_title /= Void then
|
||||
create Result.make (a_opt_title, user_url (u))
|
||||
else
|
||||
create Result.make (u.name, user_url (u))
|
||||
end
|
||||
end
|
||||
|
||||
user_html_link (u: CMS_USER): like link
|
||||
do
|
||||
Result := link (u.name, "user/" + u.id.out, Void)
|
||||
end
|
||||
|
||||
user_url (u: CMS_USER): like url
|
||||
require
|
||||
u_with_id: u.has_id
|
||||
do
|
||||
Result := url ("user/" + u.id.out, Void)
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute
|
||||
|
||||
Reference in New Issue
Block a user