2010-05-02 23:33:17 +00:00
|
|
|
module Admin::PagesHelper
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-03-08 16:20:53 +00:00
|
|
|
def page_main_url(page, options = {})
|
|
|
|
if options[:host]
|
|
|
|
url = "http://#{request.host}"
|
|
|
|
elsif page.site.domains.empty?
|
2010-07-13 00:46:17 +00:00
|
|
|
url = main_site_url(page.site)
|
|
|
|
else
|
|
|
|
url = "http://#{current_site.domains.first}"
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-03-08 16:20:53 +00:00
|
|
|
url += ":#{request.port}" if request.port != 80
|
|
|
|
|
|
|
|
if content = options.delete(:content)
|
|
|
|
File.join(url, page.fullpath.gsub('content_type_template', ''), content._slug)
|
2010-07-19 00:09:10 +00:00
|
|
|
else
|
2011-03-08 16:20:53 +00:00
|
|
|
File.join(url, page.fullpath)
|
2010-07-19 00:09:10 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
end
|
|
|
|
|
2010-05-02 23:33:17 +00:00
|
|
|
def parent_pages_options
|
|
|
|
roots = current_site.pages.roots.where(:slug.ne => '404').and(:_id.ne => @page.id)
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-10-14 14:01:18 +00:00
|
|
|
[].tap do |list|
|
2010-05-02 23:33:17 +00:00
|
|
|
roots.each do |page|
|
|
|
|
list = add_children_to_options(page, list)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-02 23:33:17 +00:00
|
|
|
def add_children_to_options(page, list)
|
|
|
|
return list if page.path.include?(@page.id) || page == @page
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-02 23:33:17 +00:00
|
|
|
offset = '- ' * (page.depth || 0) * 2
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-02 23:33:17 +00:00
|
|
|
list << ["#{offset}#{page.title}", page.id]
|
|
|
|
page.children.each { |child| add_children_to_options(child, list) }
|
|
|
|
list
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-07-09 10:38:50 +00:00
|
|
|
def options_for_page_cache_strategy
|
2010-06-16 14:43:29 +00:00
|
|
|
[
|
2010-07-23 20:09:54 +00:00
|
|
|
[t('.cache_strategy.none'), 'none'],
|
2010-07-09 10:38:50 +00:00
|
|
|
[t('.cache_strategy.simple'), 'simple'],
|
|
|
|
[t('.cache_strategy.hour'), 1.hour.to_s],
|
|
|
|
[t('.cache_strategy.day'), 1.day.to_s],
|
|
|
|
[t('.cache_strategy.week'), 1.week.to_s],
|
|
|
|
[t('.cache_strategy.month'), 1.month.to_s]
|
2010-06-16 14:43:29 +00:00
|
|
|
]
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
|
|
|
end
|