Extracted the WIDGET and FORM classes out of "cms" component

and build the wsf_html library which also include the previous css lib.
This commit is contained in:
Jocelyn Fiat
2013-03-22 20:11:44 +01:00
parent de57e814c0
commit 52cc356f8e
65 changed files with 468 additions and 358 deletions

View File

@@ -264,7 +264,7 @@ feature -- Message
add_message (a_msg, "success")
end
report_form_errors (fd: CMS_FORM_DATA)
report_form_errors (fd: WSF_FORM_DATA)
require
has_error: not fd.is_valid
do

View File

@@ -203,7 +203,7 @@ feature -- Hook: form_alter
form_alter_hooks: detachable ARRAYED_LIST [CMS_HOOK_FORM_ALTER]
call_form_alter_hooks (f: CMS_FORM; a_form_data: detachable CMS_FORM_DATA; a_execution: CMS_EXECUTION)
call_form_alter_hooks (f: CMS_FORM; a_form_data: detachable WSF_FORM_DATA; a_execution: CMS_EXECUTION)
do
if attached form_alter_hooks as lst then
across

View File

@@ -0,0 +1,43 @@
note
description: "Summary description for {CMS_FORM}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM
inherit
WSF_FORM
rename
process as process_form
end
create
make
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)
do
process_form (a_execution.request, agent on_prepared (a_execution, ?), agent on_processed (a_execution, ?))
end
on_prepared (a_execution: CMS_EXECUTION; fd: WSF_FORM_DATA)
do
a_execution.service.call_form_alter_hooks (Current, fd, a_execution)
end
on_processed (a_execution: CMS_EXECUTION; fd: WSF_FORM_DATA)
do
if not fd.is_valid or fd.has_error then
a_execution.report_form_errors (fd)
end
end
end

View File

@@ -12,7 +12,7 @@ inherit
feature -- Hook
form_alter (a_form: CMS_FORM; a_form_data: detachable CMS_FORM_DATA; a_execution: CMS_EXECUTION)
form_alter (a_form: CMS_FORM; a_form_data: detachable WSF_FORM_DATA; a_execution: CMS_EXECUTION)
deferred
end

View File

@@ -34,14 +34,14 @@ feature -- Factory
deferred
end
change_node (a_execution: CMS_EXECUTION; a_form_data: CMS_FORM_DATA; a_node: like new_node)
change_node (a_execution: CMS_EXECUTION; a_form_data: WSF_FORM_DATA; a_node: like new_node)
-- Apply data from `a_form_data' to a_node
require
a_node.has_id
deferred
end
new_node (a_execution: CMS_EXECUTION; a_form_data: CMS_FORM_DATA; a_node: detachable like new_node): CMS_NODE
new_node (a_execution: CMS_EXECUTION; a_form_data: WSF_FORM_DATA; a_node: detachable like new_node): CMS_NODE
-- New content created with `a_form_data'
deferred
ensure

View File

@@ -1,138 +0,0 @@
note
description: "Summary description for {CMS_FORM}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM
inherit
CMS_FORM_COMPOSITE
create
make
feature {NONE} -- Initialization
make (a_action: READABLE_STRING_8; a_id: READABLE_STRING_8)
do
action := a_action
id := a_id
initialize_with_count (10)
create html_classes.make (2)
set_method_post
create validation_actions
create submit_actions
end
feature -- Access
action: READABLE_STRING_8
-- URL for the web form
id: READABLE_STRING_8
-- Id of the form
is_get_method: BOOLEAN
do
Result := method.same_string ("GET")
end
is_post_method: BOOLEAN
do
Result := not is_get_method
end
method: READABLE_STRING_8
-- 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_actions: ACTION_SEQUENCE [TUPLE [CMS_FORM_DATA]]
-- Procedure to validate the data
-- report error if not valid
submit_actions: ACTION_SEQUENCE [TUPLE [CMS_FORM_DATA]]
-- Submit actions
feature -- Element change
set_method_get
do
method := "GET"
end
set_method_post
do
method := "POST"
end
feature -- Optional
html_classes: ARRAYED_LIST [STRING_8]
feature -- Conversion
append_to_html (a_theme: CMS_THEME; a_html: STRING_8)
local
s: STRING_8
do
a_html.append ("<form action=%""+ action +"%" id=%""+ id +"%" method=%""+ method +"%" ")
if not html_classes.is_empty then
create s.make_empty
across
html_classes as cl
loop
if not s.is_empty then
s.extend (' ')
end
s.append (cl.item)
end
a_html.append (" class=%"" + s + "%" ")
end
a_html.append (">%N")
across
items as c
loop
c.item.append_to_html (a_theme, a_html)
end
a_html.append ("</form>%N")
end
to_html (a_theme: CMS_THEME): STRING_8
do
create Result.make_empty
append_to_html (a_theme, Result)
end
end

View File

@@ -1,20 +0,0 @@
note
description: "Summary description for {CMS_FORM_BUTTON_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_BUTTON_INPUT
inherit
CMS_FORM_INPUT
create
make
feature -- Access
input_type: STRING = "button"
end

View File

@@ -1,23 +0,0 @@
note
description: "Summary description for {CMS_FORM_CHECKBOX_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_CHECKBOX_INPUT
inherit
CMS_FORM_SELECTABLE_INPUT
create
make,
make_with_value
feature -- Access
input_type: STRING = "checkbox"
invariant
end

View File

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

View File

@@ -1,329 +0,0 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
class
CMS_FORM_DATA
inherit
TABLE_ITERABLE [detachable WSF_VALUE, READABLE_STRING_8]
create {CMS_FORM}
make
feature {NONE} -- Initialization
make (req: WSF_REQUEST; a_form: CMS_FORM)
-- Initialize `Current'.
do
form := a_form
create items.make (a_form.count)
get_items (req)
end
feature -- Access
form: CMS_FORM
feature -- Status
is_valid: BOOLEAN
do
Result := errors = Void
end
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)
end
string_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
do
if attached {WSF_STRING} item (a_name) as s then
Result := s.value
end
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_code (91, 1) -- 91 '['
if p > 0 then
q := k.index_of_code (93, p + 1) -- 93 ']'
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
if attached {WSF_STRING} item (a_name) as s and then s.is_integer then
Result := s.integer_value
end
end
new_cursor: TABLE_ITERATION_CURSOR [detachable WSF_VALUE, READABLE_STRING_8]
-- Fresh cursor associated with current structure
do
Result := items.new_cursor
end
feature -- Basic operation
submit
require
is_valid: is_valid
do
form.submit_actions.call ([Current])
end
validate
do
across
form as f
loop
validate_item (f.item)
end
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
set_fields_invalid (b: BOOLEAN; a_name: READABLE_STRING_GENERAL)
do
if attached form.fields_by_name (a_name) as lst then
across
lst as i
loop
i.item.set_is_invalid (b)
end
end
end
apply_to_associated_form
do
if attached errors as errs then
across
errs as e
loop
if attached e.item as err then
if attached err.field as e_field then
set_fields_invalid (True, e_field.name)
end
end
end
end
across
items as c
loop
across
form as i
loop
apply_to_associated_form_item (c.key, c.item, i.item)
end
end
end
feature {NONE} -- Implementation: apply
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
if not attached {CMS_FORM_SUBMIT_INPUT} l_field then
if l_field.name.same_string (a_name) then
l_field.set_value (a_value)
end
end
elseif attached {ITERABLE [CMS_WIDGET]} i as l_set then
across
l_set as c
loop
apply_to_associated_form_item (a_name, a_value, c.item)
end
end
end
feature -- Change
report_error (a_msg: READABLE_STRING_8)
do
add_error (Void, a_msg)
ensure
is_invalid: not is_valid
end
report_invalid_field (a_field_name: READABLE_STRING_8; a_msg: READABLE_STRING_8)
require
has_field: form.has_field (a_field_name)
do
if attached form.fields_by_name (a_field_name) as lst then
across
lst as c
loop
add_error (c.item, a_msg)
end
end
ensure
is_invalid: not is_valid
end
feature {NONE} -- Implementation
get_items (req: WSF_REQUEST)
do
get_form_items (req, form)
end
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_WIDGET]} c.item as l_set then
get_form_items (req, l_set)
end
end
end
get_form_field_item (req: WSF_REQUEST; i: CMS_FORM_FIELD; n: READABLE_STRING_8)
local
v: detachable WSF_VALUE
do
if form.is_post_method then
v := req.table_item (n, agent req.form_parameter)
else
v := req.table_item (n, agent req.query_parameter)
end
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
items.force (v, n)
end
end
add_error (a_field: detachable CMS_FORM_FIELD; a_msg: detachable READABLE_STRING_8)
local
err: like errors
do
err := errors
if err = Void then
create err.make (1)
errors := err
end
err.force ([a_field, a_msg])
end
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
end

View File

@@ -1,84 +0,0 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
class
CMS_FORM_DIV
inherit
CMS_FORM_ITEM
CMS_FORM_COMPOSITE
WITH_CSS_ID
create
make,
make_with_item,
make_with_items,
make_with_text,
make_with_text_and_css_id,
make_with_item_and_css_id
feature {NONE} -- Initialization
make
-- Initialize `Current'.
do
initialize_with_count (0)
end
make_with_text (s: READABLE_STRING_8)
do
make_with_item (create {CMS_FORM_RAW_TEXT}.make (s))
end
make_with_item (i: CMS_WIDGET)
do
initialize_with_count (1)
extend (i)
end
make_with_items (it: ITERABLE [CMS_WIDGET])
do
initialize_with_count (2)
across
it as c
loop
extend (c.item)
end
end
make_with_item_and_css_id (i: CMS_WIDGET; a_css_id: READABLE_STRING_8)
do
make_with_item (i)
set_css_id (a_css_id)
end
make_with_text_and_css_id (s: READABLE_STRING_8; a_css_id: READABLE_STRING_8)
do
make_with_text (s)
set_css_id (a_css_id)
end
feature -- Conversion
append_to_html (a_theme: CMS_THEME; a_html: STRING_8)
do
a_html.append ("<div")
append_css_class_to (a_html, Void)
append_css_id_to (a_html)
append_css_style_to (a_html)
a_html.append (">%N")
across
items as c
loop
c.item.append_to_html (a_theme, a_html)
end
a_html.append ("%N</div>%N")
end
end

View File

@@ -1,146 +0,0 @@
note
description: "Summary description for {CMS_FORM_ITEM}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
CMS_FORM_FIELD
inherit
CMS_FORM_ITEM
WITH_CSS_ID
DEBUG_OUTPUT
feature -- Access
name: READABLE_STRING_8
label: detachable READABLE_STRING_8
description: detachable READABLE_STRING_8
is_required: BOOLEAN
is_invalid: BOOLEAN
is_readonly: BOOLEAN
is_description_collapsible: BOOLEAN
feature -- Status report
debug_output: STRING
-- String that should be displayed in debugger to represent `Current'.
do
Result := name + " {" + generator + "}"
end
feature -- Validation
validation_action: detachable PROCEDURE [ANY, TUPLE [CMS_FORM_DATA]]
-- Function returning True if valid, otherwise False
validate (fd: CMS_FORM_DATA)
do
if attached validation_action as act then
act.call ([fd])
end
end
feature -- Element change
update_name (a_name: like name)
require
name.is_empty
do
name := a_name
end
set_is_required (b: BOOLEAN)
do
is_required := b
end
set_is_readonly (b: BOOLEAN)
do
is_readonly := b
end
set_label (lab: like label)
do
label := lab
end
set_description (t: like description)
do
description := t
end
set_validation_action (act: like validation_action)
do
validation_action := act
end
set_is_invalid (b: BOOLEAN)
do
is_invalid := b
end
set_value (v: detachable WSF_VALUE)
-- Set value `v' if applicable to Current
deferred
end
set_description_collapsible (b: BOOLEAN)
-- Set `is_description_collapsible' to `b'
do
is_description_collapsible := b
end
feature -- Conversion
append_to_html (a_theme: CMS_THEME; a_html: STRING_8)
local
l_class_items: detachable ARRAYED_LIST [READABLE_STRING_8]
do
create l_class_items.make (2)
if is_required then
l_class_items.extend ("required")
end
if is_invalid then
l_class_items.extend ("error")
end
if l_class_items.is_empty then
l_class_items := Void
end
a_html.append ("<div")
append_css_class_to (a_html, l_class_items)
a_html.append_character ('>')
if attached label as lab then
a_html.append ("<strong><label for=%"" + name + "%">" + lab + "</label></strong>")
if is_required then
a_html.append (" (<em>required</em>)")
end
a_html.append ("<br/>%N")
end
append_item_to_html (a_theme, a_html)
if attached description as desc then
if is_description_collapsible then
a_html.append ("<div class=%"description collapsible%"><div>Description ...</div><div>" + desc + "</div></div>")
else
a_html.append ("<div class=%"description%">" + desc + "</div>")
end
end
a_html.append ("</div>")
end
append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8)
deferred
end
end

View File

@@ -1,81 +0,0 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
class
CMS_FORM_FIELD_SET
inherit
CMS_FORM_ITEM
CMS_FORM_COMPOSITE
WITH_CSS_ID
create
make
feature {NONE} -- Initialization
make
-- Initialize `Current'.
do
initialize_with_count (0)
end
feature -- Access
legend: detachable READABLE_STRING_8
is_collapsible: BOOLEAN
feature -- Change
set_legend (v: like legend)
do
legend := v
end
set_collapsible (b: BOOLEAN)
do
is_collapsible := b
if b then
add_css_class ("collapsible")
else
remove_css_class ("collapsible")
end
end
set_collapsed (b: BOOLEAN)
do
if b then
add_css_class ("collapsed")
else
remove_css_class ("collapsed")
end
end
feature -- Conversion
append_to_html (a_theme: CMS_THEME; a_html: STRING_8)
do
a_html.append ("<fieldset")
append_css_class_to (a_html, Void)
append_css_id_to (a_html)
append_css_style_to (a_html)
a_html.append (">%N")
if attached legend as leg then
a_html.append ("<legend>" + leg + "</legend>%N")
end
across
items as c
loop
c.item.append_to_html (a_theme, a_html)
end
a_html.append ("%N</fieldset>%N")
end
end

View File

@@ -1,46 +0,0 @@
note
description: "Summary description for {CMS_FORM_FILE_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_FILE_INPUT
inherit
CMS_FORM_INPUT
redefine
specific_input_attributes_string
end
create
make
feature -- Access
input_type: STRING = "file"
accepted_types: detachable READABLE_STRING_8
-- Types of files that the server accepts
feature -- Change
set_accepted_types (v: like accepted_types)
do
accepted_types := v
end
feature {NONE} -- Implementation
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
if attached accepted_types as l_accepted_types then
Result := " accept=%"" + l_accepted_types + "%""
end
end
invariant
end

View File

@@ -1,37 +0,0 @@
note
description: "Summary description for {CMS_FORM_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_HIDDEN_INPUT
inherit
CMS_FORM_INPUT
redefine
input_type,
append_item_to_html
end
create
make,
make_with_text
feature -- Access
input_type: STRING
once
Result := "hidden"
end
feature -- Conversion
append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8)
do
a_html.append ("<div style=%"display:none%">")
Precursor (a_theme, a_html)
a_html.append ("</div>")
end
end

View File

@@ -1,58 +0,0 @@
note
description: "Summary description for {CMS_FORM_IMAGE_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_IMAGE_INPUT
inherit
CMS_FORM_INPUT
redefine
specific_input_attributes_string
end
create
make
feature -- Access
input_type: STRING = "image"
src: detachable READABLE_STRING_8
-- Specifies the URL of the image to use as a submit button
alt: detachable READABLE_STRING_8
-- Alternate text for an image.
feature -- Change
set_src (v: like src)
do
src := v
end
set_alt (v: like alt)
do
alt := v
end
feature {NONE} -- Implementation
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
create Result.make_empty
if attached src as l_src then
Result.append (" src=%"" + l_src + "%"")
end
if attached alt as l_alt then
Result.append (" alt=%"" + l_alt + "%"")
end
end
invariant
end

View File

@@ -1,136 +0,0 @@
note
description: "Summary description for {CMS_FORM_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
CMS_FORM_INPUT
inherit
CMS_FORM_FIELD
feature {NONE} -- Initialization
make (a_name: like name)
do
name := a_name
end
make_with_text (a_name: like name; a_text: READABLE_STRING_32)
do
make (a_name)
set_text_value (a_text)
end
feature -- Access
default_value: detachable READABLE_STRING_32
size: INTEGER
-- Width, in characters, of an <input> element.
maxlength: INTEGER
-- Maximum number of characters allowed in an <input> element.
disabled: BOOLEAN
-- Current <input> element should be disabled?
input_type: STRING
deferred
end
feature -- Element change
set_text_value (s: detachable READABLE_STRING_32)
do
set_default_value (s)
end
set_size (i: like size)
do
size := i
end
set_maxlength (i: like maxlength)
do
maxlength := i
end
set_disabled (b: like disabled)
do
disabled := b
end
set_value (v: detachable WSF_VALUE)
do
if attached {WSF_STRING} v as s then
set_text_value (s.value)
else
set_text_value (Void)
end
end
set_default_value (v: like default_value)
do
default_value := v
end
feature -- Conversion
append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8)
local
old_count: INTEGER
do
a_html.append ("<input type=%""+ input_type +"%" name=%""+ name +"%"")
append_css_class_to (a_html, Void)
append_css_id_to (a_html)
append_css_style_to (a_html)
if is_readonly then
a_html.append (" readonly=%"readonly%"")
end
if attached default_value as dft then
a_html.append (" value=%"" + a_theme.html_encoded (dft) + "%"")
end
if disabled then
a_html.append (" disabled=%"disabled%"")
end
if size > 0 then
a_html.append (" size=%"" + size.out + "%"")
end
if maxlength > 0 then
a_html.append (" maxlength=%"" + maxlength.out + "%"")
end
if attached specific_input_attributes_string as s then
a_html.append_character (' ')
a_html.append (s)
end
a_html.append (">")
old_count := a_html.count
append_child_to_html (a_theme, a_html)
if a_html.count > old_count then
a_html.append ("</input>")
else
check a_html.item (a_html.count) = '>' end
a_html.put ('/', a_html.count) -- replace previous '>'
a_html.append (">")
end
end
feature {NONE} -- Implementation
append_child_to_html (a_theme: CMS_THEME; a_html: STRING_8)
-- Specific child element if any.
--| To redefine if needed
do
end
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
--| To redefine if needed
do
end
end

View File

@@ -1,17 +0,0 @@
note
description: "Summary description for {CMS_FORM_ITEM}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
CMS_FORM_ITEM
inherit
CMS_WIDGET
WITH_CSS_CLASS
WITH_CSS_STYLE
end

View File

@@ -1,27 +0,0 @@
note
description: "Summary description for {CMS_FORM_PASSWORD_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_PASSWORD_INPUT
inherit
CMS_FORM_INPUT
redefine
input_type
end
create
make,
make_with_text
feature -- Access
input_type: STRING
once
Result := "password"
end
end

View File

@@ -1,23 +0,0 @@
note
description: "Summary description for {CMS_FORM_RADIO_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_RADIO_INPUT
inherit
CMS_FORM_SELECTABLE_INPUT
create
make,
make_with_value
feature -- Access
input_type: STRING = "radio"
invariant
end

View File

@@ -1,34 +0,0 @@
note
description: "Summary description for {CMS_FORM_RAW_TEXT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_RAW_TEXT
inherit
CMS_WIDGET_TEXT
rename
set_text as set_value,
make_with_text as make
redefine
append_to_html
end
create
make
feature -- Conversion
append_to_html (a_theme: CMS_THEME; a_html: STRING_8)
do
append_item_html_to (a_theme, a_html)
end
append_item_html_to (a_theme: CMS_THEME; a_html: STRING_8)
do
a_html.append (text)
end
end

View File

@@ -1,20 +0,0 @@
note
description: "Summary description for {CMS_FORM_RESET_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_RESET_INPUT
inherit
CMS_FORM_INPUT
create
make
feature -- Access
input_type: STRING = "reset"
end

View File

@@ -1,151 +0,0 @@
note
description: "Summary description for {CMS_FORM_SELECT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_SELECT
inherit
CMS_FORM_FIELD
CMS_FORM_UTILITY
create
make
feature {NONE} -- Initialization
make (a_name: like name)
do
name := a_name
create options.make (0)
end
feature -- Access
options: ARRAYED_LIST [CMS_FORM_SELECT_OPTION]
feature -- Element change
set_text_by_value (a_text: detachable READABLE_STRING_GENERAL)
local
opt: CMS_FORM_SELECT_OPTION
l_found: BOOLEAN
v: READABLE_STRING_8
do
if a_text /= Void then
v := html_encoded_string (a_text.to_string_32)
across
options as o
loop
if o.item.is_same_value (v) then
l_found := True
o.item.set_is_selected (True)
else
o.item.set_is_selected (False)
end
end
if not l_found then
create opt.make (v, Void)
opt.set_is_selected (True)
add_option (opt)
end
else
across
options as o
loop
o.item.set_is_selected (False)
end
end
end
select_value_by_text (a_text: detachable READABLE_STRING_GENERAL)
local
l_found: BOOLEAN
v: READABLE_STRING_8
do
if a_text /= Void then
v := html_encoded_string (a_text.to_string_32)
across
options as o
loop
if o.item.is_same_text (v) then
l_found := True
o.item.set_is_selected (True)
else
o.item.set_is_selected (False)
end
end
else
across
options as o
loop
o.item.set_is_selected (False)
end
end
end
set_value (v: detachable WSF_VALUE)
do
if attached {WSF_STRING} v as s then
set_text_by_value (s.value)
else
set_text_by_value (Void)
end
end
add_option (opt: CMS_FORM_SELECT_OPTION)
do
options.force (opt)
end
feature -- Conversion
append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8)
local
l_is_already_selected: BOOLEAN
h: detachable STRING_8
do
a_html.append ("<select name=%""+ name +"%" ")
if css_id = Void then
set_css_id (name + "-select")
end
append_css_class_to (a_html, Void)
append_css_id_to (a_html)
append_css_style_to (a_html)
if is_readonly then
a_html.append (" readonly=%"readonly%" />")
else
a_html.append ("/>")
end
across
options as o
loop
a_html.append ("<option value=%"" + o.item.value + "%" ")
-- if not l_is_already_selected then
if
o.item.is_selected
then
l_is_already_selected := True
a_html.append (" selected=%"selected%"")
end
-- end
a_html.append (">" + o.item.text + "</option>%N")
if attached o.item.description as d then
if h = Void then
create h.make_empty
end
h.append ("<div id=%"" + name + "-" + o.item.value + "%" class=%"option%"><strong>"+ o.item.text +"</strong>:"+ d + "</div>")
end
end
a_html.append ("</select>%N")
if h /= Void then
a_html.append ("<div class=%"select help collapsible%" id=%"" + name + "-help%">" + h + "</div>%N")
end
end
end

View File

@@ -1,63 +0,0 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
class
CMS_FORM_SELECT_OPTION
inherit
CMS_FORM_SELECTABLE_ITEM
create
make
feature {NONE} -- Initialization
make (a_value: like value; a_text: detachable like text)
-- Initialize `Current'.
do
value := a_value
if a_text = Void then
text := a_value
else
text := a_text
end
end
feature -- Status
is_selected: BOOLEAN
is_same_value (v: READABLE_STRING_32): BOOLEAN
do
Result := value.same_string (v)
end
is_same_text (v: like text): BOOLEAN
do
Result := text.same_string (v)
end
feature -- Access
value: READABLE_STRING_32
text: READABLE_STRING_8
description: detachable READABLE_STRING_8
feature -- Change
set_is_selected (b: like is_selected)
do
is_selected := b
end
set_description (d: like description)
do
description := d
end
end

View File

@@ -1,112 +0,0 @@
note
description: "Summary description for {CMS_FORM_SELECTABLE_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
CMS_FORM_SELECTABLE_INPUT
inherit
CMS_FORM_INPUT
rename
default_value as value,
make_with_text as make_with_value
redefine
set_value,
specific_input_attributes_string,
append_child_to_html
end
CMS_FORM_SELECTABLE_ITEM
rename
is_selected as checked,
set_is_selected as set_checked
end
feature -- Access
checked: BOOLEAN
-- Current <input> element should be preselected when the page loads
title: detachable READABLE_STRING_32
raw_title: detachable READABLE_STRING_8
feature -- Status report
is_same_value (v: READABLE_STRING_32): BOOLEAN
do
Result := attached value as l_value and then v.same_string (l_value)
end
feature -- Change
set_title (t: detachable READABLE_STRING_32)
do
title := t
end
set_raw_title (t: detachable READABLE_STRING_8)
do
raw_title := t
end
set_checked (b: like checked)
do
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
if attached {ITERABLE [WSF_VALUE]} v as lst then
across
lst as c
loop
set_checked_by_value (c.item)
end
else
set_checked_by_value (v)
Precursor (v)
end
end
feature {NONE} -- Implementation
append_child_to_html (a_theme: CMS_THEME; a_html: STRING_8)
-- Specific child element if any.
--| To redefine if needed
do
if attached raw_title as t then
a_html.append (t)
elseif attached title as t then
a_html.append (a_theme.html_encoded (t))
end
end
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
if checked then
Result := "checked=%"checked%""
end
end
invariant
end

View File

@@ -1,25 +0,0 @@
note
description: "Summary description for {CMS_FORM_SELECTABLE_ITEM}."
date: "$Date$"
revision: "$Revision$"
deferred class
CMS_FORM_SELECTABLE_ITEM
feature -- Status report
is_selected : BOOLEAN
deferred
end
is_same_value (v: READABLE_STRING_32): BOOLEAN
deferred
end
feature -- Change
set_is_selected (b: like is_selected)
deferred
end
end

View File

@@ -1,21 +0,0 @@
note
description: "Summary description for {CMS_FORM_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_SUBMIT_INPUT
inherit
CMS_FORM_INPUT
create
make,
make_with_text
feature -- Access
input_type: STRING = "submit"
end

View File

@@ -1,21 +0,0 @@
note
description: "Summary description for {CMS_FORM_TEXT_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_TEXT_INPUT
inherit
CMS_FORM_INPUT
create
make,
make_with_text
feature -- Access
input_type: STRING = "text"
end

View File

@@ -1,89 +0,0 @@
note
description: "Summary description for {CMS_FORM_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_TEXTAREA
inherit
CMS_FORM_FIELD
create
make
feature {NONE} -- Initialization
make (a_name: like name)
do
name := a_name
end
feature -- Access
default_value: detachable READABLE_STRING_GENERAL
rows: INTEGER
cols: INTEGER
feature -- Element change
set_rows (i: like rows)
do
rows := i
end
set_cols (i: like cols)
do
cols := i
end
set_text_value (s: like default_value)
do
set_default_value (s)
end
set_value (v: detachable WSF_VALUE)
do
if attached {WSF_STRING} v as s then
set_text_value (s.value)
else
set_text_value (Void)
end
end
set_default_value (v: like default_value)
do
default_value := v
end
feature -- Conversion
append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8)
do
a_html.append ("<textarea name=%""+ name +"%"")
if rows > 0 then
a_html.append (" rows=%"" + rows.out + "%"")
end
if cols > 0 then
a_html.append (" cols=%"" + cols.out + "%"")
end
append_css_class_to (a_html, Void)
append_css_id_to (a_html)
append_css_style_to (a_html)
if is_readonly then
a_html.append (" readonly=%"readonly%">")
else
a_html.append (">")
end
if attached default_value as dft then
a_html.append (a_theme.html_encoded (dft))
end
a_html.append ("</textarea>")
end
end

View File

@@ -1,22 +0,0 @@
note
description: "Summary description for {CMS_FORM_UTILITY}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_FORM_UTILITY
feature -- Converter
html_encoded_string (s: READABLE_STRING_32): READABLE_STRING_8
do
Result := html_encoder.encoded_string (s)
end
html_encoder: HTML_ENCODER
once
create Result
end
end

View File

@@ -1,109 +0,0 @@
note
description: "Summary description for {WITH_CSS_CLASS}."
date: "$Date$"
revision: "$Revision$"
deferred class
WITH_CSS_CLASS
feature -- Status report
css_classes: detachable LIST [READABLE_STRING_8]
feature -- Change
reset_css_classes
do
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)
local
lst: like css_classes
do
lst := css_classes
if lst = Void then
create {ARRAYED_LIST [READABLE_STRING_8]} lst.make (1)
lst.compare_objects
css_classes := lst
end
lst.force (a_class)
end
remove_css_class (a_class: READABLE_STRING_8)
require
is_valid_css_class: is_valid_css_class (a_class)
local
lst: like css_classes
do
lst := css_classes
if lst /= Void then
lst.prune_all (a_class)
end
end
feature -- Query
is_valid_css_class (s: detachable READABLE_STRING_8): BOOLEAN
do
Result := s /= Void implies (not s.is_empty)
-- To complete
end
feature -- Conversion
append_css_class_to (a_target: STRING; a_additional_classes: detachable ITERABLE [READABLE_STRING_8])
local
f: BOOLEAN
cl: READABLE_STRING_8
do
if css_classes /= Void or a_additional_classes /= Void then
a_target.append (" class=%"")
f := True -- is first
if attached css_classes as l_classes then
across
l_classes as c
loop
cl := c.item
if not cl.is_empty then
if f then
f := False
else
a_target.append_character (' ')
end
a_target.append (cl)
end
end
end
if attached a_additional_classes as l_classes then
across
l_classes as c
loop
cl := c.item
if not cl.is_empty then
if not f then
a_target.append_character (' ')
end
a_target.append (cl)
end
end
end
a_target.append_character ('%"')
end
end
end

View File

@@ -1,41 +0,0 @@
note
description: "Summary description for {WITH_CSS_ID}."
date: "$Date$"
revision: "$Revision$"
deferred class
WITH_CSS_ID
feature -- Status report
css_id: detachable READABLE_STRING_8
feature -- Change
set_css_id (a_id: like css_id)
require
is_valid_css_id: is_valid_css_id (a_id)
do
css_id := a_id
end
feature -- Query
is_valid_css_id (s: detachable READABLE_STRING_8): BOOLEAN
do
Result := s /= Void implies (not s.is_empty)
-- To complete
end
feature -- Conversion
append_css_id_to (a_target: STRING)
do
if attached css_id as l_id then
a_target.append (" id=%"")
a_target.append (l_id)
a_target.append_character ('%"')
end
end
end

View File

@@ -1,43 +0,0 @@
note
description: "Summary description for {WITH_CSS_STYLE}."
date: "$Date$"
revision: "$Revision$"
deferred class
WITH_CSS_STYLE
feature -- Status report
css_style: detachable CSS_STYLE
feature -- Change
reset_css_style
do
css_style := Void
end
add_css_style (a_style: like css_style)
local
s: like css_style
do
s := css_style
if s = Void then
css_style := a_style
elseif a_style /= Void then
css_style := s + a_style
end
end
feature -- Conversion
append_css_style_to (a_target: STRING)
do
if attached css_style as l_css_style then
a_target.append (" style=%"")
l_css_style.append_inline_to (a_target)
a_target.append_character ('%"')
end
end
end

View File

@@ -1,81 +0,0 @@
note
description: "Summary description for {WITH_HTML_ATTRIBUTE}."
date: "$Date$"
revision: "$Revision$"
deferred class
WITH_HTML_ATTRIBUTE
feature -- Status report
html_attributes: detachable HASH_TABLE [detachable READABLE_STRING_8, STRING_8]
feature -- Change
reset_html_attributes
do
html_attributes := Void
end
add_html_attribute (a_name: READABLE_STRING_8; a_value: detachable READABLE_STRING_8)
require
is_valid_attribute_name: is_valid_attribute_name (a_name)
is_valid_attribute_value: is_valid_attribute_value (a_value)
local
lst: like html_attributes
do
lst := html_attributes
if lst = Void then
create lst.make (1)
lst.compare_objects
html_attributes := lst
end
lst.force (a_value, a_name)
end
remove_html_attribute (a_name: READABLE_STRING_8)
require
is_valid_attribute_name: is_valid_attribute_name (a_name)
local
lst: like html_attributes
do
lst := html_attributes
if lst /= Void then
lst.remove (a_name)
end
end
feature -- Query
is_valid_attribute_name (s: detachable READABLE_STRING_8): BOOLEAN
do
Result := s /= Void implies (not s.is_empty)
-- To complete
end
is_valid_attribute_value (s: detachable READABLE_STRING_8): BOOLEAN
do
Result := s /= Void implies (not s.has ('%"'))
-- To complete
end
feature -- Conversion
append_html_attributes_to (a_target: STRING)
do
if attached html_attributes as attribs then
across
attribs as c
loop
a_target.append (" " + c.key)
if attached c.item as v then
a_target.append_character ('=')
a_target.append_character ('%"')
a_target.append (v)
a_target.append_character ('%"')
end
end
end
end
end

View File

@@ -81,7 +81,7 @@ feature -- Execution
feature -- Forms
edit_form_submit (fd: CMS_FORM_DATA; a_roles: LIST [CMS_USER_ROLE])
edit_form_submit (fd: WSF_FORM_DATA; a_roles: LIST [CMS_USER_ROLE])
local
l_role: CMS_USER_ROLE
do
@@ -120,9 +120,9 @@ feature -- Forms
new_edit_form (a_action: READABLE_STRING_8; a_roles: LIST [CMS_USER_ROLE]; a_use_data: BOOLEAN): CMS_FORM
local
perms: ARRAYED_SET [READABLE_STRING_8]
tb: CMS_WIDGET_AGENT_TABLE [READABLE_STRING_8]
tb: WSF_WIDGET_AGENT_TABLE [READABLE_STRING_8]
i: INTEGER
tf: CMS_FORM_TEXT_INPUT
tf: WSF_FORM_TEXT_INPUT
do
create perms.make (10)
perms.compare_objects
@@ -158,10 +158,10 @@ feature -- Forms
tb.add_css_style ("border: solid 1px #999;")
tb.set_data (perms)
tb.set_compute_item_function (agent (p: READABLE_STRING_8; ia_roles: LIST [CMS_USER_ROLE]; ia_use_data: BOOLEAN): CMS_WIDGET_TABLE_ROW
tb.set_compute_item_function (agent (p: READABLE_STRING_8; ia_roles: LIST [CMS_USER_ROLE]; ia_use_data: BOOLEAN): WSF_WIDGET_TABLE_ROW
local
it: CMS_WIDGET_TABLE_ITEM
cb: CMS_FORM_CHECKBOX_INPUT
it: WSF_WIDGET_TABLE_ITEM
cb: WSF_FORM_CHECKBOX_INPUT
do
create Result.make (1 + ia_roles.count)
create it.make_with_text (p)
@@ -188,21 +188,21 @@ feature -- Forms
create Result.make (a_action, "edit-user-roles")
Result.set_method_post
Result.extend (tb.to_computed_table)
Result.extend (create {CMS_FORM_SUBMIT_INPUT}.make_with_text ("op", "Apply"))
Result.extend (create {WSF_FORM_SUBMIT_INPUT}.make_with_text ("op", "Apply"))
create tf.make ("new-role")
tf.add_css_class ("horizontal")
tf.set_size (24)
tf.set_label ("New user role")
Result.extend (tf)
Result.extend (create {CMS_FORM_SUBMIT_INPUT}.make_with_text ("op", "Add role"))
Result.extend (create {WSF_FORM_SUBMIT_INPUT}.make_with_text ("op", "Add role"))
create tf.make ("new-permission")
tf.add_css_class ("horizontal")
tf.set_size (24)
tf.set_label ("New permission")
Result.extend (tf)
Result.extend (create {CMS_FORM_SUBMIT_INPUT}.make_with_text ("op", "Add permission"))
Result.extend (create {WSF_FORM_SUBMIT_INPUT}.make_with_text ("op", "Add permission"))

View File

@@ -41,11 +41,11 @@ feature -- Factory
fill_edit_form (f: CMS_FORM; a_node: detachable CMS_NODE)
local
ti: CMS_FORM_TEXT_INPUT
fset: CMS_FORM_FIELD_SET
ta: CMS_FORM_TEXTAREA
tselect: CMS_FORM_SELECT
opt: CMS_FORM_SELECT_OPTION
ti: WSF_FORM_TEXT_INPUT
fset: WSF_FORM_FIELD_SET
ta: WSF_FORM_TEXTAREA
tselect: WSF_FORM_SELECT
opt: WSF_FORM_SELECT_OPTION
do
create ti.make ("title")
ti.set_label ("Title")
@@ -96,7 +96,7 @@ feature -- Factory
end
change_node (a_execution: CMS_EXECUTION; fd: CMS_FORM_DATA; a_node: like new_node)
change_node (a_execution: CMS_EXECUTION; fd: WSF_FORM_DATA; a_node: like new_node)
local
b: detachable READABLE_STRING_8
f: detachable CMS_FORMAT
@@ -123,7 +123,7 @@ feature -- Factory
end
end
new_node (a_execution: CMS_EXECUTION; fd: CMS_FORM_DATA; a_node: detachable like new_node): CMS_PAGE
new_node (a_execution: CMS_EXECUTION; fd: WSF_FORM_DATA; a_node: detachable like new_node): CMS_PAGE
-- <Precursor>
local
b: detachable READABLE_STRING_8

View File

@@ -18,7 +18,7 @@ feature -- Execution
local
b: STRING_8
f: like edit_form
fd: detachable CMS_FORM_DATA
fd: detachable WSF_FORM_DATA
do
create b.make_empty
if attached non_empty_string_path_parameter ("type") as s_type then

View File

@@ -12,7 +12,7 @@ inherit
feature -- Form
edit_form_validate (fd: CMS_FORM_DATA; b: STRING)
edit_form_validate (fd: WSF_FORM_DATA; b: STRING)
local
l_preview: BOOLEAN
l_format: detachable CMS_FORMAT
@@ -39,7 +39,7 @@ feature -- Form
end
end
edit_form_submit (fd: CMS_FORM_DATA; a_node: detachable CMS_NODE; a_type: CMS_CONTENT_TYPE; b: STRING)
edit_form_submit (fd: WSF_FORM_DATA; a_node: detachable CMS_NODE; a_type: CMS_CONTENT_TYPE; b: STRING)
local
l_preview: BOOLEAN
l_node: detachable CMS_NODE
@@ -77,7 +77,7 @@ feature -- Form
end
end
-- edit_form_submit (fd: CMS_FORM_DATA; a_type: CMS_CONTENT_TYPE; b: STRING)
-- edit_form_submit (fd: WSF_FORM_DATA; a_type: CMS_CONTENT_TYPE; b: STRING)
-- local
-- l_preview: BOOLEAN
-- do
@@ -110,8 +110,8 @@ feature -- Form
edit_form (a_node: detachable CMS_NODE; a_url: READABLE_STRING_8; a_name: STRING; a_type: CMS_CONTENT_TYPE): CMS_FORM
local
f: CMS_FORM
ts: CMS_FORM_SUBMIT_INPUT
th: CMS_FORM_HIDDEN_INPUT
ts: WSF_FORM_SUBMIT_INPUT
th: WSF_FORM_HIDDEN_INPUT
do
create f.make (a_url, a_name)

View File

@@ -18,7 +18,7 @@ feature -- Execution
local
b: STRING_8
f: like edit_form
fd: detachable CMS_FORM_DATA
fd: detachable WSF_FORM_DATA
do
create b.make_empty
if

View File

@@ -18,8 +18,8 @@ feature -- Execution
local
b: STRING
f: CMS_FORM
tf: CMS_FORM_TEXT_INPUT
ts: CMS_FORM_SUBMIT_INPUT
tf: WSF_FORM_TEXT_INPUT
ts: WSF_FORM_SUBMIT_INPUT
o: OPENID_CONSUMER
v: OPENID_CONSUMER_VALIDATION
tb: HASH_TABLE [READABLE_STRING_8, STRING_8]

View File

@@ -60,10 +60,10 @@ feature -- Hooks
end
end
form_alter (a_form: CMS_FORM; a_form_data: detachable CMS_FORM_DATA; a_execution: CMS_EXECUTION)
form_alter (a_form: CMS_FORM; a_form_data: detachable WSF_FORM_DATA; a_execution: CMS_EXECUTION)
local
i: CMS_FORM_DIV
fh: CMS_FORM_HIDDEN_INPUT
i: WSF_FORM_DIV
fh: WSF_FORM_HIDDEN_INPUT
do
if a_form.id.same_string ("openid-login") then
create i.make_with_text_and_css_id (
@@ -82,7 +82,7 @@ feature -- Hooks
,
"openid"
)
if attached a_form.items_by_type ({CMS_WIDGET_TEXT}) as lst and then not lst.is_empty then
if attached a_form.items_by_type ({WSF_WIDGET_TEXT}) as lst and then not lst.is_empty then
a_form.insert_before (i, lst.last)
else
a_form.extend (i)
@@ -98,7 +98,7 @@ feature -- Hooks
across
f_lst as c
loop
if attached {CMS_FORM_TEXT_INPUT} c.item as txt then
if attached {WSF_FORM_TEXT_INPUT} c.item as txt then
txt.set_text_value (l_openid_nickname.to_string_32)
end
end
@@ -110,7 +110,7 @@ feature -- Hooks
across
f_lst as c
loop
if attached {CMS_FORM_TEXT_INPUT} c.item as txt then
if attached {WSF_FORM_TEXT_INPUT} c.item as txt then
txt.set_text_value (l_openid_email.to_string_32)
end
end
@@ -122,7 +122,7 @@ feature -- Hooks
end
end
openid_user_register_submitted (a_form_data: CMS_FORM_DATA)
openid_user_register_submitted (a_form_data: WSF_FORM_DATA)
do
end

View File

@@ -94,7 +94,7 @@ feature -- Execution
l_url: detachable READABLE_STRING_8
b: STRING_8
f: CMS_FORM
fd: detachable CMS_FORM_DATA
fd: detachable WSF_FORM_DATA
do
if
attached {WSF_STRING} request.item ("destination") as s_dest
@@ -134,7 +134,7 @@ feature -- Execution
end
end
on_form_submitted (fd: CMS_FORM_DATA)
on_form_submitted (fd: WSF_FORM_DATA)
local
u: detachable CMS_USER
do
@@ -159,12 +159,12 @@ feature -- Execution
login_form (a_action: READABLE_STRING_8; a_form_name: READABLE_STRING_8; a_destination: READABLE_STRING_8): CMS_FORM
local
th: CMS_FORM_HIDDEN_INPUT
ti: CMS_FORM_TEXT_INPUT
tp: CMS_FORM_PASSWORD_INPUT
ts: CMS_FORM_SUBMIT_INPUT
l_logo: CMS_FORM_RAW_TEXT
d: CMS_FORM_DIV
th: WSF_FORM_HIDDEN_INPUT
ti: WSF_FORM_TEXT_INPUT
tp: WSF_FORM_PASSWORD_INPUT
ts: WSF_FORM_SUBMIT_INPUT
l_logo: WSF_FORM_RAW_TEXT
d: WSF_FORM_DIV
do
create Result.make (a_action, a_form_name)

View File

@@ -20,7 +20,7 @@ feature -- Execution
local
b: STRING_8
f: CMS_FORM
fd: detachable CMS_FORM_DATA
fd: detachable WSF_FORM_DATA
u: detachable CMS_USER
l_is_editing_current_user: BOOLEAN
do
@@ -63,7 +63,7 @@ feature -- Execution
set_main_content (b)
end
edit_form_validate (fd: CMS_FORM_DATA; u: CMS_USER)
edit_form_validate (fd: WSF_FORM_DATA; u: CMS_USER)
local
fu: detachable CMS_USER
do
@@ -81,7 +81,7 @@ feature -- Execution
end
end
edit_form_submit (fd: CMS_FORM_DATA; u: CMS_USER; a_is_editing_current_user: BOOLEAN; b: STRING)
edit_form_submit (fd: WSF_FORM_DATA; u: CMS_USER; a_is_editing_current_user: BOOLEAN; b: STRING)
local
up: detachable CMS_USER_PROFILE
l_roles: like {CMS_USER}.roles
@@ -138,12 +138,12 @@ feature -- Execution
edit_form (u: CMS_USER; a_url: READABLE_STRING_8; a_name: STRING): CMS_FORM
local
f: CMS_FORM
ti: CMS_FORM_TEXT_INPUT
tp: CMS_FORM_PASSWORD_INPUT
ta: CMS_FORM_TEXTAREA
ts: CMS_FORM_SUBMIT_INPUT
tset: CMS_FORM_FIELD_SET
cb: CMS_FORM_CHECKBOX_INPUT
ti: WSF_FORM_TEXT_INPUT
tp: WSF_FORM_PASSWORD_INPUT
ta: WSF_FORM_TEXTAREA
ts: WSF_FORM_SUBMIT_INPUT
tset: WSF_FORM_FIELD_SET
cb: WSF_FORM_CHECKBOX_INPUT
do
create f.make (a_url, a_name)

View File

@@ -21,7 +21,7 @@ feature -- Execution
b: STRING_8
f: CMS_FORM
u: detachable CMS_USER
fd: detachable CMS_FORM_DATA
fd: detachable WSF_FORM_DATA
do
set_title ("Request new password")
create b.make_empty
@@ -56,7 +56,7 @@ feature -- Execution
set_main_content (b)
end
password_form_validate (fd: CMS_FORM_DATA)
password_form_validate (fd: WSF_FORM_DATA)
local
u: detachable CMS_USER
do
@@ -73,7 +73,7 @@ feature -- Execution
initialize_primary_tabs (u)
end
password_form_submit (fd: CMS_FORM_DATA; b: STRING)
password_form_submit (fd: WSF_FORM_DATA; b: STRING)
local
e: detachable CMS_EMAIL
l_uuid: UUID
@@ -113,9 +113,9 @@ feature -- Execution
local
u: like user
f: CMS_FORM
ti: CMS_FORM_TEXT_INPUT
th: CMS_FORM_HIDDEN_INPUT
ts: CMS_FORM_SUBMIT_INPUT
ti: WSF_FORM_TEXT_INPUT
th: WSF_FORM_HIDDEN_INPUT
ts: WSF_FORM_SUBMIT_INPUT
err: BOOLEAN
do
create f.make (a_url, a_name)

View File

@@ -20,7 +20,7 @@ feature -- Execution
local
b: STRING_8
f: CMS_FORM
fd: detachable CMS_FORM_DATA
fd: detachable WSF_FORM_DATA
do
set_title ("Create new account")
create b.make_empty
@@ -50,7 +50,7 @@ feature -- Execution
set_main_content (b)
end
registration_form_validate (fd: CMS_FORM_DATA)
registration_form_validate (fd: WSF_FORM_DATA)
local
u: detachable CMS_USER
do
@@ -68,7 +68,7 @@ feature -- Execution
end
end
registration_form_submitted (fd: CMS_FORM_DATA; buf: STRING)
registration_form_submitted (fd: WSF_FORM_DATA; buf: STRING)
local
b: STRING
u: detachable CMS_USER
@@ -124,17 +124,17 @@ feature -- Execution
registration_form (a_url: READABLE_STRING_8; a_name: STRING): CMS_FORM
local
f: CMS_FORM
ti: CMS_FORM_TEXT_INPUT
tp: CMS_FORM_PASSWORD_INPUT
ta: CMS_FORM_TEXTAREA
ts: CMS_FORM_SUBMIT_INPUT
ti: WSF_FORM_TEXT_INPUT
tp: WSF_FORM_PASSWORD_INPUT
ta: WSF_FORM_TEXTAREA
ts: WSF_FORM_SUBMIT_INPUT
do
create f.make (a_url, a_name)
create ti.make ("username")
ti.set_label ("Username")
ti.set_is_required (True)
ti.set_validation_action (agent (fd: CMS_FORM_DATA)
ti.set_validation_action (agent (fd: WSF_FORM_DATA)
do
if attached {WSF_STRING} fd.item ("username") as f_username and then f_username.value.count >= 5 then
else

View File

@@ -8,6 +8,12 @@ deferred class
CMS_THEME
inherit
WSF_THEME
undefine
url_encoded,
html_encoded
end
CMS_COMMON_API
feature {NONE} -- Access

View File

@@ -1,22 +0,0 @@
note
description: "Summary description for {CMS_WIDGET}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
CMS_WIDGET
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

View File

@@ -1,225 +0,0 @@
note
description: "Summary description for {CMS_WIDGET_TABLE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_WIDGET_AGENT_TABLE [G]
inherit
CMS_WIDGET
WITH_CSS_ID
WITH_CSS_CLASS
WITH_CSS_STYLE
create
make
convert
to_computed_table: {CMS_WIDGET_TABLE}
feature {NONE} -- Initialization
make
do
create columns.make_empty
end
feature -- Access
column_count: INTEGER
do
Result := columns.count
end
columns: ARRAY [CMS_WIDGET_TABLE_COLUMN]
column (c: INTEGER): CMS_WIDGET_TABLE_COLUMN
do
if c > column_count then
set_column_count (c)
end
Result := columns[c]
end
has_title: BOOLEAN
do
Result := across columns as c some c.item.title /= Void end
end
head_data: detachable ITERABLE [G]
-- thead
foot_data: detachable ITERABLE [G]
-- tfoot
data: detachable ITERABLE [G]
-- tbody
compute_item_function: detachable FUNCTION [ANY, TUPLE [data: G], CMS_WIDGET_TABLE_ROW]
feature -- Change
set_head_data (d: like head_data)
do
head_data := d
end
set_foot_data (d: like foot_data)
do
foot_data := d
end
set_data (d: like data)
do
data := d
end
set_compute_item_function (fct: like compute_item_function)
do
compute_item_function := fct
end
set_column_count (nb: INTEGER)
do
if nb > columns.count then
-- columns.conservative_resize_with_default (create {CMS_WIDGET_TABLE_COLUMN}, 1, nb)
from
until
columns.count = nb
loop
columns.force (create {CMS_WIDGET_TABLE_COLUMN}.make (columns.upper + 1), columns.upper + 1)
end
else
columns.remove_tail (columns.count - nb)
end
end
set_column_title (c: INTEGER; t: READABLE_STRING_32)
do
if c > column_count then
set_column_count (c)
end
if attached column (c) as col then
col.set_title (t)
end
end
feature -- Conversion
to_computed_table: CMS_WIDGET_TABLE
local
col: CMS_WIDGET_TABLE_COLUMN
do
create Result.make
Result.set_column_count (column_count)
-- css classes
Result.add_css_classes (css_classes)
-- css id
Result.set_css_id (css_id)
-- css style
Result.add_css_style (css_style)
-- columns
across
columns as c
loop
col := Result.column (c.item.index)
col.set_title (c.item.title)
col.add_css_style (c.item.css_style)
col.add_css_classes (c.item.css_classes)
end
-- rows
if attached compute_item_function as fct then
if attached head_data as lst then
across lst as d loop
Result.add_head_row (fct.item ([d.item]))
end
end
if attached data as lst then
across lst as d loop
Result.add_row (fct.item ([d.item]))
end
end
if attached foot_data as lst then
across lst as d loop
Result.add_foot_row (fct.item ([d.item]))
end
end
end
end
feature -- Conversion: HTML
append_to_html (a_theme: CMS_THEME; a_html: STRING_8)
local
l_use_tbody: BOOLEAN
do
a_html.append ("<table")
append_css_id_to (a_html)
append_css_class_to (a_html, Void)
append_css_style_to (a_html)
a_html.append (">")
if has_title then
a_html.append ("<tr>")
across
columns as c
loop
c.item.append_table_header_to_html (a_theme, a_html)
end
a_html.append ("</tr>")
end
if attached head_data as l_head_data then
l_use_tbody := True
a_html.append ("<thead>")
append_data_to_html (l_head_data, a_theme, a_html)
a_html.append ("</thead>")
end
if attached foot_data as l_foot_data then
l_use_tbody := True
a_html.append ("<tfoot>")
append_data_to_html (l_foot_data, a_theme, a_html)
a_html.append ("</tfoot>")
end
if attached data as l_data then
if l_use_tbody then
a_html.append ("<tbody>")
end
append_data_to_html (l_data, a_theme, a_html)
if l_use_tbody then
a_html.append ("</tbody>")
end
end
a_html.append ("</table>")
end
append_data_to_html (lst: ITERABLE [G]; a_theme: CMS_THEME; a_html: STRING_8)
local
fct: like compute_item_function
do
fct := compute_item_function
across
lst as d
loop
if fct /= Void and then attached fct.item ([d.item]) as r then
r.append_to_html (a_theme, a_html)
else
a_html.append ("<tr>")
a_html.append ("<td>")
if attached d.item as g then
a_html.append (g.out)
end
a_html.append ("</td>")
a_html.append ("</tr>")
end
end
end
end

View File

@@ -1,250 +0,0 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
deferred class
CMS_WIDGET_COMPOSITE
inherit
ITERABLE [CMS_WIDGET]
feature {NONE} -- Initialization
initialize_with_count (n: INTEGER)
do
create items.make (n)
end
feature -- Status
is_empty: BOOLEAN
do
Result := count = 0
end
has_item (i: CMS_WIDGET): BOOLEAN
do
if has_immediate_item (i) then
Result := True
else
across
items as c
loop
if attached {CMS_WIDGET_COMPOSITE} c.item as comp then
Result := comp.has_item (i)
end
end
end
end
has_immediate_item (i: CMS_WIDGET): BOOLEAN
do
Result := items.has (i)
end
feature -- Access: cursor
new_cursor: ITERATION_CURSOR [CMS_WIDGET]
-- Fresh cursor associated with current structure
do
Result := items.new_cursor
end
feature -- Access
count: INTEGER
do
Result := immediate_count
across
items as c
loop
if attached {CMS_WIDGET_COMPOSITE} c.item as comp then
Result := Result + comp.count
end
end
end
immediate_count: INTEGER
do
Result := items.count
end
items_by_type (a_type: TYPE [detachable ANY]): detachable LIST [CMS_WIDGET]
-- All CMS_WIDGET items conforming to a_type.
-- Warning: you should pass {detachable CMS_FORM_SUBMIT_INPUT} rather than just {CMS_FORM_SUBMIT_INPUT}
local
int: INTERNAL
tid: INTEGER
t: TYPE [detachable ANY]
do
tid := a_type.type_id
create int
tid := int.detachable_type (tid)
if tid > 0 then
t := int.type_of_type (tid)
if not a_type.conforms_to (t) then
t := a_type
end
else
t := a_type
end
Result := items_by_type_from (Current, t)
end
items_by_css_id (a_id: READABLE_STRING_GENERAL): detachable LIST [CMS_WIDGET]
do
Result := items_by_css_id_from (Current, a_id)
end
first_item_by_css_id (a_id: READABLE_STRING_GENERAL): detachable CMS_WIDGET
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 -- Change
insert_before (i: CMS_WIDGET; a_item: CMS_WIDGET)
-- Insert `i' before `a_item'
require
has_item (a_item)
local
done: BOOLEAN
do
if has_immediate_item (a_item) then
items.start
items.search (a_item)
if items.exhausted then
items.put_front (i)
else
items.put_left (i)
end
else
across
items as c
until
done
loop
if attached {CMS_WIDGET_COMPOSITE} c.item as comp and then comp.has_item (a_item) then
comp.insert_before (i, a_item)
done := True
end
end
end
end
insert_after (i: CMS_WIDGET; a_item: CMS_WIDGET)
-- Insert `i' after `a_item'
require
has_item (a_item)
local
done: BOOLEAN
do
if has_immediate_item (a_item) then
items.start
items.search (a_item)
if items.exhausted then
items.force (i)
else
items.put_right (i)
end
else
across
items as c
until
done
loop
if attached {CMS_WIDGET_COMPOSITE} c.item as comp and then comp.has_item (a_item) then
comp.insert_after (i, a_item)
done := True
end
end
end
end
extend (i: CMS_WIDGET)
do
items.force (i)
end
prepend (i: CMS_WIDGET)
do
items.put_front (i)
end
extend_text (t: READABLE_STRING_8)
do
extend (create {CMS_WIDGET_TEXT}.make_with_text (t))
end
feature {NONE} -- Implementation: Items
items_by_type_from (a_container: ITERABLE [CMS_WIDGET]; a_type: TYPE [detachable ANY]): detachable ARRAYED_LIST [CMS_WIDGET]
local
res: detachable ARRAYED_LIST [CMS_WIDGET]
do
across
a_container as i
loop
if i.item.generating_type.conforms_to (a_type) then
if res = Void then
create res.make (1)
end
res.force (i.item)
elseif attached {ITERABLE [CMS_WIDGET]} i.item as l_cont then
if attached items_by_type_from (l_cont, a_type) 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_WIDGET]; a_id: READABLE_STRING_GENERAL): detachable ARRAYED_LIST [CMS_WIDGET]
local
res: detachable ARRAYED_LIST [CMS_WIDGET]
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_WIDGET]} 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 {NONE} -- Implementation
items: ARRAYED_LIST [CMS_WIDGET]
-- name => item
invariant
items /= Void
end

View File

@@ -1,281 +0,0 @@
note
description: "Summary description for {CMS_WIDGET_FILLED_TABLE}."
date: "$Date$"
revision: "$Revision$"
class
CMS_WIDGET_TABLE
inherit
CMS_WIDGET
WITH_CSS_ID
WITH_CSS_CLASS
WITH_CSS_STYLE
ITERABLE [CMS_WIDGET_TABLE_ITEM]
create
make
feature {NONE} -- Initialization
make
do
create columns.make_empty
end
make_from_table (tb: CMS_WIDGET_AGENT_TABLE [detachable ANY])
local
fct: like {CMS_WIDGET_AGENT_TABLE [detachable ANY]}.compute_item_function
do
make
set_column_count (tb.column_count)
-- css classes
if attached tb.css_classes as lst then
across lst as c loop
add_css_class (c.item)
end
end
-- css id
set_css_id (tb.css_id)
-- css style
add_css_style (tb.css_style)
-- columns
across
tb.columns as c
loop
columns [c.item.index] := c.item.twin
end
-- rows
fct := tb.compute_item_function
if fct /= Void then
if attached tb.head_data as lst then
across lst as d loop
add_head_row (fct.item ([d.item]))
end
end
if attached tb.data as lst then
across lst as d loop
add_row (fct.item ([d.item]))
end
end
if attached tb.foot_data as lst then
across lst as d loop
add_foot_row (fct.item ([d.item]))
end
end
end
end
feature -- Access
new_cursor: CMS_WIDGET_TABLE_ITERATION_CURSOR
-- Fresh cursor associated with current structure
do
create Result.make (Current)
end
column_count: INTEGER
do
Result := columns.count
end
head_row_count: INTEGER
do
if attached head_rows as lst then
Result := lst.count
end
end
body_row_count: INTEGER
do
if attached rows as lst then
Result := lst.count
end
end
foot_row_count: INTEGER
do
if attached foot_rows as lst then
Result := lst.count
end
end
row_count: INTEGER
do
Result := head_row_count + body_row_count + foot_row_count
end
columns: ARRAY [CMS_WIDGET_TABLE_COLUMN]
column (c: INTEGER): CMS_WIDGET_TABLE_COLUMN
do
if c > column_count then
set_column_count (c)
end
Result := columns[c]
end
row (r: INTEGER): detachable CMS_WIDGET_TABLE_ROW
do
if r <= head_row_count then
if attached head_rows as lst then
Result := lst [r]
end
elseif r <= head_row_count + body_row_count then
if attached rows as lst then
Result := lst [r - head_row_count]
end
elseif r <= row_count then
if attached foot_rows as lst then
Result := lst [r - head_row_count - body_row_count]
end
end
end
has_title: BOOLEAN
do
Result := across columns as c some c.item.title /= Void end
end
head_rows: detachable ARRAYED_LIST [CMS_WIDGET_TABLE_ROW]
-- thead
foot_rows: detachable ARRAYED_LIST [CMS_WIDGET_TABLE_ROW]
-- tfoot
rows: detachable ARRAYED_LIST [CMS_WIDGET_TABLE_ROW]
-- tbody
feature -- Change
clear_rows
do
head_rows := Void
foot_rows := Void
rows := Void
end
add_head_row (r: CMS_WIDGET_TABLE_ROW)
local
lst: like head_rows
do
lst := head_rows
if lst = Void then
create {ARRAYED_LIST [CMS_WIDGET_TABLE_ROW]} lst.make (1)
head_rows := lst
end
lst.force (r)
end
add_foot_row (r: CMS_WIDGET_TABLE_ROW)
local
lst: like foot_rows
do
lst := foot_rows
if lst = Void then
create {ARRAYED_LIST [CMS_WIDGET_TABLE_ROW]} lst.make (1)
foot_rows := lst
end
lst.force (r)
end
add_row (r: CMS_WIDGET_TABLE_ROW)
local
lst: like rows
do
lst := rows
if lst = Void then
create {ARRAYED_LIST [CMS_WIDGET_TABLE_ROW]} lst.make (1)
rows := lst
end
lst.force (r)
end
set_column_count (nb: INTEGER)
do
if nb > columns.count then
from
until
columns.count = nb
loop
columns.force (create {CMS_WIDGET_TABLE_COLUMN}.make (columns.upper + 1), columns.upper + 1)
end
else
columns.remove_tail (columns.count - nb)
end
end
set_column_title (c: INTEGER; t: READABLE_STRING_32)
do
if c > column_count then
set_column_count (c)
end
if attached column (c) as col then
col.set_title (t)
end
end
feature -- Conversion
append_to_html (a_theme: CMS_THEME; a_html: STRING_8)
local
l_use_tbody: BOOLEAN
do
a_html.append ("<table")
append_css_id_to (a_html)
append_css_class_to (a_html, Void)
append_css_style_to (a_html)
a_html.append (">")
if has_title then
a_html.append ("<tr>")
across
columns as c
loop
c.item.append_table_header_to_html (a_theme, a_html)
end
a_html.append ("</tr>")
end
if attached head_rows as l_head_rows then
l_use_tbody := True
a_html.append ("<thead>")
append_rows_to_html (l_head_rows, a_theme, a_html)
a_html.append ("</thead>")
end
if attached foot_rows as l_foot_rows then
l_use_tbody := True
a_html.append ("<tfoot>")
append_rows_to_html (l_foot_rows, a_theme, a_html)
a_html.append ("</tfoot>")
end
if attached rows as l_rows then
if l_use_tbody then
a_html.append ("<tbody>")
end
append_rows_to_html (l_rows, a_theme, a_html)
if l_use_tbody then
a_html.append ("</tbody>")
end
end
a_html.append ("</table>")
end
append_rows_to_html (lst: ITERABLE [CMS_WIDGET_TABLE_ROW]; a_theme: CMS_THEME; a_html: STRING_8)
do
across
lst as r
loop
r.item.append_to_html (a_theme, a_html)
end
end
end

View File

@@ -1,52 +0,0 @@
note
description: "Summary description for {CMS_WIDGET_COLUMN}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_WIDGET_TABLE_COLUMN
inherit
WITH_CSS_CLASS
WITH_CSS_STYLE
create
make
feature {NONE} -- Initialization
make (i: like index)
do
index := i
end
feature -- Access
index: INTEGER
title: detachable READABLE_STRING_32
feature -- Change
set_title (t: like title)
do
title := t
end
feature -- Conversion
append_table_header_to_html (a_theme: CMS_THEME; a_html: STRING_8)
do
a_html.append ("<th")
append_css_class_to (a_html, Void)
append_css_style_to (a_html)
a_html.append_character ('>')
if attached title as l_title then
a_html.append (a_theme.html_encoded (l_title))
end
a_html.append ("</th>")
end
end

View File

@@ -1,78 +0,0 @@
note
description: "Summary description for {CMS_WIDGET_TABLE_ITEM}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_WIDGET_TABLE_ITEM
inherit
CMS_WIDGET
WITH_HTML_ATTRIBUTE
WITH_CSS_CLASS
WITH_CSS_STYLE
ITERABLE [CMS_WIDGET]
create
make_with_text,
make_with_text_and_css,
make_with_content
feature {NONE} -- Initialization
make_with_text (a_text: READABLE_STRING_8)
do
make_with_content (create {CMS_WIDGET_TEXT}.make_with_text (a_text))
end
make_with_text_and_css (a_text: READABLE_STRING_8; a_css_classes: detachable ITERABLE [READABLE_STRING_8])
do
make_with_text (a_text)
if a_css_classes /= Void then
across
a_css_classes as c
loop
add_css_class (c.item)
end
end
end
make_with_content (a_widget: CMS_WIDGET)
do
content := a_widget
end
feature -- Access
content: CMS_WIDGET
feature -- Access
new_cursor: ITERATION_CURSOR [CMS_WIDGET]
-- Fresh cursor associated with current structure
local
lst: ARRAYED_LIST [CMS_WIDGET]
do
create lst.make (1)
lst.extend (content)
Result := lst.new_cursor
end
feature -- Conversion
append_to_html (a_theme: CMS_THEME; a_html: STRING_8)
do
a_html.append ("<td")
append_css_class_to (a_html, Void)
append_css_style_to (a_html)
a_html.append_character ('>')
content.append_to_html (a_theme, a_html)
a_html.append ("</td>")
end
end

View File

@@ -1,96 +0,0 @@
note
description: "Summary description for {CMS_WIDGET_TABLE_ITERATION_CURSOR}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_WIDGET_TABLE_ITERATION_CURSOR
inherit
ITERATION_CURSOR [CMS_WIDGET_TABLE_ITEM]
create
make
feature {NONE} -- Initialization
make (a_table: CMS_WIDGET_TABLE)
do
table := a_table
start
end
table: CMS_WIDGET_TABLE
row_index: INTEGER
column_index: INTEGER
feature -- Access
start
do
row_index := 1
column_index := 0
forth
end
item: CMS_WIDGET_TABLE_ITEM
-- Item at current cursor position.
do
if attached table.row (row_index) as r then
if attached r.item (column_index) as w then
Result := w
else
create Result.make_with_text ("")
end
else
create Result.make_with_text ("")
end
end
feature -- Status report
after: BOOLEAN
-- Are there no more items to iterate over?
do
if row_index > table.row_count then
Result := True
elseif row_index = table.row_count then
if attached table.row (row_index) as l_row then
if column_index > l_row.count then
Result := True
else
Result := False
end
else
Result := True
end
end
end
feature -- Cursor movement
forth
-- Move to next position.
do
if row_index <= table.row_count then
if attached table.row (row_index) as l_row then
if column_index < l_row.count then
column_index := column_index + 1
else
from
row_index := row_index + 1
column_index := 1
until
row_index > table.row_count or
attached table.row (row_index) as r and then r.count > 0
loop
row_index := row_index + 1
end
end
end
end
end
end

View File

@@ -1,106 +0,0 @@
note
description: "Summary description for {CMS_WIDGET_TABLE_ROW}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_WIDGET_TABLE_ROW
inherit
WITH_CSS_CLASS
WITH_CSS_STYLE
ITERABLE [CMS_WIDGET_TABLE_ITEM]
create
make,
make_with_items
feature {NONE} -- Initialization
make (n: INTEGER)
do
create items.make (n)
end
make_with_items (lst: ITERABLE [CMS_WIDGET_TABLE_ITEM])
local
n: INTEGER
do
across lst as c loop
n := n + 1
end
make (n)
across
lst as c
loop
add_item (c.item)
end
end
items: ARRAYED_LIST [CMS_WIDGET_TABLE_ITEM]
feature -- Access
new_cursor: ITERATION_CURSOR [CMS_WIDGET_TABLE_ITEM]
do
Result := items.new_cursor
end
count: INTEGER
do
Result := items.count
end
item (c: INTEGER): CMS_WIDGET_TABLE_ITEM
do
Result := items [c]
end
feature -- Change
set_item (w: CMS_WIDGET_TABLE_ITEM; col: INTEGER)
do
if col > items.count then
items.grow (col)
from
until
items.count >= col - 1
loop
items.force (create {CMS_WIDGET_TABLE_ITEM}.make_with_text (""))
end
items.force (w)
else
items.put_i_th (w, col)
end
end
add_widget (w: CMS_WIDGET)
do
add_item (create {CMS_WIDGET_TABLE_ITEM}.make_with_content (w))
end
force, add_item (w: CMS_WIDGET_TABLE_ITEM)
do
items.force (w)
end
feature -- Conversion
append_to_html (a_theme: CMS_THEME; a_html: STRING_8)
do
a_html.append ("<tr")
append_css_class_to (a_html, Void)
append_css_style_to (a_html)
a_html.append_character ('>')
across
items as c
loop
c.item.append_to_html (a_theme, a_html)
end
a_html.append ("</tr>")
end
end

View File

@@ -1,41 +0,0 @@
note
description: "Summary description for {CMS_WIDGET_TEXT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_WIDGET_TEXT
inherit
CMS_WIDGET
create
make_with_text
feature {NONE} -- Initialization
make_with_text (a_text: READABLE_STRING_8)
do
text := a_text
end
feature -- Access
text: READABLE_STRING_8
feature -- Change
set_text (a_text: like text)
do
text := a_text
end
feature -- Conversion
append_to_html (a_theme: CMS_THEME; a_html: STRING_8)
do
a_html.append (text)
end
end