diff --git a/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb b/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb index 57b9683e6..e5edd29a7 100644 --- a/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb +++ b/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb @@ -7,24 +7,15 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController end def get_search_result - @search = ArchiveFileCategory.solr_search do - fulltext params[:search_query] - with(:frontend_search,true) - end + @search = ArchiveFileCategory.solr_search do + fulltext params[:search_query] + with(:frontend_search,true) + end - search_result = @search.results.collect{|result| result.id} - params[:category_id] = @search.results.collect{|result| result.id} + search_result = @search.results.collect{|result| result.id} + params[:category_id] = @search.results.collect{|result| result.id} - @archive_file_categorys = ArchiveFileCategory.any_in(_id:search_result).page( params[:page_main]).per(@page_num) - end - - def get_search_category(search_query) - search_category = ArchiveFileCategory.solr_search do - fulltext search_query - with(:frontend_search, true) - end - - params[:category_id] = search_category.results.collect { |result| result.id } + @archive_file_categorys = ArchiveFileCategory.any_in(_id:search_result).page( params[:page_main]).per(@page_num) end def index @@ -36,27 +27,35 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController @page_num = 10 end - # get_search_category(params[:search_query]) - date_now = Time.now @archive_file_categorys = ArchiveFileCategory.all # @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num) + # if !params[:category_id].blank? && !params[:tag_id].blank? + # @archive_files = @archive_files.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) + + # @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil + + # elsif !params[:category_id].blank? + # @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) + # @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil + # elsif !params[:tag_id].blank? + # @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) + # else + # @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) + # end if !params[:category_id].blank? && !params[:tag_id].blank? - @archive_files = @archive_files.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) - @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil - - elsif !params[:category_id].blank? - @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) - @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil - + @archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.where(:tagged_ids.in => params[:tag_id]).any_in(:archive_file_category_id => params[:category_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num) + @current_category = ArchiveFileCategory.any_in(:_id => params[:category_id]).excludes('disable' => true) + elsif !params[:category_id].blank? + @archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.any_in(:archive_file_category_id => params[:category_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num) + @current_category = ArchiveFileCategory.any_in(:_id => params[:category_id]).excludes('disable' => true) elsif !params[:tag_id].blank? - @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) - + @archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num) else - @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) + @archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top).page( params[:page_main] ).per(@page_num) end - + get_categorys if params[:sort]