diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake
index 485db8c8..da664bab 100644
--- a/lib/tasks/migrate.rake
+++ b/lib/tasks/migrate.rake
@@ -141,6 +141,21 @@ namespace :migrate do
end
p 'End NewsBulletinLink'
+ p '====================================================='
+ p '====================================================='
+
+ p 'Start PageContext'
+ page_contexts = PageContext.admin_manager_all
+ i = 1
+ page_contexts.each do |page_context|
+ p "#{i}/#{page_contexts.size} - #{page_context.id}"
+ context = I18nVariable.first(:conditions => {:language_value_id => page_context.id, :language_value_type => page_context.class})
+ page_context.context_translations = {'en' => context['en'], 'zh_tw' => context['zh_tw']} if context
+ page_context.save(:validate => false)
+ i += 1
+ end
+ p 'End PageContext'
+
end
end
diff --git a/vendor/built_in_modules/page_content/app/models/page_context.rb b/vendor/built_in_modules/page_content/app/models/page_context.rb
index be60db27..7c9bde35 100644
--- a/vendor/built_in_modules/page_content/app/models/page_context.rb
+++ b/vendor/built_in_modules/page_content/app/models/page_context.rb
@@ -9,7 +9,7 @@ class PageContext
is_impressionable :counter_cache => { :column_name => :view_count }
- has_one :context, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
+ field :context, localize: true
field :create_user_id
field :update_user_id
@@ -26,7 +26,7 @@ class PageContext
ObjectAuthTitlesOptions = %W{Edit}
def pp_object
- page.i18n_variable[I18n.locale]
+ page.title
end
def is_top?
diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb
index 835b0511..f1dc0822 100644
--- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb
+++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb
@@ -6,7 +6,7 @@
<%= f.label :name %>
- <%= @page_context.page.i18n_variable[I18n.locale] %>
+ <%= @page_context.page.title %>
@@ -23,9 +23,9 @@
<%= f.label :context %>
- <%= f.fields_for :context, (@page_context.new_record? ? @page_context.build_context : @page_context.context ) do |f| %>
+ <%= f.fields_for :context_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
- <%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %>
+ <%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea':value => (@page_context.context_translations[locale] rescue nil) %>
<% end %>
diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb
index d1114a4a..ec61ef53 100644
--- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb
+++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb
@@ -1,7 +1,7 @@
<%= page_context.page.path %>
- <%= page_context.page.i18n_variable[I18n.locale] %>
+ <%= page_context.page.title %>
<%if is_manager? || is_admin? || page_context.authed_users(:edit).include?(current_user)%>
diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_view_page_context.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_view_page_context.html.erb
index 38d83b29..56ec11e3 100644
--- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_view_page_context.html.erb
+++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_view_page_context.html.erb
@@ -2,7 +2,7 @@
- <%= view_page_context.page.i18n_variable[I18n.locale] %>
+ <%= view_page_context.page.title %>
- <%= link_to t('view_page_context.show'), panel_page_content_back_end_page_context_path(view_page_context) %>
diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/show.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/show.html.erb
index 0c681faf..913be983 100644
--- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/show.html.erb
+++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/show.html.erb
@@ -9,11 +9,11 @@
-
<%= t('page_content.name') %>
- <%= @page_context.page.i18n_variable[I18n.locale] %>
+ <%= @page_context.page.title %>
-
<%= t('page_content.context') %>
- <%= @page_context.context[I18n.locale].html_safe %>
+ <%= @page_context.context.html_safe %>
-
<%= t('page_content.張貼者') %>
diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/front_end/page_contexts/index.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/front_end/page_contexts/index.html.erb
index 474ace53..6648b46b 100644
--- a/vendor/built_in_modules/page_content/app/views/panel/page_content/front_end/page_contexts/index.html.erb
+++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/front_end/page_contexts/index.html.erb
@@ -4,8 +4,8 @@
<%= flash_messages %>
<%= dislpay_view_count(@page_context) %>
-<%= @page_context.page.i18n_variable[I18n.locale] rescue nil %>
+<%= @page_context.page.title rescue nil %>
-<%= @page_context.context[I18n.locale].html_safe rescue nil %>
+<%= @page_context.context.html_safe rescue nil %>
| |