| Module | Cms::ApplicationHelper |
| In: |
app/helpers/cms/application_helper.rb
|
# File app/helpers/cms/application_helper.rb, line 107
107: def able_to?(*perms, &block)
108: yield if current_user.able_to?(*perms)
109: end
# File app/helpers/cms/application_helper.rb, line 68
68: def action_icon(name, options={})
69: image_tag action_icon_src(name), {:alt => name.to_s.titleize}.merge(options)
70: end
# File app/helpers/cms/application_helper.rb, line 64
64: def action_icon_src(name)
65: "cms/icons/actions/#{name}.png"
66: end
# File app/helpers/cms/application_helper.rb, line 138
138: def categories_for(category_type_name, order="name")
139: cat_type = CategoryType.named(category_type_name).first
140: cat_type ? cat_type.category_list(order) : []
141: end
# File app/helpers/cms/application_helper.rb, line 178
178: def determine_order(current_order, order)
179: if current_order == order
180: if order =~ / desc$/i
181: order.sub(/ desc$/i, '')
182: else
183: order << ' desc'
184: end
185: else
186: order
187: end
188: end
# File app/helpers/cms/application_helper.rb, line 127
127: def dk_button_wrapper(content)
128: lt_button_wrapper(content).gsub("lt_button_","dk_button_")
129: end
# File app/helpers/cms/application_helper.rb, line 95
95: def format_date(time)
96: time && "#{time.strftime("%b %e, %Y")}"
97: end
# File app/helpers/cms/application_helper.rb, line 134
134: def group_filter
135: 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))
136: end
# File app/helpers/cms/application_helper.rb, line 130
130: def group_ids
131: (params[:group_ids] || @user.group_ids).collect { |g| g.to_i }
132: end
# File app/helpers/cms/application_helper.rb, line 99
99: def link_to_check_all(selector, name="Check All")
100: link_to_function name, "$('#{selector}').attr('checked', true)"
101: end
# File app/helpers/cms/application_helper.rb, line 103
103: def link_to_uncheck_all(selector, name="Uncheck All")
104: link_to_function name, "$('#{selector}').attr('checked', false)"
105: end
# File app/helpers/cms/application_helper.rb, line 80
80: def link_to_usages(block)
81: count = block.connected_pages.count
82: if count > 0
83: # Would love a cleaner solution to this problem, see http://stackoverflow.com/questions/702728
84: path = Portlet === block ? usages_cms_portlet_path(block) : [:usages, :cms, block]
85: link_to count, path, :id => block.id, :block_type => block.content_block_type
86: else
87: count
88: end
89: end
# File app/helpers/cms/application_helper.rb, line 114
114: def lt_button_wrapper(content)
115: " <div class=\"lt_button\">\n <img src=\"/images/cms/lt_button_l.gif\" alt=\"\" />\n <div>\n \#{ content }\n </div>\n <img src=\"/images/cms/lt_button_r.gif\" alt=\"\" style=\"margin-right: 10px;\" />\n </div>\n"
116: end
# File app/helpers/cms/application_helper.rb, line 5
5: def page_title(*args)
6: if args.first
7: @controller.instance_variable_get("@template").instance_variable_set("@page_title", args.first)
8: else
9: @controller.instance_variable_get("@template").instance_variable_get("@page_title")
10: end
11: end
# File app/helpers/cms/application_helper.rb, line 25
25: def page_versions(page)
26: text = select_tag(:version,
27: options_for_select(page.versions.all(:order => "version desc").map { |r|
28: ["v#{r.version}: #{r.version_comment} by #{r.updated_by.login} at #{time_on_date(r.updated_at)}", r.version]
29: }, page.version),
30: :onchange => 'this.form.submit(); return false')
31: text << javascript_tag("$('version').selectedIndex = 0") if page.live?
32: text
33: end
# File app/helpers/cms/application_helper.rb, line 76
76: def render_cms_toolbar(tab=:dashboard)
77: render :partial => 'layouts/cms_toolbar', :locals => {:tab => tab}
78: end
# File app/helpers/cms/application_helper.rb, line 48
48: def render_connectable(content_block)
49: if content_block
50: if content_block.class.renderable?
51: logger.info "..... Rendering connectable #{content_block.class} ##{content_block.id} #{"v#{content_block.version}" if content_block.respond_to?(:version)}"
52: content_block.perform_render(@controller)
53: else
54: logger.warn "Connectable #{content_block.class} ##{content_block.id} is not renderable"
55: end
56: else
57: logger.warn "Connectable is null"
58: end
59: rescue Exception => e
60: logger.error "Error occurred while rendering #{content_block.class}##{content_block.id}: #{e.message}\n#{e.backtrace.join("\n")}"
61: "ERROR: #{e.message}"
62: end
# File app/helpers/cms/application_helper.rb, line 35
35: def render_connector(connector)
36: connectable = connector.connectable_with_deleted
37: if logged_in? && @mode == "edit"
38: if connectable.class.versioned?
39: connectable = connectable.as_of_version(connector.connectable_version)
40: end
41: render :partial => 'cms/pages/edit_connector',
42: :locals => { :connector => connector, :connectable => connectable}
43: else
44: render_connectable(connectable)
45: end
46: end
# File app/helpers/cms/application_helper.rb, line 143
143: def render_pagination(collection, collection_name, options={})
144: if collection.blank?
145: content_tag(:div, "No Content", :class => "pagination")
146: else
147: render :partial => "cms/shared/pagination", :locals => {
148: :collection => collection,
149: :first_page_path => send("cms_#{collection_name}_path", {:page => 1}.merge(options)),
150: :previous_page_path => send("cms_#{collection_name}_path", {:page => collection.previous_page ? collection.previous_page : 1}.merge(options)),
151: :current_page_path => send("cms_#{collection_name}_path", options),
152: :next_page_path => send("cms_#{collection_name}_path", {:page => collection.next_page ? collection.next_page : collection.current_page}.merge(options)),
153: :last_page_path => send("cms_#{collection_name}_path", {:page => collection.total_pages}.merge(options))
154: }
155: end
156: end
# File app/helpers/cms/application_helper.rb, line 13
13: def searchable_sections(selected = nil)
14: root = Section.root.first
15: options = [['All sections', 'all'], [root.name, root.id]]
16: root.all_children_with_name.each { |s| options << [s.full_path, s.id] }
17: options_for_select(options, selected.to_i)
18: end
# File app/helpers/cms/application_helper.rb, line 20
20: def select_per_page
21: options = [10, 20, 50, 100].collect { |c| ["#{c} per page", c] }
22: select_tag("per_page", options_for_select(options, params[:per_page].to_i))
23: end
# File app/helpers/cms/application_helper.rb, line 111
111: def span_tag(content)
112: content_tag :span, content
113: end
# File app/helpers/cms/application_helper.rb, line 72
72: def status_icon(status, options={})
73: image_tag "cms/icons/status/#{status.to_s.underscore}.gif", {:alt => status.to_s.titleize}.merge(options)
74: end
# File app/helpers/cms/application_helper.rb, line 169
169: def tb_iframe(path, options={})
170: # The order of the parameters matters. All parameters that should be sent to the server,
171: # have to appear before TB_iframe. All parameters that shouldn't be sent to the server and
172: # that are just there for Thickbox should be after TB_iframe
173: {:height => 600, :width => 600, :modal => true}.merge(options).inject("#{path}&TB_iframe=true") do |s, (k,v)|
174: s << "&#{k}=#{CGI::escape(v.to_s)}"
175: end
176: end
# File app/helpers/cms/application_helper.rb, line 91
91: def time_on_date(time)
92: time && "#{time.strftime("%l:%M %p")} on #{time.strftime("%b %e, %Y")}"
93: end
# File app/helpers/cms/application_helper.rb, line 158
158: def url_with_mode(url, mode)
159: uri = URI.parse(url)
160: if uri.query =~ /mode=[^&]*/
161: "#{uri.path}?#{uri.query.gsub(/((^|&)mode=)[^&]*/) {|s| "#{$1}#{mode}" }}"
162: elsif uri.query
163: "#{uri.path}?#{uri.query}&mode=#{mode}"
164: else
165: "#{uri.path}?mode=#{mode}"
166: end
167: end