diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb index 9cdcd0a2e..1b29f5f11 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb @@ -10,7 +10,9 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController get_categorys(params[:web_link_category_id]) - @web_links = WebLink.search(params[:search],params[:category_id]) + @web_links = WebLink.search(params[:category_id]) + + get_tags() respond_to do |format| format.html # index.html.erb @@ -35,6 +37,8 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController def new @web_link = WebLink.new + get_tags() + get_categorys respond_to do |format| @@ -47,6 +51,7 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController def edit @web_link = WebLink.find(params[:id]) get_categorys + get_tags() end # POST /web_links @@ -74,6 +79,8 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController @web_link = WebLink.find(params[:id]) @web_link.update_user_id = current_user.id + + params[:web_link][:tag_ids] ||=[] respond_to do |format| if @web_link.update_attributes(params[:web_link]) @@ -106,4 +113,9 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController @web_link_categorys = (id ? WebLinkCategory.find(id).to_a : WebLinkCategory.excludes('disabled' => true)) end + def get_tags() + module_app = ModuleApp.first(:conditions => {:key => 'web_resource'}) + @tags = Tag.all(:conditions => {:module_app_id => module_app.id}) + end + end diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb index e7400b27e..c230140d9 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb @@ -12,9 +12,7 @@ class Panel::WebResource::FrontEnd::WebLinksController < ObitWidgetController date_now = Time.now - # @web_links = WebLink.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(1) - - @web_links = WebLink.desc("is_top").page( params[:page]) + @web_links = WebLink.where( :is_hidden => false ).desc(:is_top, :name).page( params[:page]).per(20) get_categorys end diff --git a/vendor/built_in_modules/web_resource/app/models/web_link.rb b/vendor/built_in_modules/web_resource/app/models/web_link.rb index 364713a68..5f88a621e 100644 --- a/vendor/built_in_modules/web_resource/app/models/web_link.rb +++ b/vendor/built_in_modules/web_resource/app/models/web_link.rb @@ -25,26 +25,15 @@ class WebLink before_save :set_key - def self.search( search = nil, category_id = nil ) + def self.search( category_id = nil ) - if category_id.to_s.size > 0 and search.to_s.size > 0 + if category_id.to_s.size > 0 - key = /#{search}/ - - find(:all, :conditions => {name: key, web_resource_category_id: category_id}).desc( :is_top, :postdate ) - - elsif category_id.to_s.size > 0 and search.to_s.size < 1 - - find(:all, :conditions => {web_resource_category_id: category_id}).desc( :is_top, :postdate ) - - elsif search.to_s.size > 0 and category_id.to_s.size < 1 - - key = /#{search}/ - - find(:all, :conditions => {name: key}).desc( :is_top, :postdate ) + find(:all, :conditions => {web_link_category_id: category_id}).desc( :is_top, :name ) + else - find(:all).desc( :is_top, :postdate) + find(:all).desc( :is_top, :name) end @@ -55,10 +44,10 @@ class WebLink date_now = Time.now - # find(:all, :conditions => {:postdate => {"$lte" => Date.today}, deadline: nil} ).desc( :is_top, :postdate) - # where( :postdate.lte => date_now ).where( :deadline => nil ).desc(:is_top, :postdate) + # find(:all, :conditions => {:postdate => {"$lte" => Date.today}, deadline: nil} ).desc( :is_top, :name) + where( :is_hidden => false ).desc(:is_top, :name) # any_of({ :name => "test" },{:deadline => nil, :name => "123"}) - any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate) + # any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :name) end diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb index e57cba075..ce17555a8 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb @@ -44,6 +44,14 @@ <%= f.check_box :is_hidden %><%= t('hidden') %> +
+ <%= f.label :tags %>
+ <% @tags.each do |tag| %> + <%= check_box_tag 'web_link[tag_ids][]', tag.id, @web_link.tag_ids.include?(tag.id)%> + <%= tag[I18n.locale] %> + <% end %> +
+

diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb index fae2b22aa..d87b59d80 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb @@ -1,10 +1,25 @@ - + + <% if post.is_top? %> + <%= t(:top) %> + <% end %> + <% if post.is_hot? %> + <%= t(:hot) %> + <% end %> + <% if post.is_hidden? %> + <%= t(:hidden) %> + <% end %> + <%= post.web_link_category.i18n_variable[I18n.locale] %> <%= link_to post.name[I18n.locale], panel_web_resource_back_end_web_link_path(post) %> + + <% post.tags.each do |tag| %> + <%= tag[I18n.locale] %> + <% end %> + <%= link_to t('web_link.edit'), edit_panel_web_resource_back_end_web_link_path(post) %> | diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb index 5e1fceeeb..82afe4ea1 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb @@ -18,8 +18,6 @@


- -
<%= t('web_link.search') %> <%= form_for :web_link, :action => 'search', :method => 'get', :url => panel_web_resource_back_end_web_links_path do |f| %> @@ -27,15 +25,10 @@ Category <%= select_tag "category_id", options_for_select(@web_link_categorys.collect{|t| [t.i18n_variable[I18n.locale], t.id]}), :prompt => t('web_link.select') %> - KeyWord <%= text_field_tag :search, params[:search], :id => 'search_field' %> - - <%= submit_tag "Search", :name => nil %> + <%= submit_tag "OK", :name => nil %> <% end %> - -
-

@@ -46,6 +39,7 @@ <%= t('web_link.status') %> <%= t('web_link.category') %> <%= t('web_link.name') %> + <%= t('web_link.tags') %> <%= t('web_link.action') %>