diff --git a/app/helpers/admin/seminars_helper.rb b/app/helpers/admin/seminars_helper.rb index 73825f4..3aeed66 100644 --- a/app/helpers/admin/seminars_helper.rb +++ b/app/helpers/admin/seminars_helper.rb @@ -26,8 +26,58 @@ module Admin::SeminarsHelper end def page_for_seminar_url - page = Page.where(:module => 'seminar').first + page = Pag.where(:module => 'seminar').first return request.protocol+(request.host_with_port+"/#{I18n.locale}#{page.url}").gsub('//','/') rescue "/" # return "/#{I18n.locale}#{page.url}/#{seminar.to_param}" end + module MultiLang + extend self + extend ActionView::Helpers::FormTagHelper + extend ActionView::Helpers::FormOptionsHelper + extend ActionView::Helpers::DateHelper + extend ActionView::Helpers::TagHelper + extend ActionView::Helpers::RenderingHelper + extend ActionView::Context + extend OrbitBasis::RenderAnywhere + extend ActionView::Helpers::UrlHelper + extend OrbitFormHelper + extend Ckeditor::Helpers::FormHelper + def get_input_name() + 'seminar_main' + end + def create_lang_panel(field) + tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do + I18n.available_locales.collect do |key| + link_entry_ary = ["##{field}","_#{key}"] + link_entry = link_entry_ary.join + link_to(I18n.t(key),link_entry,:data=>{:toggle=>"tab"},:class=>"btn #{(key == I18n.locale ? "active" : nil)}",:for=>key) + end.join.html_safe + end + end + def multiple_lang_tag(index1,type_of_tag,field,value=nil,custom_options={},combine_element='',exteral_options={},panel_on_top=false) + content_tag(:div,{:class => "tab-content"}.merge(exteral_options)) do + if !index1.nil? + all_field = (get_input_name + "[#{index1}][#{field}][parant]").gsub(/\[/,'_').gsub(/\]/,'') + else + all_field = (get_input_name + "[#{field}][parant]").gsub(/\[/,'_').gsub(/\]/,'') + end + tmp = I18n.available_locales.collect do |locale| + active_flag = ((locale == I18n.locale) ? ' active in' : '') + content_tag(:div,:class => "tab-pane fade#{active_flag}",:id=>"#{all_field}_#{locale}") do + value_locale = value[locale.to_s] rescue nil + if !index1.nil? + self.__send__("#{type_of_tag}_tag","#{get_input_name}[#{index1}][#{field}][#{locale}]",value_locale,custom_options) + else + self.__send__("#{type_of_tag}_tag","#{get_input_name}[#{field}][#{locale}]",value_locale,custom_options) + end + end + end.join + if panel_on_top + create_lang_panel(all_field).html_safe + tmp.html_safe + combine_element + else + (tmp + create_lang_panel(all_field)).html_safe + combine_element + end + end + end + end end \ No newline at end of file diff --git a/app/models/seminar_main.rb b/app/models/seminar_main.rb index 51f7071..7626c28 100644 --- a/app/models/seminar_main.rb +++ b/app/models/seminar_main.rb @@ -7,6 +7,7 @@ class SeminarMain include OrbitCategory::Categorizable include Slug + field :signup_note, localize: true field :title, as: :slug_title, type: String, localize: true field :speaker, localize: true field :content, localize: true diff --git a/app/views/admin/seminars/_form.html.erb b/app/views/admin/seminars/_form.html.erb index a5b975e..378188f 100644 --- a/app/views/admin/seminars/_form.html.erb +++ b/app/views/admin/seminars/_form.html.erb @@ -1,3 +1,6 @@ +<% + multi_helper = Admin::SeminarsHelper::MultiLang +%> <% content_for :page_specific_css do %> <%= stylesheet_link_tag "lib/main-forms" %> <%= stylesheet_link_tag "lib/fileupload" %> @@ -118,6 +121,13 @@ +
+ +
+ <%= multi_helper.multiple_lang_tag(nil,'text_area','signup_note_translations',(@seminar.signup_note_translations rescue {}),{rows: 5, class: "input-block-level ckeditor"},'',{},true) %> +
+
+
diff --git a/app/views/seminars/show.html.erb b/app/views/seminars/show.html.erb index 93009b1..f74e5ac 100644 --- a/app/views/seminars/show.html.erb +++ b/app/views/seminars/show.html.erb @@ -28,6 +28,14 @@ <%= @seminar.title %>
+ <% if !@seminar.signup_note.blank? %> +
+ +
+ <%= @seminar.signup_note.html_safe %> +
+
+ <% end %> <% if @seminar.seminar_signup_field_sets.count != 0 %> <% @seminar.seminar_signup_field_sets.each do |signup_field| %> <% if signup_field.field_name == 'name' %> diff --git a/config/locales/en.yml b/config/locales/en.yml index d5eb7c9..bde6343 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -17,6 +17,7 @@ en: verification_failed: Verification Failed #驗證碼錯誤 seminar: + note: Note email_signup_success: Signup success email_submission_success: Submission registration success email_add_file_success: Add file success diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 9cccecd..bf4891f 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -17,6 +17,7 @@ zh_tw: verification_failed: 驗證碼錯誤 seminar: + note: 附註 email_signup_success: 報名成功 email_submission_success: 投稿註冊成功 email_add_file_success: 新增上傳成功