diff --git a/app/controllers/orbit_admin_controller.rb b/app/controllers/orbit_admin_controller.rb index 75d26b5..a7b486b 100644 --- a/app/controllers/orbit_admin_controller.rb +++ b/app/controllers/orbit_admin_controller.rb @@ -15,15 +15,12 @@ class OrbitAdminController < ApplicationController [:is_hidden,params[:order]]] when "category" @sort = {:category_id=>params[:order]} - when "title" - @sort = {:title=>params[:order]} when "start_date" @sort = {:postdate=>params[:order]} when "end_date" @sort = {:deadline=>params[:order]} when "last_modified" @sort = {:update_user_id=>params[:order]} - when "banner" @sort = {'banner_id'=>params[:order]} when "banner_name" @@ -38,6 +35,8 @@ class OrbitAdminController < ApplicationController @sort = {:height=>params[:order]} when "link" @sort = {:out_link=>params[:order]} + else + @sort = {params[:sort].to_sym=>params[:order]} end else @sort = {:created_at=>'desc'} @@ -64,6 +63,18 @@ class OrbitAdminController < ApplicationController end end + def search_data(data, fields) + if params[:keywords].present? + key_string = params[:keywords] + key_string = key_string.strip.nil? ? key_string : key_string.strip + keywords = key_string.split(/\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/) + regex = Regexp.union(keywords.map{|word| Regexp.new(".*"+word+".*", "i")}) + data = data.any_of(fields.map{|f| {f.to_sym => regex} }) + end + + data + end + def load_authorized_categories @user_authenticated_categories = current_user.is_admin? ? ["all"] : current_user.approved_categories.collect{|c| c.id} end diff --git a/app/helpers/orbit_backend_helper.rb b/app/helpers/orbit_backend_helper.rb index 9ed8578..1a30483 100644 --- a/app/helpers/orbit_backend_helper.rb +++ b/app/helpers/orbit_backend_helper.rb @@ -11,7 +11,7 @@ module OrbitBackendHelper arrow = (order.eql? "desc") ? "" : "" klass = field.eql?(:title) ? "span5" : "span2" - th_data = (sort=="preview") ? t(field.to_sym) : "#{t(field.to_sym)} #{active ? arrow : ""}" + th_data = (sort=="preview") ? t(field.to_sym) : "#{t(field.to_sym)} #{active ? arrow : ""}" "#{th_data}".html_safe end diff --git a/app/views/shared/_filter.html.erb b/app/views/shared/_filter.html.erb index 85c6d97..d476c05 100644 --- a/app/views/shared/_filter.html.erb +++ b/app/views/shared/_filter.html.erb @@ -141,6 +141,7 @@ this.addFilter = function(filter){ filters = makeFilters(); $.each(filters,function(idx,data){ + if(typeof(data)=="undefined") return true; if(data.indexOf("page=")>-1) filters.splice(idx,1); }); @@ -177,4 +178,9 @@ } var update = false; + var filter; + $(document).ready(function(){ + filter = new Filter("#<%= search_dom_id %>"); + bindPagination(); + }); diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 71e57b8..7f61e5b 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -379,6 +379,7 @@ zh_tw: or_lower: 或 organization: 組織 page: 頁面 + page_id: ID page_content: page: 頁面 page_part_kinds: