olympiamanagement/app/helpers/admin/olympiamanagements_helper.rb

11 lines
981 B
Ruby
Raw Normal View History

module Admin::OlympiamanagementsHelper
def create_pagination(page=1,fields=ClassSettingFields)
page = 1 if page == 0
per_page_num = 10
all_page_num = fields.all.count / per_page_num + 1
pagination = '<div class="PageDetails">'+((I18n.locale.to_s == 'zh_tw') ? "#{page}" : "page #{page}") +'/'+ ((I18n.locale.to_s == 'zh_tw') ? "#{all_page_num}" : "Total #{all_page_num} page(s)")+'<ol class="PageList">'+
((page == 1) ? '<li>['+t('olympiamanagement.prev_page')+']</li>' : '<li><a href="?page='+(page-1).to_s+'"> ['+t('olympiamanagement.prev_page')+'] </a></li>')
(1..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>'+page_num.to_s+'</li>' : '<li><a href="?page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination += (((page==all_page_num) ? '<li>['+t('olympiamanagement.next_page')+']</li>' : '<li><a href="?page='+(page+1).to_s+'"> ['+t('olympiamanagement.next_page')+'] </a></li>')+'</ol></div>')
end
end