Added notion of CMS_CONTENT as ancestor of CMS_NODE.

Moved CMS_CONTENT_TYPE to core library.
Added basic and limited taxonomy query /taxonomy/term/{termid} .
This commit is contained in:
2015-12-03 23:01:31 +01:00
parent a5c117e46e
commit ecbcb6a5cb
19 changed files with 319 additions and 83 deletions

View File

@@ -1,92 +0,0 @@
note
description: "[
Interface defining a CMS content type.
]"
status: "draft"
date: "$Date$"
revision: "$Revision$"
deferred class
CMS_CONTENT_TYPE
inherit
CMS_API_ACCESS
feature -- Access
name: READABLE_STRING_8
-- Internal name.
deferred
end
title: READABLE_STRING_32
-- Human readable name.
deferred
end
description: detachable READABLE_STRING_32
-- Optional description
deferred
end
feature -- Access
available_formats: LIST [CONTENT_FORMAT]
-- Available formats for Current type.
deferred
end
format (a_name: READABLE_STRING_8): detachable CONTENT_FORMAT
-- Format named `a_name', if available.
do
across
available_formats as ic
until
Result /= Void
loop
Result := ic.item
if not a_name.is_case_insensitive_equal (Result.name) then
Result := Void
end
end
end
feature -- Element change
extend_format (f: CONTENT_FORMAT)
-- Add `f' to the list of `available_formats'
require
not_has_format: format (f.name) = Void
do
available_formats.extend (f)
ensure
format_added: format (f.name) /= Void
end
remove_format (f: CONTENT_FORMAT)
-- Add `f' to the list of `available_formats'
local
lst: like available_formats
l_name: READABLE_STRING_GENERAL
do
from
l_name := f.name
lst := available_formats
lst.start
until
lst.after
loop
if l_name.is_case_insensitive_equal (lst.item.name) then
lst.remove
else
lst.forth
end
end
ensure
format_removed: format (f.name) = Void
end
note
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -40,8 +40,7 @@ feature {NONE} -- Initialization
local
ct: CMS_PAGE_NODE_TYPE
do
-- Initialize content types.
create content_types.make (1)
-- Initialize node content types.
create content_type_webform_managers.make (1)
create ct
--| For now, add all available formats to content type `ct'.
@@ -50,7 +49,7 @@ feature {NONE} -- Initialization
loop
ct.extend_format (ic.item)
end
add_content_type (ct)
add_node_type (ct)
add_content_type_webform_manager (create {CMS_PAGE_NODE_TYPE_WEBFORM_MANAGER}.make (ct))
end
@@ -60,15 +59,18 @@ feature {CMS_MODULE} -- Access nodes storage.
feature -- Content type
content_types: ARRAYED_LIST [CMS_CONTENT_TYPE]
-- Available content types
add_node_type (a_type: CMS_NODE_TYPE [CMS_NODE])
-- Register node content type `a_type'.
do
cms_api.add_content_type (a_type)
end
node_types: ARRAYED_LIST [attached like node_type]
-- Node content types.
do
create Result.make (content_types.count)
create Result.make (cms_api.content_types.count)
across
content_types as ic
cms_api.content_types as ic
loop
if attached {like node_type} ic.item as l_node_type then
Result.extend (l_node_type)
@@ -76,32 +78,11 @@ feature -- Content type
end
end
add_content_type (a_type: CMS_CONTENT_TYPE)
-- Register content type `a_type'.
do
content_types.force (a_type)
end
content_type (a_name: READABLE_STRING_GENERAL): detachable CMS_CONTENT_TYPE
-- Content type named `a_named' if any.
do
across
content_types as ic
until
Result /= Void
loop
Result := ic.item
if not a_name.is_case_insensitive_equal (Result.name) then
Result := Void
end
end
end
node_type (a_name: READABLE_STRING_GENERAL): detachable CMS_NODE_TYPE [CMS_NODE]
-- Content type named `a_named' if any.
do
across
content_types as ic
cms_api.content_types as ic
until
Result /= Void
loop

View File

@@ -158,7 +158,7 @@ feature -- Access
if attached node_api as l_node_api then
across
l_node_api.content_types as ic
l_node_api.node_types as ic
loop
l_type_name := ic.item.name
if not l_type_name.is_whitespace then
@@ -285,7 +285,7 @@ feature -- Hooks
create perms.make (2)
perms.force ("create any node")
across
l_node_api.content_types as ic
l_node_api.node_types as ic
loop
perms.force ("create " + ic.item.name)
end
@@ -300,7 +300,7 @@ feature -- Hooks
do
if
attached node_api as l_node_api and then
attached l_node_api.content_types as l_types and then
attached l_node_api.node_types as l_types and then
not l_types.is_empty
then
create lst.make (l_types.count)

View File

@@ -10,7 +10,11 @@ deferred class
CMS_NODE
inherit
DEBUG_OUTPUT
CMS_CONTENT
redefine
debug_output
end
REFACTORING_HELPER
feature{NONE} -- Initialization
@@ -67,12 +71,6 @@ feature -- Access
-- Revision value.
--| Note: for now version is not supported.
content_type: READABLE_STRING_8
-- Associated content type name.
-- Page, Article, Blog, News, etc.
deferred
end
feature -- Status reports
status: INTEGER
@@ -113,12 +111,6 @@ feature -- Access
deferred
end
format: detachable READABLE_STRING_8
-- Format associated with `content' and `summary'.
-- For example: text, mediawiki, html, etc
deferred
end
feature -- Access: date
modification_date: DATE_TIME
@@ -155,12 +147,6 @@ feature -- status report
valid_result: Result implies a_node.id = id
end
is_typed_as (a_content_type: READABLE_STRING_GENERAL): BOOLEAN
-- Is current node of type `a_content_type' ?
do
Result := a_content_type.is_case_insensitive_equal (content_type)
end
feature -- Access: menu
link: detachable CMS_LOCAL_LINK
@@ -174,13 +160,7 @@ feature -- Status report
create Result.make_from_string_general ("#")
Result.append_integer_64 (id)
Result.append_character (' ')
Result.append_character ('<')
Result.append_string_general (content_type)
Result.append_character ('>')
Result.append_character (' ')
Result.append_character ('%"')
Result.append (title)
Result.append_character ('%"')
Result.append (Precursor)
end
feature -- Element change

View File

@@ -96,7 +96,7 @@ feature -- HTTP Methods
s.append (" <em>(trashed)</em>")
end
debug
if attached node_api.content_type (n.content_type) as ct then
if attached node_api.node_type (n.content_type) as ct then
s.append ("<span class=%"description%">")
s.append (html_encoded (ct.title))
s.append ("</span>")

View File

@@ -383,7 +383,6 @@ feature -- Change: Node
local
l_parameters: STRING_TABLE [ANY]
l_time: DATE_TIME
l_sql_delete_node_aliases: STRING
do
sql_begin_transaction
create l_time.make_now_utc

View File

@@ -101,7 +101,7 @@ feature -- Persistence
l_parent_id /= a_node.id and then
attached node_storage.node_by_id (l_parent_id) as l_parent
then
if attached {CMS_PAGE_NODE_TYPE} node_api.content_type (l_parent.content_type) as l_parent_ct then
if attached {CMS_PAGE_NODE_TYPE} node_api.node_type (l_parent.content_type) as l_parent_ct then
ct := l_parent_ct
else
create ct