Patch #3962 ยป maxnesting-parameter.patch
app/helpers/application_helper.rb (working copy) | ||
---|---|---|
132 | 132 |
end |
133 | 133 |
end |
134 | 134 | |
135 |
def render_page_hierarchy(pages, node=nil) |
|
135 |
def render_page_hierarchy(pages, node=nil, maxnesting=nil, curnesting=0)
|
|
136 | 136 |
content = '' |
137 | 137 |
if pages[node] |
138 | 138 |
content << "<ul class=\"pages-hierarchy\">\n" |
... | ... | |
140 | 140 |
content << "<li>" |
141 | 141 |
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'index', :id => page.project, :page => page.title}, |
142 | 142 |
:title => (page.respond_to?(:updated_on) ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil)) |
143 |
content << "\n" + render_page_hierarchy(pages, page.id) if pages[page.id]
|
|
143 |
content << "\n" + render_page_hierarchy(pages, page.id, maxnesting, curnesting + 1) if pages[page.id] and (maxnesting.nil? or curnesting < maxnesting)
|
|
144 | 144 |
content << "</li>\n" |
145 | 145 |
end |
146 | 146 |
content << "</ul>\n" |
lib/redmine/wiki_formatting/macros.rb (working copy) | ||
---|---|---|
89 | 89 |
desc "Displays a list of child pages. With no argument, it displays the child pages of the current wiki page. Examples:\n\n" + |
90 | 90 |
" !{{child_pages}} -- can be used from a wiki page only\n" + |
91 | 91 |
" !{{child_pages(Foo)}} -- lists all children of page Foo\n" + |
92 |
" !{{child_pages(Foo, parent=1)}} -- same as above with a link to page Foo" |
|
92 |
" !{{child_pages(Foo, parent=1)}} -- same as above with a link to page Foo\n" + |
|
93 |
" !{{child_pages(Foo, parent=1, maxnesting=1)}} -- maximum nesting of 1 (show only Foo and direct children)" |
|
93 | 94 |
macro :child_pages do |obj, args| |
94 |
args, options = extract_macro_options(args, :parent) |
|
95 |
args, options = extract_macro_options(args, :parent, :maxnesting)
|
|
95 | 96 |
page = nil |
96 | 97 |
if args.size > 0 |
97 | 98 |
page = Wiki.find_page(args.first.to_s, :project => @project) |
... | ... | |
102 | 103 |
end |
103 | 104 |
raise 'Page not found' if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project) |
104 | 105 |
pages = ([page] + page.descendants).group_by(&:parent_id) |
105 |
render_page_hierarchy(pages, options[:parent] ? page.parent_id : page.id) |
|
106 |
render_page_hierarchy(pages, options[:parent] ? page.parent_id : page.id, options[:maxnesting].to_i)
|
|
106 | 107 |
end |
107 | 108 |
|
108 | 109 |
desc "Include a wiki page. Example:\n\n !{{include(Foo)}}\n\nor to include a page of a specific project wiki:\n\n !{{include(projectname:Foo)}}" |