orbit-basic/lib/parsers/parser_common.rb

35 lines
995 B
Ruby
Raw Normal View History

2011-12-22 08:23:48 +00:00
module ParserCommon
def menu_level(page, current, menu, edit = false)
if current <= menu.levels
res = "<ul id="
res << menu.values["id_#{current}"]
res << " class="
res << menu.values["class_#{current}"]
res << ">"
i = nil
i = 1 if menu.values["li_incremental_#{current}"]
if current == 1 && menu.values['home'].eql?('true')
res << menu_li(page, current, menu, i, edit)
i += 1 if i
end
page.children.each do |child|
res << menu_li(child, current, menu, i, edit)
i += 1 if i
end
res << "</ul>"
end
end
def menu_li(page, current, menu, i, edit)
res = "<li class="
res << menu.values["li_class_#{current}"]
res << "_#{i}" if i
res << ">"
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}'>#{page.name}</a>"
res << menu_level(page, current + 1, menu, edit) if page.children.size > 0 && !page.is_home?
res << "</li>"
end
end