comparison app/helpers/wiki_helper.rb @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents cbce1fd3b1b7
children 433d4f72a19b
comparison
equal deleted inserted replaced
908:c6c2cbd0afee 909:cbb26bc654de
1 # encoding: utf-8
2 #
1 # Redmine - project management software 3 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang 4 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 # 5 #
4 # This program is free software; you can redistribute it and/or 6 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 7 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 8 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 9 # of the License, or (at your option) any later version.
8 # 10 #
9 # This program is distributed in the hope that it will be useful, 11 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details. 14 # GNU General Public License for more details.
13 # 15 #
14 # You should have received a copy of the GNU General Public License 16 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software 17 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 19
18 module WikiHelper 20 module WikiHelper
19 21
20 def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0) 22 def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0)
21 pages = pages.group_by(&:parent) unless pages.is_a?(Hash) 23 pages = pages.group_by(&:parent) unless pages.is_a?(Hash)
22 s = '' 24 s = ''
23 if pages.has_key?(parent) 25 if pages.has_key?(parent)
24 pages[parent].each do |page| 26 pages[parent].each do |page|
25 attrs = "value='#{page.id}'" 27 attrs = "value='#{page.id}'"
26 attrs << " selected='selected'" if selected == page 28 attrs << " selected='selected'" if selected == page
27 indent = (level > 0) ? ('&nbsp;' * level * 2 + '&#187; ') : nil 29 indent = (level > 0) ? ('&nbsp;' * level * 2 + '&#187; ') : nil
28 30
29 s << "<option #{attrs}>#{indent}#{h page.pretty_title}</option>\n" + 31 s << "<option #{attrs}>#{indent}#{h page.pretty_title}</option>\n" +
30 wiki_page_options_for_select(pages, selected, page, level + 1) 32 wiki_page_options_for_select(pages, selected, page, level + 1)
31 end 33 end
32 end 34 end
33 s 35 s
34 end 36 end
37
38 def wiki_page_breadcrumb(page)
39 breadcrumb(page.ancestors.reverse.collect {|parent|
40 link_to(h(parent.pretty_title), {:controller => 'wiki', :action => 'show', :id => parent.title, :project_id => parent.project})
41 })
42 end
35 end 43 end