# -*- encoding : utf-8 -*-

class Public::PressReleasesController < ApplicationController
  layout "public"
  
  def index
    
    per_page = (params[:per_page] and params[:per_page] != "") ? params[:per_page] : 5
    page = (params[:page] and params[:page] != "") ? params[:page] : 1 
    
 
    if params[:sentience] 
      press_type = 2
      
    else
      press_type = 1
    end
  
		@press_releases = PressRelease.where(:press_type_id => press_type, :lang_site_id => @lang.id).enableds.before(Time.now.end_of_day).order("published_at DESC").all
    
    
    @press_releases = @press_releases.page(page).per(per_page)
    
    
  end
  
  
  
  def sentiences
    per_page = (params[:per_page] and params[:per_page] != "") ? params[:per_page] : 5
    page = (params[:page] and params[:page] != "") ? params[:page] : 1 
    
 
    if params[:sentience] 
      press_type = 2
      
    else
      press_type = 1
    end
  
		@press_releases = PressRelease.where(:press_type_id => press_type, :lang_site_id => @lang.id).enableds.before(Time.now.end_of_day).order("published_at DESC").all
    
    
    @press_releases = @press_releases.page(page).per(per_page)
    
    render :action => :index
  end
  
  def show
    

      
    if current_admin
      @press_release = PressRelease.find_by_slug(params[:id])
    else
		@press_release = PressRelease.enableds.before(Time.now.end_of_day).find_by_slug(params[:id])
  end
  end




end
