module Admin::CancerpredictsHelper def bc_yaml_dump(arr) if arr.blank? '[]' elsif arr.class != String '[' + arr.map{|s| (s.is_a?(String) && !(s.is_i?) && s.include?(' ')) ? "\"#{s}\"" : s}.join(', ') + ']' else arr end end def create_pagination(page=1,fields=Cancerpredictrecord.all,extra_params="") page = 1 if page == 0 per_page_num = 10.0 all_page_num = (fields.count / per_page_num).ceil pagination = '
'+((I18n.locale.to_s == 'zh_tw') ? "第 #{page} 頁" : "page #{page}") +'/'+ ((I18n.locale.to_s == 'zh_tw') ? "共 #{all_page_num} 頁" : "Total #{all_page_num} page(s)")+'
    '+ ((page == 1) ? '
  1. ['+I18n.t('cancerpredict.prev_page')+']
  2. ' : '
  3. ['+I18n.t('cancerpredict.prev_page')+']
  4. ') if all_page_num > 7 if page <= (all_page_num / 2) if page <= 7 (1..page).to_a.each{|page_num| pagination += ((page_num == page) ? '
  5. ['+page_num.to_s+']
  6. ' : '
  7. '+page_num.to_s+'
  8. ')} else (1..3).to_a.each{|page_num| pagination += ((page_num == page) ? '
  9. ['+page_num.to_s+']
  10. ' : '
  11. '+page_num.to_s+'
  12. ')} pagination +='
  13. ...
  14. ' (page-3..page).to_a.each{|page_num| pagination += ((page_num == page) ? '
  15. ['+page_num.to_s+']
  16. ' : '
  17. '+page_num.to_s+'
  18. ')} end (page+1..page+3).to_a.each{|page_num| pagination += ((page_num == page) ? '
  19. ['+page_num.to_s+']
  20. ' : '
  21. '+page_num.to_s+'
  22. ')} pagination +='
  23. ...
  24. ' (all_page_num-2..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '
  25. ['+page_num.to_s+']
  26. ' : '
  27. '+page_num.to_s+'
  28. ')} else (1..3).to_a.each{|page_num| pagination += ((page_num == page) ? '
  29. ['+page_num.to_s+']
  30. ' : '
  31. '+page_num.to_s+'
  32. ')} pagination +='
  33. ...
  34. ' (page-3..page).to_a.each{|page_num| pagination += ((page_num == page) ? '
  35. ['+page_num.to_s+']
  36. ' : '
  37. '+page_num.to_s+'
  38. ')} if all_page_num - page <= 7 (page+1..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '
  39. ['+page_num.to_s+']
  40. ' : '
  41. '+page_num.to_s+'
  42. ')} else (page+1..page+3).to_a.each{|page_num| pagination += ((page_num == page) ? '
  43. ['+page_num.to_s+']
  44. ' : '
  45. '+page_num.to_s+'
  46. ')} pagination +='
  47. ...
  48. ' (all_page_num-2..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '
  49. ['+page_num.to_s+']
  50. ' : '
  51. '+page_num.to_s+'
  52. ')} end end else (1..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '
  53. ['+page_num.to_s+']
  54. ' : '
  55. '+page_num.to_s+'
  56. ')} end pagination += (((page==all_page_num) ? '
  57. ['+I18n.t('cancerpredict.next_page')+']
  58. ' : '
  59. ['+I18n.t('cancerpredict.next_page')+']
  60. ')+'
') end end