module ParserCommon def menu_level(page, current, menu, edit = false) res = '' if current <= menu.levels if current != 0 res << "
" item = rand(100000) res << "#{page.i18n_variable[I18n.locale]}" if page.children.size > 0 res << "
" res << "" res << "
" end res << "
" else res << '' end end end def menu_li(page, current, menu, i, edit) res = "" end # ad_banners def parse_ad_banners(body = nil, page = nil, id = nil) body.css('ad_banner').each do |banner| res = '' ad_banner = AdBanner.find(banner["id"]) rescue nil if ad_banner && ad_banner.display? res << "" res << "
" ad_banner.ad_images.each do |ad_image| res << "" end res << "
" end fragment = Nokogiri::HTML::DocumentFragment.new(body, res) banner.swap(fragment) end end # page_images def parse_images(body, page) body.css('.page_image').each do |page_image| # image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } # image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image image = page.design.images.detect{|image| image.name.eql?(page_image['name']) } unless image if image res = "' end fragment = Nokogiri::HTML::DocumentFragment.new(body, res) page_image.swap(fragment) end end # page_menu def parse_menu(body, page, edit=nil) page_menu = body.css('.page_menu').first home = get_homepage menu = page.design.layout.menu fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, 0, menu, true)) page_menu.swap(fragment) end end