Speeds up WikiHelper#wiki_page_options_for_select.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5080 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
ef189164bf
commit
28feb58754
|
@ -18,14 +18,17 @@
|
||||||
module WikiHelper
|
module WikiHelper
|
||||||
|
|
||||||
def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0)
|
def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0)
|
||||||
|
pages = pages.group_by(&:parent) unless pages.is_a?(Hash)
|
||||||
s = ''
|
s = ''
|
||||||
pages.select {|p| p.parent == parent}.each do |page|
|
if pages.has_key?(parent)
|
||||||
attrs = "value='#{page.id}'"
|
pages[parent].each do |page|
|
||||||
attrs << " selected='selected'" if selected == page
|
attrs = "value='#{page.id}'"
|
||||||
indent = (level > 0) ? (' ' * level * 2 + '» ') : nil
|
attrs << " selected='selected'" if selected == page
|
||||||
|
indent = (level > 0) ? (' ' * level * 2 + '» ') : nil
|
||||||
s << "<option #{attrs}>#{indent}#{h page.pretty_title}</option>\n" +
|
|
||||||
wiki_page_options_for_select(pages, selected, page, level + 1)
|
s << "<option #{attrs}>#{indent}#{h page.pretty_title}</option>\n" +
|
||||||
|
wiki_page_options_for_select(pages, selected, page, level + 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue