require 'iconv'
module ApplicationHelper
def form_field(object,field,flabel,example,val)
model_name = eval(object.class.model_name)
html = ""
html << "
"
if not object.errors[field.to_sym].empty?
html << "
"
end
html << ""
if not object.errors[field.to_sym].empty?
html << " "
html << object.errors[field.to_sym].to_s
html << ""
html << "
"
end
html << ""
html << ""
html << t(:example)
html << ": "
html << example
html << ""
html << "
"
end
def show_param_view(object,field,value)
model_name = eval(object.class.model_name)
html = ""
html << "
"
html << ""
html << value
html << "
"
html
end
def area_field(object,field,flabel,example,val,cols,rows)
model_name = eval(object.class.model_name)
html = ""
html << "
"
if not object.errors[field.to_sym].empty?
html << "
"
end
html << ""
if not object.errors[field.to_sym].empty?
html << ""
html << object.errors[field.to_sym].to_s
html << ""
html << "
"
end
name = object.class.name.downcase + '[' + field + ']'
id = object.class.name.downcase+"_"+field
value = object.instance_eval(field) || val || ""
html << ""
desc = t(:example) + ": " + example
html << "#{desc}"
html << "
"
end
def form_button(text,image)
html = ""
html << "
"
html << "
"
end
def single_action(text,scope,image)
html = ""
html << "
"
html << "
"
end
def single_action_onclick(text,scope,image,onclick)
html = ""
html << "
"
html << "
"
end
def group_action(buttons)
html = ""
html << "
"
buttons.each do |b|
html << " "
end
html << "
"
end
def group_action_text(buttons,text)
html = ""
html << "
"
buttons.each do |b|
html << " "
end
html << text
html << "
"
end
def form_buttons(buttons)
html = ""
html << "
"
buttons.each do |b|
html << " "
end
html << "
"
end
def form_button_value(text,image,onclick)
html = ""
html << "
"
html << "
"
end
def simple_input_field(name,id,label,value)
html = ""
html << "
"
html << ""
html << ""
html << "
"
end
def select_field(name,object,label,blank)
html = ""
html << "
"
html << ""
html << select(name, name, object.all.collect {|p| [ p.name, p.id ] }, { :include_blank => (blank == true ? true : false)})
html << "
"
end
def select_field_table(object,field,table_choices,choice,blank)
model_name = eval(object.class.model_name)
html = ""
html << "
"
html << ""
html << select(object.class.to_s.downcase, field, options_for_select(table_choices,choice), {:include_blank => blank})
html << "
"
end
def select_field_table_t(object,field,table_choices,choice,blank)
model_name = eval(object.class.model_name)
html = ""
html << "
"
html << ""
t = []
table_choices.each do |c|
t << [t(c.to_sym,:scope=>:prefs),c.to_s]
end
html << select(object.class.to_s.downcase, field, options_for_select(t,choice), {:include_blank => blank})
html << "
"
end
#def form_simle_field(name,label,value)
# html = ""
# html << "
"
end
def multi_select(id, name, objects, selected_objects, label, value,joiner,content = {})
options = ""
objects.each do |o|
selected = selected_objects.include?(o) ? " selected=\"selected\"" : ""
option_value = escape_once(o.send(value))
text = [option_value]
unless content[:text].nil?
text = []
content[:text].each do |t|
text << o.send(t)
end
text = text.join(joiner)
end
text.gsub!(/^\./,'')
bracket = []
unless content[:bracket].nil?
content[:bracket].each do |b|
bracket << o.send(b)
end
bracket = bracket.join(joiner)
end
option_content = bracket.empty? ? "#{text}" : "#{text} (#{bracket})"
options << "\n"
end
""
end
def force_charset(text)
begin
Iconv.iconv("UTF-8",$defaults["msg_unknown_charset"],text)
rescue
text
end
end
def content_for_sidebar
s = render :partial => 'folders/list'
s += render :partial => 'events/calendar'
s += render :partial => 'internal/version'
s
end
end