Module: Admin::BaseHelper

Defined in:
app/helpers/admin/base_helper.rb

Instance Method Summary collapse

Instance Method Details

#editor_class_for(content) ⇒ Object



57
58
59
# File 'app/helpers/admin/base_helper.rb', line 57

def editor_class_for content
  "big wysiwyg"
end


36
37
38
# File 'app/helpers/admin/base_helper.rb', line 36

def link_to_clear_cached_pages(site)
  link_to(t(:'adva.cached_pages.links.clear_all'), admin_cached_pages_path(site), :method => :delete)
end


20
21
22
23
24
# File 'app/helpers/admin/base_helper.rb', line 20

def link_to_profile(options = {})
  name = options[:name].nil? ? t(:'adva.links.profile') : options[:name]
  path = admin_user_path(current_user)
  link_to(name, path)
end


40
41
42
# File 'app/helpers/admin/base_helper.rb', line 40

def link_to_restore_plugin_defaults(site, plugin)
  link_to(t(:'adva.titles.restore_defaults'), admin_plugin_path(site, plugin), :data => { :confirm => t(:'adva.plugins.confirm_reset') })
end


26
27
28
29
30
31
32
33
34
# File 'app/helpers/admin/base_helper.rb', line 26

def links_to_content_translations(content, &block)
  return '' if content.new_record?
  block = Proc.new { |locale| link_to_edit(locale, content, :cl => locale) } unless block
  locales = content.translated_locales.map { |locale| block.call(locale.to_s) }
  (:span, :class => 'content_translations') do
    t(:"adva.#{content[:type].tableize}.translation_links", :locales => locales.join(', ')) +
    "<p class=\"hint\" for=\"content_translations\">#{t(:'adva.hints.content_translations')}</p>"
  end
end

#page_cached_at(page) ⇒ Object

FIXME: translations



45
46
47
48
49
50
51
52
53
54
55
# File 'app/helpers/admin/base_helper.rb', line 45

def page_cached_at(page)
  if Date.today == page.updated_at.to_date
    if page.updated_at > Time.zone.now - 4.hours
      "#{time_ago_in_words(page.updated_at).gsub(/about /,'~ ')} ago"
    else
      "Today, #{page.updated_at.strftime('%l:%M %p')}"
    end
  else
    page.updated_at.strftime("%b %d, %Y")
  end
end


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/admin/base_helper.rb', line 2

def save_or_cancel_links(builder, options = {})
  save_text   = options.delete(:save_text)   || t(:'adva.common.save')
  or_text     = options.delete(:or_text)     || t(:'adva.common.connector.or')
  cancel_text = options.delete(:cancel_text) || t(:'adva.common.cancel')
  cancel_url  = options.delete(:cancel_url)

  save_options = options.delete(:save) || {}
  save_options.reverse_merge!(:id => 'commit')
  cancel_options = options.delete(:cancel) || {}

  builder.buttons do
    ''.html_safe.tap do |buttons|
      buttons << submit_tag(save_text, save_options)
      buttons << " #{or_text} #{link_to(cancel_text, cancel_url, cancel_options)}".html_safe if cancel_url
    end
  end.html_safe
end