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/app/controllers/mobile_controller.rb

70 lines
2.0 KiB
Ruby
Raw Normal View History

2012-12-19 19:21:50 +00:00
class MobileController < ApplicationController
layout 'mobile'
before_filter :no_footer_for_app
2012-12-19 19:21:50 +00:00
def index
2013-12-03 07:50:27 +00:00
@site = Site.first
2012-12-19 19:21:50 +00:00
date_now = Time.now
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page(params[:page_main]).per(15)
2013-11-19 02:32:13 +00:00
@ad_banner = AdBanner.find(:all, :conditions => {:title => /Home/i})[0]
2012-12-19 19:21:50 +00:00
end
def announcement
@page_title = t('mobile.bulletin')
date_now = Time.now
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page(params[:page_main]).per(15)
end
def announcement_content
@bulletin = Bulletin.find(params[:id]) rescue nil
@page_title = @bulletin.title
end
def dialog_contact
@no_menu = @no_footer = true
@page_title = t('mobile.contact')
end
def dialog_copyright
@no_menu = @no_footer = true
@page_title = t('mobile.copyright')
end
def dialog_language
@no_menu = @no_footer = true
@page_title = t('mobile.language')
end
def map
@no_menu = @no_footer = true
@page_title = t('mobile.location')
end
def page
@page_title = t('mobile.page')
@page_contexts = get_sorted_page_from_structure
2012-12-19 19:21:50 +00:00
end
def page_content
@page_context = PageContext.first(conditions: { id: params[:id], :archived => false }) rescue nil
@page_title = @page_context.page.title
end
protected
def no_footer_for_app
2013-01-16 00:14:42 +00:00
@no_footer = true if request.path =~ /app/
end
def get_sorted_page_from_structure
page_contexts = Item.structure_ordered_items.inject([]){ |pages, page|
pages << page.page_contexts.where(archived: false).limit(1)[0] if page.is_a?(Page) && !page.page_contexts.blank?
pages
}
Kaminari.paginate_array(page_contexts).page(params[:page]).per(15)
end
2012-12-19 19:21:50 +00:00
end