diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 2b9c9a32..92e4d1fb 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -8,6 +8,7 @@ class TagsController < ApplicationController include IssuesHelper include UsersHelper include BidsHelper + include ForumsHelper include ActsAsTaggableOn::TagsHelper helper :projects include TagsHelper @@ -56,7 +57,8 @@ class TagsController < ApplicationController @obj,@obj_pages,@results_count,@users_results, @projects_results, @issues_results, - @bids_results = refresh_results(@obj_id,@obj_flag,@selected_tags) + @bids_results, + @forums_results = refresh_results(@obj_id,@obj_flag,@selected_tags) # 这里是做tag推荐用的, 用来生产推荐的tags unless @obj.nil? @@ -83,7 +85,8 @@ class TagsController < ApplicationController @obj,@obj_pages,@users_results, @projects_results, @issues_results, - @bids_results = refresh_results(@obj_id,@show_flag) + @bids_results, + @forums_results = refresh_results(@obj_id,@show_flag) end # 删除已选tag @@ -98,7 +101,8 @@ class TagsController < ApplicationController @obj,@obj_pages,@results_count,@users_results, @projects_results, @issues_results, - @bids_results = refresh_results(@obj_id,@show_flag) + @bids_results, + @forums_results = refresh_results(@obj_id,@show_flag) end def show_all @@ -161,6 +165,7 @@ private @projects_results = nil @issues_results = nil @bids_results = nil + @forums_results = nil @obj_pages = nil @obj = nil @@ -176,12 +181,15 @@ private @obj = Issue.find_by_id(obj_id) @obj_pages,@issues_results,@results_count = for_pagination(get_issues_by_tag(selected_tags)) when '4' then - @obj_pages,@bids_results,@results_count = for_pagination(get_bids_by_tag(selected_tags)) - @obj = Bid.find_by_id(obj_id) + @obj_pages,@bids_results,@results_count = for_pagination(get_bids_by_tag(selected_tags)) + @obj = Bid.find_by_id(obj_id) + when '5' + @obj = Forum.find_by_id(obj_id) + @obj_pages,@forums_results,@results_count = for_pagination(get_forums_by_tag(selected_tags)) else @obj = nil end - return @obj,@obj_pages,@results_count,@users_results,@projects_results,@issues_results,@bids_results + return @obj,@obj_pages,@results_count,@users_results,@projects_results,@issues_results,@bids_results,@forums_results end def for_pagination(results) diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index 9e82fa1a..274775a5 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -1,128 +1,128 @@ -#enconding:utf-8 -# fq -module BidsHelper - - def render_notes(bid, journal, options={}) - content = '' - removable = User.current == journal.user || User.current == bid.author - links = [] - if !journal.notes.blank? - links << link_to(image_tag('comment.png'), - {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, - :remote => true, - :method => 'post', - :title => l(:button_quote)) if options[:reply_links] - if removable - url = {:controller => 'bids', - :action => 'destroy', - :object_id => journal, - :id => bid} - links << ' ' - links << link_to(image_tag('delete.png'), url, - :remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete)) - end - end - content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty? - content << textilizable(journal.notes) - css_classes = "wiki" - content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes) - end - - def link_to_in_place_notes_editor(text, field_id, url, options={}) - onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;" - link_to text, '#', options.merge(:onclick => onclick) - end - - # this method is used to get all projects that tagged one tag - # added by william - def get_bids_by_tag(tag_name) - Bid.tagged_with(tag_name).order('updated_on desc') - end - - #added by huang - def sort_bid_enterprise(state, project_type) - content = ''.html_safe - case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") - - when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type))) - end - content = content_tag('ul', content) - content_tag('div', content, :class => "tabs_enterprise") - end - #end - - def sort_bid(state, project_type) - content = ''.html_safe - case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") - - when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type))) - end - content = content_tag('ul', content) - content_tag('div', content, :class => "tabs") - end - - #huang - def sort_contest(state) - content = ''.html_safe - case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1'))) - content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0'), :class=>"selected"), :class=>"selected") - - when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1'), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0'))) - end - content = content_tag('ul', content) - content_tag('div', content, :class => "tabs") - end - #end - - def course_options_for_select(courses) - # - html = '' - courses.each do |course| - html << "" - end - html.html_safe - end - - - # used to get the reward and handle the value which can be used to display in views - # added by william - def get_prize(b_project) - b_project.get_reward - end - - def count_bid_project - bids = Bid.where('parent_id = ?', @bid.id) - @projects = [] - for bid in bids - @projects += bid.biding_projects - end - @projects.count - end - - def count_bid_user - bids = Bid.where('parent_id = ?', @bid.id) - @users = [] - for bid in bids - for project in bid.projects - @users += project.users - end - end - @users.count - end +#enconding:utf-8 +# fq +module BidsHelper + + def render_notes(bid, journal, options={}) + content = '' + removable = User.current == journal.user || User.current == bid.author + links = [] + if !journal.notes.blank? + links << link_to(image_tag('comment.png'), + {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, + :remote => true, + :method => 'post', + :title => l(:button_quote)) if options[:reply_links] + if removable + url = {:controller => 'bids', + :action => 'destroy', + :object_id => journal, + :id => bid} + links << ' ' + links << link_to(image_tag('delete.png'), url, + :remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete)) + end + end + content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty? + content << textilizable(journal.notes) + css_classes = "wiki" + content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes) + end + + def link_to_in_place_notes_editor(text, field_id, url, options={}) + onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;" + link_to text, '#', options.merge(:onclick => onclick) + end + + # this method is used to get all projects that tagged one tag + # added by william + def get_bids_by_tag(tag_name) + Bid.tagged_with(tag_name).order('updated_on desc') + end + + #added by huang + def sort_bid_enterprise(state, project_type) + content = ''.html_safe + case state + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") + + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type))) + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs_enterprise") + end + #end + + def sort_bid(state, project_type) + content = ''.html_safe + case state + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") + + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type))) + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs") + end + + #huang + def sort_contest(state) + content = ''.html_safe + case state + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1'))) + content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0'), :class=>"selected"), :class=>"selected") + + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1'), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0'))) + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs") + end + #end + + def course_options_for_select(courses) + # + html = '' + courses.each do |course| + html << "" + end + html.html_safe + end + + + # used to get the reward and handle the value which can be used to display in views + # added by william + def get_prize(b_project) + b_project.get_reward + end + + def count_bid_project + bids = Bid.where('parent_id = ?', @bid.id) + @projects = [] + for bid in bids + @projects += bid.biding_projects + end + @projects.count + end + + def count_bid_user + bids = Bid.where('parent_id = ?', @bid.id) + @users = [] + for bid in bids + for project in bid.projects + @users += project.users + end + end + @users.count + end end \ No newline at end of file diff --git a/app/helpers/forums_helper.rb b/app/helpers/forums_helper.rb index 7612b4bf..47a059e0 100644 --- a/app/helpers/forums_helper.rb +++ b/app/helpers/forums_helper.rb @@ -19,4 +19,10 @@ module ForumsHelper end options end + + # this method is used to get all projects that tagged one tag + # added by william + def get_forums_by_tag(tag_name) + Forum.tagged_with(tag_name).order('updated_at desc') + end end diff --git a/app/views/tags/_show_forums.html.erb b/app/views/tags/_show_forums.html.erb new file mode 100644 index 00000000..009ec194 --- /dev/null +++ b/app/views/tags/_show_forums.html.erb @@ -0,0 +1,15 @@ +
+ <% if forums_results.size > 0 %> +
+ <% forums_results.each do |forum| %> +

+ <%= l(:label_tags_forum) %>:<%= link_to "#{forum.name}", + :controller => "forums",:action => "show",:id => forum.id %> +
+ <%= l(:label_tags_forum_description) %>:<%= forum.description %> + <%= forum.updated_at %> +

+
+ <% end %> + <% end %> +
diff --git a/app/views/tags/_sidebar_tags.html.erb b/app/views/tags/_sidebar_tags.html.erb index d64f1c29..a9570f60 100644 --- a/app/views/tags/_sidebar_tags.html.erb +++ b/app/views/tags/_sidebar_tags.html.erb @@ -7,4 +7,6 @@ (<%= Issue.tagged_with("#{sg}").size %>) <% when '4' then %> (<%= Bid.tagged_with("#{sg}").size %>) +<% when '5' then %> +(<%= Forum.tagged_with("#{sg}").size %>) <% end %> diff --git a/app/views/tags/_tag_search_results.html.erb b/app/views/tags/_tag_search_results.html.erb index 44f6d003..b46ad7da 100644 --- a/app/views/tags/_tag_search_results.html.erb +++ b/app/views/tags/_tag_search_results.html.erb @@ -13,6 +13,9 @@ <% when show_flag == '4'%> <%= l(:label_requirement)%>(<%= @results_count %>) <%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%> + <% when show_flag == '5'%> + <%= l(:label_forum)%>(<%= @results_count %>) + <%= render :partial => "show_forums",:locals => {:forums_results => forums_results}%> <% else %> <%= l(:label_tags_all_objects)%> diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb index 121725ad..0cee8e98 100644 --- a/app/views/tags/index.html.erb +++ b/app/views/tags/index.html.erb @@ -26,7 +26,7 @@
<%= render :partial => "tag_search_results",:locals => {:issues_results => @issues_results, :projects_results => @projects_results,:users_results => @users_results , - :bids_results=>@bids_results,:show_flag => @obj_flag}%> + :bids_results=>@bids_results,:forums_results => @forums_results, :show_flag => @obj_flag}%>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 4f70904b..2db46799 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1571,6 +1571,9 @@ en: label_memo_new: new memo label_memo_edit: edit memo label_project_module_forums: Forums + label_forum: Forum + label_tags_forum_description: Forum description + label_tags_forum: Call forum diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d4eca890..d74cd076 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1735,3 +1735,6 @@ zh: label_borad_project: 项目讨论区 label_borad_course: 课程讨论区 label_memo_new_from_forum: 发布帖子 + label_forum: 讨论区 + label_tags_forum_description: 讨论区描述 + label_tags_forum: 讨论区名称