Improved taxonomy by supporting tags, multiple terms allowed, and required kind of vocabulary for specific content type.
Updated node web form, to support taxonomy editing if allowed (specific support for CMS_VOCABULARY.is_tags: BOOLEAN). Added notion of required or optional module dependencies.
This commit is contained in:
@@ -46,7 +46,7 @@ feature -- Access node
|
||||
Result := taxonomy_storage.vocabulary_count
|
||||
end
|
||||
|
||||
vocabularies (a_limit: NATURAL_32; a_offset: NATURAL_32): LIST [CMS_VOCABULARY]
|
||||
vocabularies (a_limit: NATURAL_32; a_offset: NATURAL_32): CMS_VOCABULARY_COLLECTION
|
||||
-- List of vocabularies ordered by weight and limited by limit and offset.
|
||||
do
|
||||
Result := taxonomy_storage.vocabularies (a_limit, a_offset)
|
||||
@@ -60,6 +60,26 @@ feature -- Access node
|
||||
Result := taxonomy_storage.vocabulary (a_id)
|
||||
end
|
||||
|
||||
vocabularies_for_type (a_type_name: READABLE_STRING_GENERAL): detachable CMS_VOCABULARY_COLLECTION
|
||||
-- Vocabularies associated with content type `a_type_name'.
|
||||
do
|
||||
Result := taxonomy_storage.vocabularies_for_type (a_type_name)
|
||||
end
|
||||
|
||||
fill_vocabularies_with_terms (a_vocab: CMS_VOCABULARY)
|
||||
-- Fill `a_vocab' with associated terms.
|
||||
do
|
||||
reset_error
|
||||
a_vocab.terms.wipe_out
|
||||
if attached terms (a_vocab, 0, 0) as lst then
|
||||
across
|
||||
lst as ic
|
||||
loop
|
||||
a_vocab.extend (ic.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
term_count_from_vocabulary (a_vocab: CMS_VOCABULARY): INTEGER_64
|
||||
-- Number of terms from vocabulary `a_vocab'.
|
||||
require
|
||||
@@ -68,7 +88,14 @@ feature -- Access node
|
||||
Result := taxonomy_storage.term_count_from_vocabulary (a_vocab)
|
||||
end
|
||||
|
||||
terms (a_vocab: CMS_VOCABULARY; a_limit: NATURAL_32; a_offset: NATURAL_32): LIST [CMS_TERM]
|
||||
terms_of_entity (a_type_name: READABLE_STRING_GENERAL; a_entity: READABLE_STRING_GENERAL; a_vocabulary: detachable CMS_VOCABULARY): detachable CMS_TERM_COLLECTION
|
||||
-- Terms related to `(a_type_name,a_entity)', and if `a_vocabulary' is set
|
||||
-- constrain to be part of `a_vocabulary'.
|
||||
do
|
||||
Result := taxonomy_storage.terms_of_entity (a_type_name, a_entity, a_vocabulary)
|
||||
end
|
||||
|
||||
terms (a_vocab: CMS_VOCABULARY; a_limit: NATURAL_32; a_offset: NATURAL_32): CMS_TERM_COLLECTION
|
||||
-- List of terms ordered by weight and limited by limit and offset.
|
||||
require
|
||||
has_id: a_vocab.has_id
|
||||
@@ -81,4 +108,111 @@ feature -- Access node
|
||||
Result := taxonomy_storage.term_by_id (a_tid)
|
||||
end
|
||||
|
||||
term_by_text (a_term_text: READABLE_STRING_GENERAL; a_vocabulary: detachable CMS_VOCABULARY): detachable CMS_TERM
|
||||
-- Term with text `a_term_text', included in vocabulary `a_vocabulary' if provided.
|
||||
do
|
||||
Result := taxonomy_storage.term_by_text (a_term_text, a_vocabulary)
|
||||
end
|
||||
|
||||
feature -- Write
|
||||
|
||||
save_vocabulary (a_voc: CMS_VOCABULARY)
|
||||
do
|
||||
reset_error
|
||||
taxonomy_storage.save_vocabulary (a_voc)
|
||||
error_handler.append (taxonomy_storage.error_handler)
|
||||
end
|
||||
|
||||
save_term (a_term: CMS_TERM; voc: CMS_VOCABULARY)
|
||||
do
|
||||
reset_error
|
||||
taxonomy_storage.save_term (a_term, voc)
|
||||
error_handler.append (taxonomy_storage.error_handler)
|
||||
end
|
||||
|
||||
associate_term_with_entity (a_term: CMS_TERM; a_type_name: READABLE_STRING_GENERAL; a_entity: READABLE_STRING_GENERAL)
|
||||
-- Associate term `a_term' with `(a_type_name, a_entity)'.
|
||||
do
|
||||
reset_error
|
||||
taxonomy_storage.associate_term_with_entity (a_term, a_type_name, a_entity)
|
||||
error_handler.append (taxonomy_storage.error_handler)
|
||||
end
|
||||
|
||||
unassociate_term_from_entity (a_term: CMS_TERM; a_type_name: READABLE_STRING_GENERAL; a_entity: READABLE_STRING_GENERAL)
|
||||
-- Unassociate term `a_term' from `(a_type_name, a_entity)'.
|
||||
do
|
||||
reset_error
|
||||
taxonomy_storage.unassociate_term_from_entity (a_term, a_type_name, a_entity)
|
||||
error_handler.append (taxonomy_storage.error_handler)
|
||||
end
|
||||
|
||||
associate_vocabulary_with_type (a_voc: CMS_VOCABULARY; a_type_name: READABLE_STRING_GENERAL)
|
||||
-- Associate vocabulary `a_voc' with type `a_type_name'.
|
||||
require
|
||||
existing_term: a_voc.has_id
|
||||
do
|
||||
reset_error
|
||||
taxonomy_storage.associate_vocabulary_with_type (a_voc, a_type_name)
|
||||
error_handler.append (taxonomy_storage.error_handler)
|
||||
end
|
||||
|
||||
unassociate_vocabulary_with_type (a_voc: CMS_VOCABULARY; a_type_name: READABLE_STRING_GENERAL)
|
||||
-- Un-associate vocabulary `a_voc' from type `a_type_name'.
|
||||
require
|
||||
existing_term: a_voc.has_id
|
||||
do
|
||||
reset_error
|
||||
taxonomy_storage.unassociate_vocabulary_with_type (a_voc, a_type_name)
|
||||
error_handler.append (taxonomy_storage.error_handler)
|
||||
end
|
||||
|
||||
feature -- Helpers
|
||||
|
||||
splitted_string (s: READABLE_STRING_32; sep: CHARACTER): LIST [READABLE_STRING_32]
|
||||
-- Splitted string from `s' with separator `sep', and support '"..."' wrapping.
|
||||
local
|
||||
i,j,n,b: INTEGER
|
||||
t: STRING_32
|
||||
do
|
||||
create {ARRAYED_LIST [READABLE_STRING_32]} Result.make (1)
|
||||
Result.compare_objects
|
||||
from
|
||||
i := 1
|
||||
b := 1
|
||||
n := s.count
|
||||
create t.make_empty
|
||||
until
|
||||
i > n
|
||||
loop
|
||||
if s[i].is_space then
|
||||
if not t.is_empty then
|
||||
t.append_character (s[i])
|
||||
end
|
||||
elseif s[i] = sep then
|
||||
t.left_adjust
|
||||
t.right_adjust
|
||||
if t.count > 2 and t.starts_with_general ("%"") and t.ends_with_general ("%"") then
|
||||
t.remove_head (1)
|
||||
t.remove_tail (1)
|
||||
end
|
||||
Result.force (t)
|
||||
create t.make_empty
|
||||
elseif s[i] = '"' then
|
||||
j := s.index_of ('"', i + 1)
|
||||
if j > 0 then
|
||||
t.append (s.substring (i, j))
|
||||
end
|
||||
i := j
|
||||
else
|
||||
t.append_character (s[i])
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
if not t.is_empty then
|
||||
t.left_adjust
|
||||
t.right_adjust
|
||||
Result.force (t)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user