Added support for OpenID identity
Added user roles management Improvement CMS_HOOK_FORM_ALTER design. Factorized code into CMS_WIDGET_COMPOSITE Use general notion of CMS_WIDGET (and CMS_FORM allows CMS_WIDGET, and not just CMS_FORM_ITEM) Fixed various CMS_WIDGET traversal, and fixed related issue for CMS forms Fixed CMS_FORM_CHECKBOX_INPUT when no value was set. Added CMS_FORM_DATA.cached_value .. to pass computed values during validation to submit actions (mainly for optimization) Added support for @include=filename in CMS_CONFIGURATION Added CMS_WIDGET_TABLE as filled version of CMS_WIDGET_AGENT_TABLE (renamed from previous CMS_WIDGET_TABLE) Many improvements to the CMS_FORM design Some improvements to CMS_MODULE ...
This commit is contained in:
@@ -16,7 +16,8 @@ create
|
||||
|
||||
convert
|
||||
make_from_manifest ({ ARRAY [TUPLE [key: STRING; value: detachable ANY]],
|
||||
ARRAY [TUPLE [STRING_8, ARRAY [TUPLE [STRING_8, READABLE_STRING_32]]]]
|
||||
ARRAY [TUPLE [STRING_8, ARRAY [TUPLE [STRING_8, STRING_32]]]],
|
||||
ARRAY [TUPLE [STRING_8, ARRAY [TUPLE [STRING_8, STRING_8]]]]
|
||||
})
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
@@ -63,6 +63,41 @@ feature -- Access
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Permission
|
||||
|
||||
roles: detachable LIST [INTEGER]
|
||||
-- Associated roles
|
||||
-- Note: does not include "authenticated" and "anonymous".
|
||||
|
||||
has_role (r: CMS_USER_ROLE): BOOLEAN
|
||||
do
|
||||
Result := attached roles as lst and then lst.has (r.id)
|
||||
end
|
||||
|
||||
clear_roles
|
||||
do
|
||||
roles := Void
|
||||
end
|
||||
|
||||
add_role_by_id (r_id: INTEGER)
|
||||
local
|
||||
lst: like roles
|
||||
do
|
||||
lst := roles
|
||||
if r_id <= 2 then -- Anonymous=1 and Authenticated=2
|
||||
lst := roles
|
||||
if lst /= Void and then lst.is_empty then
|
||||
clear_roles
|
||||
end
|
||||
else
|
||||
if lst = Void then
|
||||
create {ARRAYED_SET [INTEGER]} lst.make (1)
|
||||
roles := lst
|
||||
end
|
||||
lst.force (r_id)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
has_id: BOOLEAN
|
||||
|
||||
85
draft/application/cms/src/kernel/cms_user_role.e
Normal file
85
draft/application/cms/src/kernel/cms_user_role.e
Normal file
@@ -0,0 +1,85 @@
|
||||
note
|
||||
description: "Summary description for {CMS_USER_ROLE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_USER_ROLE
|
||||
|
||||
inherit
|
||||
ANY
|
||||
redefine
|
||||
is_equal
|
||||
end
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_id
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_with_id (a_id: like id; a_name: like name)
|
||||
do
|
||||
id := a_id
|
||||
make (a_name)
|
||||
end
|
||||
|
||||
make (a_name: like name)
|
||||
do
|
||||
name := a_name
|
||||
create {ARRAYED_LIST [READABLE_STRING_8]} permissions.make (0)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
has_id: BOOLEAN
|
||||
do
|
||||
Result := id > 0
|
||||
end
|
||||
|
||||
has_permission (p: READABLE_STRING_8): BOOLEAN
|
||||
do
|
||||
Result := across permissions as c some c.item.is_case_insensitive_equal (p) end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
id: INTEGER
|
||||
|
||||
name: READABLE_STRING_8
|
||||
|
||||
permissions: LIST [READABLE_STRING_8]
|
||||
|
||||
feature -- Comparison
|
||||
|
||||
same_user_role (r: CMS_USER_ROLE): BOOLEAN
|
||||
do
|
||||
Result := r.id = id
|
||||
end
|
||||
|
||||
is_equal (other: like Current): BOOLEAN
|
||||
-- Is `other' attached to an object considered
|
||||
-- equal to current object?
|
||||
do
|
||||
Result := id = other.id
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_id (a_id: like id)
|
||||
do
|
||||
id := a_id
|
||||
end
|
||||
|
||||
set_name (a_name: like name)
|
||||
do
|
||||
name := a_name
|
||||
end
|
||||
|
||||
add_permission (n: READABLE_STRING_8)
|
||||
do
|
||||
permissions.force (n)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -8,7 +8,7 @@ class
|
||||
CMS_FORM
|
||||
|
||||
inherit
|
||||
ITERABLE [CMS_FORM_ITEM]
|
||||
CMS_FORM_COMPOSITE
|
||||
|
||||
create
|
||||
make
|
||||
@@ -19,10 +19,11 @@ feature {NONE} -- Initialization
|
||||
do
|
||||
action := a_action
|
||||
id := a_id
|
||||
|
||||
initialize_with_count (10)
|
||||
create html_classes.make (2)
|
||||
create items.make (10)
|
||||
set_method_post
|
||||
create validation_actions
|
||||
create submit_actions
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
@@ -33,11 +34,6 @@ feature -- Access
|
||||
id: READABLE_STRING_8
|
||||
-- Id of the form
|
||||
|
||||
count: INTEGER
|
||||
do
|
||||
Result := items.count
|
||||
end
|
||||
|
||||
is_get_method: BOOLEAN
|
||||
do
|
||||
Result := method.same_string ("GET")
|
||||
@@ -52,14 +48,42 @@ feature -- Access
|
||||
-- Form's method
|
||||
--| GET or POST
|
||||
|
||||
feature -- Basic operation
|
||||
|
||||
prepare (a_execution: CMS_EXECUTION)
|
||||
do
|
||||
a_execution.service.call_form_alter_hooks (Current, Void, a_execution)
|
||||
end
|
||||
|
||||
process (a_execution: CMS_EXECUTION)
|
||||
local
|
||||
fd: CMS_FORM_DATA
|
||||
do
|
||||
create fd.make (a_execution.request, Current)
|
||||
last_data := fd
|
||||
a_execution.service.call_form_alter_hooks (Current, fd, a_execution)
|
||||
fd.validate
|
||||
fd.apply_to_associated_form -- Maybe only when has error?
|
||||
if fd.is_valid then
|
||||
fd.submit
|
||||
if fd.has_error then
|
||||
a_execution.report_form_errors (fd)
|
||||
end
|
||||
else
|
||||
a_execution.report_form_errors (fd)
|
||||
end
|
||||
end
|
||||
|
||||
last_data: detachable CMS_FORM_DATA
|
||||
|
||||
feature -- Validation
|
||||
|
||||
validation_action: detachable PROCEDURE [ANY, TUPLE [CMS_FORM_DATA]]
|
||||
validation_actions: ACTION_SEQUENCE [TUPLE [CMS_FORM_DATA]]
|
||||
-- Procedure to validate the data
|
||||
-- report error if not valid
|
||||
|
||||
-- submit_callbacks_actions: HASH_TABLE [PROCEDURE [ANY, TUPLE [CMS_FORM_DATA]], STRING]
|
||||
-- -- Submit callbacks indexed by submit names
|
||||
submit_actions: ACTION_SEQUENCE [TUPLE [CMS_FORM_DATA]]
|
||||
-- Submit actions
|
||||
|
||||
feature -- Element change
|
||||
|
||||
@@ -73,141 +97,10 @@ feature -- Element change
|
||||
method := "POST"
|
||||
end
|
||||
|
||||
set_validation_action (act: like validation_action)
|
||||
do
|
||||
validation_action := act
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: ITERATION_CURSOR [CMS_FORM_ITEM]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
Result := items.new_cursor
|
||||
end
|
||||
|
||||
feature -- Optional
|
||||
|
||||
html_classes: ARRAYED_LIST [STRING_8]
|
||||
|
||||
feature -- Items
|
||||
|
||||
has_field (a_name: READABLE_STRING_GENERAL): BOOLEAN
|
||||
do
|
||||
Result := container_has_field (Current, a_name)
|
||||
end
|
||||
|
||||
fields_by_name (a_name: READABLE_STRING_GENERAL): detachable LIST [CMS_FORM_FIELD]
|
||||
do
|
||||
Result := fields_by_name_from (Current, a_name)
|
||||
end
|
||||
|
||||
items_by_css_id (a_id: READABLE_STRING_GENERAL): detachable LIST [CMS_FORM_ITEM]
|
||||
do
|
||||
Result := items_by_css_id_from (Current, a_id)
|
||||
end
|
||||
|
||||
first_item_by_css_id (a_id: READABLE_STRING_GENERAL): detachable CMS_FORM_ITEM
|
||||
do
|
||||
if attached items_by_css_id_from (Current, a_id) as lst then
|
||||
if not lst.is_empty then
|
||||
Result := lst.first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation: Items
|
||||
|
||||
container_has_field (a_container: ITERABLE [CMS_FORM_ITEM]; a_name: READABLE_STRING_GENERAL): BOOLEAN
|
||||
do
|
||||
across
|
||||
a_container as i
|
||||
until
|
||||
Result
|
||||
loop
|
||||
if attached {CMS_FORM_FIELD} i.item as l_field and then l_field.name.same_string_general (a_name) then
|
||||
Result := True
|
||||
elseif attached {ITERABLE [CMS_FORM_ITEM]} i.item as l_cont then
|
||||
Result := container_has_field (l_cont, a_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
fields_by_name_from (a_container: ITERABLE [CMS_FORM_ITEM]; a_name: READABLE_STRING_GENERAL): detachable ARRAYED_LIST [CMS_FORM_FIELD]
|
||||
local
|
||||
res: detachable ARRAYED_LIST [CMS_FORM_FIELD]
|
||||
do
|
||||
across
|
||||
a_container as i
|
||||
loop
|
||||
if attached {CMS_FORM_FIELD} i.item as l_field and then l_field.name.same_string_general (a_name) then
|
||||
if res = Void then
|
||||
create res.make (1)
|
||||
end
|
||||
res.force (l_field)
|
||||
elseif attached {ITERABLE [CMS_FORM_ITEM]} i.item as l_cont then
|
||||
if attached fields_by_name_from (l_cont, a_name) as lst then
|
||||
if res = Void then
|
||||
res := lst
|
||||
else
|
||||
res.append (lst)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Result := res
|
||||
end
|
||||
|
||||
items_by_css_id_from (a_container: ITERABLE [CMS_FORM_ITEM]; a_id: READABLE_STRING_GENERAL): detachable ARRAYED_LIST [CMS_FORM_ITEM]
|
||||
local
|
||||
res: detachable ARRAYED_LIST [CMS_FORM_ITEM]
|
||||
do
|
||||
across
|
||||
a_container as i
|
||||
loop
|
||||
if
|
||||
attached {WITH_CSS_ID} i.item as l_with_css_id and then
|
||||
attached l_with_css_id.css_id as l_css_id and then
|
||||
l_css_id.same_string_general (a_id)
|
||||
then
|
||||
if res = Void then
|
||||
create res.make (1)
|
||||
end
|
||||
res.force (i.item)
|
||||
elseif attached {ITERABLE [CMS_FORM_ITEM]} i.item as l_cont then
|
||||
if attached items_by_css_id_from (l_cont, a_id) as lst then
|
||||
if res = Void then
|
||||
res := lst
|
||||
else
|
||||
res.append (lst)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Result := res
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
extend (i: CMS_FORM_ITEM)
|
||||
local
|
||||
n: READABLE_STRING_8
|
||||
do
|
||||
if attached {CMS_FORM_FIELD} i as l_field then
|
||||
n := l_field.name
|
||||
if n.is_empty then
|
||||
n := (items.count + 1).out
|
||||
l_field.update_name (n)
|
||||
end
|
||||
end
|
||||
items.force (i)
|
||||
end
|
||||
|
||||
extend_text (t: READABLE_STRING_8)
|
||||
do
|
||||
extend (create {CMS_FORM_RAW_TEXT}.make (t))
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: CMS_THEME; a_html: STRING_8)
|
||||
@@ -242,11 +135,4 @@ feature -- Conversion
|
||||
append_to_html (a_theme, Result)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
items: ARRAYED_LIST [CMS_FORM_ITEM]
|
||||
-- name => item
|
||||
|
||||
invariant
|
||||
|
||||
end
|
||||
|
||||
@@ -62,6 +62,19 @@ feature -- Change
|
||||
checked := b
|
||||
end
|
||||
|
||||
set_checked_by_value (v: detachable WSF_VALUE)
|
||||
do
|
||||
if attached {WSF_STRING} v as s then
|
||||
if value /= Void then
|
||||
set_checked (is_same_value (s.value))
|
||||
else
|
||||
set_checked (s.value.same_string ("on") or s.value.same_string ("true") or s.value.same_string ("yes") or s.value.same_string ("enabled"))
|
||||
end
|
||||
else
|
||||
set_checked (False)
|
||||
end
|
||||
end
|
||||
|
||||
set_value (v: detachable WSF_VALUE)
|
||||
-- Set value `v' if applicable to Current
|
||||
do
|
||||
@@ -69,14 +82,10 @@ feature -- Change
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
if
|
||||
attached {WSF_STRING} c.item as s and then
|
||||
is_same_value (s.value)
|
||||
then
|
||||
set_checked (True)
|
||||
end
|
||||
set_checked_by_value (c.item)
|
||||
end
|
||||
else
|
||||
set_checked_by_value (v)
|
||||
Precursor (v)
|
||||
end
|
||||
end
|
||||
@@ -91,8 +100,8 @@ feature {NONE} -- Implementation
|
||||
a_html.append (t)
|
||||
elseif attached text as t then
|
||||
a_html.append (a_theme.html_encoded (t))
|
||||
elseif attached value as v then
|
||||
a_html.append (a_theme.html_encoded (v))
|
||||
-- elseif attached value as v then
|
||||
-- a_html.append (a_theme.html_encoded (v))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
89
draft/application/cms/src/kernel/form/cms_form_composite.e
Normal file
89
draft/application/cms/src/kernel/form/cms_form_composite.e
Normal file
@@ -0,0 +1,89 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author$"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_FORM_COMPOSITE
|
||||
|
||||
inherit
|
||||
CMS_WIDGET_COMPOSITE
|
||||
redefine
|
||||
extend
|
||||
end
|
||||
|
||||
feature -- Status
|
||||
|
||||
has_field (a_name: READABLE_STRING_GENERAL): BOOLEAN
|
||||
do
|
||||
Result := container_has_field (Current, a_name)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
fields_by_name (a_name: READABLE_STRING_GENERAL): detachable LIST [CMS_FORM_FIELD]
|
||||
do
|
||||
Result := fields_by_name_from (Current, a_name)
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
extend (i: CMS_WIDGET)
|
||||
local
|
||||
n: READABLE_STRING_8
|
||||
do
|
||||
if attached {CMS_FORM_FIELD} i as l_field then
|
||||
n := l_field.name
|
||||
if n.is_empty then
|
||||
n := (items.count + 1).out
|
||||
l_field.update_name (n)
|
||||
end
|
||||
end
|
||||
Precursor (i)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation: Items
|
||||
|
||||
container_has_field (a_container: ITERABLE [CMS_WIDGET]; a_name: READABLE_STRING_GENERAL): BOOLEAN
|
||||
do
|
||||
across
|
||||
a_container as i
|
||||
until
|
||||
Result
|
||||
loop
|
||||
if attached {CMS_FORM_FIELD} i.item as l_field and then l_field.name.same_string_general (a_name) then
|
||||
Result := True
|
||||
elseif attached {ITERABLE [CMS_WIDGET]} i.item as l_cont then
|
||||
Result := container_has_field (l_cont, a_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
fields_by_name_from (a_container: ITERABLE [CMS_WIDGET]; a_name: READABLE_STRING_GENERAL): detachable ARRAYED_LIST [CMS_FORM_FIELD]
|
||||
local
|
||||
res: detachable ARRAYED_LIST [CMS_FORM_FIELD]
|
||||
do
|
||||
across
|
||||
a_container as i
|
||||
loop
|
||||
if attached {CMS_FORM_FIELD} i.item as l_field and then l_field.name.same_string_general (a_name) then
|
||||
if res = Void then
|
||||
create res.make (1)
|
||||
end
|
||||
res.force (l_field)
|
||||
elseif attached {ITERABLE [CMS_WIDGET]} i.item as l_cont then
|
||||
if attached fields_by_name_from (l_cont, a_name) as lst then
|
||||
if res = Void then
|
||||
res := lst
|
||||
else
|
||||
res.append (lst)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Result := res
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -10,7 +10,7 @@ class
|
||||
inherit
|
||||
TABLE_ITERABLE [detachable WSF_VALUE, READABLE_STRING_8]
|
||||
|
||||
create
|
||||
create {CMS_FORM}
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
@@ -21,7 +21,6 @@ feature {NONE} -- Initialization
|
||||
form := a_form
|
||||
create items.make (a_form.count)
|
||||
get_items (req)
|
||||
validate
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
@@ -37,6 +36,14 @@ feature -- Status
|
||||
|
||||
feature -- Access
|
||||
|
||||
item_same_string (a_name: READABLE_STRING_GENERAL; s: READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Is there any item named `a_name' with a value `v'?
|
||||
do
|
||||
if attached item (a_name) as l_value then
|
||||
Result := l_value.same_string (s)
|
||||
end
|
||||
end
|
||||
|
||||
item (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
|
||||
do
|
||||
Result := items.item (a_name.as_string_8)
|
||||
@@ -49,11 +56,49 @@ feature -- Access
|
||||
end
|
||||
end
|
||||
|
||||
-- table_item (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
|
||||
-- do
|
||||
-- FIXME
|
||||
-- Result := items.item (a_name.as_string_8 + "[]")
|
||||
-- end
|
||||
table_item (a_name: READABLE_STRING_GENERAL): detachable WSF_TABLE
|
||||
local
|
||||
s,k: READABLE_STRING_GENERAL
|
||||
p,q: INTEGER
|
||||
do
|
||||
if attached {WSF_TABLE} item (a_name) as tb then
|
||||
Result := tb
|
||||
else
|
||||
s := a_name + "["
|
||||
create Result.make (a_name.to_string_8) -- FIXME
|
||||
across
|
||||
items as c
|
||||
loop
|
||||
if attached c.item as v then
|
||||
k := c.key
|
||||
if k.starts_with (s) then
|
||||
if attached {WSF_TABLE} v as tb then
|
||||
across
|
||||
tb as t
|
||||
loop
|
||||
Result.add_value (t.item, t.item.name)
|
||||
end
|
||||
else
|
||||
p := k.index_of ('[', 1)
|
||||
if p > 0 then
|
||||
q := k.index_of (']', p + 1)
|
||||
if q > p then
|
||||
if q = p + 1 then
|
||||
-- []
|
||||
Result.add_value (v, (Result.count+1).out)
|
||||
else
|
||||
Result.add_value (v, k.substring (p + 1, q - 1))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
-- skip
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
integer_item (a_name: READABLE_STRING_GENERAL): INTEGER
|
||||
do
|
||||
@@ -70,17 +115,33 @@ feature -- Access
|
||||
|
||||
feature -- Basic operation
|
||||
|
||||
submit
|
||||
require
|
||||
is_valid: is_valid
|
||||
do
|
||||
form.submit_actions.call ([Current])
|
||||
end
|
||||
|
||||
validate
|
||||
do
|
||||
across
|
||||
form as f
|
||||
loop
|
||||
if attached {CMS_FORM_FIELD} f.item as l_field then
|
||||
l_field.validate (Current)
|
||||
end
|
||||
validate_item (f.item)
|
||||
end
|
||||
if attached form.validation_action as act then
|
||||
act.call ([Current])
|
||||
form.validation_actions.call ([Current])
|
||||
end
|
||||
|
||||
validate_item (w: CMS_WIDGET)
|
||||
do
|
||||
if attached {CMS_FORM_FIELD} w as l_field then
|
||||
l_field.validate (Current)
|
||||
elseif attached {ITERABLE [CMS_WIDGET]} w as lst then
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
validate_item (c.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -121,7 +182,7 @@ feature -- Basic operation
|
||||
|
||||
feature {NONE} -- Implementation: apply
|
||||
|
||||
apply_to_associated_form_item (a_name: READABLE_STRING_8; a_value: detachable WSF_VALUE; i: CMS_FORM_ITEM)
|
||||
apply_to_associated_form_item (a_name: READABLE_STRING_8; a_value: detachable WSF_VALUE; i: CMS_WIDGET)
|
||||
local
|
||||
do
|
||||
if attached {CMS_FORM_FIELD} i as l_field then
|
||||
@@ -130,7 +191,7 @@ feature {NONE} -- Implementation: apply
|
||||
l_field.set_value (a_value)
|
||||
end
|
||||
end
|
||||
elseif attached {ITERABLE [CMS_FORM_ITEM]} i as l_set then
|
||||
elseif attached {ITERABLE [CMS_WIDGET]} i as l_set then
|
||||
across
|
||||
l_set as c
|
||||
loop
|
||||
@@ -170,14 +231,14 @@ feature {NONE} -- Implementation
|
||||
get_form_items (req, form)
|
||||
end
|
||||
|
||||
get_form_items (req: WSF_REQUEST; lst: ITERABLE [CMS_FORM_ITEM])
|
||||
get_form_items (req: WSF_REQUEST; lst: ITERABLE [CMS_WIDGET])
|
||||
do
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
if attached {CMS_FORM_FIELD} c.item as l_field then
|
||||
get_form_field_item (req, l_field, l_field.name)
|
||||
elseif attached {ITERABLE [CMS_FORM_ITEM]} c.item as l_set then
|
||||
elseif attached {ITERABLE [CMS_WIDGET]} c.item as l_set then
|
||||
get_form_items (req, l_set)
|
||||
end
|
||||
end
|
||||
@@ -186,49 +247,24 @@ feature {NONE} -- Implementation
|
||||
get_form_field_item (req: WSF_REQUEST; i: CMS_FORM_FIELD; n: READABLE_STRING_8)
|
||||
local
|
||||
v: detachable WSF_VALUE
|
||||
-- tb: detachable WSF_TABLE
|
||||
do
|
||||
if form.is_post_method then
|
||||
v := req.form_parameter (n)
|
||||
v := req.table_item (n, agent req.form_parameter)
|
||||
else
|
||||
v := req.query_parameter (n)
|
||||
v := req.table_item (n, agent req.query_parameter)
|
||||
end
|
||||
if v = Void and then n.ends_with_general ("[]") then
|
||||
if form.is_post_method then
|
||||
v := req.form_parameter (n.substring (1, n.count - 2))
|
||||
else
|
||||
v := req.query_parameter (n.substring (1, n.count - 2))
|
||||
if v = Void then
|
||||
if n.ends_with_general ("[]") then
|
||||
if form.is_post_method then
|
||||
v := req.form_parameter (n.substring (1, n.count - 2))
|
||||
else
|
||||
v := req.query_parameter (n.substring (1, n.count - 2))
|
||||
end
|
||||
end
|
||||
end
|
||||
if i.is_required and (v = Void or else v.is_empty) then
|
||||
add_error (i, "Field %"<em>" + n + "</em>%" is required")
|
||||
else
|
||||
-- if attached {WSF_TABLE} v then
|
||||
-- -- `v' overwrite any previous values if any
|
||||
-- -- since it is already a WSF_TABLE
|
||||
-- else
|
||||
-- attached items.item (n) as ov then
|
||||
-- if attached {WSF_TABLE} ov as vtb then
|
||||
-- tb := vtb
|
||||
-- elseif attached {WSF_MULTIPLE_STRING} ov as vm then
|
||||
-- if tb = Void then
|
||||
-- create tb.make (n)
|
||||
-- end
|
||||
-- across
|
||||
-- vm as c
|
||||
-- loop
|
||||
-- tb.add_value (c.item, (tb.count + 1).out)
|
||||
-- end
|
||||
-- else
|
||||
-- create tb.make (n)
|
||||
---- create v_multi.make_with_value (ov)
|
||||
-- end
|
||||
-- if v /= Void then
|
||||
-- tb.add_value (v, (tb.count + 1).out)
|
||||
---- v_multi.add_value (v)
|
||||
-- end
|
||||
-- v := tb
|
||||
-- end
|
||||
items.force (v, n)
|
||||
end
|
||||
end
|
||||
@@ -247,8 +283,45 @@ feature {NONE} -- Implementation
|
||||
|
||||
items: HASH_TABLE [detachable WSF_VALUE, READABLE_STRING_8]
|
||||
|
||||
feature -- Cached values
|
||||
|
||||
cached_value (k: READABLE_STRING_8): detachable ANY
|
||||
do
|
||||
if attached cached_values as tb then
|
||||
Result := tb.item (k)
|
||||
end
|
||||
end
|
||||
|
||||
add_cached_value (k: READABLE_STRING_8; v: detachable ANY)
|
||||
local
|
||||
tb: like cached_values
|
||||
do
|
||||
tb := cached_values
|
||||
if tb = Void then
|
||||
create tb.make (1)
|
||||
cached_values := tb
|
||||
end
|
||||
tb.force (v, k)
|
||||
end
|
||||
|
||||
remove_cached_value (k: READABLE_STRING_8; v: detachable ANY)
|
||||
do
|
||||
if attached cached_values as tb then
|
||||
tb.remove (k)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation: cached values
|
||||
|
||||
cached_values: detachable HASH_TABLE [detachable ANY, READABLE_STRING_8]
|
||||
|
||||
feature -- Reports
|
||||
|
||||
has_error: BOOLEAN
|
||||
do
|
||||
Result := attached errors as err and then not err.is_empty
|
||||
end
|
||||
|
||||
errors: detachable ARRAYED_LIST [TUPLE [field: detachable CMS_FORM_FIELD; message: detachable READABLE_STRING_8]]
|
||||
|
||||
invariant
|
||||
|
||||
@@ -10,7 +10,7 @@ class
|
||||
inherit
|
||||
CMS_FORM_ITEM
|
||||
|
||||
ITERABLE [CMS_FORM_ITEM]
|
||||
CMS_FORM_COMPOSITE
|
||||
|
||||
WITH_CSS_ID
|
||||
|
||||
@@ -18,14 +18,16 @@ create
|
||||
make,
|
||||
make_with_item,
|
||||
make_with_items,
|
||||
make_with_text
|
||||
make_with_text,
|
||||
make_with_text_and_css_id,
|
||||
make_with_item_and_css_id
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
create items.make (0)
|
||||
initialize_with_count (0)
|
||||
end
|
||||
|
||||
make_with_text (s: READABLE_STRING_8)
|
||||
@@ -33,15 +35,15 @@ feature {NONE} -- Initialization
|
||||
make_with_item (create {CMS_FORM_RAW_TEXT}.make (s))
|
||||
end
|
||||
|
||||
make_with_item (i: CMS_FORM_ITEM)
|
||||
make_with_item (i: CMS_WIDGET)
|
||||
do
|
||||
create items.make (1)
|
||||
initialize_with_count (1)
|
||||
extend (i)
|
||||
end
|
||||
|
||||
make_with_items (it: ITERABLE [CMS_FORM_ITEM])
|
||||
make_with_items (it: ITERABLE [CMS_WIDGET])
|
||||
do
|
||||
create items.make (2)
|
||||
initialize_with_count (2)
|
||||
across
|
||||
it as c
|
||||
loop
|
||||
@@ -49,19 +51,16 @@ feature {NONE} -- Initialization
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: ITERATION_CURSOR [CMS_FORM_ITEM]
|
||||
-- Fresh cursor associated with current structure
|
||||
make_with_item_and_css_id (i: CMS_WIDGET; a_css_id: READABLE_STRING_8)
|
||||
do
|
||||
Result := items.new_cursor
|
||||
make_with_item (i)
|
||||
set_css_id (a_css_id)
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
extend (i: CMS_FORM_ITEM)
|
||||
make_with_text_and_css_id (s: READABLE_STRING_8; a_css_id: READABLE_STRING_8)
|
||||
do
|
||||
items.force (i)
|
||||
make_with_text (s)
|
||||
set_css_id (a_css_id)
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
@@ -82,8 +81,4 @@ feature -- Conversion
|
||||
a_html.append ("%N</div>%N")
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
items: ARRAYED_LIST [CMS_FORM_ITEM]
|
||||
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ class
|
||||
inherit
|
||||
CMS_FORM_ITEM
|
||||
|
||||
ITERABLE [CMS_FORM_ITEM]
|
||||
CMS_FORM_COMPOSITE
|
||||
|
||||
WITH_CSS_ID
|
||||
|
||||
@@ -22,7 +22,7 @@ feature {NONE} -- Initialization
|
||||
make
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
create items.make (0)
|
||||
initialize_with_count (0)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
@@ -31,14 +31,6 @@ feature -- Access
|
||||
|
||||
is_collapsible: BOOLEAN
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: ITERATION_CURSOR [CMS_FORM_ITEM]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
Result := items.new_cursor
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_legend (v: like legend)
|
||||
@@ -46,21 +38,6 @@ feature -- Change
|
||||
legend := v
|
||||
end
|
||||
|
||||
extend (i: CMS_FORM_ITEM)
|
||||
do
|
||||
items.force (i)
|
||||
end
|
||||
|
||||
prepend (i: CMS_FORM_ITEM)
|
||||
do
|
||||
items.put_front (i)
|
||||
end
|
||||
|
||||
extend_text (t: READABLE_STRING_8)
|
||||
do
|
||||
items.force (create {CMS_FORM_RAW_TEXT}.make (t))
|
||||
end
|
||||
|
||||
set_collapsible (b: BOOLEAN)
|
||||
do
|
||||
is_collapsible := b
|
||||
@@ -101,8 +78,4 @@ feature -- Conversion
|
||||
a_html.append ("%N</fieldset>%N")
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
items: ARRAYED_LIST [CMS_FORM_ITEM]
|
||||
|
||||
end
|
||||
|
||||
@@ -8,20 +8,10 @@ deferred class
|
||||
CMS_FORM_ITEM
|
||||
|
||||
inherit
|
||||
CMS_WIDGET
|
||||
|
||||
WITH_CSS_CLASS
|
||||
|
||||
WITH_CSS_STYLE
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: CMS_THEME; a_html: STRING_8)
|
||||
deferred
|
||||
end
|
||||
|
||||
to_html (a_theme: CMS_THEME): STRING_8
|
||||
do
|
||||
create Result.make_empty
|
||||
append_to_html (a_theme, Result)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,7 +8,10 @@ class
|
||||
CMS_FORM_RAW_TEXT
|
||||
|
||||
inherit
|
||||
CMS_FORM_ITEM
|
||||
CMS_WIDGET_TEXT
|
||||
rename
|
||||
set_text as set_value,
|
||||
make_with_text as make
|
||||
redefine
|
||||
append_to_html
|
||||
end
|
||||
@@ -16,24 +19,6 @@ inherit
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_text: like text)
|
||||
do
|
||||
text := a_text
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
text: READABLE_STRING_8
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_value (v: detachable WSF_VALUE)
|
||||
do
|
||||
-- Not applicable
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: CMS_THEME; a_html: STRING_8)
|
||||
|
||||
@@ -17,6 +17,17 @@ feature -- Change
|
||||
css_classes := Void
|
||||
end
|
||||
|
||||
add_css_classes (a_classes: detachable ITERABLE [READABLE_STRING_8])
|
||||
do
|
||||
if a_classes /= Void then
|
||||
across
|
||||
a_classes as c
|
||||
loop
|
||||
add_css_class (c.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
add_css_class (a_class: READABLE_STRING_8)
|
||||
require
|
||||
is_valid_css_class: is_valid_css_class (a_class)
|
||||
|
||||
@@ -51,7 +51,7 @@ feature -- Status report
|
||||
Result := attached children as l_children and then not l_children.is_empty
|
||||
end
|
||||
|
||||
permission_arguments: detachable ITERABLE [STRING]
|
||||
permission_arguments: detachable ITERABLE [READABLE_STRING_8]
|
||||
|
||||
children: detachable LIST [CMS_LINK]
|
||||
|
||||
@@ -106,14 +106,17 @@ feature -- Element change
|
||||
qs: STRING
|
||||
do
|
||||
create qs.make_from_string (req.path_info)
|
||||
if attached req.query_string as l_query_string and then not l_query_string.is_empty then
|
||||
qs.append_character ('?')
|
||||
qs.append (l_query_string)
|
||||
end
|
||||
is_active := qs.same_string (location)
|
||||
if not is_active then
|
||||
if attached req.query_string as l_query_string and then not l_query_string.is_empty then
|
||||
qs.append_character ('?')
|
||||
qs.append (l_query_string)
|
||||
end
|
||||
is_active := qs.same_string (location)
|
||||
end
|
||||
end
|
||||
|
||||
set_permission_arguments (args: ITERABLE [STRING])
|
||||
set_permission_arguments (args: like permission_arguments)
|
||||
do
|
||||
permission_arguments := args
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user