fix error
This commit is contained in:
parent
10590cf08d
commit
858f3f8b85
|
@ -161,15 +161,19 @@ class Admin::AsksController < OrbitAdminController
|
||||||
custom_exist_nums = []
|
custom_exist_nums = []
|
||||||
custom_exists = text.scan(/{custom\d+}/)
|
custom_exists = text.scan(/{custom\d+}/)
|
||||||
custom_exists.each do |custom_exist|
|
custom_exists.each do |custom_exist|
|
||||||
k = custom_exist[6...-1]
|
k = custom_exist[6...-1].to_i - 1
|
||||||
custom_exist_nums << k
|
custom_exist_nums << k
|
||||||
end
|
end
|
||||||
customs.each do |custom|
|
customs.each do |custom|
|
||||||
tmp = custom_fields.keys.select{|key| custom_exist_nums.exclude? key}.collect do |k|
|
tmp = custom_fields.keys.collect.with_index do |k,i|
|
||||||
tp = custom.gsub(/{custom}/,"{custom#{k}}")
|
if custom_exist_nums.exclude?(i)
|
||||||
tp = tp.gsub(/{custom_title}/,"{custom#{k}_title}")
|
tp = custom.gsub(/{custom}/,"{custom#{i+1}}")
|
||||||
tp
|
tp = tp.gsub(/{custom_title}/,"{custom#{i+1}_title}")
|
||||||
end.join
|
tp
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end.compact.join
|
||||||
text = text.gsub(custom,tmp)
|
text = text.gsub(custom,tmp)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -178,10 +182,10 @@ class Admin::AsksController < OrbitAdminController
|
||||||
if format_text[-7...-1] == '_title'
|
if format_text[-7...-1] == '_title'
|
||||||
case format_text[1...-7]
|
case format_text[1...-7]
|
||||||
when /custom\d+/
|
when /custom\d+/
|
||||||
i = format_text.scan(/\d+/)[0]
|
i = format_text.scan(/\d+/)[0].to_i - 1
|
||||||
k = custom_fields.keys.index(i) rescue nil
|
k = custom_fields.keys[i] rescue nil
|
||||||
if !k.blank?
|
if !k.blank?
|
||||||
text_tp = custom_fields.values[k]['field'][I18n.locale] rescue ''
|
text_tp = custom_fields[k]['field'][I18n.locale] rescue ''
|
||||||
text = text.gsub(format_text,text_tp)
|
text = text.gsub(format_text,text_tp)
|
||||||
end
|
end
|
||||||
when 'title'
|
when 'title'
|
||||||
|
@ -223,18 +227,18 @@ class Admin::AsksController < OrbitAdminController
|
||||||
text = text.gsub(format_text,I18n.t('ask,no'))
|
text = text.gsub(format_text,I18n.t('ask,no'))
|
||||||
end
|
end
|
||||||
when /custom\d+\|format/
|
when /custom\d+\|format/
|
||||||
i = format_text.scan(/\d+/)[0]
|
i = format_text.scan(/\d+/)[0].to_i - 1
|
||||||
k = custom_fields.keys.index(i) rescue nil
|
k = custom_fields.keys[i] rescue nil
|
||||||
if !k.blank?
|
if !k.blank?
|
||||||
v = custom_fields.values[k] rescue {}
|
v = custom_fields[k] rescue {}
|
||||||
text_tp = Admin::AsksHelper.show_on_front(k,v,@ask_question.custom_values[k],true,true)
|
text_tp = Admin::AsksHelper.show_on_front(k,v,@ask_question.custom_values[k],true,true)
|
||||||
text = text.gsub(format_text,text_tp.to_s)
|
text = text.gsub(format_text,text_tp.to_s)
|
||||||
end
|
end
|
||||||
when /custom\d+/
|
when /custom\d+/
|
||||||
i = format_text.scan(/\d+/)[0]
|
i = format_text.scan(/\d+/)[0].to_i - 1
|
||||||
k = custom_fields.keys.index(i) rescue nil
|
k = custom_fields.keys[i] rescue nil
|
||||||
if !k.blank?
|
if !k.blank?
|
||||||
v = custom_fields.values[k] rescue {}
|
v = custom_fields[k] rescue {}
|
||||||
text_tp = Admin::AsksHelper.show_on_front(k,v,@ask_question.custom_values[k],true)
|
text_tp = Admin::AsksHelper.show_on_front(k,v,@ask_question.custom_values[k],true)
|
||||||
text = text.gsub(format_text,text_tp.to_s)
|
text = text.gsub(format_text,text_tp.to_s)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue