Added weight into to the CMS_LINK and provide a `sort' feature for CMS_MENU and related.

Protected cms service from registering many time the same module type.
Moved library/persistence/implementation/* under library/persistence/.
Moved site/www/themes to site/themes
For SQLite storage driver, auto create sqlite db file using associated sql script (to be completed).
Added code in demo module to reuse storage for module purpose.
Always call sql_post_execution in sql_query and sql_change, and not anymore by the callers.
Removed is_web and is_html from {CMS_SETUP}, it was not used.
Reused SHARED_*_ENCODER in CMS_ENCODERS
Added CMS_API.logger rather than using directly the SHARED_LOGGER.log ...
Centralize the implementation of current_user in CMS_REQUEST_UTIL
Removed the inheritance on WSF_FILTER for node handlers, since it is useless and unused.
Added CMS_NODE_API and CMS_USER_API
Prefix html id for block generated html items with "block-", to avoid css name conflict on "main", "content" or similar.
Code cleaning
This commit is contained in:
2015-02-16 13:01:06 +01:00
parent a810b1176c
commit 8d59d25ace
165 changed files with 1430 additions and 2206 deletions

View File

@@ -0,0 +1,75 @@
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
Result.force (ic.item)
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 c loop
Result.force (c.item)
end
end
feature -- Access: iterator
nodes_iterator: DATABASE_ITERATION_CURSOR [CMS_NODE]
-- List of nodes.
local
l_parameters: STRING_TABLE [ANY]
do
error_handler.reset
log.write_information (generator + ".nodes_iterator")
create l_parameters.make (0)
sql_query (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 [CMS_NODE]
-- The most recent `a_rows'.
local
l_parameters: STRING_TABLE [ANY]
l_query: STRING
do
-- FIXME: check implementation...
error_handler.reset
log.write_information (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 (select_recent_nodes)
sql_query (l_query, l_parameters)
create Result.make (db_handler, agent fetch_node)
sql_post_execution
end
end

View File

@@ -0,0 +1,31 @@
note
description: "Summary description for {CMS_STORAGE_MYSQL}."
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
revision: "$Revision: 96596 $"
class
CMS_STORAGE_MYSQL
inherit
CMS_STORAGE
CMS_STORAGE_STORE_SQL
CMS_USER_STORAGE_MYSQL
CMS_NODE_STORAGE_MYSQL
REFACTORING_HELPER
create
make
feature -- Status report
is_initialized: BOOLEAN
-- Is storage initialized?
do
Result := has_user
end
end

View File

@@ -0,0 +1,40 @@
note
description: "[
Objects that ...
]"
author: "$Author: jfiat $"
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
revision: "$Revision: 96542 $"
class
CMS_STORAGE_MYSQL_BUILDER
inherit
CMS_STORAGE_BUILDER
create
make
feature {NONE} -- Initialization
make
-- Initialize `Current'.
do
end
feature -- Factory
storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_MYSQL
local
conn: DATABASE_CONNECTION
do
if attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (a_setup.layout.application_config_path) as l_database_config then
create {DATABASE_CONNECTION_MYSQL} conn.login_with_connection_string (l_database_config.connection_string)
if conn.is_connected then
create Result.make (conn)
end
end
end
end

View File

@@ -0,0 +1,14 @@
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

View File

@@ -0,0 +1,140 @@
note
description: "Object that handle a database connection for ODBC"
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
revision: "$Revision: 95678 $"
class
DATABASE_CONNECTION_MYSQL
inherit
DATABASE_CONNECTION
redefine
db_application
end
create
make, make_common, make_basic, login_with_connection_string, login_with_schema
feature -- Initialization
make_common
-- Create a database handler for MYSQL with common settings.
local
l_retried: BOOLEAN
do
create database_error_handler.make
create db_application.login (username, password)
if not l_retried then
db_application.set_hostname (hostname)
db_application.set_data_source (database_name)
db_application.set_base
create db_control.make
keep_connection := is_keep_connection
if keep_connection then
connect
end
else
create db_control.make
end
rescue
create database_error_handler.make
exception_as_error ((create {EXCEPTION_MANAGER}).last_exception)
l_retried := True
retry
end
make_basic (a_database_name: STRING)
-- Create a database handler and
-- set database_name to `a_database_name'.
local
l_retried: BOOLEAN
do
create database_error_handler.make
create db_application.login (username, password)
if not l_retried then
db_application.set_hostname (hostname)
db_application.set_data_source (a_database_name)
db_application.set_base
create db_control.make
keep_connection := is_keep_connection
if keep_connection then
connect
end
else
create db_control.make
end
rescue
create database_error_handler.make
exception_as_error ((create {EXCEPTION_MANAGER}).last_exception)
l_retried := True
retry
end
make (a_username: STRING; a_password: STRING; a_hostname: STRING; a_database_name: STRING; connection: BOOLEAN)
-- Create a database handler for ODBC and set `username' to `a_username',
-- `password' to `a_password'
-- `database_name' to `a_database_name'
-- `connection' to `a_connection'
do
create database_error_handler.make
create db_application.login (a_username, a_password)
db_application.set_hostname (a_hostname)
db_application.set_data_source (a_database_name)
db_application.set_base
create db_control.make
keep_connection := connection
if keep_connection then
connect
end
end
login_with_connection_string (a_string: STRING)
-- Login with `a_connection_string'and immediately connect to database.
local
l_string: LIST[STRING]
l_server: STRING
l_port: STRING
l_schema: STRING
l_user: STRING
l_password: STRING
do
create database_error_handler.make
l_string := a_string.split (';')
l_server := l_string.at (2).split ('=').at (2)
l_port := l_string.at (3).split ('=').at (2)
l_schema := l_string.at (4).split ('=').at (2)
l_user := l_string.at (5).split ('=').at (2)
l_password := l_string.at (6).split ('=').at (2)
create db_application
db_application.set_application (l_schema)
db_application.set_hostname (l_server + ":" + l_port)
db_application.login_and_connect (l_user, l_password)
db_application.set_base
create db_control.make
keep_connection := is_keep_connection
end
login_with_schema (a_schema: STRING; a_username: STRING; a_password: STRING)
-- Login with `a_connection_string'and immediately connect to database.
do
create database_error_handler.make
create db_application
db_application.set_application (a_schema)
db_application.login_and_connect (a_username, a_password)
db_application.set_base
create db_control.make
keep_connection := is_keep_connection
end
feature -- Databse Connection
db_application: DATABASE_APPL [MYSQL]
-- Database application.
end