From e48a1ffecea6df93f16707ac42cbd4a7b602bacd Mon Sep 17 00:00:00 2001 From: iCross Date: Fri, 7 Jun 2013 22:36:51 +0800 Subject: [PATCH] archive module: add sort to frontend module Conflicts: vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb Conflicts: vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb Conflicts: vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb --- .../front_end/archive_files_controller.rb | 32 +++++------ .../front_end/archive_files/_index.html.erb | 56 +++++++++++++++++++ .../front_end/archive_files/index.html.erb | 51 ++--------------- .../front_end/archive_files/index.js.erb | 1 + 4 files changed, 79 insertions(+), 61 deletions(-) create mode 100644 vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/_index.html.erb create mode 100644 vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.js.erb 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 a0d1cc899..03ada60ff 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 @@ -1,4 +1,5 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController + include AdminHelper def initialize super @@ -30,27 +31,26 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController @archive_file_categorys = ArchiveFileCategory.all # @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num) - if params[:search_query] - get_search_result - @archive_files = ArchiveFile.can_display.where(:archive_file_category_id.in => @archive_file_categorys.collect{|t| t.id}).desc( :is_top, :created_at ).page( params[:page_main] ).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 - if !params[:category_id].blank? && !params[:tag_id].blank? - @archive_files = @archive_files.can_display.where(:archive_file_category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).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.can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top, :created_at ).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.can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) - else - @archive_files = ArchiveFile.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) - end + @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) end get_categorys + + if params[:sort] + @archive_files = get_sorted_and_filtered('archive_file', nil, @archive_files) + end end def show diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/_index.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/_index.html.erb new file mode 100644 index 000000000..b5aded496 --- /dev/null +++ b/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/_index.html.erb @@ -0,0 +1,56 @@ +<% # encoding: utf-8 %> + + +
+ + + + + + + + + + + + <% @archive_files.each_with_index do |post,i| %> + class="even" <% end %>> + + + + + <% end %> + + +
<%= sortable(:title, t("archive.Title"))%><%= t("archive.Files")%><%= sortable(:archive_file_category, t("archive.Category"))%>
<%= post.title %>
+
+ <% if !post.archive_file_multiples.blank? %> +
    + <% post.archive_file_multiples.asc(:_id).each do | afile | %> + <% if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) %> +
  1. + <%= link_to afile.file_title, afile.file.url, {:target => '_blank', :title => afile.file_title, :class => "o-archives-file"} %> + <%= post.get_file_icon(afile.file.url) %> +
  2. + <% end %> + <% end %> +
+ <% end %> +
+
+ <%= post.archive_file_category.title %> +
+
+ +<%= paginate @archive_files, :param_name => :page_main, :params => {:inner => 'false'} %> + +<%= stylesheet_link_tag "archive/archives" %> + + + + + + + + + diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb index 3028774db..14377a7c7 100644 --- a/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb +++ b/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb @@ -1,49 +1,10 @@ -<% # encoding: utf-8 %> +<%= stylesheet_link_tag "default_widget" %> + + -<%= render :partial => 'shared/search_header',:locals=>{:items=>@archive_files} %> - -
- - - - - - - - - - - - <% @archive_files.each_with_index do |post,i| %> - class="even" <% end %>> - - - - - <% end %> - - -
<%= t("archive.Title")%><%= t("archive.Files")%><%= t("archive.Category")%>
<%= post.title %>
-
- <% if !post.archive_file_multiples.blank? %> -
    - <% post.archive_file_multiples.asc(:_id).each do | afile | %> - <% if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) %> -
  1. - <%= link_to afile.file_title, afile.file.url, {:target => '_blank', :title => afile.file_title, :class => "o-archives-file"} %> - <%= post.get_file_icon(afile.file.url) %> -
  2. - <% end %> - <% end %> -
- <% end %> -
-
- <%= post.archive_file_category.title %> -
-
- -<%= paginate @archive_files, :param_name => :page_main, :params => {:inner => 'false'} %> +
+ <%= render 'index' %> +
<%= stylesheet_link_tag "archive/archives" %> diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.js.erb b/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.js.erb new file mode 100644 index 000000000..a0afb16fa --- /dev/null +++ b/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.js.erb @@ -0,0 +1 @@ +$('#archive_file_widget').html("<%= j render 'index' %>")