This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/controllers/front_controller.rb

80 lines
2.1 KiB
Ruby
Raw Normal View History

class FrontController < ApplicationController
layout false
2013-01-31 11:20:55 +00:00
def show_breadcrumb
2013-02-01 09:07:16 +00:00
@ancestors = Page.find(params[:page_id]).ancestors_and_self
2013-01-31 11:20:55 +00:00
@ancestors.delete_at(0)
end
def show_banner
@ad_banner = AdBanner.find(params[:id]) rescue nil
end
def show_footer
render :text => @site.footer
end
def show_menu
page = Page.find(params[:id]) rescue nil
render :text => menu_level(Page.root, page, 1, page.design.layout.menu) if page
end
def show_site_sub_menu
render :text => @site.sub_menu
end
def show_sitemap
@items = get_homepage.children.excludes(sitemap_enabled: false) rescue []
end
def show_page_sub_menu
@menu_page = Page.find(params[:menu_page_id]) rescue nil
@page_id = params[:page_id]
end
2013-01-09 08:54:33 +00:00
def show_inner_ad_image
@ad_image = AdImage.find(params[:id]) rescue nil
@ad_images = AdImage.all
end
private
def menu_level(page, current_page, current, menu)
res = ''
if page.visible_children.size > 0
res << "<ul class='"
res << menu.values["class_#{current}"] rescue nil
res << "'>"
i = nil
i = 1 if menu.values["li_incremental_#{current}"]
2012-12-28 03:37:37 +00:00
children = current == 1 ? page.visible_children : page.visible_children
children.each do |child|
res << menu_li(child, current_page, current, menu, i)
i += 1 if i
end
if menu.values['home'] && current == 1
res << menu_li(page, current_page, current, menu, i)
end
res << "</ul>"
end
res
end
def menu_li(page, current_page, current, menu, i)
res = "<li class='"
res << menu.values["li_class_#{current}"] rescue nil
res << "_#{i}" if i
res << " active" if (current_page.id.eql?(page.id) || current_page.descendant_of?(page))
res << "'>"
root = "/"
res << "<a href='#{(page.class.to_s.eql?('Page') ? root + page.path : page.url)}'><span>#{page.title}</span></a>"
if page.visible_children.size > 0 && current < menu.levels
res << "<span class='dot'></span>"
res << menu_level(page, current_page, current + 1, menu)
end unless (page.root? rescue nil)
res << "</li>"
end
end