Refactor directory structrue
This commit is contained in:
53
library/model/src/link/cms_external_link.e
Normal file
53
library/model/src/link/cms_external_link.e
Normal file
@@ -0,0 +1,53 @@
|
||||
note
|
||||
description: "[
|
||||
Abstraction to represent a link outside current CMS system.
|
||||
For instance, a web url.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision: 95883 $"
|
||||
|
||||
class
|
||||
CMS_EXTERNAL_LINK
|
||||
|
||||
inherit
|
||||
CMS_LINK
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_title: like title; a_location: like location)
|
||||
-- Create current external link with optional title `a_title' and location `a_location'.
|
||||
do
|
||||
title := a_title
|
||||
location := a_location
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_active: BOOLEAN = False
|
||||
-- <Precursor>
|
||||
|
||||
is_expanded: BOOLEAN = False
|
||||
-- <Precursor>
|
||||
|
||||
is_collapsed: BOOLEAN = False
|
||||
-- <Precursor>
|
||||
|
||||
is_expandable: BOOLEAN = False
|
||||
-- <Precursor>
|
||||
|
||||
has_children: BOOLEAN = False
|
||||
-- <Precursor>
|
||||
|
||||
feature -- Access
|
||||
|
||||
children: detachable LIST [CMS_LINK]
|
||||
-- <Precursor>
|
||||
|
||||
invariant
|
||||
note
|
||||
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
92
library/model/src/link/cms_link.e
Normal file
92
library/model/src/link/cms_link.e
Normal file
@@ -0,0 +1,92 @@
|
||||
note
|
||||
description: "[
|
||||
Abstraction to represent a URI link in the CMS system.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_LINK
|
||||
|
||||
inherit
|
||||
REFACTORING_HELPER
|
||||
|
||||
DEBUG_OUTPUT
|
||||
|
||||
ITERABLE [CMS_LINK]
|
||||
|
||||
feature -- Access
|
||||
|
||||
title: READABLE_STRING_32
|
||||
-- Associated title.
|
||||
|
||||
location: READABLE_STRING_8
|
||||
-- Associated url location.
|
||||
|
||||
feature -- status report
|
||||
|
||||
is_active: BOOLEAN
|
||||
-- Is current link active?
|
||||
-- i.e: related to requested url.
|
||||
deferred
|
||||
end
|
||||
|
||||
is_expanded: BOOLEAN
|
||||
-- Is expanded and visually expanded?
|
||||
deferred
|
||||
end
|
||||
|
||||
is_collapsed: BOOLEAN
|
||||
-- Is expanded, but visually collapsed?
|
||||
deferred
|
||||
ensure
|
||||
Result implies is_expandable
|
||||
end
|
||||
|
||||
is_expandable: BOOLEAN
|
||||
-- Is expandable?
|
||||
deferred
|
||||
end
|
||||
|
||||
has_children: BOOLEAN
|
||||
-- Has sub link?
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
parent: detachable CMS_LINK
|
||||
-- Optional parent link.
|
||||
|
||||
children: detachable LIST [CMS_LINK]
|
||||
-- Optional children links.
|
||||
-- Useful to have a non flat menu.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: ITERATION_CURSOR [CMS_LINK]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
if attached children as lst then
|
||||
Result := lst.new_cursor
|
||||
else
|
||||
Result := (create {ARRAYED_LIST [CMS_LINK]}.make (0)).new_cursor
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
debug_output: STRING_32
|
||||
-- String that should be displayed in debugger to represent `Current'.
|
||||
do
|
||||
create Result.make_from_string (title)
|
||||
Result.append_string_general (" -> ")
|
||||
Result.append_string_general (location)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
52
library/model/src/link/cms_link_composite.e
Normal file
52
library/model/src/link/cms_link_composite.e
Normal file
@@ -0,0 +1,52 @@
|
||||
note
|
||||
description: "[
|
||||
Abstraction to represent a links container in the CMS system.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_LINK_COMPOSITE
|
||||
|
||||
inherit
|
||||
ITERABLE [CMS_LINK]
|
||||
|
||||
feature -- Access
|
||||
|
||||
items: detachable LIST [CMS_LINK]
|
||||
-- Children links.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
extend (lnk: CMS_LINK)
|
||||
-- Add `lnk' as a sub link.
|
||||
deferred
|
||||
end
|
||||
|
||||
remove (lnk: CMS_LINK)
|
||||
-- Remove link `lnk' from Current container.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- status report
|
||||
|
||||
is_empty: BOOLEAN
|
||||
-- Is container empty?
|
||||
do
|
||||
Result := not attached items as l_items or else l_items.is_empty
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
-- Number of immediate sub links.
|
||||
do
|
||||
if attached items as l_items then
|
||||
Result := l_items.count
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
173
library/model/src/link/cms_local_link.e
Normal file
173
library/model/src/link/cms_local_link.e
Normal file
@@ -0,0 +1,173 @@
|
||||
note
|
||||
description: "[
|
||||
Abstraction to represent a link to a CMS resource.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_LOCAL_LINK
|
||||
|
||||
inherit
|
||||
CMS_LINK
|
||||
|
||||
CMS_LINK_COMPOSITE
|
||||
rename
|
||||
items as children,
|
||||
extend as add_link,
|
||||
remove as remove_link
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_title: detachable like title; a_location: like location)
|
||||
-- Create current local link with optional title `a_title' and location `a_location'.
|
||||
do
|
||||
if a_title /= Void then
|
||||
title := a_title
|
||||
else
|
||||
title := a_location
|
||||
end
|
||||
location := a_location
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
permission_arguments: detachable ITERABLE [READABLE_STRING_8]
|
||||
-- Permissions required by current link resource.
|
||||
|
||||
children: detachable LIST [CMS_LINK]
|
||||
-- <Precursor>
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_active: BOOLEAN
|
||||
-- <Precursor>
|
||||
|
||||
is_expanded: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := is_expandable and then internal_is_expanded
|
||||
end
|
||||
|
||||
is_collapsed: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := is_expandable and then internal_is_collapsed
|
||||
end
|
||||
|
||||
is_expandable: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := internal_is_expandable or internal_is_expanded or has_children
|
||||
end
|
||||
|
||||
has_children: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := attached children as l_children and then not l_children.is_empty
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
add_link (lnk: CMS_LINK)
|
||||
-- <Precursor>
|
||||
local
|
||||
lst: like children
|
||||
do
|
||||
lst := children
|
||||
if lst = Void then
|
||||
create {ARRAYED_LIST [CMS_LINK]} lst.make (1)
|
||||
children := lst
|
||||
end
|
||||
lst.force (lnk)
|
||||
end
|
||||
|
||||
remove_link (lnk: CMS_LINK)
|
||||
-- <Precursor>
|
||||
local
|
||||
lst: like children
|
||||
do
|
||||
lst := children
|
||||
if lst /= Void then
|
||||
lst.prune_all (lnk)
|
||||
if lst.is_empty then
|
||||
children := Void
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_children (lst: like children)
|
||||
-- Set `children' to `lst'.
|
||||
do
|
||||
children := lst
|
||||
ensure
|
||||
children_set: children = lst
|
||||
end
|
||||
|
||||
set_permission_arguments (args: like permission_arguments)
|
||||
-- Set `permission_arguments' to `args'.
|
||||
do
|
||||
permission_arguments := args
|
||||
ensure
|
||||
permission_arguments_set: permission_arguments = args
|
||||
end
|
||||
|
||||
feature -- Status change
|
||||
|
||||
set_is_active (b: BOOLEAN)
|
||||
-- Set `is_active' to `b'.
|
||||
do
|
||||
is_active := b
|
||||
ensure
|
||||
is_active: is_active = b
|
||||
end
|
||||
|
||||
set_expanded (b: like is_expanded)
|
||||
-- Set `is_expanded' to `b'.
|
||||
do
|
||||
if b then
|
||||
set_expandable (True)
|
||||
set_collapsed (False)
|
||||
end
|
||||
internal_is_expanded := b
|
||||
ensure
|
||||
is_expanded: is_expanded = b
|
||||
end
|
||||
|
||||
set_collapsed (b: like is_collapsed)
|
||||
-- Set `is_collapsed' to `b'.
|
||||
do
|
||||
if b then
|
||||
set_expanded (False)
|
||||
end
|
||||
internal_is_collapsed := b
|
||||
ensure
|
||||
is_collapsed: is_collapsed= b
|
||||
end
|
||||
|
||||
set_expandable (b: like is_expandable)
|
||||
-- Set `is_expandable' to `b'.
|
||||
do
|
||||
internal_is_expandable := b
|
||||
ensure
|
||||
is_expandable: is_expandable = b
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
internal_is_expandable: BOOLEAN
|
||||
|
||||
internal_is_expanded: BOOLEAN
|
||||
|
||||
internal_is_collapsed: BOOLEAN
|
||||
|
||||
invariant
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
96
library/model/src/link/cms_menu.e
Normal file
96
library/model/src/link/cms_menu.e
Normal file
@@ -0,0 +1,96 @@
|
||||
note
|
||||
description: "[
|
||||
Abstraction to represent a MENU in the CMS system.
|
||||
It has items as sub menu/link.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_MENU
|
||||
|
||||
inherit
|
||||
CMS_LINK_COMPOSITE
|
||||
redefine
|
||||
is_empty
|
||||
end
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_title
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: like name; a_capacity: INTEGER)
|
||||
-- Create menu with name `a_name' and a capacity of `a_capacity'.
|
||||
do
|
||||
name := a_name
|
||||
create items.make (a_capacity)
|
||||
ensure
|
||||
name_set: name = a_name
|
||||
items_set: items.capacity = a_capacity
|
||||
end
|
||||
|
||||
make_with_title (a_name: like name; a_title: READABLE_STRING_32; a_capacity: INTEGER)
|
||||
-- Create menu with name `a_name' and a capacity of `a_capacity', and title `a_title'
|
||||
do
|
||||
make (a_name, a_capacity)
|
||||
set_title (a_title)
|
||||
ensure
|
||||
name_set: name = a_name
|
||||
title_set: title = a_title
|
||||
items_set: items.capacity = a_capacity
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: READABLE_STRING_8
|
||||
-- Identifier for Current menu.
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
-- Optional title.
|
||||
|
||||
items: ARRAYED_LIST [CMS_LINK]
|
||||
-- <Precursor>
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_empty: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := items.is_empty
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
extend (lnk: CMS_LINK)
|
||||
-- <Precursor>
|
||||
do
|
||||
items.extend (lnk)
|
||||
end
|
||||
|
||||
remove (lnk: CMS_LINK)
|
||||
-- <Precursor>
|
||||
do
|
||||
items.prune_all (lnk)
|
||||
end
|
||||
|
||||
set_title (t: like title)
|
||||
do
|
||||
title := t
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: ITERATION_CURSOR [CMS_LINK]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
Result := items.new_cursor
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
Reference in New Issue
Block a user