summaryrefslogtreecommitdiffstats
path: root/redmine/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'redmine/app/helpers')
-rw-r--r--redmine/app/helpers/account_helper.rb19
-rw-r--r--redmine/app/helpers/admin_helper.rb19
-rw-r--r--redmine/app/helpers/application_helper.rb65
-rw-r--r--redmine/app/helpers/custom_fields_helper.rb36
-rw-r--r--redmine/app/helpers/documents_helper.rb19
-rw-r--r--redmine/app/helpers/enumerations_helper.rb19
-rw-r--r--redmine/app/helpers/help_helper.rb19
-rw-r--r--redmine/app/helpers/issue_categories_helper.rb19
-rw-r--r--redmine/app/helpers/issue_statuses_helper.rb19
-rw-r--r--redmine/app/helpers/issues_helper.rb19
-rw-r--r--redmine/app/helpers/members_helper.rb19
-rw-r--r--redmine/app/helpers/news_helper.rb19
-rw-r--r--redmine/app/helpers/projects_helper.rb19
-rw-r--r--redmine/app/helpers/reports_helper.rb32
-rw-r--r--redmine/app/helpers/roles_helper.rb19
-rw-r--r--redmine/app/helpers/search_filter_helper.rb55
-rw-r--r--redmine/app/helpers/sort_helper.rb157
-rw-r--r--redmine/app/helpers/trackers_helper.rb19
-rw-r--r--redmine/app/helpers/users_helper.rb19
-rw-r--r--redmine/app/helpers/versions_helper.rb19
-rw-r--r--redmine/app/helpers/welcome_helper.rb19
21 files changed, 649 insertions, 0 deletions
diff --git a/redmine/app/helpers/account_helper.rb b/redmine/app/helpers/account_helper.rb
new file mode 100644
index 000000000..e18ab6ff4
--- /dev/null
+++ b/redmine/app/helpers/account_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module AccountHelper
+end
diff --git a/redmine/app/helpers/admin_helper.rb b/redmine/app/helpers/admin_helper.rb
new file mode 100644
index 000000000..db2777392
--- /dev/null
+++ b/redmine/app/helpers/admin_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module AdminHelper
+end
diff --git a/redmine/app/helpers/application_helper.rb b/redmine/app/helpers/application_helper.rb
new file mode 100644
index 000000000..4a50b949a
--- /dev/null
+++ b/redmine/app/helpers/application_helper.rb
@@ -0,0 +1,65 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module ApplicationHelper
+
+ def loggedin?
+ session[:user]
+ end
+
+ def admin_loggedin?
+ session[:user] && session[:user].admin
+ end
+
+ def authorize_for(controller, action)
+ # check if action is allowed on public projects
+ if @project.public? and Permission.allowed_to_public "%s/%s" % [ controller, action ]
+ return true
+ end
+ # check if user is authorized
+ if session[:user] and (session[:user].admin? or Permission.allowed_to_role( "%s/%s" % [ controller, action ], session[:user].role_for_project(@project.id) ) )
+ return true
+ end
+ return false
+ end
+
+ def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
+ link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller], options[:action])
+ end
+
+ # Display a link to user's account page
+ def link_to_user(user)
+ link_to user.display_name, :controller => 'account', :action => 'show', :id => user
+ end
+
+ def format_date(date)
+ _('(date)', date) if date
+ end
+
+ def format_time(time)
+ _('(time)', time) if time
+ end
+
+ def pagination_links_full(paginator, options={}, html_options={})
+ html =''
+ html << link_to(('&#171; ' + _('Previous') ), { :page => paginator.current.previous }) + ' ' if paginator.current.previous
+ html << (pagination_links(paginator, options, html_options) || '')
+ html << ' ' + link_to((_('Next') + ' &#187;'), { :page => paginator.current.next }) if paginator.current.next
+ html
+ end
+
+end
diff --git a/redmine/app/helpers/custom_fields_helper.rb b/redmine/app/helpers/custom_fields_helper.rb
new file mode 100644
index 000000000..4e3aea50f
--- /dev/null
+++ b/redmine/app/helpers/custom_fields_helper.rb
@@ -0,0 +1,36 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module CustomFieldsHelper
+ def custom_field_tag(custom_value)
+
+ custom_field = custom_value.custom_field
+
+ field_name = "custom_fields[#{custom_field.id}]"
+
+ case custom_field.typ
+ when 0 .. 2
+ text_field_tag field_name, custom_value.value
+ when 3
+ check_box field_name
+ when 4
+ select_tag field_name,
+ options_for_select(custom_field.possible_values.split('|'),
+ custom_value.value)
+ end
+ end
+end
diff --git a/redmine/app/helpers/documents_helper.rb b/redmine/app/helpers/documents_helper.rb
new file mode 100644
index 000000000..c9897647d
--- /dev/null
+++ b/redmine/app/helpers/documents_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module DocumentsHelper
+end
diff --git a/redmine/app/helpers/enumerations_helper.rb b/redmine/app/helpers/enumerations_helper.rb
new file mode 100644
index 000000000..11a216a82
--- /dev/null
+++ b/redmine/app/helpers/enumerations_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module EnumerationsHelper
+end
diff --git a/redmine/app/helpers/help_helper.rb b/redmine/app/helpers/help_helper.rb
new file mode 100644
index 000000000..bb629316c
--- /dev/null
+++ b/redmine/app/helpers/help_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module HelpHelper
+end
diff --git a/redmine/app/helpers/issue_categories_helper.rb b/redmine/app/helpers/issue_categories_helper.rb
new file mode 100644
index 000000000..997d830d7
--- /dev/null
+++ b/redmine/app/helpers/issue_categories_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module IssueCategoriesHelper
+end
diff --git a/redmine/app/helpers/issue_statuses_helper.rb b/redmine/app/helpers/issue_statuses_helper.rb
new file mode 100644
index 000000000..17704b7ba
--- /dev/null
+++ b/redmine/app/helpers/issue_statuses_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module IssueStatusesHelper
+end
diff --git a/redmine/app/helpers/issues_helper.rb b/redmine/app/helpers/issues_helper.rb
new file mode 100644
index 000000000..40c0e40ae
--- /dev/null
+++ b/redmine/app/helpers/issues_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module IssuesHelper
+end
diff --git a/redmine/app/helpers/members_helper.rb b/redmine/app/helpers/members_helper.rb
new file mode 100644
index 000000000..8bf90913d
--- /dev/null
+++ b/redmine/app/helpers/members_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module MembersHelper
+end
diff --git a/redmine/app/helpers/news_helper.rb b/redmine/app/helpers/news_helper.rb
new file mode 100644
index 000000000..f4a633f4b
--- /dev/null
+++ b/redmine/app/helpers/news_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module NewsHelper
+end
diff --git a/redmine/app/helpers/projects_helper.rb b/redmine/app/helpers/projects_helper.rb
new file mode 100644
index 000000000..0c85ce24c
--- /dev/null
+++ b/redmine/app/helpers/projects_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module ProjectsHelper
+end
diff --git a/redmine/app/helpers/reports_helper.rb b/redmine/app/helpers/reports_helper.rb
new file mode 100644
index 000000000..ed7fd7884
--- /dev/null
+++ b/redmine/app/helpers/reports_helper.rb
@@ -0,0 +1,32 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module ReportsHelper
+
+ def aggregate(data, criteria)
+ a = 0
+ data.each { |row|
+ match = 1
+ criteria.each { |k, v|
+ match = 0 unless row[k].to_s == v.to_s
+ } unless criteria.nil?
+ a = a + row["total"].to_i if match == 1
+ } unless data.nil?
+ a
+ end
+
+end
diff --git a/redmine/app/helpers/roles_helper.rb b/redmine/app/helpers/roles_helper.rb
new file mode 100644
index 000000000..8ae339053
--- /dev/null
+++ b/redmine/app/helpers/roles_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module RolesHelper
+end
diff --git a/redmine/app/helpers/search_filter_helper.rb b/redmine/app/helpers/search_filter_helper.rb
new file mode 100644
index 000000000..3a76b3f57
--- /dev/null
+++ b/redmine/app/helpers/search_filter_helper.rb
@@ -0,0 +1,55 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module SearchFilterHelper
+
+ def search_filter_criteria(field, options = {})
+ session[:search_filter] ||= {}
+ session[:search_filter][field] ||= options
+ # session[:search_filter][field][:values] = options[:values] unless options[:values].nil?
+ # session[:search_filter][field][:label] = options[:label] unless options[:label].nil?
+ end
+
+ def search_filter_update
+ session[:search_filter].each_key {|field| session[:search_filter][field][:value] = params[field] }
+ #@search_filter[:value] = params[@search_filter[:field]]
+ end
+
+ def search_filter_clause
+ clause = "1=1"
+ session[:search_filter].each {|field, criteria| clause = clause + " AND " + field + "='" + session[:search_filter][field][:value] + "'" unless session[:search_filter][field][:value].nil? || session[:search_filter][field][:value].empty? }
+ clause
+ #@search_filter[:field] + "='" + @search_filter[:value] + "'" unless @search_filter[:value].nil? || @search_filter[:value].empty?
+ end
+
+ def search_filter_tag(field)
+ option_values = []
+ #values = eval @search_filter[:values_expr]
+ option_values = eval session[:search_filter][field][:values]
+
+ content_tag("select",
+ content_tag("option", "[All]", :value => "") +
+ options_from_collection_for_select(option_values,
+ "id",
+ session[:search_filter][field][:label] || "name",
+ session[:search_filter][field][:value].to_i
+ ),
+ :name => field
+ )
+ end
+
+end \ No newline at end of file
diff --git a/redmine/app/helpers/sort_helper.rb b/redmine/app/helpers/sort_helper.rb
new file mode 100644
index 000000000..bec2117ec
--- /dev/null
+++ b/redmine/app/helpers/sort_helper.rb
@@ -0,0 +1,157 @@
+# Helpers to sort tables using clickable column headers.
+#
+# Author: Stuart Rackham <srackham@methods.co.nz>, March 2005.
+# License: This source code is released under the MIT license.
+#
+# - Consecutive clicks toggle the column's sort order.
+# - Sort state is maintained by a session hash entry.
+# - Icon image identifies sort column and state.
+# - Typically used in conjunction with the Pagination module.
+#
+# Example code snippets:
+#
+# Controller:
+#
+# helper :sort
+# include SortHelper
+#
+# def list
+# sort_init 'last_name'
+# sort_update
+# @items = Contact.find_all nil, sort_clause
+# end
+#
+# Controller (using Pagination module):
+#
+# helper :sort
+# include SortHelper
+#
+# def list
+# sort_init 'last_name'
+# sort_update
+# @contact_pages, @items = paginate :contacts,
+# :order_by => sort_clause,
+# :per_page => 10
+# end
+#
+# View (table header in list.rhtml):
+#
+# <thead>
+# <tr>
+# <%= sort_header_tag('id', :title => 'Sort by contact ID') %>
+# <%= sort_header_tag('last_name', :caption => 'Name') %>
+# <%= sort_header_tag('phone') %>
+# <%= sort_header_tag('address', :width => 200) %>
+# </tr>
+# </thead>
+#
+# - The ascending and descending sort icon images are sort_asc.png and
+# sort_desc.png and reside in the application's images directory.
+# - Introduces instance variables: @sort_name, @sort_default.
+# - Introduces params :sort_key and :sort_order.
+#
+module SortHelper
+
+ # Initializes the default sort column (default_key) and sort order
+ # (default_order).
+ #
+ # - default_key is a column attribute name.
+ # - default_order is 'asc' or 'desc'.
+ # - name is the name of the session hash entry that stores the sort state,
+ # defaults to '<controller_name>_sort'.
+ #
+ def sort_init(default_key, default_order='asc', name=nil)
+ @sort_name = name || @params[:controller] + @params[:action] + '_sort'
+ @sort_default = {:key => default_key, :order => default_order}
+ end
+
+ # Updates the sort state. Call this in the controller prior to calling
+ # sort_clause.
+ #
+ def sort_update()
+ if @params[:sort_key]
+ sort = {:key => @params[:sort_key], :order => @params[:sort_order]}
+ elsif @session[@sort_name]
+ sort = @session[@sort_name] # Previous sort.
+ else
+ sort = @sort_default
+ end
+ @session[@sort_name] = sort
+ end
+
+ # Returns an SQL sort clause corresponding to the current sort state.
+ # Use this to sort the controller's table items collection.
+ #
+ def sort_clause()
+ @session[@sort_name][:key] + ' ' + @session[@sort_name][:order]
+ end
+
+ # Returns a link which sorts by the named column.
+ #
+ # - column is the name of an attribute in the sorted record collection.
+ # - The optional caption explicitly specifies the displayed link text.
+ # - A sort icon image is positioned to the right of the sort link.
+ #
+ def sort_link(column, caption=nil)
+ key, order = @session[@sort_name][:key], @session[@sort_name][:order]
+ if key == column
+ if order.downcase == 'asc'
+ icon = 'sort_asc'
+ order = 'desc'
+ else
+ icon = 'sort_desc'
+ order = 'asc'
+ end
+ else
+ icon = nil
+ order = 'desc' # changed for desc order by default
+ end
+ caption = titleize(Inflector::humanize(column)) unless caption
+ params = {:params => {:sort_key => column, :sort_order => order}}
+ link_to(caption, params) + (icon ? nbsp(2) + image_tag(icon) : '')
+ end
+
+ # Returns a table header <th> tag with a sort link for the named column
+ # attribute.
+ #
+ # Options:
+ # :caption The displayed link name (defaults to titleized column name).
+ # :title The tag's 'title' attribute (defaults to 'Sort by :caption').
+ #
+ # Other options hash entries generate additional table header tag attributes.
+ #
+ # Example:
+ #
+ # <%= sort_header_tag('id', :title => 'Sort by contact ID', :width => 40) %>
+ #
+ # Renders:
+ #
+ # <th title="Sort by contact ID" width="40">
+ # <a href="/contact/list?sort_order=desc&amp;sort_key=id">Id</a>
+ # &nbsp;&nbsp;<img alt="Sort_asc" src="/images/sort_asc.png" />
+ # </th>
+ #
+ def sort_header_tag(column, options = {})
+ if options[:caption]
+ caption = options[:caption]
+ options.delete(:caption)
+ else
+ caption = titleize(Inflector::humanize(column))
+ end
+ options[:title]= "Sort by #{caption}" unless options[:title]
+ content_tag('th', sort_link(column, caption), options)
+ end
+
+ private
+
+ # Return n non-breaking spaces.
+ def nbsp(n)
+ '&nbsp;' * n
+ end
+
+ # Return capitalized title.
+ def titleize(title)
+ title.split.map {|w| w.capitalize }.join(' ')
+ end
+
+end
diff --git a/redmine/app/helpers/trackers_helper.rb b/redmine/app/helpers/trackers_helper.rb
new file mode 100644
index 000000000..839327efe
--- /dev/null
+++ b/redmine/app/helpers/trackers_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module TrackersHelper
+end
diff --git a/redmine/app/helpers/users_helper.rb b/redmine/app/helpers/users_helper.rb
new file mode 100644
index 000000000..035db3d00
--- /dev/null
+++ b/redmine/app/helpers/users_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module UsersHelper
+end
diff --git a/redmine/app/helpers/versions_helper.rb b/redmine/app/helpers/versions_helper.rb
new file mode 100644
index 000000000..e2724fe84
--- /dev/null
+++ b/redmine/app/helpers/versions_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module VersionsHelper
+end
diff --git a/redmine/app/helpers/welcome_helper.rb b/redmine/app/helpers/welcome_helper.rb
new file mode 100644
index 000000000..cace5f542
--- /dev/null
+++ b/redmine/app/helpers/welcome_helper.rb
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module WelcomeHelper
+end