|
|
|
@ -33,6 +33,35 @@ module ApplicationHelper
|
|
|
|
|
extend Forwardable
|
|
|
|
|
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
|
|
|
|
|
|
|
|
|
|
# Time 2015-03-24 15:27:29
|
|
|
|
|
# Author lizanle
|
|
|
|
|
# Description 从硬盘上删除对应的资源文件
|
|
|
|
|
def delete_kindeditor_assets_from_disk owner_id,owner_type
|
|
|
|
|
assets = Kindeditor::Asset.where(["owner_id = ? and owner_type = ?",owner_id,owner_type])
|
|
|
|
|
if !assets.nil? && !assets.blank?
|
|
|
|
|
assets.all.each do |asset|
|
|
|
|
|
next if asset.nil?
|
|
|
|
|
filepath = File.join(Rails.root,"public","files","uploads",
|
|
|
|
|
asset[:created_at].to_s.gsub("+0800","").to_datetime.strftime("%Y%m").to_s,
|
|
|
|
|
asset[:asset].to_s)
|
|
|
|
|
File.delete(filepath) if File.exist?filepath
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Time 2015-03-24 16:38:05
|
|
|
|
|
# Author lizanle
|
|
|
|
|
# Description after save后需要进行资源记录的更新
|
|
|
|
|
# owner_type = 1 对应的是 memo
|
|
|
|
|
def update_kindeditor_assets_owner ids,owner_id,owner_type
|
|
|
|
|
ids.each do |id|
|
|
|
|
|
asset = Kindeditor::Asset.find(id.to_i)
|
|
|
|
|
asset.owner_id = owner_id
|
|
|
|
|
asset.owner_type = owner_type
|
|
|
|
|
asset.save
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Added by young
|
|
|
|
|
# Define the course menu's link class
|
|
|
|
|
# 不是数组的转化成数组,然后判断当前menu_item是否在给定的列表
|
|
|
|
|