@ -128,6 +128,24 @@ module ApplicationHelper
end
end
def link_to_isuue_user ( user , options = { } )
if user . is_a? ( User )
name = h ( user . name ( options [ :format ] ) )
link_to name , { :controller = > 'users' , :action = > 'show' , id : user . id , host : Setting . user_domain } , :class = > " pro_info_p "
else
h ( user . to_s )
end
end
def link_to_settings_user ( user , options = { } )
if user . is_a? ( User )
name = h ( user . name ( options [ :format ] ) )
link_to name , { :controller = > 'users' , :action = > 'show' , id : user . id , host : Setting . user_domain } , :class = > " w90 c_orange fl "
else
h ( user . to_s )
end
end
#重载上面方法,增加样式显示
def link_to_user_header user , canShowRealName = false , options = { }
if user . is_a? ( User )
@ -170,6 +188,28 @@ module ApplicationHelper
s
end
def link_to_issue_version ( issue , options = { } )
title = nil
subject = nil
text = options [ :tracker ] == false ? " # #{ issue . id } " : " #{ issue . tracker } # #{ issue . id } "
if options [ :subject ] == false
title = truncate ( issue . subject , :length = > 60 )
else
subject = issue . subject
if options [ :truncate ]
subject = truncate ( subject , :length = > 60 )
end
end
if issue . status_id == 5
s = link_to text , issue_path ( issue ) , :class = > " text_line_s " , :title = > title
else
s = link_to text , issue_path ( issue ) , :class = > " c_blue " , :title = > title
end
s << h ( " : #{ subject } " ) if subject
s = h ( " #{ issue . project } - " ) + s if options [ :project ]
s
end
# Generates a link to an attachment.
# Options:
# * :text - Link text (default to attachment filename)
@ -193,7 +233,7 @@ module ApplicationHelper
route_method = options . delete ( :download ) ? :download_named_attachment_path : :named_attachment_path
html_options = options . slice! ( :only_path )
url = send ( route_method , attachment , attachment . filename , options )
url << " ?token= #{ token } " unless token . nil?
url << " ?token= #{ token } " unless token . nil?
link_to text , url , html_options
end
@ -218,18 +258,18 @@ module ApplicationHelper
h ( text ) ,
{ :controller = > 'repositories' , :action = > 'revision' , :id = > repository . project , :repository_id = > repository . identifier_param , :rev = > rev } ,
:title = > l ( :label_revision_id , format_revision ( revision ) )
)
)
end
# Generates a link to a message
def link_to_message ( message , options = { } , html_options = nil )
link_to (
truncate ( message . subject , :length = > 60 ) ,
board_message_path ( message . board_id , message . parent_id || message . id , {
:r = > ( message . parent_id && message . id ) ,
:anchor = > ( message . parent_id ? " message- #{ message . id } " : nil )
} . merge ( options ) ) ,
html_options
truncate ( message . subject , :length = > 60 ) ,
board_message_path ( message . board_id , message . parent_id || message . id , {
:r = > ( message . parent_id && message . id ) ,
:anchor = > ( message . parent_id ? " message- #{ message . id } " : nil )
} . merge ( options ) ) ,
html_options
)
end
@ -281,8 +321,23 @@ module ApplicationHelper
def thumbnail_tag ( attachment )
link_to image_tag ( thumbnail_path ( attachment ) ) ,
named_attachment_path ( attachment , attachment . filename ) ,
:title = > attachment . filename
named_attachment_path ( attachment , attachment . filename ) ,
:title = > attachment . filename
end
def thumbnail_issue_tag ( attachment )
imagesize = attachment . thumbnail ( :size = > " 200*200 " )
imagepath = named_attachment_path ( attachment , attachment . filename )
if imagesize
link_to image_tag ( thumbnail_path ( attachment ) , height : '73' , width : '100' , name : 'issue_attachment_picture' ) ,
imagepath ,
:title = > attachment . filename
else
link_to image_tag ( imagepath , height : '73' , width : '100' , name : 'issue_attachment_picture' ) ,
imagepath ,
:title = > attachment . filename
end
end
# 图片缩略图链接
@ -310,9 +365,9 @@ module ApplicationHelper
def image_to_function ( name , function , html_options = { } )
html_options . symbolize_keys!
tag ( :input , html_options . merge ( {
:type = > " image " , :src = > image_path ( name ) ,
:onclick = > ( html_options [ :onclick ] ? " #{ html_options [ :onclick ] } ; " : " " ) + " #{ function } ; "
} ) )
:type = > " image " , :src = > image_path ( name ) ,
:onclick = > ( html_options [ :onclick ] ? " #{ html_options [ :onclick ] } ; " : " " ) + " #{ function } ; "
} ) )
end
def format_activity_title ( text )
@ -330,9 +385,9 @@ module ApplicationHelper
def format_version_name ( version )
if version . project == @project
h ( version)
h ( truncate( version. name , :length = > 20 ) )
else
h ( " #{ version . project } - #{ version} " )
h ( " #{ version . project } - #{ truncate( version. name , :length = > 20 ) } " )
end
end
@ -346,7 +401,7 @@ module ApplicationHelper
# The given collection may be a subset of the whole project tree
# (eg. some intermediate nodes are private and can not be seen)
#Modified by nie.
def render_project_nested_lists ( projects )
def render_project_nested_lists ( projects )
s = ''
if projects . any?
ancestors = [ ]
@ -375,9 +430,9 @@ module ApplicationHelper
if project . try ( :project_type ) == Project :: ProjectType_project
unless User . current . member_of? ( @project )
s << " <span style = 'float: right;'> "
s << watcher_link ( @project , User . current ) #, ['whiteButton'])
s << " </span> "
s << " <span style = 'float: right;'> "
s << watcher_link ( @project , User . current ) #, ['whiteButton'])
s << " </span> "
end
s << ( render :partial = > 'projects/project' , :locals = > { :project = > project } ) . to_s
else
@ -390,7 +445,7 @@ module ApplicationHelper
@project = original_project
end
s . html_safe
end
end
def render_course_nested_lists ( courses )
s = ''
@ -425,7 +480,7 @@ module ApplicationHelper
end
#added by young
#added by young
def render_project_nested_lists_new ( projects )
s = ''
if projects . any?
@ -454,7 +509,7 @@ module ApplicationHelper
end
s . html_safe
end
#end
#end
def render_page_hierarchy ( pages , node = nil , options = { } )
content = ''
if pages [ node ]
@ -489,14 +544,22 @@ module ApplicationHelper
end
end
def render_project_settings_tabs ( tabs )
if tabs . any?
render :partial = > 'common/project_tab' , :locals = > { :tabs = > tabs }
else
content_tag 'p' , l ( :label_no_data ) , :class = > " nodata "
end
end
# Renders the project quick-jump box
def render_project_jump_box
return unless User . current . logged?
projects = User . current . memberships . collect ( & :project ) . compact . select ( & :active? ) . uniq
if projects . any?
options =
( " <option value=''> #{ l ( :label_jump_to_a_project ) } </option> " +
'<option value="" disabled="disabled">---</option>' ) . html_safe
( " <option value=''> #{ l ( :label_jump_to_a_project ) } </option> " +
'<option value="" disabled="disabled">---</option>' ) . html_safe
options << project_tree_options_for_select ( projects , :selected = > @project ) do | p |
{ :value = > project_path ( :id = > p , :jump = > current_menu_item ) }
@ -547,6 +610,17 @@ module ApplicationHelper
s . html_safe
end
#缺陷追踪者列表复选框生成
def issue_watcher_check_box_tags_ex name , principals
s = ''
principals . each do | principal |
s << " <li> #{ check_box_tag name , principal . id , false , :id = > nil } #{ h link_to principal . userInfo , user_path ( principal . id ) } </li> \n "
end
s . html_safe
end
#扩展的checkbox生成
def principals_check_box_tags_ex ( name , principals )
s = ''
@ -556,6 +630,15 @@ module ApplicationHelper
s . html_safe
end
# li标签checkbos扩展
def principals_check_box_tags_li ( name , principals )
s = ''
principals . each do | principal |
s << " <li> #{ check_box_tag name , principal . id , false , :id = > nil } #{ h link_to principal . userInfo , user_path ( principal . id ) } </li> \n "
end
s . html_safe
end
#扩展的checkbox生成
def principals_radio_box_tags_ex ( name , principals )
s = ''
@ -666,24 +749,24 @@ module ApplicationHelper
link_to ( image_tag ( '2uparrow.png' , :alt = > l ( :label_sort_highest ) ) ,
url . merge ( { " #{ name } [move_to] " = > 'highest' } ) ,
:method = > method , :title = > l ( :label_sort_highest ) ) +
link_to ( image_tag ( '1uparrow.png' , :alt = > l ( :label_sort_higher ) ) ,
url . merge ( { " #{ name } [move_to] " = > 'higher' } ) ,
:method = > method , :title = > l ( :label_sort_higher ) ) +
link_to ( image_tag ( '1downarrow.png' , :alt = > l ( :label_sort_lower ) ) ,
url . merge ( { " #{ name } [move_to] " = > 'lower' } ) ,
:method = > method , :title = > l ( :label_sort_lower ) ) +
link_to ( image_tag ( '2downarrow.png' , :alt = > l ( :label_sort_lowest ) ) ,
url . merge ( { " #{ name } [move_to] " = > 'lowest' } ) ,
:method = > method , :title = > l ( :label_sort_lowest ) )
link_to ( image_tag ( '1uparrow.png' , :alt = > l ( :label_sort_higher ) ) ,
url . merge ( { " #{ name } [move_to] " = > 'higher' } ) ,
:method = > method , :title = > l ( :label_sort_higher ) ) +
link_to ( image_tag ( '1downarrow.png' , :alt = > l ( :label_sort_lower ) ) ,
url . merge ( { " #{ name } [move_to] " = > 'lower' } ) ,
:method = > method , :title = > l ( :label_sort_lower ) ) +
link_to ( image_tag ( '2downarrow.png' , :alt = > l ( :label_sort_lowest ) ) ,
url . merge ( { " #{ name } [move_to] " = > 'lowest' } ) ,
:method = > method , :title = > l ( :label_sort_lowest ) )
end
def breadcrumb ( * args )
elements = args . flatten
elements . any? ? content_tag ( 'p' , ( args . join ( " \xc2 \xbb " ) + " \xc2 \xbb " ) . html_safe , :class = > ' breadcrumb ') : nil
elements . any? ? content_tag ( 'p' , ( args . join ( " \xc2 \xbb " ) + " \xc2 \xbb " ) . html_safe , :class = > ' wiki_con_tit" ') : nil
end
def other_formats_links ( & block )
concat ( '<p class="other-formats ">'. html_safe + l ( :label_export_to ) )
concat ( '<p class="other-formats fl ">'. html_safe + l ( :label_export_to ) )
yield Redmine :: Views :: OtherFormatsBuilder . new ( self )
concat ( '</p>' . html_safe )
end
@ -758,15 +841,15 @@ module ApplicationHelper
def textilizable ( * args )
options = args . last . is_a? ( Hash ) ? args . pop : { }
case args . size
when 1
obj = options [ :object ]
text = args . shift
when 2
obj = args . shift
attr = args . shift
text = obj . send ( attr ) . to_s
else
raise ArgumentError , 'invalid arguments to textilizable'
when 1
obj = options [ :object ]
text = args . shift
when 2
obj = args . shift
attr = args . shift
text = obj . send ( attr ) . to_s
else
raise ArgumentError , 'invalid arguments to textilizable'
end
return '' if text . blank?
project = options [ :project ] || @project || ( obj && obj . respond_to? ( :project ) ? obj . project : nil )
@ -922,18 +1005,18 @@ module ApplicationHelper
# check if page exists
wiki_page = link_project . wiki . find_page ( page )
url = if anchor . present? && wiki_page . present? && ( obj . is_a? ( WikiContent ) || obj . is_a? ( WikiContent :: Version ) ) && obj . page == wiki_page
" # #{ anchor } "
else
case options [ :wiki_links ]
when :local ; " #{ page . present? ? Wiki . titleize ( page ) : '' } .html " + ( anchor . present? ? " # #{ anchor } " : '' )
when :anchor ; " # #{ page . present? ? Wiki . titleize ( page ) : title } " + ( anchor . present? ? " _ #{ anchor } " : '' ) # used for single-file wiki export
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 ,
:id = > wiki_page_id , :version = > nil , :anchor = > anchor , :parent = > parent )
end
end
" # #{ anchor } "
else
case options [ :wiki_links ]
when :local ; " #{ page . present? ? Wiki . titleize ( page ) : '' } .html " + ( anchor . present? ? " # #{ anchor } " : '' )
when :anchor ; " # #{ page . present? ? Wiki . titleize ( page ) : title } " + ( anchor . present? ? " _ #{ anchor } " : '' ) # used for single-file wiki export
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 ,
:id = > wiki_page_id , :version = > nil , :anchor = > anchor , :parent = > parent )
end
end
link_to ( title . present? ? title . html_safe : h ( page ) , url , :class = > ( 'wiki-page' + ( wiki_page ? '' : ' new' ) ) )
else
# project or wiki doesn't exist
@ -1008,110 +1091,110 @@ module ApplicationHelper
# project.changesets.visible raises an SQL error because of a double join on repositories
if repository && ( changeset = Changeset . visible . find_by_repository_id_and_revision ( repository . id , identifier ) )
link = link_to ( h ( " #{ project_prefix } #{ repo_prefix } r #{ identifier } " ) , { :only_path = > only_path , :controller = > 'repositories' , :action = > 'revision' , :id = > project , :repository_id = > repository . identifier_param , :rev = > changeset . revision } ,
:class = > 'changeset' ,
:title = > truncate_single_line ( changeset . comments , :length = > 100 ) )
:class = > 'changeset' ,
:title = > truncate_single_line ( changeset . comments , :length = > 100 ) )
end
end
elsif sep == '#'
oid = identifier . to_i
case prefix
when nil
if oid . to_s == identifier && issue = Issue . visible . find_by_id ( oid , :include = > :status )
anchor = comment_id ? " note- #{ comment_id } " : nil
link = link_to ( " # #{ oid } " , { :only_path = > only_path , :controller = > 'issues' , :action = > 'show' , :id = > oid , :anchor = > anchor } ,
:class = > issue . css_classes ,
:title = > " #{ truncate ( issue . subject , :length = > 100 ) } ( #{ issue . status . name } ) " )
end
when 'document'
if document = Document . visible . find_by_id ( oid )
link = link_to h ( document . title ) , { :only_path = > only_path , :controller = > 'documents' , :action = > 'show' , :id = > document } ,
:class = > 'document'
end
when 'version'
if version = Version . visible . find_by_id ( oid )
link = link_to h ( version . name ) , { :only_path = > only_path , :controller = > 'versions' , :action = > 'show' , :id = > version } ,
:class = > 'version'
end
when 'message'
if message = Message . visible . find_by_id ( oid , :include = > :parent )
link = link_to_message ( message , { :only_path = > only_path } , :class = > 'message' )
end
when 'forum'
if board = Board . visible . find_by_id ( oid )
link = link_to h ( board . name ) , { :only_path = > only_path , :controller = > 'boards' , :action = > 'show' , :id = > board , :project_id = > board . project } ,
:class = > 'board'
end
when 'news'
if news = News . visible . find_by_id ( oid )
link = link_to h ( news . title ) , { :only_path = > only_path , :controller = > 'news' , :action = > 'show' , :id = > news } ,
:class = > 'news'
end
when 'project'
if p = Project . visible . find_by_id ( oid )
link = link_to_project ( p , { :only_path = > only_path } , :class = > 'project' )
end
when nil
if oid . to_s == identifier && issue = Issue . visible . find_by_id ( oid , :include = > :status )
anchor = comment_id ? " note- #{ comment_id } " : nil
link = link_to ( " # #{ oid } " , { :only_path = > only_path , :controller = > 'issues' , :action = > 'show' , :id = > oid , :anchor = > anchor } ,
:class = > issue . css_classes ,
:title = > " #{ truncate ( issue . subject , :length = > 100 ) } ( #{ issue . status . name } ) " )
end
when 'document'
if document = Document . visible . find_by_id ( oid )
link = link_to h ( document . title ) , { :only_path = > only_path , :controller = > 'documents' , :action = > 'show' , :id = > document } ,
:class = > 'document'
end
when 'version'
if version = Version . visible . find_by_id ( oid )
link = link_to h ( version . name ) , { :only_path = > only_path , :controller = > 'versions' , :action = > 'show' , :id = > version } ,
:class = > 'version'
end
when 'message'
if message = Message . visible . find_by_id ( oid , :include = > :parent )
link = link_to_message ( message , { :only_path = > only_path } , :class = > 'message' )
end
when 'forum'
if board = Board . visible . find_by_id ( oid )
link = link_to h ( board . name ) , { :only_path = > only_path , :controller = > 'boards' , :action = > 'show' , :id = > board , :project_id = > board . project } ,
:class = > 'board'
end
when 'news'
if news = News . visible . find_by_id ( oid )
link = link_to h ( news . title ) , { :only_path = > only_path , :controller = > 'news' , :action = > 'show' , :id = > news } ,
:class = > 'news'
end
when 'project'
if p = Project . visible . find_by_id ( oid )
link = link_to_project ( p , { :only_path = > only_path } , :class = > 'project' )
end
end
elsif sep == ':'
# removes the double quotes if any
name = identifier . gsub ( %r{ ^"(.*)"$ } , " \\ 1 " )
case prefix
when 'document'
if project && document = project . documents . visible . find_by_title ( name )
link = link_to h ( document . title ) , { :only_path = > only_path , :controller = > 'documents' , :action = > 'show' , :id = > document } ,
:class = > 'document'
end
when 'version'
if project && version = project . versions . visible . find_by_name ( name )
link = link_to h ( version . name ) , { :only_path = > only_path , :controller = > 'versions' , :action = > 'show' , :id = > version } ,
:class = > 'version'
end
when 'forum'
if project && board = project . boards . visible . find_by_name ( name )
link = link_to h ( board . name ) , { :only_path = > only_path , :controller = > 'boards' , :action = > 'show' , :id = > board , :project_id = > board . project } ,
:class = > 'board'
end
when 'news'
if project && news = project . news . visible . find_by_title ( name )
link = link_to h ( news . title ) , { :only_path = > only_path , :controller = > 'news' , :action = > 'show' , :id = > news } ,
:class = > 'news'
end
when 'commit' , 'source' , 'export'
if project
repository = nil
if name =~ %r{ ^(([a-z0-9 \ -_]+) \ |)(.+)$ }
repo_prefix , repo_identifier , name = $1 , $2 , $3
repository = project . repositories . detect { | repo | repo . identifier == repo_identifier }
else
repository = project . repository
when 'document'
if project && document = project . documents . visible . find_by_title ( name )
link = link_to h ( document . title ) , { :only_path = > only_path , :controller = > 'documents' , :action = > 'show' , :id = > document } ,
:class = > 'document'
end
when 'version'
if project && version = project . versions . visible . find_by_name ( name )
link = link_to h ( version . name ) , { :only_path = > only_path , :controller = > 'versions' , :action = > 'show' , :id = > version } ,
:class = > 'version'
end
when 'forum'
if project && board = project . boards . visible . find_by_name ( name )
link = link_to h ( board . name ) , { :only_path = > only_path , :controller = > 'boards' , :action = > 'show' , :id = > board , :project_id = > board . project } ,
:class = > 'board'
end
when 'news'
if project && news = project . news . visible . find_by_title ( name )
link = link_to h ( news . title ) , { :only_path = > only_path , :controller = > 'news' , :action = > 'show' , :id = > news } ,
:class = > 'news'
end
if prefix == 'commit'
if repository && ( changeset = Changeset . visible . where ( " repository_id = ? AND scmid LIKE ? " , repository . id , " #{ name } % " ) . first )
link = link_to h ( " #{ project_prefix } #{ repo_prefix } #{ name } " ) , { :only_path = > only_path , :controller = > 'repositories' , :action = > 'revision' , :id = > project , :repository_id = > repository . identifier_param , :rev = > changeset . identifier } ,
:class = > 'changeset' ,
:title = > truncate_single_line ( changeset . comments , :length = > 100 )
when 'commit' , 'source' , 'export'
if project
repository = nil
if name =~ %r{ ^(([a-z0-9 \ -_]+) \ |)(.+)$ }
repo_prefix , repo_identifier , name = $1 , $2 , $3
repository = project . repositories . detect { | repo | repo . identifier == repo_identifier }
else
repository = project . repository
end
else
if repository && User . current . allowed_to? ( :browse_repository , project )
name =~ %r{ ^[/ \\ ]*(.*?)(@([^/ \\ @]+?))?( # (L \ d+))?$ }
path , rev , anchor = $1 , $3 , $5
link = link_to h ( " #{ project_prefix } #{ prefix } : #{ repo_prefix } #{ name } " ) , { :controller = > 'repositories' , :action = > ( prefix == 'export' ? 'raw' : 'entry' ) , :id = > project , :repository_id = > repository . identifier_param ,
:path = > to_path_param ( path ) ,
:rev = > rev ,
:anchor = > anchor } ,
:class = > ( prefix == 'export' ? 'source download' : 'source' )
if prefix == 'commit'
if repository && ( changeset = Changeset . visible . where ( " repository_id = ? AND scmid LIKE ? " , repository . id , " #{ name } % " ) . first )
link = link_to h ( " #{ project_prefix } #{ repo_prefix } #{ name } " ) , { :only_path = > only_path , :controller = > 'repositories' , :action = > 'revision' , :id = > project , :repository_id = > repository . identifier_param , :rev = > changeset . identifier } ,
:class = > 'changeset' ,
:title = > truncate_single_line ( changeset . comments , :length = > 100 )
end
else
if repository && User . current . allowed_to? ( :browse_repository , project )
name =~ %r{ ^[/ \\ ]*(.*?)(@([^/ \\ @]+?))?( # (L \ d+))?$ }
path , rev , anchor = $1 , $3 , $5
link = link_to h ( " #{ project_prefix } #{ prefix } : #{ repo_prefix } #{ name } " ) , { :controller = > 'repositories' , :action = > ( prefix == 'export' ? 'raw' : 'entry' ) , :id = > project , :repository_id = > repository . identifier_param ,
:path = > to_path_param ( path ) ,
:rev = > rev ,
:anchor = > anchor } ,
:class = > ( prefix == 'export' ? 'source download' : 'source' )
end
end
repo_prefix = nil
end
when 'attachment'
attachments = options [ :attachments ] || ( obj && obj . respond_to? ( :attachments ) ? obj . attachments : nil )
if attachments && attachment = Attachment . latest_attach ( attachments , name )
link = link_to_attachment ( attachment , :only_path = > only_path , :download = > true , :class = > 'attachment' )
end
when 'project'
if p = Project . visible . where ( " identifier = :s OR LOWER(name) = :s " , :s = > name . downcase ) . first
link = link_to_project ( p , { :only_path = > only_path } , :class = > 'project' )
end
repo_prefix = nil
end
when 'attachment'
attachments = options [ :attachments ] || ( obj && obj . respond_to? ( :attachments ) ? obj . attachments : nil )
if attachments && attachment = Attachment . latest_attach ( attachments , name )
link = link_to_attachment ( attachment , :only_path = > only_path , :download = > true , :class = > 'attachment' )
end
when 'project'
if p = Project . visible . where ( " identifier = :s OR LOWER(name) = :s " , :s = > name . downcase ) . first
link = link_to_project ( p , { :only_path = > only_path } , :class = > 'project' )
end
end
end
end
@ -1128,9 +1211,9 @@ module ApplicationHelper
@current_section += 1
if @current_section > 1
content_tag ( 'div' ,
link_to ( image_tag ( 'edit.png' ) , options [ :edit_section_links ] . merge ( :section = > @current_section ) ) ,
:class = > 'contextual' ,
:title = > l ( :button_edit_section ) ) + heading . html_safe
link_to ( image_tag ( 'edit.png' ) , options [ :edit_section_links ] . merge ( :section = > @current_section ) ) ,
:class = > 'contextual' ,
:title = > l ( :button_edit_section ) ) + heading . html_safe
else
heading
end
@ -1249,10 +1332,10 @@ module ApplicationHelper
# Same as Rails' simple_format helper without using paragraphs
def simple_format_without_paragraph ( text )
text . to_s .
gsub ( / \ r \ n? / , " \n " ) . # \r\n and \r -> \n
gsub ( / \ n \ n+ / , " <br /><br /> " ) . # 2+ newline -> 2 br
gsub ( / ([^ \ n] \ n)(?=[^ \ n]) / , '\1<br />' ) . # 1 newline -> br
html_safe
gsub ( / \ r \ n? / , " \n " ) . # \r\n and \r -> \n
gsub ( / \ n \ n+ / , " <br /><br /> " ) . # 2+ newline -> 2 br
gsub ( / ([^ \ n] \ n)(?=[^ \ n]) / , '\1<br />' ) . # 1 newline -> br
html_safe
end
def wiki_simple_format_without_paragraph ( text )
@ -1267,7 +1350,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 = { } )
@ -1334,9 +1417,31 @@ module ApplicationHelper
def delete_link ( url , options = { } )
options = {
:method = > :delete ,
:data = > { :confirm = > l ( :text_are_you_sure ) } ,
:class = > 'icon icon-del'
:method = > :delete ,
:data = > { :confirm = > l ( :text_are_you_sure ) } ,
:class = > 'icon icon-del'
} . merge ( options )
link_to l ( :button_delete ) , url , options
end
def delete_link_version ( url , options = { } )
options = {
:method = > :delete ,
:data = > { :confirm = > l ( :text_are_you_sure ) } ,
:class = > 'c_purple'
} . merge ( options )
link_to l ( :button_delete ) , url , options
end
def delete_new_link ( url , options = { } )
options = {
:method = > :delete ,
:data = > { :confirm = > l ( :text_are_you_sure ) } ,
:class = > " c_purple "
} . merge ( options )
link_to l ( :button_delete ) , url , options
@ -1347,11 +1452,11 @@ module ApplicationHelper
:href = > " # " ,
:onclick = > %|submitPreview("#{escape_javascript url_for(url)}", "#{escape_javascript form}", "#{escape_javascript target}"); return false;| ,
:accesskey = > accesskey ( :preview )
} . merge ( options )
} . merge ( options )
end
def link_to_function ( name , function , html_options = { } )
content_tag ( :a , name , { :href = > '#' , :onclick = > " #{ function } ; return false; " } . merge ( html_options ) )
content_tag ( :a , name , { :href = > '#' , :onclick = > " #{ function } ; return false; " } . merge ( :class = > " c_purple " ) )
end
# Helper to render JSON in views
@ -1373,9 +1478,8 @@ module ApplicationHelper
end
def check_all_links ( form_name )
link_to_function ( l ( :button_check_all ) , " checkAll(' #{ form_name } ', true) " ) +
" | " . html_safe +
link_to_function ( l ( :button_uncheck_all ) , " checkAll(' #{ form_name } ', false) " )
link_to_function ( l ( :button_check_all ) , " checkAll(' #{ form_name } ', true) " ) + " " . html_safe + " | " + " " . html_safe +
link_to_function ( l ( :button_uncheck_all ) , " checkAll(' #{ form_name } ', false) " )
end
def progress_bar ( pcts , options = { } )
@ -1386,12 +1490,12 @@ module ApplicationHelper
width = options [ :width ] || '100px;'
legend = options [ :legend ] || ''
content_tag ( 'table' ,
content_tag ( 'tr' ,
( pcts [ 0 ] > 0 ? content_tag ( 'td' , '' , :style = > " width: #{ pcts [ 0 ] } %; " , :class = > 'closed' ) : '' . html_safe ) +
( pcts [ 1 ] > 0 ? content_tag ( 'td' , '' , :style = > " width: #{ pcts [ 1 ] } %; " , :class = > 'done' ) : '' . html_safe ) +
( pcts [ 2 ] > 0 ? content_tag ( 'td' , '' , :style = > " width: #{ pcts [ 2 ] } %; " , :class = > 'todo' ) : '' . html_safe )
) , :class = > 'progress' , :style = > " width: #{ width } ; " ) . html_safe +
content_tag ( 'p' , legend , :class = > 'percent' ) . html_safe
content_tag ( 'tr' ,
( pcts [ 0 ] > 0 ? content_tag ( 'td' , '' , :style = > " width: #{ pcts [ 0 ] } %; " , :class = > 'closed' ) : '' . html_safe ) +
( pcts [ 1 ] > 0 ? content_tag ( 'td' , '' , :style = > " width: #{ pcts [ 1 ] } %; " , :class = > 'done' ) : '' . html_safe ) +
( pcts [ 2 ] > 0 ? content_tag ( 'td' , '' , :style = > " width: #{ pcts [ 2 ] } %; " , :class = > 'todo' ) : '' . html_safe )
) , :class = > 'progress' , :style = > " width: #{ width } ; " ) . html_safe +
content_tag ( 'p' , legend , :class = > 'percent' ) . html_safe
end
def checked_image ( checked = true )
@ -1404,7 +1508,7 @@ module ApplicationHelper
unless @context_menu_included
content_for :header_tags do
javascript_include_tag ( 'context_menu' ) +
stylesheet_link_tag ( 'context_menu' )
stylesheet_link_tag ( 'context_menu' )
end
if l ( :direction ) == 'rtl'
content_for :header_tags do
@ -1435,7 +1539,7 @@ module ApplicationHelper
tags = javascript_tag (
" var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{ start_of_week } , " +
" showOn: 'button', buttonImageOnly: true, buttonImage: ' " +
path_to_image ( '/images/ calendar .png') +
path_to_image ( '/images/ public_icon .png') +
" ', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true}; " )
jquery_locale = l ( 'jquery.locale' , :default = > current_language . to_s )
unless jquery_locale == 'en'
@ -1457,7 +1561,7 @@ module ApplicationHelper
tags = javascript_tag (
" var datepickerOptions={dateFormat: 'yy-mm-dd',minDate: new Date(), firstDay: #{ start_of_week } , " +
" showOn: 'button', buttonImageOnly: true, buttonImage: ' " +
path_to_image ( '/images/ calendar .png') +
path_to_image ( '/images/ public_icon .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'
@ -1717,6 +1821,17 @@ module ApplicationHelper
candown
end
def project_type_link ( text , value )
if value == 1
link_to " <span class='pr_kafa'></span> #{ text } " . html_safe , " javascript:void(0) " , :onClick = > " show_window(); " , :class = > " pr_join_a " , :id = > " setting_project_type "
elsif value == 2
link_to " <span class='pr_keyan'></span> #{ text } " . html_safe , " javascript:void(0) " , :onClick = > " show_window(); " , :class = > " pr_join_a " , :id = > " setting_project_type "
else
link_to " <span class='pr_friend'></span> #{ text } " . html_safe , " javascript:void(0) " , :onClick = > " show_window(); " , :class = > " pr_join_a " , :id = > " setting_project_type "
end
end
private
def wiki_helper
@ -1746,11 +1861,11 @@ module ApplicationHelper
html << ( content_tag " span " , l ( :label_no_current_watchers ) )
end
for user in User . watched_by ( obj . id )
html << ( link_to image_tag ( url_to_avatar ( user ) , :class = > " avatar " ) , user_path ( user ) , :class = > " avatar " , :title = > " #{ user . name } " )
count = count + 1
if count > = 12
break
end
html << ( link_to image_tag ( url_to_avatar ( user ) , :class = > " avatar " ) , user_path ( user ) , :class = > " avatar " , :title = > " #{ user . name } " )
count = count + 1
if count > = 12
break
end
end
html . html_safe
end
@ -1776,13 +1891,13 @@ module ApplicationHelper
html . html_safe
end
def show_bid_fans_picture ( obj )
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 |
html << ( link_to image_tag ( url_to_avatar ( user ) , :class = > " avatar " ) , user_path ( user ) , :class = > " avatar " , :title = > user . name )
html << ( link_to image_tag ( url_to_avatar ( user ) , :class = > " avatar " ) , user_path ( user ) , :class = > " avatar " , :title = > user . name )
end
end
html . html_safe
@ -1817,7 +1932,7 @@ module ApplicationHelper
html . html_safe
end
def show_contest_project ( contest )
def show_contest_project ( contest )
html = ''
if contest . projects . where ( 'is_public = 1' ) . count == 0
html << ( content_tag " p " , l ( :label_no_bid_project ) , :class = > " font_lighter " )
@ -1829,7 +1944,7 @@ module ApplicationHelper
html . html_safe
end
def show_contest_softapplication ( contest )
def show_contest_softapplication ( contest )
html = ''
if contest . softapplications . where ( 'is_public = 1' ) . count == 0
html << ( content_tag " p " , l ( :label_no_contest_softapplication ) , :class = > " font_lighter " )
@ -1841,17 +1956,17 @@ module ApplicationHelper
html . html_safe
end
def show_contest_fans_picture ( obj )
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 |
html << ( link_to image_tag ( url_to_avatar ( user ) , :class = > " avatar " ) , user_path ( user ) , :class = > " avatar " , :title = > user . name )
html << ( link_to image_tag ( url_to_avatar ( user ) , :class = > " avatar " ) , user_path ( user ) , :class = > " avatar " , :title = > user . name )
end
end
html . html_safe
end
end
#display fans picture
def show_more_fans? ( obj )
@ -1868,13 +1983,13 @@ module ApplicationHelper
html << ( content_tag " span " , l ( :label_no_current_fans ) )
else
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 )
html << ( link_to image_tag ( url_to_avatar ( user ) , :class = > " avatar " ) , user_path ( user ) , :class = > " avatar " , :title = > user . name )
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
@ -1883,18 +1998,18 @@ module ApplicationHelper
end
end
def show_participate_picture ( obj )
def show_participate_picture ( obj )
html = ''
count = 0
if obj . join_in_contests . count == 0
html << ( content_tag " span " , l ( :label_no_current_participate ) )
end
for temp in obj . join_in_contests
html << ( link_to image_tag ( url_to_avatar ( temp . user ) , :class = > " avatar " ) , user_path ( temp . user ) , :class = > " avatar " , :title = > " #{ temp . user . name } " )
count = count + 1
if count > = 12
break
end
html << ( link_to image_tag ( url_to_avatar ( temp . user ) , :class = > " avatar " ) , user_path ( temp . user ) , :class = > " avatar " , :title = > " #{ temp . user . name } " )
count = count + 1
if count > = 12
break
end
end
html . html_safe
end
@ -1903,14 +2018,14 @@ module ApplicationHelper
# add by huang
def show_watcher_list ( user )
html = ''
count = 0
html = ''
count = 0
for user in User . watched_by ( user . id )
html << ( link_to image_tag ( url_to_avatar ( user ) , :class = > " avatar " ) , user_path ( user ) , :class = > " avatar " , :title = > " #{ user . name } " )
count = count + 1
if count > = 12
break
end
html << ( link_to image_tag ( url_to_avatar ( user ) , :class = > " avatar " ) , user_path ( user ) , :class = > " avatar " , :title = > " #{ user . name } " )
count = count + 1
if count > = 12
break
end
end
html . html_safe
end
@ -1928,14 +2043,14 @@ module ApplicationHelper
return true if bid . nil?
case bid . homework_type
when Bid :: HomeworkFile
attaches = HomeworkAttach . where ( bid_id : curb )
attaches . map ( & :user_id ) . include? cur
when Bid :: HomeworkProject
attaches = BidingProject . where ( user_id : User . current , bid_id : bid )
attaches . count > 0 # > 0 则有提交记录
else
true
when Bid :: HomeworkFile
attaches = HomeworkAttach . where ( bid_id : curb )
attaches . map ( & :user_id ) . include? cur
when Bid :: HomeworkProject
attaches = BidingProject . where ( user_id : User . current , bid_id : bid )
attaches . count > 0 # > 0 则有提交记录
else
true
end
end
@ -1964,6 +2079,8 @@ module ApplicationHelper
forum_link = link_to l ( :label_forum_all ) , { :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' }
project_new_link = link_to l ( :label_project_new ) , { :controller = > 'projects' , :action = > 'new' , :host = > Setting . project_domain }
# project_mine_link = link_to l(:label_my_project), {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain}
#@nav_dispaly_project_label
nav_list = Array . new
@ -1976,6 +2093,8 @@ module ApplicationHelper
nav_list . push ( main_contest_link ) if @nav_dispaly_main_contest_label && @show_contest == 1 && visiable
nav_list . push ( courses_link ) if @nav_dispaly_course_label && @show_course == 1 && visiable
nav_list . push ( project_new_link ) if @nav_dispaly_project_label
# nav_list.push(project_mine_link) if @nav_dispaly_main_project_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 && @show_contest == 1
@ -1995,12 +2114,12 @@ module ApplicationHelper
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
# end
# end
# 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
# end
# end
# end
def footer_logo ( ul_class = nil , li_class = nil )
@ -2020,16 +2139,16 @@ module ApplicationHelper
def sort_homework_path ( bid , sort , direction )
case self . action_name
when 'show_courseEx'
get_not_batch_homework_homework_attach_index_path ( bid_id : bid . id , sort : sort , direction : 'asc' )
when 'get_not_batch_homework'
get_not_batch_homework_homework_attach_index_path ( bid_id : bid . id , sort : sort , direction : direction )
when 'get_batch_homeworks'
get_batch_homeworks_homework_attach_index_path ( bid_id : bid . id , sort : sort , direction : direction )
when 'get_homeworks'
get_homeworks_homework_attach_index_path ( bid_id : bid . id , sort : sort , direction : direction )
else
'#'
when 'show_courseEx'
get_not_batch_homework_homework_attach_index_path ( bid_id : bid . id , sort : sort , direction : 'asc' )
when 'get_not_batch_homework'
get_not_batch_homework_homework_attach_index_path ( bid_id : bid . id , sort : sort , direction : direction )
when 'get_batch_homeworks'
get_batch_homeworks_homework_attach_index_path ( bid_id : bid . id , sort : sort , direction : direction )
when 'get_homeworks'
get_homeworks_homework_attach_index_path ( bid_id : bid . id , sort : sort , direction : direction )
else
'#'
end
end