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/lib/parsers/parser_common.rb

48 lines
1.5 KiB
Ruby

module ParserCommon
def menu_level(page, current, menu, edit = false)
res = ''
if current <= menu.levels
if current != 0
res << "<div class='rc_dm'>"
item = rand(100000)
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl' rel='#{item}'>#{page.name}<span class='down'></span></a>"
if page.children.size > 0
res << "<div id='#{item}' class='dm_list #{menu.values['class_#{current}']}'>"
res << "<ul class='ini_list'>"
i = nil
i = 1 if menu.values["li_incremental_#{current}"]
page.children.each do |child|
res << menu_li(child, current, menu, i, edit)
i += 1 if i
end
res << "</ul>"
res << "</div>"
end
res << "</div>"
else
res << '<ul>'
res << "<li>" + "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl'>#{page.name}</a>" + "</li>"
page.children.each do |child|
res << "<li>" + menu_level(child, current + 1, menu, edit) + "</li>"
end
res << '</ul>'
end
end
end
def menu_li(page, current, menu, i, edit)
res = "<li class="
res << menu.values["li_class_#{current}"]
res << "_#{i}" if i
res << ">"
if page.children.size > 0
res << menu_level(page, current + 1, menu, edit)
else
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='nav dm_ctrl'>#{page.name}</a>"
end
res << "</li>"
end
end