diff --git a/app/assets/images/evenet_news-default.jpg b/app/assets/images/event_news-default.jpg similarity index 100% rename from app/assets/images/evenet_news-default.jpg rename to app/assets/images/event_news-default.jpg diff --git a/app/controllers/admin/event_news_controller.rb b/app/controllers/admin/event_news_controller.rb index d5b6654..7a3ecd6 100644 --- a/app/controllers/admin/event_news_controller.rb +++ b/app/controllers/admin/event_news_controller.rb @@ -455,6 +455,22 @@ class Admin::EventNewsController < OrbitAdminController end end + def custom_fields_title + @event_news_custom_titles = EventNewsCustomTitle.get_map + end + + def update_custom_title + event_news_custom_title_params = params.require(:event_news_custom_title).permit! + event_news_custom_title_params.each do |k,event_news_custom_title_param| + EventNewsCustomTitle.find(event_news_custom_title_param['id']).update_attributes(event_news_custom_title_param) + end + Thread.new do + content = "UNICORN_PID=\"`fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock` `cat tmp/pids/unicorn.pid `\" && kill -s USR2 $UNICORN_PID ; n=20; while (kill -0 $UNICORN_PID > /dev/null 2>&1) && test $n -ge 0; do printf '.' && sleep 1 && n=$(( $n - 1 )); done ; if test $n -lt 0; then kill -s TERM $UNICORN_PID; sleep 3; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{Rails.env}; else kill -s QUIT $UNICORN_PID; fi" + system(content) + end + redirect_to action: :index + end + private def load_settings diff --git a/app/controllers/event_news_controller.rb b/app/controllers/event_news_controller.rb index c95ca4e..a631490 100644 --- a/app/controllers/event_news_controller.rb +++ b/app/controllers/event_news_controller.rb @@ -68,11 +68,11 @@ class EventNewsController < ApplicationController "extras" => { "widget-title" =>t('event_news.event_news'), "title-head" => t('event_news.table.title'), - "speaker-head" => t('event_news.speaker'), - "place-head" => t('event_news.place'), - "host-head" => t('event_news.host'), + "speaker-head" => EventNewsCustomTitle.get_trans('speaker'), + "place-head" => EventNewsCustomTitle.get_trans('place'), + "host-head" => EventNewsCustomTitle.get_trans('host'), "notes-head" => t('event_news.notes'), - "event_date-head" => t('date_'), + "event_date-head" => EventNewsCustomTitle.get_trans('event_date'), "date-head" => t('event_news.table.date'), "status-head" => t('event_news.table.status'), "author-head" => t('event_news.table.author'), @@ -415,11 +415,11 @@ class EventNewsController < ApplicationController "main_picture" => mp, "main_picture_description" => mpd, "title-head" => t('event_news.table.title'), - "speaker-head" => t('event_news.speaker'), - "place-head" => t('event_news.place'), - "host-head" => t('event_news.host'), + "speaker-head" => EventNewsCustomTitle.get_trans('speaker'), + "place-head" => EventNewsCustomTitle.get_trans('place'), + "host-head" => EventNewsCustomTitle.get_trans('host'), "notes-head" => t('event_news.notes'), - "event_date-head" => t('date_'), + "event_date-head" => EventNewsCustomTitle.get_trans('event_date'), "date-head" => t('event_news.table.date'), "author-head" => t('event_news.table.author'), "status-head" => t('event_news.table.status'), @@ -561,10 +561,11 @@ class EventNewsController < ApplicationController "event_news_links" => links, "event_carousel_images" => event_carousel_images, "data" => { - "speaker-head" => t('event_news.speaker'), - "host-head" => t('event_news.host'), + "speaker-head" => EventNewsCustomTitle.get_trans('speaker'), + "host-head" => EventNewsCustomTitle.get_trans('host'), "notes-head" => t('event_news.notes'), "speaker" => event_news.speaker, + "speaker-css" => (event_news.speaker.blank? ? "display: none;" : "display: inline-block;"), "host" => event_news.host, "notes" => event_news.notes, "title" => event_news.title, @@ -583,7 +584,7 @@ class EventNewsController < ApplicationController "next_btn_title" => next_btn_title, "carousel_display_style" => (event_carousel_images.count == 0 ? 'display: none' : "width: #{event_news.carousel_image_width};margin: auto;"), "carousel_count" => event_carousel_images.count, - "place_text" => (event_news.place.present? rescue false) ? "#{I18n.t("event_news.place")}: #{event_news.place}" : "" + "place_text" => (event_news.place.present? rescue false) ? "#{EventNewsCustomTitle.get_trans("place")}: #{event_news.place}" : "" }, "impressionist" => (event_news.is_preview ? nil : event_news), "url_to_edit"=>url_to_edit @@ -658,10 +659,10 @@ class EventNewsController < ApplicationController "update_user" => update_user, "updated_at" => event_time, "body" => event_news["text_translations"][locale], - "speaker-head" => t('event_news.speaker'), - "host-head" => t('event_news.host'), + "speaker-head" => EventNewsCustomTitle.get_trans('speaker'), + "host-head" => EventNewsCustomTitle.get_trans('host'), "notes-head" => t('event_news.notes'), - "event_date-head" => t('date_'), + "event_date-head" => EventNewsCustomTitle.get_trans('event_date'), "speaker" => (event_news["speaker_translations"][locale].to_s rescue ""), "host" => (event_news["host_translations"][locale].to_s rescue ""), "notes" => (event_news["notes_translations"][locale].to_s rescue ""), @@ -777,10 +778,10 @@ class EventNewsController < ApplicationController "extras" => { "widget-title" =>t('event_news.event_news'), "title-head" => t('event_news.table.title'), - "speaker-head" => t('event_news.speaker'), - "host-head" => t('event_news.host'), + "speaker-head" => EventNewsCustomTitle.get_trans('speaker'), + "host-head" => EventNewsCustomTitle.get_trans('host'), "notes-head" => t('event_news.notes'), - "event_date-head" => t('date_'), + "event_date-head" => EventNewsCustomTitle.get_trans('event_date'), "date-head" => t('event_news.table.date'), "status-head" => t('event_news.table.status'), "author-head" => t('event_news.table.author'), diff --git a/app/helpers/admin/event_news_helper.rb b/app/helpers/admin/event_news_helper.rb index 57a5c6a..4da2df4 100644 --- a/app/helpers/admin/event_news_helper.rb +++ b/app/helpers/admin/event_news_helper.rb @@ -3,6 +3,84 @@ require "uri" require 'json' module Admin::EventNewsHelper + module FormHelper + 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 available_locales + @available_locales = @available_locales || Site.first.in_use_locales || I18n.available_locales + end + def set_input_name(input_name) + @input_name = input_name + end + + def get_input_name + @input_name.to_s + end + def create_lang_panel(field) + tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do + 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={},sortable=false) + 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 = (available_locales.collect do |locale| + active_flag = ((locale == I18n.locale) ? ' in active' : '') + content_tag(:div,:class => "tab-content 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 + create_lang_panel(all_field)).html_safe + combine_element + + if sortable + if exteral_options['style'].nil? + exteral_options['style'] = 'display: flex;align-items: center;flex-wrap: nowrap;' + else + exteral_options['style'] = exteral_options['style'] + 'display: flex;align-items: center;flex-wrap: nowrap;' + end + content_tag(:div,{:class => "tab-panel border"}.merge(exteral_options)) do + ("" +content_tag(:div) do + tmp + end).html_safe + end + else + content_tag(:div,{:class => "tab-panel"}.merge(exteral_options)) do + tmp + end + end + end + end + + def self.thead(field,center=false,enable_sort=true) + sort = field.to_s.include?('.') ? field.to_s.split('.')[1] : field.to_s + active = OrbitHelper.params[:sort].eql? sort + order = active ? (["asc", "desc"]-[OrbitHelper.params[:order]]).first : "asc" + arrow = (order.eql? "desc") ? "" : "" + klass = field.eql?(:title) ? "span5" : "span2" + th_data = (sort=="preview" || !enable_sort) ? EventNewsCustomTitle.get_trans(field) : "#{EventNewsCustomTitle.get_trans(field)} #{active ? arrow : ""}" + "