class Panel::Faq::FrontEnd::QasController < OrbitWidgetController
  
  def initialize
    super
    @app_title = 'faq'
  end
  
  # GET /qas
  # GET /qas.xml
  
  def index
    
    @item = Page.find(params[:page_id])
  
    @title = @item.title
  
    if @item.frontend_data_count
      @page_num = @item.frontend_data_count
    else
      @page_num = 0
    end
  
    date_now = Time.now
    
    if params[:category_id] !="[]" && !params[:category_id].blank?
      @qas = Qa.all.can_display.any_in(:qa_category_id => params[:category_id]).merge(QaCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num)
      @qa_categorys = QaCategory.any_in(:_id => @item.category).excludes('disable' => true) rescue nil
    elsif params[:tag_id] !="[]" && !params[:tag_id].blank?
      Qa.all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(QaCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num)
      @qas = @tag.archive_files.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
      get_categorys
    else
      @qas = Qa.all.can_display.merge(QaCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num)
      get_categorys
    end
  end
  
  def show
    @qa = Qa.find(params[:id])
	  # get_categorys
  end
  
  
  protected
  
  def get_categorys
    # @qa_categorys = QaCategory.excludes('disable' => true)
  end
  
end
