forked from zotonic/zotonic
/
m_category.html
264 lines (221 loc) · 13.9 KB
/
m_category.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Module m_category</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
</head>
<body bgcolor="white">
<div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<hr>
<h1>Module m_category</h1>
<ul class="index"><li><a href="#description">Description</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>Model for categories.
<p>Copyright © 2009 Marc Worrell
Date: 2009-04-08
</p>
<p><b>Behaviours:</b> <a href="gen_model.html"><tt>gen_model</tt></a>.</p>
<p><b>Authors:</b> Marc Worrell (<a href="mailto:marc@worrell.nl"><tt>marc@worrell.nl</tt></a>).</p>
<h2><a name="description">Description</a></h2>Model for categories. Add, change and re-order categories.
<h2><a name="index">Function Index</a></h2>
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#all_flat-1">all_flat/1</a></td><td>Return a flattened representation of the complete category tree.</td></tr>
<tr><td valign="top"><a href="#all_flat-2">all_flat/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#all_flat_meta-1">all_flat_meta/1</a></td><td></td></tr>
<tr><td valign="top"><a href="#boundaries-2">boundaries/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#delete-3">delete/3</a></td><td>Delete the category, move referring pages to another category.</td></tr>
<tr><td valign="top"><a href="#enumerate-1">enumerate/1</a></td><td>Take a category list and make it into a tree, recalculating the left/right and lvl nrs.</td></tr>
<tr><td valign="top"><a href="#get-2">get/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#get_by_name-2">get_by_name/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#get_by_parent-2">get_by_parent/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#get_page_count-2">get_page_count/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#get_path-2">get_path/2</a></td><td>Return the path from a root to the category (excluding the category itself).</td></tr>
<tr><td valign="top"><a href="#get_range-2">get_range/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#get_range_by_name-2">get_range_by_name/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#get_root-1">get_root/1</a></td><td></td></tr>
<tr><td valign="top"><a href="#id_to_name-2">id_to_name/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#image-2">image/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#insert-4">insert/4</a></td><td></td></tr>
<tr><td valign="top"><a href="#is_a-2">is_a/2</a></td><td>Return the list of categories (as atoms) that the category is part of.</td></tr>
<tr><td valign="top"><a href="#is_a-3">is_a/3</a></td><td>Check if the id is within another category.</td></tr>
<tr><td valign="top"><a href="#last_modified-2">last_modified/2</a></td><td>Return the last modification date of the category.</td></tr>
<tr><td valign="top"><a href="#m_find_value-3">m_find_value/3</a></td><td>Fetch the value for the key from a model source.</td></tr>
<tr><td valign="top"><a href="#m_to_list-2">m_to_list/2</a></td><td>Transform a m_config value to a list, used for template loops.</td></tr>
<tr><td valign="top"><a href="#m_value-2">m_value/2</a></td><td>Transform a model value so that it can be formatted or piped through filters.</td></tr>
<tr><td valign="top"><a href="#menu-1">menu/1</a></td><td>Return the category tree as a menu resource.</td></tr>
<tr><td valign="top"><a href="#move-2">move/2</a></td><td>Move categories to the given positions, no checks (except ACL done).</td></tr>
<tr><td valign="top"><a href="#move_before-3">move_before/3</a></td><td>Move a category in front of another category, resetting the parent of the moved category to
the parent of the other category.</td></tr>
<tr><td valign="top"><a href="#move_below-3">move_below/3</a></td><td>Move the category below another category, placing it at the end of the children of that category.</td></tr>
<tr><td valign="top"><a href="#move_end-2">move_end/2</a></td><td>Move the category to the end of all categories, making it a top category in the process.</td></tr>
<tr><td valign="top"><a href="#name_to_id-2">name_to_id/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#name_to_id_check-2">name_to_id_check/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#ranges-2">ranges/2</a></td><td>Given a list of category ids, return the list of numeric ranges they cover.</td></tr>
<tr><td valign="top"><a href="#renumber-1">renumber/1</a></td><td>Renumber all categories so that the left/right and level indices are correct.</td></tr>
<tr><td valign="top"><a href="#renumber_pivot_task-1">renumber_pivot_task/1</a></td><td>Resync all ids that have their category nr changed.</td></tr>
<tr><td valign="top"><a href="#tree-1">tree/1</a></td><td>Return the tree of all categories.</td></tr>
<tr><td valign="top"><a href="#tree-2">tree/2</a></td><td>Return the tree of all categories below a category id.</td></tr>
<tr><td valign="top"><a href="#tree_depth-2">tree_depth/2</a></td><td>Return the tree of all categories till a certain depth.</td></tr>
<tr><td valign="top"><a href="#tree_depth-3">tree_depth/3</a></td><td>Return the tree of all categories below a category id till a certain depth.</td></tr>
<tr><td valign="top"><a href="#update_sequence-2">update_sequence/2</a></td><td></td></tr>
</table>
<h2><a name="functions">Function Details</a></h2>
<h3 class="function"><a name="all_flat-1">all_flat/1</a></h3>
<div class="spec">
<p><tt>all_flat(Context) -> any()</tt></p>
</div><p>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.</p>
<h3 class="function"><a name="all_flat-2">all_flat/2</a></h3>
<div class="spec">
<p><tt>all_flat(CatId, Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="all_flat_meta-1">all_flat_meta/1</a></h3>
<div class="spec">
<p><tt>all_flat_meta(Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="boundaries-2">boundaries/2</a></h3>
<div class="spec">
<p><tt>boundaries(CatId::Id, Context::C) -> {Left, Right}</tt></p>
</div>
<h3 class="function"><a name="delete-3">delete/3</a></h3>
<div class="spec">
<p><tt>delete(Id::<a href="#type-int">int()</a>, TransferId::<a href="#type-int">int()</a>, Context) -> ok | {error, Reason}</tt></p>
</div><p>Delete the category, move referring pages to another category. Fails when the transfer id is not a category.</p>
<h3 class="function"><a name="enumerate-1">enumerate/1</a></h3>
<div class="spec">
<p><tt>enumerate(Cats::[Cat]) -> [Sort]</tt>
<ul class="definitions"><li><tt>Cat = {CatId, Parent, NodeSeq}</tt></li>
<li><tt>Sort = {CatId, Nr, Level, Left, Right, Path}</tt></li>
</ul></p>
</div><p>Take a category list and make it into a tree, recalculating the left/right and lvl nrs</p>
<h3 class="function"><a name="get-2">get/2</a></h3>
<div class="spec">
<p><tt>get(Name, Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="get_by_name-2">get_by_name/2</a></h3>
<div class="spec">
<p><tt>get_by_name(Name, Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="get_by_parent-2">get_by_parent/2</a></h3>
<div class="spec">
<p><tt>get_by_parent(Id, Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="get_page_count-2">get_page_count/2</a></h3>
<div class="spec">
<p><tt>get_page_count(Id, Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="get_path-2">get_path/2</a></h3>
<div class="spec">
<p><tt>get_path(Id, Context) -> [CatId]</tt></p>
</div><p>Return the path from a root to the category (excluding the category itself)</p>
<h3 class="function"><a name="get_range-2">get_range/2</a></h3>
<div class="spec">
<p><tt>get_range(Id, Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="get_range_by_name-2">get_range_by_name/2</a></h3>
<div class="spec">
<p><tt>get_range_by_name(Name, Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="get_root-1">get_root/1</a></h3>
<div class="spec">
<p><tt>get_root(Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="id_to_name-2">id_to_name/2</a></h3>
<div class="spec">
<p><tt>id_to_name(Name, Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="image-2">image/2</a></h3>
<div class="spec">
<p><tt>image(Id, Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="insert-4">insert/4</a></h3>
<div class="spec">
<p><tt>insert(ParentId, Name, Props, Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="is_a-2">is_a/2</a></h3>
<div class="spec">
<p><tt>is_a(Id::<a href="#type-int">int()</a>, Context) -> <a href="#type-atomlist">atomlist()</a></tt></p>
</div><p>Return the list of categories (as atoms) that the category is part of</p>
<h3 class="function"><a name="is_a-3">is_a/3</a></h3>
<div class="spec">
<p><tt>is_a(Id::<a href="#type-int">int()</a>, Cat, Context) -> <a href="#type-atomlist">atomlist()</a></tt></p>
</div><p>Check if the id is within another category.</p>
<h3 class="function"><a name="last_modified-2">last_modified/2</a></h3>
<div class="spec">
<p><tt>last_modified(Cat::term(), Context) -> {ok, {{Y, M, D}, {Hour, Min, Sec}}} | {error, Reason}</tt></p>
</div><p>Return the last modification date of the category. Returns false</p>
<h3 class="function"><a name="m_find_value-3">m_find_value/3</a></h3>
<div class="spec">
<p><tt>m_find_value(Index::Key, M::Source, Context) -> term()</tt></p>
</div><p>Fetch the value for the key from a model source</p>
<h3 class="function"><a name="m_to_list-2">m_to_list/2</a></h3>
<div class="spec">
<p><tt>m_to_list(M::Source, Context) -> List</tt></p>
</div><p>Transform a m_config value to a list, used for template loops</p>
<h3 class="function"><a name="m_value-2">m_value/2</a></h3>
<div class="spec">
<p><tt>m_value(M::Source, Context) -> term()</tt></p>
</div><p>Transform a model value so that it can be formatted or piped through filters</p>
<h3 class="function"><a name="menu-1">menu/1</a></h3>
<div class="spec">
<p><tt>menu(Context) -> any()</tt></p>
</div><p>Return the category tree as a menu resource</p>
<h3 class="function"><a name="move-2">move/2</a></h3>
<div class="spec">
<p><tt>move(Cats, Context) -> any()</tt></p>
</div><p>Move categories to the given positions, no checks (except ACL done)</p>
<h3 class="function"><a name="move_before-3">move_before/3</a></h3>
<div class="spec">
<p><tt>move_before(CatId::<a href="#type-int">int()</a>, BeforeCatId::<a href="#type-int">int()</a>, Context) -> ok | {error, Reason}</tt></p>
</div><p>Move a category in front of another category, resetting the parent of the moved category to
the parent of the other category.</p>
<h3 class="function"><a name="move_below-3">move_below/3</a></h3>
<div class="spec">
<p><tt>move_below(CatId::<a href="#type-int">int()</a>, NewParentId::<a href="#type-int">int()</a>, Context) -> ok | {error, Reason}</tt></p>
</div><p>Move the category below another category, placing it at the end of the children of that category.</p>
<h3 class="function"><a name="move_end-2">move_end/2</a></h3>
<div class="spec">
<p><tt>move_end(CatId::<a href="#type-int">int()</a>, Context) -> ok | {error, Reason}</tt></p>
</div><p>Move the category to the end of all categories, making it a top category in the process</p>
<h3 class="function"><a name="name_to_id-2">name_to_id/2</a></h3>
<div class="spec">
<p><tt>name_to_id(Id, Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="name_to_id_check-2">name_to_id_check/2</a></h3>
<div class="spec">
<p><tt>name_to_id_check(Name, Context) -> any()</tt></p>
</div>
<h3 class="function"><a name="ranges-2">ranges/2</a></h3>
<div class="spec">
<p><tt>ranges(Cat::CatList, Context) -> RangeList</tt></p>
</div><p>Given a list of category ids, return the list of numeric ranges they cover.</p>
<h3 class="function"><a name="renumber-1">renumber/1</a></h3>
<div class="spec">
<p><tt>renumber(Context) -> ok</tt></p>
</div><p>Renumber all categories so that the left/right and level indices are correct.</p>
<h3 class="function"><a name="renumber_pivot_task-1">renumber_pivot_task/1</a></h3>
<div class="spec">
<p><tt>renumber_pivot_task(Context) -> any()</tt></p>
</div><p>Resync all ids that have their category nr changed.</p>
<h3 class="function"><a name="tree-1">tree/1</a></h3>
<div class="spec">
<p><tt>tree(Context) -> Tree</tt></p>
</div><p>Return the tree of all categories</p>
<h3 class="function"><a name="tree-2">tree/2</a></h3>
<div class="spec">
<p><tt>tree(CatId, Context) -> TreeNode</tt></p>
</div><p>Return the tree of all categories below a category id</p>
<h3 class="function"><a name="tree_depth-2">tree_depth/2</a></h3>
<div class="spec">
<p><tt>tree_depth(Depth, Context) -> Tree</tt></p>
</div><p>Return the tree of all categories till a certain depth</p>
<h3 class="function"><a name="tree_depth-3">tree_depth/3</a></h3>
<div class="spec">
<p><tt>tree_depth(CatId, Depth, Context) -> TreeNode</tt></p>
</div><p>Return the tree of all categories below a category id till a certain depth</p>
<h3 class="function"><a name="update_sequence-2">update_sequence/2</a></h3>
<div class="spec">
<p><tt>update_sequence(Ids, Context) -> any()</tt></p>
</div>
<hr>
<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Oct 13 2011, 14:45:56.</i></p>
</body>
</html>