aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-06-11 00:51:11 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-06-11 00:51:11 +0000
commit43c6d7ee955e1dd55d76c49f5d93f2fcc4540670 (patch)
tree9d951d925a360c6ae5b485c12adb45bcd1ab6ea7 /actionpack/lib/action_view/helpers
parent4e23e6596418a830d56c3750341e3eebcac7c9ef (diff)
downloadrails-43c6d7ee955e1dd55d76c49f5d93f2fcc4540670.tar.gz
rails-43c6d7ee955e1dd55d76c49f5d93f2fcc4540670.tar.bz2
rails-43c6d7ee955e1dd55d76c49f5d93f2fcc4540670.zip
Deprecation: remove pagination. Install the classic_pagination plugin for forward compatibility, or move to the superior will_paginate plugin. Closes #8157.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6992 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/pagination_helper.rb86
1 files changed, 0 insertions, 86 deletions
diff --git a/actionpack/lib/action_view/helpers/pagination_helper.rb b/actionpack/lib/action_view/helpers/pagination_helper.rb
deleted file mode 100644
index 6123b7381a..0000000000
--- a/actionpack/lib/action_view/helpers/pagination_helper.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-module ActionView
- module Helpers
- # Provides methods for linking to ActionController::Pagination objects.
- #
- # You can also build your links manually, like in this example:
- #
- # <%= link_to "Previous page", { :page => paginator.current.previous } if paginator.current.previous %>
- #
- # <%= link_to "Next page", { :page => paginator.current.next } if paginator.current.next %>
- module PaginationHelper
- unless const_defined?(:DEFAULT_OPTIONS)
- DEFAULT_OPTIONS = {
- :name => :page,
- :window_size => 2,
- :always_show_anchors => true,
- :link_to_current_page => false,
- :params => {}
- }
- end
-
- # Creates a basic HTML link bar for the given +paginator+.
- # +html_options+ are passed to +link_to+.
- #
- # +options+ are:
- # <tt>:name</tt>:: the routing name for this paginator
- # (defaults to +page+)
- # <tt>:window_size</tt>:: the number of pages to show around
- # the current page (defaults to +2+)
- # <tt>:always_show_anchors</tt>:: whether or not the first and last
- # pages should always be shown
- # (defaults to +true+)
- # <tt>:link_to_current_page</tt>:: whether or not the current page
- # should be linked to (defaults to
- # +false+)
- # <tt>:params</tt>:: any additional routing parameters
- # for page URLs
- def pagination_links(paginator, options={}, html_options={})
- name = options[:name] || DEFAULT_OPTIONS[:name]
- params = (options[:params] || DEFAULT_OPTIONS[:params]).clone
-
- pagination_links_each(paginator, options) do |n|
- params[name] = n
- link_to(n.to_s, params, html_options)
- end
- end
-
- # Iterate through the pages of a given +paginator+, invoking a
- # block for each page number that needs to be rendered as a link.
- def pagination_links_each(paginator, options)
- options = DEFAULT_OPTIONS.merge(options)
- link_to_current_page = options[:link_to_current_page]
- always_show_anchors = options[:always_show_anchors]
-
- current_page = paginator.current_page
- window_pages = current_page.window(options[:window_size]).pages
- return if window_pages.length <= 1 unless link_to_current_page
-
- first, last = paginator.first, paginator.last
-
- html = ''
- if always_show_anchors and not (wp_first = window_pages[0]).first?
- html << yield(first.number)
- html << ' ... ' if wp_first.number - first.number > 1
- html << ' '
- end
-
- window_pages.each do |page|
- if current_page == page && !link_to_current_page
- html << page.number.to_s
- else
- html << yield(page.number)
- end
- html << ' '
- end
-
- if always_show_anchors and not (wp_last = window_pages[-1]).last?
- html << ' ... ' if last.number - wp_last.number > 1
- html << yield(last.number)
- end
-
- html
- end
-
- end # PaginationHelper
- end # Helpers
-end # ActionView