diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 91176efdf..75bf6fefd 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -29,15 +29,16 @@ class FilesController < ApplicationController helper :project_score def show_attachments obj - all_attachments = [] + @all_attachments = [] obj.each do |container| - all_attachments += container.attachments + @all_attachments += container.attachments end @limit = 10 - @feedback_count = all_attachments.count + @feedback_count = @all_attachments.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @offset ||= @feedback_pages.offset - @curse_attachments = all_attachments[@offset, @limit] + @curse_attachments_all = @all_attachments[@offset, @limit] + @curse_attachments = paginateHelper @all_attachments,10 end def index diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index b64c18b33..27f7fe61d 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -20,6 +20,7 @@ class TagsController < ApplicationController include OpenSourceProjectsHelper before_filter :require_admin,:only => [:delete,:show_all] + before_filter :require_login,:only => [:tag_save] # $selected_tags = Array.new # $related_tags = Array.new @@ -187,6 +188,49 @@ class TagsController < ApplicationController # end end end + + def tag_save + @tags = params[:tag_for_save][:name] + @obj_id = params[:tag_for_save][:object_id] + @obj_flag = params[:tag_for_save][:object_flag] + + case @obj_flag + when '1' then + @obj = User.find_by_id(@obj_id) + when '2' then + @obj = Project.find_by_id(@obj_id) + when '3' then + @obj = Issue.find_by_id(@obj_id) + when '4' then + @obj = Bid.find_by_id(@obj_id) + when '5' then + @obj = Forum.find_by_id(@obj_id) + when '6' + @obj = Attachment.find_by_id(@obj_id) + when '7' then + @obj = Contest.find_by_id(@obj_id) + when '8' + @obj = OpenSourceProject.find_by_id(@obj_id) + when '9' + @obj = Course.find_by_id(@obj_id) + else + @obj = nil + end + unless @obj.nil? + @obj.tag_list.add(@tags.split(",")) + else + return + end + if @obj.save + logger.debug "#{__FILE__}:#{__LINE__} ===> #{@obj.to_json}" + else + logger.error "#{__FILE__}:#{__LINE__} ===> #{@obj.errors.try(:full_messages)}" + end + respond_to do |format| + format.js + format.html + end + end private # 这里用来刷新搜索结果的区域 @@ -307,5 +351,7 @@ class TagsController < ApplicationController return end end + + end diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 46a954746..8edd054be 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -1,6 +1,71 @@ <% attachmenttypes = @course.attachmenttypes %> <% sufixtypes = @course.contenttypes %> +<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %> +<%= stylesheet_link_tag 'resource', :media => 'all' %> + +
+
+
+ + 发布资源 +
+
+ +
+
+

共有 <%= User.current.member_of_course?(@course) ? @all_attachments.count : 0 %> 个资源

+

按 时间 / 下载次数 / 引用次数 排序

+
+
+<% @curse_attachments.each do |file| %> + <%if file.is_public == 0 && !User.current.member_of_course?(@course)%> + <%next%> + <%end%> +
+
+ <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> + 选入我的课程公开 +
+
+
+

文件大小:<%= number_to_human_size(file.filesize) %>

+ <%= link_to( l(:button_delete), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed %> +

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用0

+
+
+
+ <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6"} %> + <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6"} %> +
+
+
+<% end %> +
    <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
+
+
+ +
+ +
+ + + + + + + + + + + + + <%= t(:label_user_course) %>资源共享区 diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 6cdc19471..bc665ea41 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -24,7 +24,7 @@ -<%= render :partial => 'courses/course_ad' %> +
diff --git a/app/views/tags/_tag_add.html.erb b/app/views/tags/_tag_add.html.erb new file mode 100644 index 000000000..14f2dc965 --- /dev/null +++ b/app/views/tags/_tag_add.html.erb @@ -0,0 +1,13 @@ +<%= link_to '+ 添加标签', 'javascript:void(0);', + :class => "yellowBtn f_l", + :onclick=>"$('#add_tag_#{obj.id}').slideToggle();" if User.current.logged? %> + \ No newline at end of file diff --git a/app/views/tags/_tag_list.html.erb b/app/views/tags/_tag_list.html.erb new file mode 100644 index 000000000..092e0d898 --- /dev/null +++ b/app/views/tags/_tag_list.html.erb @@ -0,0 +1,20 @@ +<% @tags = obj.reload.tag_list %> + +<% if @tags.size > 0 %> + <% @tags.each do |tag| %> + <%= link_to tag, :controller => "tags", :action => "index", :q => tag, :object_flag => object_flag, :obj_id => obj.id %> + + <% case object_flag %> + <% when '6' %> + <% if obj.author_id == User.current.id || User.current.admin?%> + <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, + :taggable_id => obj.id, :taggable_type => object_flag %> + <% end %> + <% end %> + + <% end %> +<% else %> + +    <%= l(:label_tags_no) %> + +<% end %> \ No newline at end of file diff --git a/app/views/tags/_tag_new.html.erb b/app/views/tags/_tag_new.html.erb new file mode 100644 index 000000000..eb49005ae --- /dev/null +++ b/app/views/tags/_tag_new.html.erb @@ -0,0 +1,24 @@ + <%#begin + 1 代表是user类型 + 2 代表是project类型 + 3 代表是issue类型 + 4 代表是bid类型 + 5 代表是forum类型 + 6 代表是Attachment类型 + 7 代表是contest类型 + 8 代表是OpenSourceProject类型 + 9 代表是RelativeMemo类型 + #end%> + + <% if object_flag == '3' %> + + <% elsif object_flag == '6' %> +
+ <%= render :partial => "tags/tag_list",:locals => {:obj => obj,:object_flag => object_flag} %> +
+ + <% else %> + + <% end %> diff --git a/app/views/tags/tag_save.js.erb b/app/views/tags/tag_save.js.erb new file mode 100644 index 000000000..20ffb54cf --- /dev/null +++ b/app/views/tags/tag_save.js.erb @@ -0,0 +1,9 @@ +//本js使用的新的tag显示方法 +<% if @obj_flag == '6'%> +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty(); +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_list', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +//$("#put-tag-form-<%#=@obj.class%>-<%#=@obj.id%>").hide(); +$("#tags_name_<%= @obj.id%>").val(""); +//$('#put-tag-form').hide(); +<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 1a2309c2c..35b7b6ca2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -792,6 +792,7 @@ RedmineApp::Application.routes.draw do match 'parise_tread/tread_plus', :as=>"tread" match 'tags/delete' match 'tags/remove_tag', :as=>"remove_tag" + match 'tags/tag_save', :as => "save_tag" match 'words/add_brief_introdution' diff --git a/public/images/files/btn.png b/public/images/files/btn.png new file mode 100644 index 000000000..85cea7f5c Binary files /dev/null and b/public/images/files/btn.png differ diff --git a/public/images/files/close.png b/public/images/files/close.png new file mode 100644 index 000000000..301ba5e85 Binary files /dev/null and b/public/images/files/close.png differ diff --git a/public/images/files/inputBg.png b/public/images/files/inputBg.png new file mode 100644 index 000000000..243bbf7ec Binary files /dev/null and b/public/images/files/inputBg.png differ diff --git a/public/images/files/pic_open01.png b/public/images/files/pic_open01.png new file mode 100644 index 000000000..45552ae00 Binary files /dev/null and b/public/images/files/pic_open01.png differ diff --git a/public/images/files/pic_open02.png b/public/images/files/pic_open02.png new file mode 100644 index 000000000..b457f302f Binary files /dev/null and b/public/images/files/pic_open02.png differ diff --git a/public/images/files/pic_select01.png b/public/images/files/pic_select01.png new file mode 100644 index 000000000..4f3b294fe Binary files /dev/null and b/public/images/files/pic_select01.png differ diff --git a/public/images/files/pic_select02.png b/public/images/files/pic_select02.png new file mode 100644 index 000000000..e620fad1f Binary files /dev/null and b/public/images/files/pic_select02.png differ diff --git a/public/stylesheets/images/btn.png b/public/stylesheets/images/btn.png new file mode 100644 index 000000000..85cea7f5c Binary files /dev/null and b/public/stylesheets/images/btn.png differ diff --git a/public/stylesheets/images/inputBg.png b/public/stylesheets/images/inputBg.png new file mode 100644 index 000000000..243bbf7ec Binary files /dev/null and b/public/stylesheets/images/inputBg.png differ diff --git a/public/stylesheets/images/pic_open01.png b/public/stylesheets/images/pic_open01.png new file mode 100644 index 000000000..45552ae00 Binary files /dev/null and b/public/stylesheets/images/pic_open01.png differ diff --git a/public/stylesheets/images/pic_open02.png b/public/stylesheets/images/pic_open02.png new file mode 100644 index 000000000..b457f302f Binary files /dev/null and b/public/stylesheets/images/pic_open02.png differ diff --git a/public/stylesheets/images/pic_select01.png b/public/stylesheets/images/pic_select01.png new file mode 100644 index 000000000..4f3b294fe Binary files /dev/null and b/public/stylesheets/images/pic_select01.png differ diff --git a/public/stylesheets/images/pic_select02.png b/public/stylesheets/images/pic_select02.png new file mode 100644 index 000000000..e620fad1f Binary files /dev/null and b/public/stylesheets/images/pic_select02.png differ diff --git a/public/stylesheets/resource.css b/public/stylesheets/resource.css new file mode 100644 index 000000000..3c7ab35bb --- /dev/null +++ b/public/stylesheets/resource.css @@ -0,0 +1,84 @@ +body{ font-size:12px; font-family:"微软雅黑","宋体"; line-height:1.9; background:#fff; font-style:normal;} +div,html,img,ul,li,p,body,h1,h2,h3,h4,p,a,table,tr,td,fieldset,input,form,span,textarea{ margin:0; padding:0;} +div,img,tr,td,textarea{ border:0;} +table,tr,td{border:0; cellspacing:0; cellpadding:0;} +ul,li{ list-style-type:none} +.cl{ clear:both; overflow:hidden; } +a{ text-decoration:none; text-align:center; } +a:hover{ text-decoration:underline;} +/**** 常用***/ +.f_l{ float:left;} +.f_r{ float:right;} +.b_lblue{ background:#64bdd9 !important;} +.b_dblue{ background:#55a1b9 !important; cursor:pointer !important;} +.f_b{ font-weight: bold !important;} +.c_blue{ color:#64bdd9;} +.c_grey{ color:#999999 !important;} +.c_grey02{ color:#666666 !important;} +.f_14{ font-size:14px ;} +.c_dblue{ color:#3e6d8e;} +.w90{width:90px;} +.ml10{margin-left:10px;} + + +.container{ } + +/****搜索***/ +.resource{ width:693px;} +.re_top{width:688px; height:50px; margin-left:5px; background:#eaeaea;} +.re_top input{ float:left;} +.re_search{ margin:12px;} +.re_schbox{ width:240px; height:24px; border:1px solid #64bdd9 !important; color:#666666;} +.re_schbtn +{ + width:60px !important; + height:26px !important; + color:#fff !important; + margin-right:5px !important; + border:none !important; + margin-left:0px !important; + box-shadow: none !important; + padding: 0px !important; + border-radius: 0 !important; + text-shadow: none !important; +} +a.re_fabu { display:block; width:90px; height:35px; font-size:14px; color:#fff; text-align:center; padding-top:5px; margin:5px; } +a:hover.re_fabu{background:#55a1b9;} +/****列表***/ +.re_con{ margin:5px; width:683px;} +.re_con_top{color:#494949; } +.re_con_top span{ color:#999999; font-weight:bold;} +a.re_select{ display:block; width:88px; height:22px; background:url(images/pic_select01.png) 0 0 no-repeat; color:#fff; font-weight:bold; margin-left:10px;} +a:hover.re_select{background:url(images/pic_select02.png) 0 0 no-repeat;} +.re_open{display:block; width:46px; height:22px; background:url(images/pic_open01.png) 0 0 no-repeat; color:#fff; font-weight:bold; margin-left:10px;} +a:hover.re_open{background:url(images/pic_open02.png) 0 0 no-repeat;} +a.re_de{ color:#6883b6; margin-left:15px;} +.re_con_box{ border-bottom:1px dashed #dadada; padding:10px 0;} +/****翻页***/ +.wlist{ margin-top:15px;} +.wlist a{ float:right; border:1px solid #15bccf; padding:0 5px; margin-left:3px; color:#15bccf;} +.wlist a:hover{border:1px solid #15bccf; background-color:#15bccf; color:#fff;} +.wlist_select a { background-color:#64bdd9; color:#fff;} +/****标签***/ +a.yellowBtn{ display:inline-block;color:#0d90c3; height:22px;} +.submit +{ + height:21px !important; + border:0 !important; + cursor:pointer !important; + background:url(images/btn.png) no-repeat 0 0 !important; + width:42px !important; + margin-top:2px !important; + margin-left:3px !important; + border:none !important; + margin-left:0px !important; + box-shadow: none !important; + padding: 0px !important; + border-radius: 0 !important; + text-shadow: none !important; +} +.isTxt{background:#fbfbfb url(images/inputBg.png) repeat-x left top !important;height:22px !important;line-height:22px !important;border:1px solid #c1c1c1 !important;padding:0 5px !important;color:#666666 !important;} +.re_tag{ width: auto; padding:0 5px; height:22px; border:1px solid #f8df8c; background:#fffce6; margin-right:10px;} +.re_tag a{ color:#0d90c3;} +.tag_h span,.tag_h a{ margin-bottom:5px;} +