summaryrefslogtreecommitdiffstats
path: root/lib/redmine
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-09-16 15:24:35 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-09-16 15:24:35 +0000
commit747e4ecd3a981e5d48d3028f5cd870b130eb65b4 (patch)
tree8f8bdf941521d4647db1ebcb0e9c450427ecbd63 /lib/redmine
parentca4f2c59b6479ad088aa87e6173bcdd5c7c66629 (diff)
downloadredmine-747e4ecd3a981e5d48d3028f5cd870b130eb65b4.tar.gz
redmine-747e4ecd3a981e5d48d3028f5cd870b130eb65b4.zip
Adds a "depth" option to the child_pages macro (#10789).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10401 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine')
-rw-r--r--lib/redmine/wiki_formatting/macros.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb
index 23e6caf00..1ae86345b 100644
--- a/lib/redmine/wiki_formatting/macros.rb
+++ b/lib/redmine/wiki_formatting/macros.rb
@@ -183,7 +183,9 @@ module Redmine
" !{{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)
+ args, options = extract_macro_options(args, :parent, :depth)
+ options[:depth] = options[:depth].to_i if options[:depth].present?
+
page = nil
if args.size > 0
page = Wiki.find_page(args.first.to_s, :project => @project)
@@ -193,7 +195,7 @@ module Redmine
raise 'With no argument, this macro can be called from wiki pages only.'
end
raise 'Page not found' if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project)
- pages = ([page] + page.descendants).group_by(&:parent_id)
+ pages = page.self_and_descendants(options[:depth]).group_by(&:parent_id)
render_page_hierarchy(pages, options[:parent] ? page.parent_id : page.id)
end