74 lines
2.1 KiB
Ruby
74 lines
2.1 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
module MenuItemsHelper
|
|
|
|
def menu_item_link(menu_item, active = nil)
|
|
|
|
menu_item_lang = menu_item.menu_item_langs.find_by_lang_site_id(@lang.id)
|
|
if active == nil
|
|
if @menu_item and (@menu_item == menu_item or @menu_item.ancestors.include?(menu_item))
|
|
active = true
|
|
else
|
|
active = false
|
|
end
|
|
end
|
|
name = menu_item_lang.name
|
|
if menu_item_lang.enabled == true and menu_item_lang.visible == true
|
|
link_to name, @gravier_host.to_s+menu_item_path(:url => menu_item_lang.url, :lang => @lang.slug), :class => ("active" if active)
|
|
end
|
|
end
|
|
|
|
def menu_item_link_force(menu_item, active = nil)
|
|
|
|
menu_item_lang = menu_item.menu_item_langs.find_by_lang_site_id(@lang.id)
|
|
if active == nil
|
|
if @menu_item and (@menu_item == menu_item or @menu_item.ancestors.include?(menu_item))
|
|
active = true
|
|
else
|
|
active = false
|
|
end
|
|
end
|
|
name = menu_item_lang.name
|
|
if menu_item_lang.enabled == true
|
|
link_to name, menu_item_path(:url => menu_item_lang.url, :lang => @lang.slug), :class => ("active" if active)
|
|
end
|
|
end
|
|
|
|
|
|
def menu_item_url(menu_item, sym = false)
|
|
|
|
menu_item_lang = menu_item.menu_item_langs.find_by_lang_site_id(@lang.id)
|
|
|
|
@menu_item and (@menu_item == menu_item or @menu_item.ancestors.include?(menu_item)) ? active = true : active = false
|
|
|
|
name = menu_item_lang.name+("" if sym and @menu_item and @menu_item == menu_item ).to_s
|
|
if menu_item_lang.enabled == true and menu_item_lang.visible == true
|
|
menu_item_path(:url => menu_item_lang.url, :lang => @lang.slug)
|
|
end
|
|
end
|
|
|
|
def menu_item_valid_to_show(menu_item, lang, time=Time.now)
|
|
if menu_item.menu_item_langs.find_by_lang_site_id(@lang.id).visible and menu_item.menu_item_langs.find_by_lang_site_id(@lang.id).enabled
|
|
|
|
true
|
|
|
|
else
|
|
false
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def article_valid_to_show(article, lang, time=Time.now)
|
|
if article.lang_articles.find_by_lang_site_id(@lang.id).enabled and ( !article.published_at? or article.published_at <= time )
|
|
|
|
|
|
true
|
|
|
|
else
|
|
false
|
|
end
|
|
|
|
end
|
|
|
|
end
|