2014-01-14 11:54:35 +00:00
|
|
|
class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
|
|
|
|
|
|
|
# GET /bulletins
|
|
|
|
# GET /bulletins.xml
|
|
|
|
def index_bulletins_by_unit
|
|
|
|
@item = Page.find(params[:page_id]) rescue nil
|
|
|
|
@bulletins=Bulletin.all.available_for_lang(I18n.locale).can_display.where("cache_dept.#{I18n.locale.to_s.downcase}"=>params[:name]).page( params[:page_main]).per(15)
|
|
|
|
render :index
|
|
|
|
end
|
|
|
|
|
|
|
|
def search_result
|
|
|
|
if params[:search_query] == ""
|
|
|
|
@bulletins = get_bulletins_for_index
|
|
|
|
else
|
|
|
|
@search = Bulletin.tire.search "#{params[:search_query]}"
|
|
|
|
search_result = @search.collect{|result| result.id}
|
|
|
|
|
|
|
|
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(@page_num)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def index
|
|
|
|
@bulletins = get_bulletins_for_index
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_bulletins_for_index
|
|
|
|
|
|
|
|
@item = Page.find(params[:page_id]) rescue nil
|
|
|
|
|
|
|
|
if @item
|
|
|
|
if @item.frontend_data_count
|
|
|
|
@page_num = @item.frontend_data_count
|
|
|
|
else
|
|
|
|
@page_num = 15
|
|
|
|
end
|
|
|
|
@frontend_style = @item.frontend_style
|
|
|
|
end
|
|
|
|
|
|
|
|
date_now = Time.now
|
|
|
|
if !params[:category_id].blank? && !params[:tag_id].blank?
|
|
|
|
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
|
|
|
|
# @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in=>params[:category_id],:tagged_ids.in=>params[:tag_id])
|
|
|
|
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
|
|
|
|
elsif !params[:category_id].blank?
|
|
|
|
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:category_id.in => params[:category_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
|
|
|
|
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
|
|
|
|
elsif !params[:tag_id].blank?
|
|
|
|
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
|
|
|
|
else
|
|
|
|
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
|
|
|
|
end
|
|
|
|
# delayed_impressionist(@tag) if @tag
|
|
|
|
@bulletins
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
@item = Page.find(params[:page_id]) rescue nil
|
2014-02-24 06:59:12 +00:00
|
|
|
@fb_share = eval(params[:facebook_share]) rescue false
|
2014-01-14 11:54:35 +00:00
|
|
|
if params[:preview] == "true"
|
|
|
|
preview_content
|
|
|
|
else
|
|
|
|
@bulletin = Bulletin.all.can_display.where(_id: params[:id]).first
|
|
|
|
if @bulletin and !@bulletin.disable?
|
|
|
|
if @bulletin.enabled_for_lang(I18n.locale.to_s)
|
|
|
|
# delayed_impressionist(@bulletin)
|
|
|
|
impressionist(@bulletin)
|
|
|
|
else
|
|
|
|
render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe
|
|
|
|
end
|
|
|
|
else
|
|
|
|
render :nothing => true, :status => 403
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def preview_content
|
|
|
|
@bulletin = Bulletin.find params[:id] rescue nil
|
|
|
|
@bulletin = Preview.find(params[:id]).get_virtual_object if @bulletin.nil?
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|