PageRenderTime 46ms CodeModel.GetById 8ms app.highlight 29ms RepoModel.GetById 1ms app.codeStats 0ms

/doc/core/m_category.html

https://code.google.com/p/zotonic/
HTML | 252 lines | 211 code | 41 blank | 0 comment | 0 complexity | 6bf4d94716eb908f9b84a6f6fbc3c07a 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="#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
 46  the parent of the other category.</td></tr>
 47<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>
 48<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>
 49<tr><td valign="top"><a href="#name_to_id-2">name_to_id/2</a></td><td></td></tr>
 50<tr><td valign="top"><a href="#name_to_id_check-2">name_to_id_check/2</a></td><td></td></tr>
 51<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>
 52<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>
 53<tr><td valign="top"><a href="#renumber_pivot_task-2">renumber_pivot_task/2</a></td><td>Resync all ids that have their category nr changed.</td></tr>
 54<tr><td valign="top"><a href="#tree-1">tree/1</a></td><td>Return the tree of all categories.</td></tr>
 55<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>
 56<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>
 57<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>
 58<tr><td valign="top"><a href="#update_sequence-2">update_sequence/2</a></td><td></td></tr>
 59</table>
 60
 61<h2><a name="functions">Function Details</a></h2>
 62
 63<h3 class="function"><a name="all_flat-1">all_flat/1</a></h3>
 64<div class="spec">
 65<p><tt>all_flat(Context) -&gt; any()</tt></p>
 66</div><p>Return a flattened representation of the complete category tree.  Can be used for overviews or select boxes.
 67  The "meta" categories of predicate, category and group are suppressed.</p>
 68
 69<h3 class="function"><a name="all_flat-2">all_flat/2</a></h3>
 70<div class="spec">
 71<p><tt>all_flat(CatId, Context) -&gt; any()</tt></p>
 72</div>
 73
 74<h3 class="function"><a name="all_flat_meta-1">all_flat_meta/1</a></h3>
 75<div class="spec">
 76<p><tt>all_flat_meta(Context) -&gt; any()</tt></p>
 77</div>
 78
 79<h3 class="function"><a name="boundaries-2">boundaries/2</a></h3>
 80<div class="spec">
 81<p><tt>boundaries(CatId::Id, Context::C) -&gt; {Left, Right}</tt></p>
 82</div>
 83
 84<h3 class="function"><a name="delete-3">delete/3</a></h3>
 85<div class="spec">
 86<p><tt>delete(Id::<a href="#type-int">int()</a>, TransferId::<a href="#type-int">int()</a>, Context) -&gt; ok | {error, Reason}</tt></p>
 87</div><p>Delete the category, move referring pages to another category. Fails when the transfer id is not a category.</p>
 88
 89<h3 class="function"><a name="enumerate-1">enumerate/1</a></h3>
 90<div class="spec">
 91<p><tt>enumerate(Cats::[Cat]) -&gt; [Sort]</tt>
 92<ul class="definitions"><li><tt>Cat = {CatId, Parent, NodeSeq}</tt></li>
 93<li><tt>Sort = {CatId, Nr, Level, Left, Right, Path}</tt></li>
 94</ul></p>
 95</div><p>Take a category list and make it into a tree, recalculating the left/right and lvl nrs</p>
 96
 97<h3 class="function"><a name="get-2">get/2</a></h3>
 98<div class="spec">
 99<p><tt>get(Name, Context) -&gt; any()</tt></p>
100</div>
101
102<h3 class="function"><a name="get_by_name-2">get_by_name/2</a></h3>
103<div class="spec">
104<p><tt>get_by_name(Name, Context) -&gt; any()</tt></p>
105</div>
106
107<h3 class="function"><a name="get_by_parent-2">get_by_parent/2</a></h3>
108<div class="spec">
109<p><tt>get_by_parent(Id, Context) -&gt; any()</tt></p>
110</div>
111
112<h3 class="function"><a name="get_page_count-2">get_page_count/2</a></h3>
113<div class="spec">
114<p><tt>get_page_count(Id, Context) -&gt; any()</tt></p>
115</div>
116
117<h3 class="function"><a name="get_path-2">get_path/2</a></h3>
118<div class="spec">
119<p><tt>get_path(Id, Context) -&gt; [CatId]</tt></p>
120</div><p>Return the path from a root to the category (excluding the category itself)</p>
121
122<h3 class="function"><a name="get_range-2">get_range/2</a></h3>
123<div class="spec">
124<p><tt>get_range(Id, Context) -&gt; any()</tt></p>
125</div>
126
127<h3 class="function"><a name="get_range_by_name-2">get_range_by_name/2</a></h3>
128<div class="spec">
129<p><tt>get_range_by_name(Name, Context) -&gt; any()</tt></p>
130</div>
131
132<h3 class="function"><a name="get_root-1">get_root/1</a></h3>
133<div class="spec">
134<p><tt>get_root(Context) -&gt; any()</tt></p>
135</div>
136
137<h3 class="function"><a name="id_to_name-2">id_to_name/2</a></h3>
138<div class="spec">
139<p><tt>id_to_name(Name, Context) -&gt; any()</tt></p>
140</div>
141
142<h3 class="function"><a name="image-2">image/2</a></h3>
143<div class="spec">
144<p><tt>image(Id, Context) -&gt; any()</tt></p>
145</div>
146
147<h3 class="function"><a name="insert-4">insert/4</a></h3>
148<div class="spec">
149<p><tt>insert(ParentId, Name, Props, Context) -&gt; any()</tt></p>
150</div>
151
152<h3 class="function"><a name="is_a-2">is_a/2</a></h3>
153<div class="spec">
154<p><tt>is_a(Id::<a href="#type-int">int()</a>, Context) -&gt; <a href="#type-atomlist">atomlist()</a></tt></p>
155</div><p>Return the list of categories (as atoms) that the category is part of</p>
156
157<h3 class="function"><a name="is_a-3">is_a/3</a></h3>
158<div class="spec">
159<p><tt>is_a(Id::<a href="#type-int">int()</a>, Cat, Context) -&gt; <a href="#type-atomlist">atomlist()</a></tt></p>
160</div><p>Check if the id is within another category.</p>
161
162<h3 class="function"><a name="last_modified-2">last_modified/2</a></h3>
163<div class="spec">
164<p><tt>last_modified(Cat::term(), Context) -&gt; {ok, {{Y, M, D}, {Hour, Min, Sec}}} | {error, Reason}</tt></p>
165</div><p>Return the last modification date of the category. Returns false</p>
166
167<h3 class="function"><a name="m_find_value-3">m_find_value/3</a></h3>
168<div class="spec">
169<p><tt>m_find_value(Index::Key, M::Source, Context) -&gt; term()</tt></p>
170</div><p>Fetch the value for the key from a model source</p>
171
172<h3 class="function"><a name="m_to_list-2">m_to_list/2</a></h3>
173<div class="spec">
174<p><tt>m_to_list(M::Source, Context) -&gt; List</tt></p>
175</div><p>Transform a m_config value to a list, used for template loops</p>
176
177<h3 class="function"><a name="m_value-2">m_value/2</a></h3>
178<div class="spec">
179<p><tt>m_value(M::Source, Context) -&gt; term()</tt></p>
180</div><p>Transform a model value so that it can be formatted or piped through filters</p>
181
182<h3 class="function"><a name="move_before-3">move_before/3</a></h3>
183<div class="spec">
184<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>
185</div><p>Move a category in front of another category, resetting the parent of the moved category to
186  the parent of the other category.</p>
187
188<h3 class="function"><a name="move_below-3">move_below/3</a></h3>
189<div class="spec">
190<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>
191</div><p>Move the category below another category, placing it at the end of the children of that category.</p>
192
193<h3 class="function"><a name="move_end-2">move_end/2</a></h3>
194<div class="spec">
195<p><tt>move_end(CatId::<a href="#type-int">int()</a>, Context) -&gt; ok | {error, Reason}</tt></p>
196</div><p>Move the category to the end of all categories, making it a top category in the process</p>
197
198<h3 class="function"><a name="name_to_id-2">name_to_id/2</a></h3>
199<div class="spec">
200<p><tt>name_to_id(Id, Context) -&gt; any()</tt></p>
201</div>
202
203<h3 class="function"><a name="name_to_id_check-2">name_to_id_check/2</a></h3>
204<div class="spec">
205<p><tt>name_to_id_check(Name, Context) -&gt; any()</tt></p>
206</div>
207
208<h3 class="function"><a name="ranges-2">ranges/2</a></h3>
209<div class="spec">
210<p><tt>ranges(Cat::CatList, Context) -&gt; RangeList</tt></p>
211</div><p>Given a list of category ids, return the list of numeric ranges they cover.</p>
212
213<h3 class="function"><a name="renumber-1">renumber/1</a></h3>
214<div class="spec">
215<p><tt>renumber(Context) -&gt; ok</tt></p>
216</div><p>Renumber all categories so that the left/right and level indices are correct.</p>
217
218<h3 class="function"><a name="renumber_pivot_task-2">renumber_pivot_task/2</a></h3>
219<div class="spec">
220<p><tt>renumber_pivot_task(LowId, Context) -&gt; any()</tt></p>
221</div><p>Resync all ids that have their category nr changed.</p>
222
223<h3 class="function"><a name="tree-1">tree/1</a></h3>
224<div class="spec">
225<p><tt>tree(Context) -&gt; Tree</tt></p>
226</div><p>Return the tree of all categories</p>
227
228<h3 class="function"><a name="tree-2">tree/2</a></h3>
229<div class="spec">
230<p><tt>tree(CatId, Context) -&gt; TreeNode</tt></p>
231</div><p>Return the tree of all categories below a category id</p>
232
233<h3 class="function"><a name="tree_depth-2">tree_depth/2</a></h3>
234<div class="spec">
235<p><tt>tree_depth(Depth, Context) -&gt; Tree</tt></p>
236</div><p>Return the tree of all categories till a certain depth</p>
237
238<h3 class="function"><a name="tree_depth-3">tree_depth/3</a></h3>
239<div class="spec">
240<p><tt>tree_depth(CatId, Depth, Context) -&gt; TreeNode</tt></p>
241</div><p>Return the tree of all categories below a category id till a certain depth</p>
242
243<h3 class="function"><a name="update_sequence-2">update_sequence/2</a></h3>
244<div class="spec">
245<p><tt>update_sequence(Ids, Context) -&gt; any()</tt></p>
246</div>
247<hr>
248
249<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>
250<p><i>Generated by EDoc, Aug 12 2011, 20:01:40.</i></p>
251</body>
252</html>