reverse.patch

F. P., 2021-06-29 11:36

Download (1.51 KB)

View differences:

lib/redmine/wiki_formatting/macros.rb (Arbeitskopie)
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)}} -- 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, :parent, :depth, :reverse)
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
......
210 212
        raise t(:error_page_not_found) if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project)
211 213

  
212 214
        pages = page.self_and_descendants(options[:depth]).group_by(&:parent_id)
215
        
216
        if options[:reverse]
217
          pages.reverse()
218
          
213 219
        render_page_hierarchy(pages, options[:parent] ? page.parent_id : page.id)
214 220
      end
215 221