orbit-basic/lib/parsers/parser_common.rb

48 lines
1.6 KiB
Ruby
Raw Normal View History

2011-12-23 10:34:21 +00:00
module ParserCommon
def menu_level(page, current, menu, edit = false)
2012-01-24 03:38:53 +00:00
res = ''
2011-12-23 10:34:21 +00:00
if current <= menu.levels
2012-01-24 03:38:53 +00:00
if current != 0
res << "<div class='rc_dm'>"
item = rand(100000)
2012-02-24 11:11:51 +00:00
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl' rel='#{item}'>#{page.i18n_variable[I18n.locale]}<span class='down'></span></a>"
2012-01-24 03:38:53 +00:00
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>'
2012-02-24 11:11:51 +00:00
res << "<li>" + "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl'>#{page.i18n_variable[I18n.locale]}</a>" + "</li>"
2012-01-24 03:38:53 +00:00
page.children.each do |child|
res << "<li>" + menu_level(child, current + 1, menu, edit) + "</li>"
end
res << '</ul>'
2011-12-23 10:34:21 +00:00
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 << ">"
2012-01-24 03:38:53 +00:00
if page.children.size > 0
res << menu_level(page, current + 1, menu, edit)
else
2012-02-24 11:11:51 +00:00
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='nav dm_ctrl'>#{page.i18n_variable[I18n.locale]}</a>"
2012-01-24 03:38:53 +00:00
end
2011-12-23 10:34:21 +00:00
res << "</li>"
end
end