Commit ed391b46e436b4eff7744c5389a09ff1d4ed11e8

Authored by Andrey Karpikov
1 parent d785d583

add language part support

... ... @@ -176,7 +176,7 @@ module Kanjai
176 176 @obj.update(permitted_params[:page_content])
177 177
178 178 if params[:frontend_part].to_i == 1
179   - render :json => {:status => 'ok', :structure_id => @structure_id, frontentd: 1, :html => @obj.get_content_frontend}
  179 + render :json => {:status => 'ok', :structure_id => @structure_id, frontentd: 1, :html => @obj.get_content_frontend(session) }
180 180 else
181 181 render :json => {:status => 'ok', :structure_id => @structure_id, :html => @obj.get_content}
182 182 end
... ... @@ -294,7 +294,7 @@ module Kanjai
294 294
295 295
296 296
297   - render :json => {:status => 'ok', :structure_id => @structure_id, :html => @obj.get_content_frontend}
  297 + render :json => {:status => 'ok', :structure_id => @structure_id, :html => @obj.get_content_frontend(session) }
298 298 end
299 299
300 300 private
... ...
... ... @@ -49,7 +49,7 @@ module Kanjai
49 49 end
50 50 end
51 51 else
52   - page_content = get_html_by_json_client(@page_data)
  52 + page_content = get_html_by_json_client(@page_data, session)
53 53 render :html => page_content.html_safe and return
54 54 end
55 55
... ... @@ -125,7 +125,7 @@ module Kanjai
125 125 markers.each do |marker|
126 126 case marker
127 127 when '###CONTENT###'
128   - page_content = get_html_by_json_client(page_data)
  128 + page_content = get_html_by_json_client(page_data, session)
129 129 layer.gsub!(marker, page_content)
130 130 layer.gsub!('make-checked="false"', '')
131 131 layer.gsub!("make-checked='false'", '')
... ...
... ... @@ -45,7 +45,7 @@ module Kanjai
45 45 end
46 46
47 47
48   - def get_html_by_json_client(page_data)
  48 + def get_html_by_json_client(page_data, session = nil)
49 49 json_data = page_data.template_content
50 50 html = ''
51 51 #row_template = File.open("#{Rails.root}/app/view/kanjai/pages/templates/row.html.erb").read
... ... @@ -70,7 +70,7 @@ module Kanjai
70 70 if page_content.type_content.split('-').include?('wrapper')
71 71 html += (page_content.get_simple_content).html_safe
72 72 else
73   - cells = page_content.nil? ? '' : page_content.get_content_frontend
  73 + cells = page_content.nil? ? '' : page_content.get_content_frontend(session)
74 74
75 75 data_attributes = [
76 76 "data-id=#{row['attributes']['id']}",
... ... @@ -78,9 +78,6 @@ module Kanjai
78 78 ]
79 79 html += ApplicationController.render(file: 'kanjai/pages/templates/block', assigns: {content: cells.html_safe, data_attributes: data_attributes.join(' '), row: row}, layout: false).html_safe
80 80
81   - #html += ActionController::Base.helpers.content_tag(:div, '', html_attributes) do
82   - # ActionController::Base.helpers.concat((page_content.nil? ? '' : page_content.get_content_frontend).html_safe)
83   - #end
84 81 end
85 82 end
86 83 end
... ... @@ -92,7 +89,7 @@ module Kanjai
92 89 row["cells"].each do |cell|
93 90 if cell['status'].to_s == 'enabled' || cell['status'].to_s.empty?
94 91 page_content = page_data.page_contents.where(:structure_id => cell['id']).first
95   - html_content = page_content.nil? ? '' : page_content.get_content_frontend
  92 + html_content = page_content.nil? ? '' : page_content.get_content_frontend(session)
96 93 cell_class_name = cell['className']
97 94
98 95 data_attributes = [
... ... @@ -121,9 +118,9 @@ module Kanjai
121 118 html.to_s
122 119 end
123 120
124   - def get_html_by_json_client_url(url, locale)
  121 + def get_html_by_json_client_url(url, locale, session = nil)
125 122 page_data = PageDatum.where(:url => url, lang: locale).first
126   - get_html_by_json_client(page_data)
  123 + get_html_by_json_client(page_data, session)
127 124 end
128 125
129 126 def make_navigation(parent_id, level)
... ...
... ... @@ -164,7 +164,7 @@ module Kanjai
164 164 end
165 165 end
166 166
167   - def get_content_frontend
  167 + def get_content_frontend(session = nil)
168 168 if self.type_content == 'rte_editor'
169 169 self.text_html.to_s
170 170 elsif self.type_content == 'plugin'
... ... @@ -180,7 +180,7 @@ module Kanjai
180 180 page_template = self.page.page_template
181 181 subpart = page_template.template_parts.find_by_code(self.type_content)
182 182 if subpart
183   - html = Kanjai::TemplateGenerator.subpart_generate(nil, self.page.domain, page_template, 'content', subpart.elements, self.marker_hash, self.id)
  183 + html = Kanjai::TemplateGenerator.subpart_generate(session, self.page.domain, page_template, 'content', subpart.elements, self.marker_hash, self.id)
184 184 else
185 185 html = ''
186 186 end
... ...
... ... @@ -245,6 +245,11 @@ module Kanjai
245 245
246 246 end
247 247
  248 + when 'language'
  249 + code = item[:attributes]['code']
  250 + if I18n.locale.to_s == code.to_s
  251 + self.content_generator(session, domain, item[:children], subparts, hash_value)
  252 + end
248 253 else
249 254 condition_process = true
250 255
... ...
1 1 module Kanjai
2   - VERSION = "0.0.279"
  2 + VERSION = "0.0.280"
3 3 end
... ...