diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/admin_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/application.rb | 15 | ||||
-rw-r--r-- | app/controllers/boards_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/issues_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/repositories_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/users_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/wiki_controller.rb | 2 |
7 files changed, 21 insertions, 6 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 5ad3d696b..0f8eb32a5 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -35,7 +35,7 @@ class AdminController < ApplicationController @project_count = Project.count(:conditions => conditions) @project_pages = Paginator.new self, @project_count, - 25, + per_page_option, params['page'] @projects = Project.find :all, :order => sort_clause, :conditions => conditions, diff --git a/app/controllers/application.rb b/app/controllers/application.rb index ad86b6b33..607ac091b 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -158,6 +158,21 @@ class ApplicationController < ActionController::Base attachments end + # Returns the number of objects that should be displayed + # on the paginated list + def per_page_option + per_page = nil + if params[:per_page] && Setting.per_page_options_array.include?(params[:per_page].to_s.to_i) + per_page = params[:per_page].to_s.to_i + session[:per_page] = per_page + elsif session[:per_page] + per_page = session[:per_page] + else + per_page = Setting.per_page_options_array.first || 25 + end + per_page + end + # qvalues http header parser # code taken from webrick def parse_qvalues(value) diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 200792370..5bf4499bd 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -40,7 +40,7 @@ class BoardsController < ApplicationController sort_update @topic_count = @board.topics.count - @topic_pages = Paginator.new self, @topic_count, 25, params['page'] + @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] @topics = @board.topics.find :all, :order => "#{Message.table_name}.sticky DESC, #{sort_clause}", :include => [:author, {:last_reply => :author}], :limit => @topic_pages.items_per_page, diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index f202e9bba..be854f98e 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -45,7 +45,7 @@ class IssuesController < ApplicationController sort_update retrieve_query if @query.valid? - limit = %w(pdf csv).include?(params[:format]) ? Setting.issues_export_limit.to_i : 25 + limit = %w(pdf csv).include?(params[:format]) ? Setting.issues_export_limit.to_i : per_page_option @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement) @issue_pages = Paginator.new self, @issue_count, limit, params['page'] @issues = Issue.find :all, :order => sort_clause, diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index ef332eb37..f8b1eae81 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -75,7 +75,7 @@ class RepositoriesController < ApplicationController def revisions @changeset_count = @repository.changesets.count @changeset_pages = Paginator.new self, @changeset_count, - 25, + per_page_option, params['page'] @changesets = @repository.changesets.find(:all, :limit => @changeset_pages.items_per_page, diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3f3adb57d..f67d1ae53 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -39,7 +39,7 @@ class UsersController < ApplicationController @user_count = User.count(:conditions => conditions) @user_pages = Paginator.new self, @user_count, - 15, + per_page_option, params['page'] @users = User.find :all,:order => sort_clause, :conditions => conditions, diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index bc4b7b451..53c5ec53b 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -97,7 +97,7 @@ class WikiController < ApplicationController @page = @wiki.find_page(params[:page]) @version_count = @page.content.versions.count - @version_pages = Paginator.new self, @version_count, 25, params['p'] + @version_pages = Paginator.new self, @version_count, per_page_option, params['p'] # don't load text @versions = @page.content.versions.find :all, :select => "id, author_id, comments, updated_on, version", |