PageRenderTime 56ms CodeModel.GetById 17ms app.highlight 31ms RepoModel.GetById 2ms app.codeStats 0ms

/doc/core/m_category.html

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