orbit-basic/app/controllers/mobile_controller.rb

77 lines
2.5 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
date_now = Time.now
2013-12-04 10:07:27 +00:00
@site = Site.first
category = @site.announcement_category
@bulletins = Bulletin.where(:category_id.in => category).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
2013-12-04 10:07:27 +00:00
@site = Site.first
category = @site.announcement_category
2012-12-19 19:21:50 +00:00
@page_title = t('mobile.bulletin')
date_now = Time.now
2013-12-04 10:07:27 +00:00
@bulletins = Bulletin.where(:category_id.in => category).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)
# @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)
2012-12-19 19:21:50 +00:00
end
def announcement_content
@bulletin = Bulletin.find(params[:id]) rescue nil
@page_title = @bulletin.title
end
def dialog_contact
@site = Site.first
2012-12-19 19:21:50 +00:00
@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
site = Site.first
@coordinates = Geocoder.coordinates("#{site.address}")
2012-12-19 19:21:50 +00:00
@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