Module m_category

Model for categories.

Copyright 2009 Marc Worrell Date: 2009-04-08

Behaviours: gen_model.

Authors: Marc Worrell (marc@worrell.nl).

Description

Model for categories. Add, change and re-order categories.

Function Index

all_flat/1Return a flattened representation of the complete category tree.
all_flat/2
all_flat_meta/1
boundaries/2
delete/3Delete the category, move referring pages to another category.
enumerate/1Take a category list and make it into a tree, recalculating the left/right and lvl nrs.
fold/4Perform a function on all resource ids in a category.
foreach/3Perform a function on all resource ids in a category.
get/2
get_by_name/2
get_by_parent/2
get_page_count/2
get_path/2Return the path from a root to the category (excluding the category itself).
get_range/2
get_range_by_name/2
get_root/1
id_to_name/2Return the name for a given category.
image/2
insert/4
is_a/2Return the list of categories (as atoms) that the category is part of.
is_a/3Check if the id is within another category.
is_tree_dirty/1Whether the category tree is currently marked dirty (e.g.
last_modified/2Return the last modification date of the category.
m_find_value/3Fetch the value for the key from a model source.
m_to_list/2Transform a m_config value to a list, used for template loops.
m_value/2Transform a model value so that it can be formatted or piped through filters.
menu/1Return the category tree as a menu resource.
move/2Move categories to the given positions, no checks (except ACL done).
move_before/3Move a category in front of another category, resetting the parent of the moved category to the parent of the other category.
move_below/3Move the category below another category, placing it at the end of the children of that category.
move_end/2Move the category to the end of all categories, making it a top category in the process.
name_to_id/2
name_to_id_check/2
ranges/2Given a list of category ids, return the list of numeric ranges they cover.
renumber/1Renumber all categories so that the left/right and level indices are correct.
renumber_pivot_task/1Resync all ids that have their category nr changed.
tree/1Return the tree of all categories.
tree/2Return the tree of all categories below a category id.
tree_depth/2Return the tree of all categories till a certain depth.
tree_depth/3Return the tree of all categories below a category id till a certain depth.
update_sequence/2

Function Details

all_flat/1

all_flat(Context) -> any()

Return a flattened representation of the complete category tree. Can be used for overviews or select boxes. The "meta" categories of predicate, category and group are suppressed.

all_flat/2

all_flat(CatId, Context) -> any()

all_flat_meta/1

all_flat_meta(Context) -> any()

boundaries/2

boundaries(CatId::Id, Context::C) -> {Left, Right}

delete/3

delete(Id::int(), TransferId::int(), Context) -> ok | {error, Reason}

Delete the category, move referring pages to another category. Fails when the transfer id is not a category.

enumerate/1

enumerate(Cats::[Cat]) -> [Sort]

Take a category list and make it into a tree, recalculating the left/right and lvl nrs

fold/4

fold(Category::integer() | atom(), F::function(), Acc0::term(), Context::#context{}) -> term() | {error, term()}

Perform a function on all resource ids in a category. Order of the ids is unspecified.

foreach/3

foreach(Category::integer() | atom(), F::function(), Context::#context{}) -> ok | {error, term()}

Perform a function on all resource ids in a category. Order of the ids is unspecified.

get/2

get(Name, Context) -> any()

get_by_name/2

get_by_name(Name, Context) -> any()

get_by_parent/2

get_by_parent(Id, Context) -> any()

get_page_count/2

get_page_count(Id, Context) -> any()

get_path/2

get_path(Id, Context) -> [CatId]

Return the path from a root to the category (excluding the category itself)

get_range/2

get_range(Id, Context) -> any()

get_range_by_name/2

get_range_by_name(Name, Context) -> any()

get_root/1

get_root(Context) -> any()

id_to_name/2

id_to_name(Id::integer(), Context::#context{}) -> atom() | undefined

Return the name for a given category.

If the category does not have a unique name will result in undefined. If the lookup is made by name, the name is checked for existence, and if not found, results in undefined.

image/2

image(Id, Context) -> any()

insert/4

insert(ParentId, Name, Props, Context) -> any()

is_a/2

is_a(Id::int(), Context) -> atomlist()

Return the list of categories (as atoms) that the category is part of

is_a/3

is_a(Id::int(), Cat, Context) -> atomlist()

Check if the id is within another category.

is_tree_dirty/1

is_tree_dirty(Context) -> any()

Whether the category tree is currently marked dirty (e.g. resource pivot numbers are being updated)

last_modified/2

last_modified(Cat::term(), Context) -> {ok, {{Y, M, D}, {Hour, Min, Sec}}} | {error, Reason}

Return the last modification date of the category. Returns false

m_find_value/3

m_find_value(Index::Key, M::Source, Context) -> term()

Fetch the value for the key from a model source

m_to_list/2

m_to_list(M::Source, Context) -> List

Transform a m_config value to a list, used for template loops

m_value/2

m_value(M::Source, Context) -> term()

Transform a model value so that it can be formatted or piped through filters

menu/1

menu(Context) -> any()

Return the category tree as a menu resource

move/2

move(Cats, Context) -> any()

Move categories to the given positions, no checks (except ACL done)

move_before/3

move_before(CatId::int(), BeforeCatId::int(), Context) -> ok | {error, Reason}

Move a category in front of another category, resetting the parent of the moved category to the parent of the other category.

move_below/3

move_below(CatId::int(), NewParentId::int(), Context) -> ok | {error, Reason}

Move the category below another category, placing it at the end of the children of that category.

move_end/2

move_end(CatId::int(), Context) -> ok | {error, Reason}

Move the category to the end of all categories, making it a top category in the process

name_to_id/2

name_to_id(Id, Context) -> any()

name_to_id_check/2

name_to_id_check(Name, Context) -> any()

ranges/2

ranges(Cat::CatList, Context) -> RangeList

Given a list of category ids, return the list of numeric ranges they cover.

renumber/1

renumber(Context) -> ok

Renumber all categories so that the left/right and level indices are correct.

renumber_pivot_task/1

renumber_pivot_task(Context) -> any()

Resync all ids that have their category nr changed.

tree/1

tree(Context) -> Tree

Return the tree of all categories

tree/2

tree(CatId, Context) -> TreeNode

Return the tree of all categories below a category id

tree_depth/2

tree_depth(Depth, Context) -> Tree

Return the tree of all categories till a certain depth

tree_depth/3

tree_depth(CatId, Depth, Context) -> TreeNode

Return the tree of all categories below a category id till a certain depth

update_sequence/2

update_sequence(Ids, Context) -> any()


Generated by EDoc, Sep 1 2014, 10:45:39.