|
|
|
@ -32,7 +32,7 @@ module ApplicationHelper
|
|
|
|
|
|
|
|
|
|
extend Forwardable
|
|
|
|
|
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Added by young
|
|
|
|
|
#Define the course menu's link class
|
|
|
|
|
# 不是数组的转化成数组,然后判断当前menu_item是否在给定的列表
|
|
|
|
@ -53,10 +53,10 @@ module ApplicationHelper
|
|
|
|
|
def authorize_for_course(controller, action)
|
|
|
|
|
User.current.allowed_to?({:controller => controller, :action => action}, @course)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def authorize_for_contest(controller, action)
|
|
|
|
|
User.current.allowed_to?({:controller => controller, :action => action}, @contest)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Display a link if user is authorized
|
|
|
|
|
#
|
|
|
|
@ -309,7 +309,7 @@ module ApplicationHelper
|
|
|
|
|
s << h(block_given? ? yield(project) : project.name)
|
|
|
|
|
else
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if project.try(:project_type) == Project::ProjectType_project
|
|
|
|
|
unless User.current.member_of?(@project)
|
|
|
|
|
s << "<span style = 'float: right;'>"
|
|
|
|
@ -382,7 +382,7 @@ module ApplicationHelper
|
|
|
|
|
s << "</ul></li>\n"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
classes = (ancestors.empty? ? 'root' : 'child')
|
|
|
|
|
classes = (ancestors.empty? ? 'root' : 'child')
|
|
|
|
|
s << h(block_given? ? yield(project) : project.name)
|
|
|
|
|
ancestors << project
|
|
|
|
|
end
|
|
|
|
@ -545,11 +545,11 @@ module ApplicationHelper
|
|
|
|
|
def authoring(created, author, options={})
|
|
|
|
|
l(options[:label] || :label_added_time_by, :author => link_to_user(author), :age => time_tag(created)).html_safe
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def added_time(created)
|
|
|
|
|
l(:label_added_time, :age => time_tag(created)).html_safe
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def user_url_and_time(user_name, user_url, created)
|
|
|
|
|
unless user_name.nil? || user_name == ''
|
|
|
|
|
l(:label_added_time_by, :author => link_to(user_name, user_url), :age => time_tag(created)).html_safe
|
|
|
|
@ -851,7 +851,7 @@ module ApplicationHelper
|
|
|
|
|
else
|
|
|
|
|
wiki_page_id = page.present? ? Wiki.titleize(page) : nil
|
|
|
|
|
parent = wiki_page.nil? && obj.is_a?(WikiContent) && obj.page && project == link_project ? obj.page.title : nil
|
|
|
|
|
url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project,
|
|
|
|
|
url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project,
|
|
|
|
|
:id => wiki_page_id, :version => nil, :anchor => anchor, :parent => parent)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -865,7 +865,7 @@ module ApplicationHelper
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def select_option_helper option
|
|
|
|
|
tmp = Hash.new
|
|
|
|
|
tmp={"" => ""}
|
|
|
|
@ -1177,7 +1177,7 @@ module ApplicationHelper
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def lang_options_for_select(blank=true)
|
|
|
|
|
{ 'Chinese简体中文 '=> 'zh', :English => :en}
|
|
|
|
|
{ 'Chinese简体中文 '=> 'zh', :English => :en}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def label_tag_for(name, option_tags = nil, options = {})
|
|
|
|
@ -1240,7 +1240,7 @@ module ApplicationHelper
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
html.html_safe
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def delete_link(url, options={})
|
|
|
|
|
options = {
|
|
|
|
@ -1254,8 +1254,8 @@ module ApplicationHelper
|
|
|
|
|
|
|
|
|
|
def preview_link(url, form, target='preview', options={})
|
|
|
|
|
content_tag 'a', l(:label_preview), {
|
|
|
|
|
:href => "#",
|
|
|
|
|
:onclick => %|submitPreview("#{escape_javascript url_for(url)}", "#{escape_javascript form}", "#{escape_javascript target}"); return false;|,
|
|
|
|
|
:href => "#",
|
|
|
|
|
:onclick => %|submitPreview("#{escape_javascript url_for(url)}", "#{escape_javascript form}", "#{escape_javascript target}"); return false;|,
|
|
|
|
|
:accesskey => accesskey(:preview)
|
|
|
|
|
}.merge(options)
|
|
|
|
|
end
|
|
|
|
@ -1343,12 +1343,12 @@ module ApplicationHelper
|
|
|
|
|
|
|
|
|
|
tags = javascript_tag(
|
|
|
|
|
"var datepickerOptions={dateFormat: 'yy-mm-dd',minDate: new Date(), firstDay: #{start_of_week}, " +
|
|
|
|
|
"showOn: 'button', buttonImageOnly: true, buttonImage: '" +
|
|
|
|
|
"showOn: 'button', buttonImageOnly: true, buttonImage: '" +
|
|
|
|
|
path_to_image('/images/calendar.png') +
|
|
|
|
|
"', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true, onClose: function(dateText, inst) {TimeClose(dateText,inst);}, beforeShow : function(input){TimeBeforeShow(input);} };")
|
|
|
|
|
jquery_locale = l('jquery.locale', :default => current_language.to_s)
|
|
|
|
|
unless jquery_locale == 'en'
|
|
|
|
|
tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
|
|
|
|
|
tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
|
|
|
|
|
end
|
|
|
|
|
tags
|
|
|
|
|
end
|
|
|
|
@ -1516,14 +1516,14 @@ module ApplicationHelper
|
|
|
|
|
options
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Add by Tao
|
|
|
|
|
def url_to_avatar(source)
|
|
|
|
|
source = nil if source.kind_of?(String)
|
|
|
|
|
get_avatar(source)
|
|
|
|
|
end
|
|
|
|
|
# Endof Tao's code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def date_format_local(time)
|
|
|
|
|
date = time.strftime("%Y年%m月%d日")
|
|
|
|
|
end
|
|
|
|
@ -1539,7 +1539,7 @@ module ApplicationHelper
|
|
|
|
|
def link_to_content_update(text, url_params = {}, html_options = {})
|
|
|
|
|
link_to(text, url_params, html_options)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#added by nie
|
|
|
|
|
# Display watcher picture
|
|
|
|
|
def show_more_watchers?(obj)
|
|
|
|
@ -1549,7 +1549,7 @@ module ApplicationHelper
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_watcher_profile(obj)
|
|
|
|
|
count = 0
|
|
|
|
|
html = ''
|
|
|
|
@ -1574,7 +1574,7 @@ module ApplicationHelper
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_bid_project(bid)
|
|
|
|
|
html = ''
|
|
|
|
|
if bid.projects.where('is_public = 1').count == 0
|
|
|
|
@ -1586,15 +1586,15 @@ module ApplicationHelper
|
|
|
|
|
end
|
|
|
|
|
html.html_safe
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_bid_fans_picture(obj)
|
|
|
|
|
html = ''
|
|
|
|
|
if obj.watcher_users.count == 0
|
|
|
|
|
html << (content_tag "span", l(:label_project_no_follow))
|
|
|
|
|
else
|
|
|
|
|
obj.watcher_users.take(12).each do |user|
|
|
|
|
|
obj.watcher_users.take(12).each do |user|
|
|
|
|
|
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
html.html_safe
|
|
|
|
|
end
|
|
|
|
@ -1615,7 +1615,7 @@ module ApplicationHelper
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_contest_project(bid)
|
|
|
|
|
html = ''
|
|
|
|
|
if contest.projects.where('is_public = 1').count == 0
|
|
|
|
@ -1627,7 +1627,7 @@ module ApplicationHelper
|
|
|
|
|
end
|
|
|
|
|
html.html_safe
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_contest_project(contest)
|
|
|
|
|
html = ''
|
|
|
|
|
if contest.projects.where('is_public = 1').count == 0
|
|
|
|
@ -1639,7 +1639,7 @@ module ApplicationHelper
|
|
|
|
|
end
|
|
|
|
|
html.html_safe
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_contest_softapplication(contest)
|
|
|
|
|
html = ''
|
|
|
|
|
if contest.softapplications.where('is_public = 1').count == 0
|
|
|
|
@ -1651,19 +1651,19 @@ module ApplicationHelper
|
|
|
|
|
end
|
|
|
|
|
html.html_safe
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_contest_fans_picture(obj)
|
|
|
|
|
html = ''
|
|
|
|
|
if obj.watcher_users.count == 0
|
|
|
|
|
html << (content_tag "span", l(:label_project_no_follow))
|
|
|
|
|
else
|
|
|
|
|
obj.watcher_users.take(12).each do |user|
|
|
|
|
|
obj.watcher_users.take(12).each do |user|
|
|
|
|
|
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
html.html_safe
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#display fans picture
|
|
|
|
|
def show_more_fans?(obj)
|
|
|
|
|
if obj.watcher_users.count > 12
|
|
|
|
@ -1672,20 +1672,20 @@ module ApplicationHelper
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_fans_picture(obj)
|
|
|
|
|
html = ''
|
|
|
|
|
if obj.watcher_users.count == 0
|
|
|
|
|
html << (content_tag "span", l(:label_no_current_fans))
|
|
|
|
|
else
|
|
|
|
|
obj.watcher_users.take(12).each do |user|
|
|
|
|
|
obj.watcher_users.take(12).each do |user|
|
|
|
|
|
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
html.html_safe
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# added by bai
|
|
|
|
|
|
|
|
|
|
# added by bai
|
|
|
|
|
def show_more_participate?(obj)
|
|
|
|
|
if obj.join_in_contests.count > 12
|
|
|
|
|
return true
|
|
|
|
@ -1693,7 +1693,7 @@ module ApplicationHelper
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_participate_picture(obj)
|
|
|
|
|
html = ''
|
|
|
|
|
count = 0
|
|
|
|
@ -1706,10 +1706,10 @@ module ApplicationHelper
|
|
|
|
|
if count >= 12
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
html.html_safe
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
# add by huang
|
|
|
|
@ -1724,7 +1724,7 @@ module ApplicationHelper
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
html.html_safe
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
#added by william
|
|
|
|
@ -1733,7 +1733,7 @@ module ApplicationHelper
|
|
|
|
|
end
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def hadcommittedhomework(cur,curb)
|
|
|
|
|
bid = Bid.find_by_id(curb)
|
|
|
|
|
return true if bid.nil?
|
|
|
|
@ -1748,7 +1748,7 @@ module ApplicationHelper
|
|
|
|
|
else
|
|
|
|
|
true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def render_dynamic_nav
|
|
|
|
@ -1759,10 +1759,10 @@ module ApplicationHelper
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def bootstrap_render_dynamic_nav
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main_course_link = link_to l(:label_course_practice), {:controller => 'welcome', :action => 'index', :host => Setting.course_domain}
|
|
|
|
|
main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain}
|
|
|
|
|
main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain}
|
|
|
|
|
main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain}
|
|
|
|
|
|
|
|
|
|
course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'}
|
|
|
|
|
course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain}
|
|
|
|
@ -1774,20 +1774,20 @@ module ApplicationHelper
|
|
|
|
|
forum_link = link_to l(:label_project_module_forums), {:controller => "forums", :action => "index"}
|
|
|
|
|
stores_link = link_to l(:label_stores_index), {:controller => 'stores', :action=> 'index'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
school_all_school_link = link_to l(:label_school_all), {:controller => 'school', :action => 'index'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#@nav_dispaly_project_label
|
|
|
|
|
nav_list = Array.new
|
|
|
|
|
nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label && @show_course == 1
|
|
|
|
|
nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label && @show_course == 1
|
|
|
|
|
nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label && @show_course == 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nav_list.push(main_project_link) if @nav_dispaly_main_project_label
|
|
|
|
|
nav_list.push(main_course_link) if @nav_dispaly_main_course_label && @show_course == 1
|
|
|
|
|
nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label && @show_contest == 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nav_list.push(courses_link) if @nav_dispaly_course_label && @show_course == 1
|
|
|
|
|
nav_list.push(projects_link) if @nav_dispaly_project_label
|
|
|
|
|
nav_list.push(users_link) if @nav_dispaly_user_label
|
|
|
|
@ -1797,7 +1797,7 @@ module ApplicationHelper
|
|
|
|
|
nav_list.push(stores_link) if @nav_dispaly_store_all_label
|
|
|
|
|
|
|
|
|
|
content_li = ''
|
|
|
|
|
nav_list.collect do |nav_item|
|
|
|
|
|
nav_list.collect do |nav_item|
|
|
|
|
|
content_li << content_tag(:li, nav_item)
|
|
|
|
|
end
|
|
|
|
|
content_li.html_safe
|
|
|
|
@ -1806,12 +1806,12 @@ module ApplicationHelper
|
|
|
|
|
def current_user
|
|
|
|
|
User.current
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# def hadcommittedforcontest(curu)
|
|
|
|
|
# message = JournalsForMessage.find_by_sql("select * from journals_for_messages where jour_type = 'Softapplication' ")
|
|
|
|
|
# message.each do |createmessage|
|
|
|
|
|
# if createmessage.user_id == curu
|
|
|
|
|
# return true
|
|
|
|
|
# if createmessage.user_id == curu
|
|
|
|
|
# return true
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
@ -1824,11 +1824,12 @@ module ApplicationHelper
|
|
|
|
|
logos.push(link_to image_tag('/images/footer_logo/iscas.png', :alt=>"iscas"), "http://www.iscas.ac.cn" )
|
|
|
|
|
logos.push(link_to image_tag('/images/footer_logo/inforbus.png', :alt=>"inforbus"), "http://www.inforbus.com" )
|
|
|
|
|
|
|
|
|
|
logos.collect! { |logo|
|
|
|
|
|
logos.collect! { |logo|
|
|
|
|
|
content_tag(:li, logo.html_safe, :class => li_class.to_s)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
content_tag(:ul, logos.join("").html_safe, :class => ul_class.to_s).html_safe
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|