Added support for log stored in CMS_STORAGE.
Added support for custom value stored in CMS_STORAGE. Added optional css classes addition to CMS_BLOCK output. Refactored storage, to manage node from node module code only (or mostly). TODO: improved view for a cms node, for now hardcoded.
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Interface defining a CMS content type.
|
||||
]"
|
||||
status: "draft"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_CONTENT_TYPE
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: READABLE_STRING_8
|
||||
-- Internal name.
|
||||
deferred
|
||||
end
|
||||
|
||||
title: READABLE_STRING_32
|
||||
-- Human readable name.
|
||||
deferred
|
||||
end
|
||||
|
||||
description: detachable READABLE_STRING_32
|
||||
-- Optional description
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Factory
|
||||
|
||||
new_node (a_partial_node: detachable CMS_NODE): CMS_NODE
|
||||
-- New node based on partial `a_partial_node', or from none.
|
||||
deferred
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
127
library/model/src/log/cms_log.e
Normal file
127
library/model/src/log/cms_log.e
Normal file
@@ -0,0 +1,127 @@
|
||||
note
|
||||
description: "Summary description for {CMS_LOG}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_LOG
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_category: like category; a_message: like message; a_level: like level; a_date: detachable like date)
|
||||
do
|
||||
category := a_category
|
||||
message := a_message
|
||||
set_level (a_level)
|
||||
if a_date = Void then
|
||||
create date.make_now_utc
|
||||
else
|
||||
date := a_date
|
||||
end
|
||||
end
|
||||
|
||||
make_with_id (a_id: like id; a_category: like category; a_message: like message; a_level: like level; a_date: detachable like date)
|
||||
do
|
||||
id := a_id
|
||||
make (a_category, a_message, a_level, a_date)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
id: INTEGER
|
||||
-- Unique identifier of Current.
|
||||
|
||||
category: READABLE_STRING_8
|
||||
-- Associated title (optional).
|
||||
|
||||
message: READABLE_STRING_8
|
||||
-- Log message
|
||||
|
||||
level: INTEGER
|
||||
-- Severity level
|
||||
|
||||
level_name: STRING
|
||||
do
|
||||
Result := level_to_string (level)
|
||||
end
|
||||
|
||||
info: detachable READABLE_STRING_8
|
||||
|
||||
link: detachable CMS_LINK
|
||||
|
||||
date: DATE_TIME
|
||||
|
||||
feature -- status report
|
||||
|
||||
has_id: BOOLEAN
|
||||
do
|
||||
Result := id > 0
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_id (a_id: like id)
|
||||
require
|
||||
not has_id
|
||||
do
|
||||
id := a_id
|
||||
end
|
||||
|
||||
set_level (a_level: like level)
|
||||
do
|
||||
if a_level = 0 then
|
||||
level := level_notice
|
||||
else
|
||||
level := a_level
|
||||
end
|
||||
end
|
||||
|
||||
set_link (lnk: like link)
|
||||
do
|
||||
link := lnk
|
||||
end
|
||||
|
||||
set_info (inf: like info)
|
||||
do
|
||||
info := inf
|
||||
end
|
||||
|
||||
feature -- Constants
|
||||
|
||||
level_to_string (a_level: INTEGER): STRING
|
||||
do
|
||||
inspect a_level
|
||||
when level_emergency then
|
||||
Result := "emergency"
|
||||
when level_alert then
|
||||
Result := "alert"
|
||||
when level_critical then
|
||||
Result := "critical"
|
||||
when level_error then
|
||||
Result := "error"
|
||||
when level_warning then
|
||||
Result := "warning"
|
||||
when level_notice then
|
||||
Result := "notice"
|
||||
when level_info then
|
||||
Result := "info"
|
||||
when level_debug then
|
||||
Result := "debug"
|
||||
else
|
||||
Result := "level-" + a_level.out
|
||||
end
|
||||
end
|
||||
|
||||
level_emergency: INTEGER = 1
|
||||
level_alert: INTEGER = 2
|
||||
level_critical: INTEGER = 3
|
||||
level_error: INTEGER = 4
|
||||
level_warning: INTEGER = 5
|
||||
level_notice: INTEGER = 6
|
||||
level_info: INTEGER = 7
|
||||
level_debug: INTEGER = 8
|
||||
|
||||
end
|
||||
@@ -10,7 +10,7 @@ deferred class
|
||||
inherit
|
||||
CMS_STORAGE
|
||||
|
||||
CMS_STORAGE_SQL
|
||||
CMS_STORAGE_SQL_I
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_NODE_STORAGE_MYSQL}."
|
||||
author: ""
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
deferred class
|
||||
CMS_NODE_STORAGE_MYSQL
|
||||
|
||||
inherit
|
||||
CMS_NODE_STORAGE_SQL
|
||||
redefine
|
||||
nodes, recent_nodes
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
db_handler: DATABASE_HANDLER
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
nodes: LIST [CMS_NODE]
|
||||
-- List of nodes.
|
||||
do
|
||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||
across nodes_iterator as ic loop
|
||||
if attached ic.item as l_node then
|
||||
Result.force (l_node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
||||
-- List of recent `a_count' nodes with an offset of `lower'.
|
||||
do
|
||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (a_count)
|
||||
across recent_nodes_iterator (a_lower, a_count) as ic loop
|
||||
if attached ic.item as l_node then
|
||||
Result.force (l_node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access: iterator
|
||||
|
||||
nodes_iterator: DATABASE_ITERATION_CURSOR [detachable CMS_NODE]
|
||||
-- List of nodes.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
write_information_log (generator + ".nodes_iterator")
|
||||
create l_parameters.make (0)
|
||||
sql_query (sql_select_nodes, l_parameters)
|
||||
create Result.make (db_handler, agent fetch_node)
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
recent_nodes_iterator (a_lower, a_rows: INTEGER): DATABASE_ITERATION_CURSOR [detachable CMS_NODE]
|
||||
-- The most recent `a_rows'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
l_query: STRING
|
||||
do
|
||||
-- FIXME: check implementation...
|
||||
error_handler.reset
|
||||
write_information_log (generator + ".recent_nodes_iterator")
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (a_rows, "rows")
|
||||
l_parameters.put (a_lower, "offset")
|
||||
create l_query.make_from_string (sql_select_recent_nodes)
|
||||
sql_query (l_query, l_parameters)
|
||||
create Result.make (db_handler, agent fetch_node)
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
end
|
||||
@@ -7,13 +7,11 @@ class
|
||||
CMS_STORAGE_MYSQL
|
||||
|
||||
inherit
|
||||
CMS_STORAGE
|
||||
|
||||
CMS_STORAGE_STORE_SQL
|
||||
|
||||
CMS_USER_STORAGE_MYSQL
|
||||
CMS_CORE_STORAGE_SQL_I
|
||||
|
||||
CMS_NODE_STORAGE_MYSQL
|
||||
CMS_USER_STORAGE_SQL_I
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class
|
||||
CMS_STORAGE_MYSQL_BUILDER
|
||||
|
||||
inherit
|
||||
CMS_STORAGE_BUILDER
|
||||
CMS_STORAGE_SQL_BUILDER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_USER_STORAGE_MYSQL}."
|
||||
author: ""
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
deferred class
|
||||
CMS_USER_STORAGE_MYSQL
|
||||
|
||||
inherit
|
||||
CMS_USER_STORAGE_SQL
|
||||
|
||||
|
||||
end
|
||||
@@ -1,77 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_NODE_STORAGE_SQLITE}."
|
||||
author: ""
|
||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision: "$Revision: 96616 $"
|
||||
|
||||
deferred class
|
||||
CMS_NODE_STORAGE_SQLITE
|
||||
|
||||
inherit
|
||||
CMS_NODE_STORAGE_SQL
|
||||
redefine
|
||||
nodes, recent_nodes
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
db_handler: DATABASE_HANDLER
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
nodes: LIST [CMS_NODE]
|
||||
-- List of nodes.
|
||||
do
|
||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||
across nodes_iterator as ic loop
|
||||
if attached ic.item as l_node then
|
||||
Result.force (l_node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
||||
-- List of recent `a_count' nodes with an offset of `lower'.
|
||||
do
|
||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (a_count)
|
||||
across recent_nodes_iterator (a_lower, a_count) as ic loop
|
||||
if attached ic.item as l_node then
|
||||
Result.force (l_node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access: iterator
|
||||
|
||||
nodes_iterator: DATABASE_ITERATION_CURSOR [detachable CMS_NODE]
|
||||
-- List of nodes.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
write_information_log (generator + ".nodes_iterator")
|
||||
create l_parameters.make (0)
|
||||
sql_query (sql_select_nodes, l_parameters)
|
||||
create Result.make (db_handler, agent fetch_node)
|
||||
end
|
||||
|
||||
recent_nodes_iterator (a_lower, a_rows: INTEGER): DATABASE_ITERATION_CURSOR [detachable CMS_NODE]
|
||||
-- The most recent `a_rows'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
l_query: STRING
|
||||
do
|
||||
-- FIXME: check implementation...
|
||||
error_handler.reset
|
||||
write_information_log (generator + ".recent_nodes_iterator")
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (a_rows, "rows")
|
||||
l_parameters.put (a_lower, "offset")
|
||||
create l_query.make_from_string (sql_select_recent_nodes)
|
||||
sql_query (l_query, l_parameters)
|
||||
create Result.make (db_handler, agent fetch_node)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -7,13 +7,11 @@ class
|
||||
CMS_STORAGE_SQLITE
|
||||
|
||||
inherit
|
||||
CMS_STORAGE
|
||||
|
||||
CMS_STORAGE_STORE_SQL
|
||||
|
||||
CMS_USER_STORAGE_SQLITE
|
||||
CMS_CORE_STORAGE_SQL_I
|
||||
|
||||
CMS_NODE_STORAGE_SQLITE
|
||||
CMS_USER_STORAGE_SQL_I
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
@@ -27,5 +25,5 @@ feature -- Status report
|
||||
do
|
||||
Result := has_user
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ class
|
||||
CMS_STORAGE_SQLITE_BUILDER
|
||||
|
||||
inherit
|
||||
CMS_STORAGE_BUILDER
|
||||
CMS_STORAGE_SQL_BUILDER
|
||||
|
||||
create
|
||||
make
|
||||
@@ -66,6 +66,11 @@ feature -- Factory
|
||||
r.add_permission ("create page")
|
||||
r.add_permission ("edit page")
|
||||
a_storage.save_user_role (r)
|
||||
|
||||
-- Test custom value
|
||||
|
||||
a_storage.set_custom_value ("abc", "123", "test")
|
||||
a_storage.set_custom_value ("abc", "OK", "test")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_USER_STORAGE_SQLITE}."
|
||||
author: ""
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
deferred class
|
||||
CMS_USER_STORAGE_SQLITE
|
||||
|
||||
inherit
|
||||
CMS_USER_STORAGE_SQL
|
||||
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user