Project

General

Profile

Feature #31215 » reverse.patch

F. P., 2023-03-23 13:56

View differences:

<unbenannt>
desc "Displays a list of child pages. With no argument, it displays the child pages of the current wiki page. Examples:\n\n" +
"{{child_pages}} -- can be used from a wiki page only\n" +
"{{child_pages(depth=2)}} -- display 2 levels nesting only\n" +
"{{child_pages(reverse=true)}} -- reverse sorting order\n" +
"{{child_pages(Foo)}} -- lists all children of page Foo\n" +
"{{child_pages(Foo, parent=1)}} -- same as above with a link to page Foo"
macro :child_pages do |obj, args|
args, options = extract_macro_options(args, :parent, :depth)
args, options = extract_macro_options(args, :reverse, :parent, :depth)
options[:depth] = options[:depth].to_i if options[:depth].present?
options[:reverse] = true if options[:reverse].present?
page = nil
if args.size > 0
......
end
raise t(:error_page_not_found) if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project)
pages = page.self_and_descendants(options[:depth]).group_by(&:parent_id)
if(options[:reverse])
pages = page.self_and_descendants(options[:depth]).reverse
pages = pages.group_by(&:parent_id)
else
pages = page.self_and_descendants(options[:depth]).group_by(&:parent_id)
end
render_page_hierarchy(pages, options[:parent] ? page.parent_id : page.id)
end
(2-2/2)