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,:scope=>:common) 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 = val || object.instance_eval(field) || "" html << "" desc = t(:example,:scope=>:common) + ": " + 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 << "
" # html << "" # html << "" # html << "
" #end #def nav_to_folders # link_to( t(:folders,:scope=>:folder), :controller=>:folders, :action=>:index ) #end # #def nav_to_messages # link_to( t(:messages,:scope=>:message), :controller=>:messages, :action=>:index ) #end # #def nav_to_compose # link_to( t(:compose,:scope=>:compose), :controller=>:messages, :action=>:compose ) #end # #def nav_to_contacts # link_to( t(:contacts,:scope=>:contact), contacts_path ) #end # #def nav_to_prefs # link_to( t(:prefs,:scope=>:prefs), prefs_look_path ) #end def main_navigation(active) instance_variable_set("@#{active}", "active") s = "" s += "" end def prefs_navigation(active) instance_variable_set("@#{active}", "active") s = "" s += "" 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