@ -36,13 +36,11 @@ module ApplicationHelper
#Added by young
#Define the course menu's link class
# 不是数组的转化成数组, 然后判断当前menu_item是否在给定的列表
# REVIEW: 目测menu的机制, 貌似不是很需要转换, 再说
def link_class ( label )
if current_menu_item == label
@class = 'selected'
else
@class = ''
end
return @class
labels = label . is_a? ( Array ) ? label : ( [ ] << label )
labels . include? ( current_menu_item ) ? 'selected' : ''
end
#Ended by young
# Return true if user is authorized for controller/action, otherwise false
@ -65,7 +63,7 @@ module ApplicationHelper
if user . is_a? ( User )
name = h ( user . name ( options [ :format ] ) )
if user . active? || ( User . current . admin? && user . logged? )
link_to name , { :controller = > 'users' , :action = > 'show' , id : user . id , host : Setting . forge _domain} , :class = > user . css_classes
link_to name , { :controller = > 'users' , :action = > 'show' , id : user . id , host : Setting . user _domain} , :class = > user . css_classes
else
name
end
@ -1479,16 +1477,7 @@ module ApplicationHelper
user . watcher_users . count
end
#end
#author : nyan
def stringCut240 ( str )
( str . length > 240 ) ? ( str [ 0 , 240 ] << " ...... " ) : str
end
#author : xianbo
def objCut12 ( obj )
for obj1 in obj [ 0 .. 11 ]
obj2 = obj1
end
end
def hadcommittedhomework ( cur , curb )
@attaches = HomeworkAttach . find_by_sql ( " select * from homework_attaches where(bid_id = #{ curb } ) " )
@ -1501,29 +1490,35 @@ module ApplicationHelper
def render_dynamic_nav
home_link = link_to l ( :field_homepage ) , { :controller = > 'welcome' , :action = > 'index' }
course_all_course_link = link_to l ( :label_course_all ) , { :controller = > 'projects' , :action = > 'course' , :project_type = > 1 }
course_teacher_all_link = link_to l ( :label_teacher_all ) , { :controller = > 'users' , :action = > 'index' , :role = > 'teacher' }
courses_link = link_to l ( :label_course_practice ) , { :controller = > 'projects' , :action = > 'course' , :project_type = > 1 }
projects_link = link_to l ( :label_project_deposit ) , { :controller = > 'projects' , :action = > 'index' , :project_type = > 0 }
users_link = link_to l ( :label_software_user ) , { :controller = > 'users' , :action = > 'index' }
contest_link = link_to l ( :label_contest_innovate ) , { :controller = > 'bids' , :action = > 'contest' , :project_type = > 1 }
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 }
course_all_course_link = link_to l ( :label_course_all ) , { :controller = > 'projects' , :action = > 'course' , :project_type = > 1 , :host = > Setting . course_domain }
course_teacher_all_link = link_to l ( :label_teacher_all ) , { :controller = > 'users' , :action = > 'index' , :role = > 'teacher' , :host = > Setting . course_domain }
courses_link = link_to l ( :label_course_practice ) , { :controller = > 'projects' , :action = > 'course' , :project_type = > 1 , :host = > Setting . course_domain }
projects_link = link_to l ( :label_project_deposit ) , { :controller = > 'projects' , :action = > 'index' , :project_type = > 0 , :host = > Setting . project_domain }
users_link = link_to l ( :label_software_user ) , { :controller = > 'users' , :action = > 'index' , :host = > Setting . user_domain }
contest_link = link_to l ( :label_contest_innovate ) , { :controller = > 'bids' , :action = > 'contest' , :project_type = > 1 , :host = > Setting . contest_domain }
bids_link = link_to l ( :label_requirement_enterprise ) , { :controller = > 'bids' , :action = > 'index' }
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' }
#@nav_dispaly_project_label
nav_list = Array . new
nav_list . push ( home_link )
nav_list . push ( home_link ) if ! @nav_dispaly_home_path_label
nav_list . push ( course_all_course_link ) if @nav_dispaly_course_all_label
nav_list . push ( course_teacher_all_link ) if @nav_dispaly_teacher_all_label
nav_list . push ( main_project_link ) if @nav_dispaly_main_project_label
nav_list . push ( main_course_link ) if @nav_dispaly_main_course_label
nav_list . push ( courses_link ) if @nav_dispaly_course_label
nav_list . push ( projects_link ) if @nav_dispaly_project_label
nav_list . push ( users_link ) if @nav_dispaly_user_label
nav_list . push ( contest_link ) if @nav_dispaly_contest_label
nav_list . push ( bids_link ) if @nav_dispaly_bid_label
nav_list . push ( forum_link ) if @nav_dispaly_forum_label
nav_list . push ( stores_link ) if ! @nav_dispaly_cours e_all_label
nav_list . push ( stores_link ) if @nav_dispaly_stor e_all_label
content_li = ''
nav_list . collect do | nav_item |