Module | Cms::ApplicationHelper |
In: |
app/helpers/cms/application_helper.rb
|
# File app/helpers/cms/application_helper.rb, line 49 49: def action_icon(name, options={}) 50: image_tag action_icon_src(name), {:alt => name.to_s.titleize}.merge(options) 51: end
# File app/helpers/cms/application_helper.rb, line 45 45: def action_icon_src(name) 46: "cms/icons/actions/#{name}.png" 47: end
# File app/helpers/cms/application_helper.rb, line 112 112: def categories_for(category_type_name, order="name") 113: cat_type = CategoryType.named(category_type_name).first 114: cat_type ? cat_type.category_list(order) : [] 115: end
# File app/helpers/cms/application_helper.rb, line 143 143: def determine_order(current_order, order) 144: if current_order == order 145: if order =~ / desc$/i 146: order.sub(/ desc$/i, '') 147: else 148: order << ' desc' 149: end 150: else 151: order 152: end 153: end
# File app/helpers/cms/application_helper.rb, line 101 101: def dk_button_wrapper(content) 102: lt_button_wrapper(content).gsub("lt_button_","dk_button_") 103: end
# File app/helpers/cms/application_helper.rb, line 72 72: def format_date(time) 73: time && "#{time.strftime("%b %e, %Y")}" 74: end
# File app/helpers/cms/application_helper.rb, line 108 108: def group_filter 109: select_tag("group_id", options_from_collection_for_select(Group.all.insert(0, Group.new(:id => nil, :name => "Show All Groups")), "id", "name", params[:group_id].to_i)) 110: end
# File app/helpers/cms/application_helper.rb, line 104 104: def group_ids 105: (params[:group_ids] || @user.group_ids).collect { |g| g.to_i } 106: end
# File app/helpers/cms/application_helper.rb, line 76 76: def link_to_check_all(selector, name="Check All") 77: link_to_function name, "$('#{selector}').attr('checked', true)" 78: end
# File app/helpers/cms/application_helper.rb, line 80 80: def link_to_uncheck_all(selector, name="Uncheck All") 81: link_to_function name, "$('#{selector}').attr('checked', false)" 82: end
# File app/helpers/cms/application_helper.rb, line 57 57: def link_to_usages(block) 58: count = block.connected_pages.count 59: if count > 0 60: # Would love a cleaner solution to this problem, see http://stackoverflow.com/questions/702728 61: path = Portlet === block ? usages_cms_portlet_path(block) : [:usages, :cms, block] 62: link_to count, path, :id => block.id, :block_type => block.content_block_type 63: else 64: count 65: end 66: end
# File app/helpers/cms/application_helper.rb, line 88 88: def lt_button_wrapper(content) 89: " <div class=\"lt_button\">\n <img src=\"/images/cms/lt_button_l.gif\" alt=\"\" />\n <div class=\"lt_button_content\">\n <span>\#{ content }</span>\n </div>\n <img src=\"/images/cms/lt_button_r.gif\" alt=\"\" style=\"margin-right: 10px;\" />\n </div>\n" 90: end
# File app/helpers/cms/application_helper.rb, line 35 35: def page_versions(page) 36: text = select_tag(:version, 37: options_for_select(page.versions.all(:order => "version desc").map { |r| 38: ["v#{r.version}: #{r.version_comment} by #{r.updated_by.login} at #{time_on_date(r.updated_at)}", r.version] 39: }, page.version), 40: :onchange => 'this.form.submit(); return false') 41: text << javascript_tag("$('version').selectedIndex = 0") if page.live? 42: text 43: end
# File app/helpers/cms/application_helper.rb, line 117 117: def render_pagination(collection, collection_name, options={}) 118: if collection.blank? 119: content_tag(:div, "No Content", :class => "pagination") 120: else 121: render :partial => "cms/shared/pagination", :locals => { 122: :collection => collection, 123: :first_page_path => send("cms_#{collection_name}_path", {:page => 1}.merge(options)), 124: :previous_page_path => send("cms_#{collection_name}_path", {:page => collection.previous_page ? collection.previous_page : 1}.merge(options)), 125: :current_page_path => send("cms_#{collection_name}_path", options), 126: :next_page_path => send("cms_#{collection_name}_path", {:page => collection.next_page ? collection.next_page : collection.current_page}.merge(options)), 127: :last_page_path => send("cms_#{collection_name}_path", {:page => collection.total_pages}.merge(options)) 128: } 129: end 130: end
# File app/helpers/cms/application_helper.rb, line 14 14: def require_javascript_include(sources=(), content_area=:html_head) 15: @required_javascript_includes ||= [] 16: new_links = sources.to_a - @required_javascript_includes 17: if !new_links.empty? 18: @required_javascript_includes |= new_links 19: content_for(content_area, javascript_include_tag(new_links)) 20: end 21: end
# File app/helpers/cms/application_helper.rb, line 5 5: def require_stylesheet_link(sources=(), content_area=:html_head) 6: @required_stylesheet_links ||= [] 7: new_links = sources.to_a - @required_stylesheet_links 8: if !new_links.empty? 9: @required_stylesheet_links |= new_links 10: content_for(content_area, stylesheet_link_tag(new_links)) 11: end 12: end
# File app/helpers/cms/application_helper.rb, line 23 23: def searchable_sections(selected = nil) 24: root = Section.root.first 25: options = [['All sections', 'all'], [root.name, root.id]] 26: root.all_children_with_name.each { |s| options << [s.full_path, s.id] } 27: options_for_select(options, selected.to_i) 28: end
# File app/helpers/cms/application_helper.rb, line 30 30: def select_per_page 31: options = [10, 20, 50, 100].collect { |c| ["#{c} per page", c] } 32: select_tag("per_page", options_for_select(options, params[:per_page].to_i)) 33: end
# File app/helpers/cms/application_helper.rb, line 85 85: def span_tag(content) 86: content_tag :span, content 87: end
# File app/helpers/cms/application_helper.rb, line 53 53: def status_icon(status, options={}) 54: image_tag "cms/icons/status/#{status.to_s.underscore}.gif", {:alt => status.to_s.titleize}.merge(options) 55: end
# File app/helpers/cms/application_helper.rb, line 68 68: def time_on_date(time) 69: time && "#{time.strftime("%l:%M %p")} on #{time.strftime("%b %e, %Y")}" 70: end
# File app/helpers/cms/application_helper.rb, line 132 132: def url_with_mode(url, mode) 133: uri = URI.parse(url) 134: if uri.query =~ /mode=[^&]*/ 135: "#{uri.path}?#{uri.query.gsub(/((^|&)mode=)[^&]*/) {|s| "#{$1}#{mode}" }}" 136: elsif uri.query 137: "#{uri.path}?#{uri.query}&mode=#{mode}" 138: else 139: "#{uri.path}?mode=#{mode}" 140: end 141: end