Feature #31215 » reverse.patch
<unbenannt> | ||
---|---|---|
193 | 193 |
desc "Displays a list of child pages. With no argument, it displays the child pages of the current wiki page. Examples:\n\n" + |
194 | 194 |
"{{child_pages}} -- can be used from a wiki page only\n" + |
195 | 195 |
"{{child_pages(depth=2)}} -- display 2 levels nesting only\n" + |
196 |
"{{child_pages(reverse=true)}} -- reverse sorting order\n" + |
|
196 | 197 |
"{{child_pages(Foo)}} -- lists all children of page Foo\n" + |
197 | 198 |
"{{child_pages(Foo, parent=1)}} -- same as above with a link to page Foo" |
198 | 199 |
macro :child_pages do |obj, args| |
199 |
args, options = extract_macro_options(args, :parent, :depth) |
|
200 |
args, options = extract_macro_options(args, :reverse, :parent, :depth)
|
|
200 | 201 |
options[:depth] = options[:depth].to_i if options[:depth].present? |
202 |
options[:reverse] = true if options[:reverse].present? |
|
201 | 203 | |
202 | 204 |
page = nil |
203 | 205 |
if args.size > 0 |
... | ... | |
209 | 211 |
end |
210 | 212 |
raise t(:error_page_not_found) if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project) |
211 | 213 | |
212 |
pages = page.self_and_descendants(options[:depth]).group_by(&:parent_id) |
|
214 |
if(options[:reverse]) |
|
215 |
pages = page.self_and_descendants(options[:depth]).reverse |
|
216 |
pages = pages.group_by(&:parent_id) |
|
217 |
else |
|
218 |
pages = page.self_and_descendants(options[:depth]).group_by(&:parent_id) |
|
219 |
end |
|
220 | ||
213 | 221 |
render_page_hierarchy(pages, options[:parent] ? page.parent_id : page.id) |
214 | 222 |
end |
215 | 223 |
- « Previous
- 1
- 2
- Next »