Added functionalities to CMS_FORM_.. classes

This commit is contained in:
Jocelyn Fiat
2013-02-21 19:08:26 +01:00
parent a417cc1e16
commit b543a6b6f2
3 changed files with 59 additions and 0 deletions

View File

@@ -102,6 +102,20 @@ feature -- Items
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
@@ -144,6 +158,35 @@ feature {NONE} -- Implementation: Items
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)

View File

@@ -17,6 +17,7 @@ inherit
create
make,
make_with_item,
make_with_items,
make_with_text
feature {NONE} -- Initialization
@@ -38,6 +39,16 @@ feature {NONE} -- Initialization
extend (i)
end
make_with_items (it: ITERABLE [CMS_FORM_ITEM])
do
create items.make (2)
across
it as c
loop
extend (c.item)
end
end
feature -- Access
new_cursor: ITERATION_CURSOR [CMS_FORM_ITEM]

View File

@@ -51,6 +51,11 @@ feature -- Change
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))