diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb
index 2b44d51de..be6543be2 100644
--- a/app/controllers/forums_controller.rb
+++ b/app/controllers/forums_controller.rb
@@ -7,7 +7,7 @@ class ForumsController < ApplicationController
before_filter :find_forum_if_available
before_filter :authenticate_user_edit, :only => [:edit, :update]
before_filter :authenticate_user_destroy, :only => [:destroy]
- before_filter :require_login, :only => [:new, :create]
+ before_filter :require_login, :only => [:new, :create,:destroy,:update,:edit]
helper :sort
include SortHelper
@@ -97,7 +97,24 @@ class ForumsController < ApplicationController
def index
@offset, @limit = api_offset_and_limit({:limit => 10})
- @forums_all = Forum.reorder("sticky DESC")
+ if(params[:reorder_complex])
+ @type="reorder_complex"
+ @str=params[:reorder_complex]
+ @forums_all = Forum.reorder("topic_count #{params[:reorder_complex]},updated_at #{params[:reorder_complex]}")
+ elsif(params[:reorder_popu])
+ @type="reorder_popu"
+ @str=params[:reorder_popu]
+ @forums_all = Forum.reorder("topic_count #{params[:reorder_popu]}")
+ elsif(params[:reorder_time])
+ @type="reorder_time"
+ @str=params[:reorder_time]
+ @forums_all = Forum.reorder("updated_at #{params[:reorder_time]}")
+ else
+ params[:reorder_complex] = "desc"
+ @type="reorder_complex"
+ @str=params[:reorder_complex]
+ @forums_all = Forum.reorder("topic_count desc,updated_at desc")
+ end
@forums_count = @forums_all.count
@forums_pages = Paginator.new @forums_count, @limit, params['page']
@@ -106,6 +123,7 @@ class ForumsController < ApplicationController
#@forums = Forum.all
respond_to do |format|
format.html # index.html.erb
+ format.js
format.json { render json: @forums }
end
end
@@ -113,11 +131,25 @@ class ForumsController < ApplicationController
# GET /forums/1
# GET /forums/1.json
def show
- sort_init 'updated_at', 'desc'
- sort_update 'created_at' => "#{Memo.table_name}.created_at",
- 'replies' => "#{Memo.table_name}.replies_count",
- 'updated_at' => "COALESCE (last_replies_memos.created_at, #{Memo.table_name}.created_at)"
-
+ # sort_init 'updated_at', 'desc'
+ # sort_update 'created_at' => "#{Memo.table_name}.created_at",
+ # 'replies' => "#{Memo.table_name}.replies_count",
+ # 'updated_at' => "COALESCE (last_replies_memos.created_at, #{Memo.table_name}.created_at)"
+ order = ""
+ @order_str = ""
+ if(params[:reorder_complex])
+ order = " last_replies_memos.created_at #{params[:reorder_complex]}, #{Memo.table_name}.created_at #{params[:reorder_complex]}"
+ @order_str = "reorder_complex="+params[:reorder_complex]
+ elsif(params[:reorder_popu])
+ order = "replies_count #{params[:reorder_popu]}"
+ @order_str = "reorder_popu="+params[:reorder_popu]
+ elsif(params[:reorder_time])
+ order = "#{Memo.table_name}.updated_at #{params[:reorder_time]}"
+ @order_str = "reorder_time="+params[:reorder_time]
+ else
+ order = "last_replies_memos.created_at desc, #{Memo.table_name}.created_at desc"
+ @order_str = "reorder_complex=desc"
+ end
@memo = Memo.new(:forum => @forum)
@topic_count = @forum.topics.count
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
@@ -126,19 +158,15 @@ class ForumsController < ApplicationController
includes(:last_reply).
limit(@topic_pages.per_page).
offset(@topic_pages.offset).
- order(sort_clause).
+ reorder(order).
preload(:author, {:last_reply => :author}).
all
@memos
- # @offset, @limit = api_offset_and_limit({:limit => 10})
- # @forum = Forum.find(params[:id])
- # @memos_all = @forum.topics
- # @topic_count = @memos_all.count
- # @topic_pages = Paginator.new @topic_count, @limit, params['page']
-
- # @offset ||= @topic_pages.offset
- # @memos = @memos_all.offset(@offset).limit(@limit).all
+ @my_topic_count = Memo.where("forum_id = #{@forum.id} and author_id = #{User.current.id} and parent_id is null").count
+ @my_replies_count = Memo.where("forum_id = #{@forum.id} and author_id = #{User.current.id} and parent_id is not null").count
+ @errors = params[:errors]
respond_to do |format|
+ format.js
format.html {
render :layout => 'base_forums'
}# show.html.erb
@@ -172,20 +200,23 @@ class ForumsController < ApplicationController
# Author lizanle
# Description after save后需要进行资源记录的更新
# owner_type = 2 对应的是 forum
+ @save_flag=true
if params[:asset_id]
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids ,@forum.id,OwnerTypeHelper::FORUM
end
#end
respond_to do |format|
-
+ format.js
format.html { redirect_to @forum, notice: l(:label_forum_create_succ) }
format.json { render json: @forum, status: :created, location: @forum }
end
else
+ @save_flag=false
respond_to do |format|
flash.now[:error] = "#{l :label_forum_create_fail}: #{@forum.errors.full_messages[0]}"
+ format.js
format.html { render action: "new" }
format.json { render json: @forum.errors, status: :unprocessable_entity }
end
@@ -199,10 +230,12 @@ class ForumsController < ApplicationController
respond_to do |format|
if @forum.update_attributes(params[:forum])
+ format.js {render :text=> true}
format.html { redirect_to @forum, notice: l(:label_forum_update_succ) }
format.json { head :no_content }
else
flash.now[:error] = "#{l :label_forum_update_fail}: #{@forum.errors.full_messages[0]}"
+ format.js { render :text=> false}
format.html { render action: "edit" }
format.json { render json: @forum.errors, status: :unprocessable_entity }
end
@@ -261,6 +294,47 @@ class ForumsController < ApplicationController
end
end
+ #检查forum的名字
+ def check_forum_name
+ forum_name_exist = Forum.where("name = '#{params[:forum_name]}'").count >= 1 ? true : false
+ render :text => forum_name_exist
+ end
+
+ #添加论坛tag
+ def add_forum_tag
+ @forum = Forum.find(params[:id])
+ unless @forum.nil?
+ @forum.tag_list.add(params[:tag_str].split(','))
+ @forum.save
+ end
+ respond_to do |format|
+ format.js {render :delete_forum_tag}
+ end
+ end
+
+ #删除forum的tag
+ def delete_forum_tag
+ @tag_id = (ActsAsTaggableOn::Tag.find_by_name(params[:tag_name])).id
+ #forum的taggable_type = 5
+ @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,params[:id],'Forum')
+
+ unless @taggings.nil?
+ @taggings.delete
+ end
+
+ # 是否还有其他记录 引用了 tag_id
+ @tagging = ActsAsTaggableOn::Tagging.find_by_tag_id(@tag_id)
+ # 如果taggings表中记录已经不存在 ,那么检查tags表 作删除动作
+ if @tagging.nil?
+ @tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id)
+ @tag.delete unless @tag.nil?
+ end
+ @forum = Forum.find(params[:id])
+ respond_to do |format|
+ format.js
+ end
+ end
+
private
def find_forum_if_available
diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb
index 27e0d472f..4181090a5 100644
--- a/app/controllers/memos_controller.rb
+++ b/app/controllers/memos_controller.rb
@@ -11,7 +11,7 @@ class MemosController < ApplicationController
include AttachmentsHelper
include ApplicationHelper
- layout 'base_memos'
+ # layout 'base_memos'
def quote
@subject = @memo.subject
@@ -73,41 +73,14 @@ class MemosController < ApplicationController
end
end
#end
- format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" }
- format.json { render json: @memo, status: :created, location: @memo }
+ format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" }
+ format.json { render json: @memo, status: :created, location: @memo }
else
flash.now[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}"
- # back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id)
- pre_count = REPLIES_PER_PAGE
-
- @memo_new = @memo.dup
- @memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示
- unless @memo.new_record?
- @memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1))
- end
-
-
- page = params[:page]
- if params[:r] && page.nil?
- offset = @memo.children.where("#{Memo.table_name}.id < ?", params[:r].to_i).count
- page = 1 + offset / pre_count
- else
-
- end
- @reply_count = @memo.children.count
- @reply_pages = Paginator.new @reply_count, pre_count, page
- @replies = @memo.children.
- includes(:author, :attachments).
- reorder("#{Memo.table_name}.created_at DESC").
- limit(@reply_pages.per_page).
- offset(@reply_pages.offset).
- all
- if @memo.new_record?
- format.html { render :new,:layout=>'base'}
- else
- format.html { render action: :show }
+ format.js
+ format.html { redirect_to( forum_path(Forum.find(params[:forum_id]),:errors=>@memo.errors.full_messages[0])) }
format.json { render json: @memo.errors, status: :unprocessable_entity }
- end
+ #end
end
end
@@ -115,6 +88,7 @@ class MemosController < ApplicationController
REPLIES_PER_PAGE = 20 unless const_defined?(:REPLIES_PER_PAGE)
def show
+
# 更新贴吧帖子留言对应的memo_messages的viewed字段
unless @memo.children.blank?
@memo.children.each do |child|
@@ -154,21 +128,27 @@ class MemosController < ApplicationController
@memo_new = Memo.new
-
+ @my_topic_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is null").count
+ @my_replies_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is not null").count
# @memo = Memo.find_by_id(params[:id])
# @forum = Forum.find(params[:forum_id])
# @replies = @memo.replies
# @mome_new = Memo.new
respond_to do |format|
- format.html # show.html.erb
+ format.html {render :layout=> 'base_forums'}#:layout=> 'base_forums',
format.json { render json: @memo }
format.xml { render xml: @memo }
end
end
def edit
+ @my_topic_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is null").count
+ @my_replies_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is not null").count
@replying = false
+ respond_to do |format|
+ format.html {render :layout=>'base_forums'}
+ end
end
def update
@@ -176,7 +156,8 @@ class MemosController < ApplicationController
if( #@memo.update_column(:subject, params[:memo][:subject]) &&
@memo.update_column(:content, params[:memo][:content]) &&
@memo.update_column(:sticky, params[:memo][:sticky]) &&
- @memo.update_column(:lock, params[:memo][:lock]))
+ @memo.update_column(:lock, params[:memo][:lock]) &&
+ @memo.update_column(:subject,params[:memo][:subject]))
@memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads]))
@memo.save
# @memo.root.update_attribute(:updated_at, @memo.updated_at)
@@ -227,7 +208,7 @@ class MemosController < ApplicationController
end
def back_memo_url
- forum_memo_path(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))
+ forum_memo_path(@forum, (@memo.root.nil? ? @memo : @memo.root))
end
def back_memo_or_forum_url
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index e0cb8af8e..0ffa334c2 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -15,6 +15,7 @@ class TagsController < ApplicationController
include ContestsHelper
include ActsAsTaggableOn::TagsHelper
include TagsHelper
+ include FilesHelper
helper :projects
helper :courses
helper :tags
@@ -236,47 +237,91 @@ class TagsController < ApplicationController
@rename_tag_name = params[:renameName]
@taggable_id = params[:taggableId]
@taggable_type = numbers_to_object_type(params[:taggableType])
-
+ @course_id = params[:courseId]
@rename_tag = (ActsAsTaggableOn::Tag.find_by_name(@rename_tag_name)) #查找重命名后的tag
@tag_id = (ActsAsTaggableOn::Tag.find_by_name(@tag_name)).id #重命名前的tag_id
- @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type)
- @obj = get_object(@taggable_id,params[:taggableType])
- if(@rename_tag.nil?) #这次命名的是新的tag
-
- # 是否还有其他记录 引用了 tag_id
- @tagging = ActsAsTaggableOn::Tagging.where("tag_id = #{@tag_id}")
- # 如果taggings表中记录为 1 ,那么改变@tag_id对应的tag的名字
- if @tagging.count == 1
- @tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id)
- @tag.update_attributes({:name=>@rename_tag_name})
- else #如果tagging表中的记录大于1,那么就要新增tag记录
-
- unless @obj.nil?
- @obj.tag_list.add(@rename_tag_name.split(","))
- @obj.save
- end
- #删除原来的对应的taggings的记录
- unless @taggings.nil?
- @taggings.delete
- end
- end
- else #这是已有的tag
- # 更改taggings记录里的tag_id
- unless @taggings.nil?
+ @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type) unless @taggable_id.blank?
+ @obj = get_object(@taggable_id,params[:taggableType]) unless @taggable_id.blank?
+ if @taggable_id.blank? #如果没有传tag_id,那么直接更新tag_name就好了。但是要防止 重命名后的tag存在。
+ #看重命名后的tag是否存在。如果存在的话,只需要更改taggings里边的id即可
+ if @rename_tag
+ @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type)
@taggings.update_attributes({:tag_id=>@rename_tag.id})
+ else #如果不存在,那么就直接更新该tag名称为新的名称
+ (ActsAsTaggableOn::Tag.find_by_name(@tag_name)).update_attributes(:name=>@rename_tag_name)
+ end
+ else
+ if(@rename_tag.nil?) #这次命名的是新的tag
+
+ # 是否还有其他记录 引用了 tag_id
+ @tagging = ActsAsTaggableOn::Tagging.where("tag_id = #{@tag_id}")
+ # 如果taggings表中记录为 1 ,那么改变@tag_id对应的tag的名字
+ if @tagging.count == 1
+ @tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id)
+ @tag.update_attributes({:name=>@rename_tag_name})
+ else #如果tagging表中的记录大于1,那么就要新增tag记录
+
+ unless @obj.nil?
+ @obj.tag_list.add(@rename_tag_name.split(","))
+ @obj.save
+ end
+ #删除原来的对应的taggings的记录
+ unless @taggings.nil?
+ @taggings.delete
+ end
+ end
+ else #这是已有的tag
+ # 更改taggings记录里的tag_id
+ unless @taggings.nil?
+ @taggings.update_attributes({:tag_id=>@rename_tag.id})
+ end
end
end
+
@obj_flag = params[:taggableType]
if @obj && @obj_flag == '6' && @obj.container.kind_of?(Course)
@course = @obj.container
@tag_list = @tag_list = get_course_tag_list @course
+ elsif @course_id
+ @course = Course.find(@course_id)
+ @tag_list = get_course_tag_list @course
+
+ #这里要引用FilesController里的逻辑了。将资源库当前的文件列表刷新一遍。
+ @flag = params[:flag] || false
+ sort = ""
+ @sort = ""
+ @order = ""
+ @is_remote = false
+ @isproject = false
+
+ sort = "#{Attachment.table_name}.created_on desc"
+
+ @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
+
+ show_attachments @containers
+ elsif @obj && @obj_flag == '5'
+ @forum = @obj
end
respond_to do |format|
format.js
end
end
+ def show_attachments obj
+ @attachments = []
+ obj.each do |container|
+ @attachments += container.attachments
+ end
+ @all_attachments = User.current.admin? ? @attachments : visable_attachemnts(@attachments)
+ @limit = 10
+ @feedback_count = @all_attachments.count
+ @feedback_pages = Paginator.new @feedback_count, @limit, params['page']
+ @offset ||= @feedback_pages.offset
+ #@curse_attachments_all = @all_attachments[@offset, @limit]
+ @obj_attachments = paginateHelper @all_attachments,10
+ end
+
def tag_save
@select_tag_name = params[:tag_for_save][:tag_name]
@tags = params[:tag_for_save][:name]
diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb
index 284ee8c43..2e8b98a2d 100644
--- a/app/helpers/tags_helper.rb
+++ b/app/helpers/tags_helper.rb
@@ -1,5 +1,6 @@
module TagsHelper
include StoresHelper
+ include CoursesHelper
# 通过 id和type获取对象
def get_object(obj_id,obj_type)
@obj = nil
@@ -62,6 +63,27 @@ module TagsHelper
end
+#判断课程course中是否包含课件attachment,course中引用了attachment也算作包含
+def course_contains_attachment? course,attachment
+ course.attachments.each do |att|
+ if att.id == attachment.id || (!att.copy_from.nil? && !attachment.copy_from.nil? && att.copy_from == attachment.copy_from) || att.copy_from == attachment.id || att.id == attachment.copy_from
+ return true
+ end
+ end
+ false
+end
+
+#判断用户是否拥有不包含当前资源的课程,需用户在该课程中角色为教师且该课程属于当前学期或下一学期
+def has_course? user,file
+ result = false
+ user.courses.each do |course|
+ if !course_contains_attachment?(course,file) && is_course_teacher(User.current,course) && course_in_current_or_next_term(course)
+ return true
+ end
+ end
+ result
+end
+
# 判断用户是否是贴吧的管理员
# add by chenmin
def is_forum_manager?(user_id,forum_id)
diff --git a/app/models/forum.rb b/app/models/forum.rb
index 530639f81..9fa1b7dfd 100644
--- a/app/models/forum.rb
+++ b/app/models/forum.rb
@@ -14,7 +14,7 @@ class Forum < ActiveRecord::Base
'sticky',
'locked'
validates_presence_of :name, :creator_id, :description
- validates_length_of :name, maximum: 50
+ validates_length_of :name, maximum: 160
#validates_length_of :description, maximum: 255
validates :name, :uniqueness => true
after_destroy :delete_kindeditor_assets
diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb
index 353d19dab..e31eea960 100644
--- a/app/views/files/_course_list.html.erb
+++ b/app/views/files/_course_list.html.erb
@@ -3,13 +3,13 @@
共有 <%= all_attachments.count%> 个资源
<% if order == "asc" %>
- 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /
- <%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> /
- <%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序
+ 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /
+ <%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> /
+ <%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序
<% else %>
- 按 <%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /
- <%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> /
- <%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序
+ 按 <%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /
+ <%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> /
+ <%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序
<% end %>
diff --git a/app/views/files/_tag_yun.html.erb b/app/views/files/_tag_yun.html.erb
index 9db34ece4..b2c7ab79f 100644
--- a/app/views/files/_tag_yun.html.erb
+++ b/app/views/files/_tag_yun.html.erb
@@ -3,7 +3,7 @@
<% if tag_name && tag_name == k%>
<%= k%>×<%= v%>
<% else%>
- <%= k%>×<%= v%>
+ <%= k%>×<%= v%>
<% end%>
<% end%>
<% end%>
\ No newline at end of file
diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb
index fa15c1fc7..489c0357d 100644
--- a/app/views/files/index.html.erb
+++ b/app/views/files/index.html.erb
@@ -229,6 +229,9 @@
var ele; //当前双击的链接
var tagId; //标签的id
var taggableType; //被标签的类型
+ //这里renameTag有两种情况,一种是改变某个资源的tag名称。如果其他资源也有这个tag。则新增一个改变后的tag名
+ //第二种是改变某个tag名称。其他所有的资源如果拥有这个tag。那么对应的tag名也要改掉。
+ //目前这两种依据 的来源就是 是否 传了参数 id。如果有id。就指定了资源id,就是第一种情况。如果没有id。就是第二种情况
function rename_tag(domEle,name,id,type){
if(domEle.children().get(0) != undefined ){ //已经是编辑框的情况下不要动
return;
@@ -239,7 +242,8 @@
ele = domEle;
tagId = id;
taggableType = type;
- domEle.html(' ');
+ width = parseInt(domEle.css('width').replace('px','')) >=100 ? parseInt(domEle.css('width').replace('px','')) : 100
+ domEle.html(' ');
domEle.parent().css("border","1px solid #ffffff");
$("#renameTagName").focus();
}
@@ -256,14 +260,10 @@
}else{ //否则就要更新tag名称了
if(confirm("是否将标签改为 "+ $("#renameTagName").val().trim())){
- $.post(
- '<%= update_tag_name_path %>',
- {"taggableId":tagId,"taggableType":taggableType,"tagName":tagName,"renameName":$("#renameTagName").val().trim()}
-// function(data){
-// ele.parent().css("border","");
-// ele.parent().html(tagNameHtml);
-// }
- )
+ $.post(
+ '<%= update_tag_name_path %>',
+ {"taggableId": tagId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim(),"courseId":<%= @course.id%>}
+ )
}else{
ele.parent().css("border","");
ele.parent().html(tagNameHtml);
diff --git a/app/views/forums/_file_form.html.erb b/app/views/forums/_file_form.html.erb
new file mode 100644
index 000000000..030c8ff0e
--- /dev/null
+++ b/app/views/forums/_file_form.html.erb
@@ -0,0 +1,79 @@
+
+
+
+<% if defined?(container) && container && container.saved_attachments %>
+ <% container.attachments.each_with_index do |attachment, i| %>
+
+ <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %><%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %><%= l(:field_is_public) %>:
+ <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %>
+ <%= if attachment.id.nil?
+ #待补充代码
+ else
+ link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload')
+ end
+ %>
+ <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
+
+ <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
+
+
+ <% end %>
+ <% container.saved_attachments.each_with_index do |attachment, i| %>
+
+ <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %>
+ <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %>
+ <%= l(:field_is_public) %>:
+ <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %>
+ <%= if attachment.id.nil?
+ #待补充代码
+ else
+ link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload')
+ end
+ %>
+ <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
+
+ <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
+
+
+ <% end %>
+<% end %>
+
+ <% project = project %>
+
+
+ <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
+
+ <%#= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file').click();",:onmouseover => 'this.focus()',:class => 'AnnexBtn fl mt3' %>
+
上传附件
+ <%= file_field_tag 'attachments[dummy][file]',
+ :id => '_file',
+ :class => 'file_selector',
+ :multiple => true,
+ :onchange => 'addInputFiles(this);',
+ :style => ie8? ? '' : 'display:none',
+ :data => {
+ :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
+ :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
+ :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
+ :upload_path => uploads_path(:format => 'js', :project => project),
+ :description_placeholder => l(:label_optional_description),
+ :field_is_public => l(:field_is_public),
+ :are_you_sure => l(:text_are_you_sure),
+ :file_count => l(:label_file_count),
+ :delete_all_files => l(:text_are_you_sure_all)
+ } %>
+
+
+
+
+ <%#= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>
+
+
+
+ <% content_for :header_tags do %>
+ <%= javascript_include_tag 'attachments' %>
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/forums/_form_edit_mode.html.erb b/app/views/forums/_form_edit_mode.html.erb
index a9bb05f79..9c0ec27bd 100644
--- a/app/views/forums/_form_edit_mode.html.erb
+++ b/app/views/forums/_form_edit_mode.html.erb
@@ -1,49 +1,26 @@
-
-
-
- <%= labelled_form_for(@forum) do |f| %>
- <% if @forum.errors.any? %>
-
- <% end %>
-
-
- <%= f.text_field :name, :required => true, :style => 'width: 100%;', :class => 'create-share', :maxlength => 50%>
-
-
- <% if User.current.logged? && User.current.admin? %>
- <% if @forum.safe_attribute? 'sticky' %>
- <%= f.check_box :sticky %>
- <%= label_tag 'message_sticky', l(:label_board_sticky) %>
- <% end %>
- <% if @forum.safe_attribute? 'locked' %>
- <%= f.check_box :locked %>
- <%= label_tag 'message_locked', l(:label_board_locked) %>
- <% end %>
+
+ <%= labelled_form_for(@forum) do |f| %>
+
+
+
+
+
+
+
+
+
<% end %>
-
-
- <%= f.kindeditor :description, :required => true,:owner_id => @forum.id,:owner_type => 2 %>
-
-
-
- (<%= l(:label_forums_max_length) %>)
-
-
-
- <%= submit_tag l(:button_submit) %>
- <%= link_to l(:button_back), forums_path ,:style => 'font-size: 14px; padding: 0px 3px;' %>
-
- <% end %>
-
+
\ No newline at end of file
diff --git a/app/views/forums/_forum_form.html.erb b/app/views/forums/_forum_form.html.erb
new file mode 100644
index 000000000..9888b674e
--- /dev/null
+++ b/app/views/forums/_forum_form.html.erb
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/forums/_forum_list.html.erb b/app/views/forums/_forum_list.html.erb
index ac27235eb..fbbe023a0 100644
--- a/app/views/forums/_forum_list.html.erb
+++ b/app/views/forums/_forum_list.html.erb
@@ -1,57 +1,38 @@
-
-
+
<% if forums.any? %>
<% forums.each do |forum| %>
-
-
- <%= forum.creator.nil? ? (link_to image_tag(url_to_avatar(forum.creator), :class => "avatar")) : (link_to image_tag(url_to_avatar(forum.creator), :class => "avatar"), user_path(forum.creator)) %>
-
-
-
-
-
-
- <%= link_to h(forum.name), forum_path(forum) %>
-
-
-
-
-
-
- <%= textAreailizable forum.description%>
-
-
-
-
-
-
- <%= authoring forum.created_at, forum.creator %>
-
-
-
-
-
-
-
-
-
- <%= link_to (forum.memo_count), forum_path(forum) %>
-
-
- <%= link_to (forum.topic_count), forum_path(forum) %>
-
-
-
- 回答
- 帖子
-
-
-
-
+
+
+
+
+
+ <%= link_to forum.name, forum_path(forum),:class=>"f16 linkBlue" %>
+
+
<%= textAreailizable forum.description%>
+
+
创建时间:<%= format_date(forum.created_at) %>
+
+
+
+
+ <%= link_to ( forum.topic_count), forum_path(forum),:class=>"linkGrey5 fb" %>
+
+
帖子
+
+
+
+
+
+ <%= link_to (forum.memo_count), forum_path(forum),:class=>"linkGrey5 fb" %>
+
+
回答
+
+
+
<% end %>
-
+
<% else %>
-<% end %>
-
\ No newline at end of file
+ <%= render :partial => "layouts/no_content" %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/forums/_forum_tag_list.html.erb b/app/views/forums/_forum_tag_list.html.erb
new file mode 100644
index 000000000..2a0257d63
--- /dev/null
+++ b/app/views/forums/_forum_tag_list.html.erb
@@ -0,0 +1,8 @@
+<% forum.tag_list.each do |tag|%>
+
+ <%= tag %>
+ <%if forum.creator.id == User.current.id%>
+ ×
+ <% end %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/forums/_post_banner.html.erb b/app/views/forums/_post_banner.html.erb
new file mode 100644
index 000000000..797b43245
--- /dev/null
+++ b/app/views/forums/_post_banner.html.erb
@@ -0,0 +1,33 @@
+
+
+综合
+ <% if order_type=='reorder_complex' && order_str == 'desc' %>
+
+ <% elsif order_type=='reorder_complex' && order_str == 'asc' %>
+
+ <% else %>
+
+ <% end %>
+
+人气
+ <% if order_type=='reorder_popu' && order_str == 'desc' %>
+
+ <% elsif order_type=='reorder_popu' && order_str == 'asc' %>
+
+ <% else %>
+
+ <% end %>
+
+时间
+ <% if order_type=='reorder_time' && order_str == 'desc' %>
+
+ <% elsif order_type=='reorder_time' && order_str == 'asc' %>
+
+ <% else %>
+
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/forums/_show_topics.html.erb b/app/views/forums/_show_topics.html.erb
index f8679cefa..d6e3f607b 100644
--- a/app/views/forums/_show_topics.html.erb
+++ b/app/views/forums/_show_topics.html.erb
@@ -1,47 +1,31 @@
-
-共有 <%=link_to @forum.memos.count %> 个贴子
<% if memos.any? %>
<% memos.each do |topic| %>
-
-
-
- <%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) if topic.author%>
-
-
-
-
- <%= link_to h(topic.subject), forum_memo_path(topic.forum, topic) %>
-
-
-
- <%= link_to (topic.replies_count), forum_memo_path(topic.forum, topic) %>
-
-
- 回答
-
-
-
-
-
-
-
- <%= authoring topic.created_at, topic.author %>
-
- <% author = topic.last_reply.try(:author)%>
- <% if author%>
- 最后回复:<%=link_to_user author %>
- <% end%>
-
-
-
-
-
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(topic.author), :width => 50,:height => 50,:alt => '贴吧图片'), user_path(topic.author) if topic.author%>
+
+
+
+
<%= topic.content.html_safe%>
+
+
+ <% author = topic.last_reply.try(:author)%>
+ <% if author%>
+
+
<%= format_date(topic.last_reply.created_at)%>
+ <% end%>
+
+
+
+
+ <%= link_to (topic.replies_count), forum_memo_path(topic.forum, topic),:target =>'_blank',:class=>'linkGrey2' %>
+
+
+
<% end %>
-
+
<% else %>
<%= l(:label_no_data) %>
<% end %>
diff --git a/app/views/forums/create.js.erb b/app/views/forums/create.js.erb
new file mode 100644
index 000000000..be99d724a
--- /dev/null
+++ b/app/views/forums/create.js.erb
@@ -0,0 +1,6 @@
+<%if @save_flag%>
+$('#new_forum_div').slideToggle();$('#create_btn').parent().slideToggle();
+$('#reorder_time').click();
+<%else%>
+ $("#error").html("<%= @forum.errors.full_messages[0]%>").show();
+<%end %>
\ No newline at end of file
diff --git a/app/views/forums/delete_forum_tag.js.erb b/app/views/forums/delete_forum_tag.js.erb
new file mode 100644
index 000000000..5080b3bdd
--- /dev/null
+++ b/app/views/forums/delete_forum_tag.js.erb
@@ -0,0 +1,2 @@
+$("#forum_tag_list").html("<%= escape_javascript( render :partial=>'forum_tag_list',:locals=>{:forum=>@forum}) %>");
+$('#add_tag01').hide();
\ No newline at end of file
diff --git a/app/views/forums/edit.html.erb b/app/views/forums/edit.html.erb
index 0a40120c7..24130e727 100644
--- a/app/views/forums/edit.html.erb
+++ b/app/views/forums/edit.html.erb
@@ -1,4 +1,72 @@
-
-
编辑讨论区
-<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
+
+<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'new_user' %>
+
<%= render 'form_edit_mode' %>
+
\ No newline at end of file
diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb
index 85cab957a..8f5cb15cc 100644
--- a/app/views/forums/index.html.erb
+++ b/app/views/forums/index.html.erb
@@ -1,48 +1,170 @@
-<% @nav_dispaly_home_path_label = 1
- @nav_dispaly_main_course_label = 1
- @nav_dispaly_main_project_label = 1
- @nav_dispaly_main_contest_label = 1 %>
-
-
-
-
- 公共贴吧
-
-
- <%= l(:label_user_location) %> :
-
-
-
- <% if User.current.logged? %>
- <%= link_to( l(:label_forum_new), new_forum_path, :class => 'icon icon-add') %>
- <% end %>
-
-
-
- <%#= form_tag(:controller => 'forums', :action => "search_forum", :method => :get) do %>
- <%#= text_field_tag 'name', params[:name], :size => 20 %>
- <%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
- <%# end %>
-
-
-
-
-
-
- <%= link_to request.host()+"/forums", forums_path %>
-
-
-
- <%= link_to l(:field_homepage), home_path %> >
- <%= link_to "公共贴吧", forums_path %>
-
-
-
-
-<% if @forums.size > 0 %>
- <%= render :partial => 'forums/forum_list', :locals => {:forums => @forums} %>
-<% else %>
- <%= render :partial => "layouts/no_content" %>
-<% end %>
+<%= javascript_include_tag 'new_user' %>
+<%= stylesheet_link_tag 'public'%>
+
+
+
+
+
+
+
error
+ <%= form_tag({:controller => 'forums',:action=>'create',:format=>'js'},:method => 'post',:remote=>'true') do |f| %>
+
+
+
+
+
+
+
+
+
+ <% end %>
+
+
+ <%= render :partial => 'post_banner' ,:locals => {:order_type=>@type,:order_str=>@str}%>
+
+
+
+
+
+
+
+
+ <%= render :partial => 'forum_list',:locals => {:forums=>@forums}%>
+
+
+ <%= pagination_links_full @forums_pages, @forums_count ,:per_page_links => true,:remote =>true,:flag=>true%>
+
+
+
+
+
diff --git a/app/views/forums/index.js.erb b/app/views/forums/index.js.erb
new file mode 100644
index 000000000..642c3c20a
--- /dev/null
+++ b/app/views/forums/index.js.erb
@@ -0,0 +1,4 @@
+//$("#postBanner").html("<%#= render :partial => 'post_banner' ,:locals => {:order_type=>@type,:order_str=>@str }%>");
+$("#forum_list").html("<%= escape_javascript(render :partial => 'forum_list',:locals => {:forums=>@forums}) %>");
+//这里出现一个问题竟然是单双引号引起的。注意!!
+$("#pages").html('<%= pagination_links_full @forums_pages, @forums_count,:per_page_links => false,:remote =>true,:flag=>true%>');
\ No newline at end of file
diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb
index 24aa74c23..34c7d6e64 100644
--- a/app/views/forums/show.html.erb
+++ b/app/views/forums/show.html.erb
@@ -1,42 +1,144 @@
-
-
-
- <%=l(:label_memo_new)%>
-
- <% if User.current.logged? %>
- <%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %>
-
- <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
-
- <%= f.text_field :subject, :required => true, :maxlength => 50%>
-
-
- <%= f.kindeditor :content, :required => true %>
-
-
-
- (<%= l(:label_memos_max_length) %>)
-
-
- <%= l(:label_attachment_plural) %>
-
- <%= render :partial => 'attachments/form', :locals => {:container => @memo} %>
-
-
- <%= f.submit :value => l(:label_memo_create) %>
- <%= link_to l(:button_cancel), "#", :onclick => '$("#add-memo").hide(); return false;' %>
-
- <% end %>
- <% end %>
+<%= javascript_include_tag 'new_user' %>
+
+
+
+
error
+ <%= labelled_form_for(@memo, :url => forum_memos_path(@forum)) do |f| %>
+
+
+
+
+
+
+
+
+
+
+ <%= render :partial => 'file_form', :locals => {:container => @memo} %>
+
+
+
+
+ <% end %>
+
+
+
+ <%= render :partial => 'show_topics',:locals => {:memos=>@memos}%>
+
+
+ <%= pagination_links_full @topic_pages, @topic_count ,:per_page_links => true, :remote => true, :flag => true %>
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- <%= link_to(image_tag('edit.png')+l(:label_forum_edit),{:action => 'edit', :id => @forum}, :method => 'get', :title => l(:button_edit)) if @forum.editable_by?(User.current) %>
- <%= link_to(image_tag('delete.png')+'删除讨论区', {:action => 'destroy', :id => @forum}, :method => :delete, :data => {:confirm => l(:text_are_you_sure)}, :title => l(:button_delete)
- ) if @forum.destroyable_by?(User.current) %>
-
-
- <%= link_to l(:label_memo_new_from_forum), new_forum_memo_path(@forum), :class => 'icon icon-add',
- :onclick => 'showAndScrollTo("add-memo", "memo_subject"); return false;' if User.current.logged? %>
-
-<%= render :partial => 'forums/show_topics', :locals => {:memos => @memos} %>
+
\ No newline at end of file
diff --git a/app/views/forums/show.js.erb b/app/views/forums/show.js.erb
new file mode 100644
index 000000000..9e36215ac
--- /dev/null
+++ b/app/views/forums/show.js.erb
@@ -0,0 +1,2 @@
+$("#topics_list").html("<%= escape_javascript(render :partial => 'show_topics',:locals => {:memos=>@memos})%>")
+$("#pages").html('<%= pagination_links_full @topic_pages, @topic_count,:per_page_links => false,:remote =>true%>');
\ No newline at end of file
diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb
index 812873045..752853c60 100644
--- a/app/views/layouts/_footer.html.erb
+++ b/app/views/layouts/_footer.html.erb
@@ -5,7 +5,7 @@
服务协议 |
<%= l(:label_recruitment_information)%> |
<%= l(:label_surpport_group)%> |
-
<%= l(:label_forums)%>
+
<%= l(:label_forums)%>
diff --git a/app/views/layouts/base_forums.html.erb b/app/views/layouts/base_forums.html.erb
index c68e917f5..0a377b1e5 100644
--- a/app/views/layouts/base_forums.html.erb
+++ b/app/views/layouts/base_forums.html.erb
@@ -7,7 +7,7 @@
<%= csrf_meta_tag %>
<%= favicon %>
- <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application','prettify', 'nyan', :media => 'all' %>
+ <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','application','prettify', 'nyan','leftside', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'prettify' %>
@@ -15,7 +15,114 @@
<%= call_hook :view_layouts_base_html_head %>
<%= yield :header_tags -%>
- <%= stylesheet_link_tag 'base','header', :media => 'all'%>
+ <%= stylesheet_link_tag 'base','header','new_user', :media => 'all'%>
+
@@ -28,82 +135,77 @@
<% end%>
+
+
+
+
+
<%= link_to image_tag(url_to_avatar(@forum.creator),:width=>75,:height => 75,:alt=>'贴吧图像' ),user_path( @forum.creator) %>
+
+
+
+
+
+
+
+ <%if @forum.creator.id == User.current.id%>
+
+
+
编辑贴吧
+
删除贴吧
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current),:width=>50,:height => 50,:alt=>'贴吧图像' ),user_path( User.current) %>
+
我在贴吧
+
+
+
+
+
-
-
-
-
-
-
-
- <%= l(:label_projects_community)%>
- <%= l(:label_user_location) %> :
-
-
- <%#= form_tag(:controller => 'forums', :action => "search_memo", :id => params[:id], :method => :get) do %>
- <%#= text_field_tag 'name', params[:name], :size => 20 %>
- <%#= hidden_field_tag 'forum_id', params[:id] %>
- <%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
- <%# end %>
-
-
-
-
- <%= link_to request.host()+"/forums", forums_path %>
- <%=link_to l(:label_home),home_path %> > <%=link_to '公共贴吧', :controller => 'forums', :action => 'index' %> > <%=link_to @forum.name, forum_path(@forum) %>
-
-
-
-
-
+
+
+
+ <%= yield %>
+ <%#= call_hook :view_layouts_base_content %>
+
+
+
- <%= render_flash_messages %>
- <%= yield %>
- <%= call_hook :view_layouts_base_content %>
-
-
-
- <%#= render :partial => 'layouts/base_footer'%>
-
-
- <%= l(:label_loading) %>
-
-
-
-
-
<%= render :partial => 'layouts/footer' %>
- <%= call_hook :view_layouts_base_body_bottom %>
+ <%#= call_hook :view_layouts_base_body_bottom %>