fix for passing args. code in complete,fronted controller need to take care params,too. backend parser need to catch up.
This commit is contained in:
parent
f2706ff2c1
commit
7729161123
|
@ -110,7 +110,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
# Render the page
|
# Render the page
|
||||||
def render_page(args=nil)
|
def render_page(args={})
|
||||||
if @item
|
if @item
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :text => parse_page_content(@item,args), :layout => 'page_layout' }
|
format.html { render :text => parse_page_content(@item,args), :layout => 'page_layout' }
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
class OrbitWidgetController< OrbitFrontendComponentController
|
class OrbitWidgetController< OrbitFrontendComponentController
|
||||||
|
include FrontEndArrayParamsHelper
|
||||||
|
|
||||||
|
before_filter :get_tags_and_cates
|
||||||
|
|
||||||
|
def get_tags_and_cates
|
||||||
|
binding.pry
|
||||||
|
params = tags_and_cates(params)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -45,12 +45,28 @@ class PagesController < ApplicationController
|
||||||
#end
|
#end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def convert_array_param(key,array)
|
||||||
|
array.collect{|t| "#{key}[]=#{t}"}.join("&")
|
||||||
|
end
|
||||||
|
|
||||||
def index_from_link
|
def index_from_link
|
||||||
url = "/#{@item.path}"
|
url = "/#{@item.path}"
|
||||||
options = ''
|
options = ''
|
||||||
options << "#{options.blank? ? '?' : '&'}page_main=#{params[:page_main]}" unless params[:page_main].blank?
|
options << "#{options.blank? ? '?' : '&'}page_main=#{params[:page_main]}" unless params[:page_main].blank?
|
||||||
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
|
||||||
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
if params[:category_id].is_a? Array
|
||||||
|
options << "#{options.blank? ? '?' : '&'}#{convert_array_param('category_id',params[:category_id])}" unless params[:category_id].blank?
|
||||||
|
elsif params[:category_id].is_a? String
|
||||||
|
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:tag_id].is_a? Array
|
||||||
|
options << "#{options.blank? ? '?' : '&'}#{convert_array_param('tag_id',params[:tag_id])}" unless params[:tag_id].blank?
|
||||||
|
elsif params[:category_id].is_a? String
|
||||||
|
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank?
|
options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank?
|
||||||
options << "#{options.blank? ? '?' : '&'}name=#{params[:name]}" unless params[:name].blank?
|
options << "#{options.blank? ? '?' : '&'}name=#{params[:name]}" unless params[:name].blank?
|
||||||
uri = URI::escape(url + options)
|
uri = URI::escape(url + options)
|
||||||
|
|
|
@ -4,6 +4,7 @@ require "orbit_app/helper/renderer"
|
||||||
require "orbit_app/helper/side_bar_renderer"
|
require "orbit_app/helper/side_bar_renderer"
|
||||||
require "orbit_app/helper/context_link_renderer"
|
require "orbit_app/helper/context_link_renderer"
|
||||||
require "orbit_app/helper/default_widget_tag_helper"
|
require "orbit_app/helper/default_widget_tag_helper"
|
||||||
|
require "orbit_app/helper/front_end_array_params_helper"
|
||||||
require "orbit_app/module/side_bar"
|
require "orbit_app/module/side_bar"
|
||||||
require "orbit_app/module/widget"
|
require "orbit_app/module/widget"
|
||||||
require "orbit_app/module/front_end"
|
require "orbit_app/module/front_end"
|
||||||
|
|
|
@ -4,9 +4,20 @@ module DefaultWidgetTagHelper
|
||||||
|
|
||||||
def link_to_more_tag(req,params)
|
def link_to_more_tag(req,params)
|
||||||
@request = req
|
@request = req
|
||||||
@params =params
|
params.delete :inner
|
||||||
|
@params = params
|
||||||
|
|
||||||
|
params_str ="?"
|
||||||
|
params.each do |index,param|
|
||||||
|
if param.is_a?(Array) and !param.blank?
|
||||||
|
params_str << param.collect{|t| "#{index}[]=#{t}"}.join("&")
|
||||||
|
params.delete index
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
params_str = params_str + (params_str.eql?("?") ? params.to_param : "&#{params.to_param}" )
|
||||||
content_tag :div,:class=> 'more' do
|
content_tag :div,:class=> 'more' do
|
||||||
link_to I18n.t(@more_link[:label_i18n]),eval(@more_link[:path_method])
|
link_to I18n.t(@more_link[:label_i18n]),[eval("#{@more_link[:path_method]}"),params_str].join()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -0,0 +1,21 @@
|
||||||
|
module FrontEndArrayParamsHelper
|
||||||
|
|
||||||
|
#Deal with multi tags and cates that could be sat at both from setting or passed by views like tag cloud.
|
||||||
|
#Take Tag as example: Those tags which be sat at setting will be pass as params 'tag_ext',and the rest will be pass as 'tag'
|
||||||
|
#But when the showing process goes to fronend or default widget itself the controller will need to know what data it should use exactly.
|
||||||
|
#That's why we need tags_and_cates
|
||||||
|
|
||||||
|
def tags_and_cates(params)
|
||||||
|
|
||||||
|
params["category_id"] = params["category_id"].collect{|t| t.gsub(/\"|\[|\]/,'').split(",").each(&:strip!)}.flatten if params["category_id"].is_a? Array
|
||||||
|
params["tag_id"] = params["tag_id"].collect{|t| t.gsub(/\"|\[|\]/,'').split(",").each(&:strip!)}.flatten if params["tag_id"].is_a? Array
|
||||||
|
|
||||||
|
params["category_id"] = [ params["base_category_id"],params["category_id"]].flatten.reject(&:nil?).reject(&:empty?)
|
||||||
|
params.delete :base_category_id
|
||||||
|
params["tag_id"] = [ params["base_tag_id"],params["tag_id"]].flatten.reject(&:nil?).reject(&:empty?)
|
||||||
|
params.delete :base_tag_id
|
||||||
|
|
||||||
|
return params
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -18,11 +18,12 @@ module ParserFrontEnd
|
||||||
i18n
|
i18n
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_page_content(page,args=nil)
|
def parse_page_content(page,args={})
|
||||||
args["category_id"] = args["category_id"].gsub(/\"|\[|\]/,'').split(",").each(&:strip!) if args["category_id"].is_a? String
|
args["category_id"] = args["category_id"].gsub(/\"|\[|\]/,'').split(",").each(&:strip!) if !args["category_id"].blank? and args["category_id"].is_a?(String)
|
||||||
args["tag_id"] = args["tag_id"].gsub(/\"|\[|\]/,'').split(",").each(&:strip!) if args["tag_id"].is_a? String
|
args["tag_id"] = args["tag_id"].gsub(/\"|\[|\]/,'').split(",").each(&:strip!) if !args["tag_id"].blank? and args["tag_id"].is_a? String
|
||||||
# tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id]
|
# tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id]
|
||||||
# category = params[:category_id].blank? ? page[:category] : params[:category_id]
|
# category = params[:category_id].blank? ? page[:category] : params[:category_id]
|
||||||
|
|
||||||
body = Nokogiri::HTML(page.content)
|
body = Nokogiri::HTML(page.content)
|
||||||
body.css('orbit_front').each do |front|
|
body.css('orbit_front').each do |front|
|
||||||
if front['value']
|
if front['value']
|
||||||
|
@ -129,8 +130,8 @@ module ParserFrontEnd
|
||||||
url = "/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}\#{(\"/\" + params[:id]) if params[:id] && !params[:id].eql?(page.id.to_s)}\#{(\"/\" + params[:controller_action]) if params[:controller_action] && params[:id]}?inner=true"
|
url = "/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}\#{(\"/\" + params[:id]) if params[:id] && !params[:id].eql?(page.id.to_s)}\#{(\"/\" + params[:controller_action]) if params[:controller_action] && params[:id]}?inner=true"
|
||||||
end
|
end
|
||||||
|
|
||||||
categories_str=category.collect{|t| "category_id[]=#{t}"}.join('&')
|
categories_str=category.collect{|t| "base_category_id[]=#{t}"}.join('&')
|
||||||
tags_str=tag.collect{|t| "tag_id[]=#{t}"}.join('&')
|
tags_str=tag.collect{|t| "base_tag_id[]=#{t}"}.join('&')
|
||||||
categories_str = "&#{categories_str}" unless categories_str.blank?
|
categories_str = "&#{categories_str}" unless categories_str.blank?
|
||||||
tags_str = "&#{tags_str}" unless tags_str.blank?
|
tags_str = "&#{tags_str}" unless tags_str.blank?
|
||||||
|
|
||||||
|
@ -152,12 +153,13 @@ module ParserFrontEnd
|
||||||
"/panel/\#{part.module_app.key}/widget/\#{part.widget_path}?inner=true"
|
"/panel/\#{part.module_app.key}/widget/\#{part.widget_path}?inner=true"
|
||||||
end
|
end
|
||||||
|
|
||||||
categories_str=part[:category].collect{|t| "category_id[]=#{t}"}.join('&')
|
categories_str=part[:category].collect{|t| "base_category_id[]=#{t}"}.join('&')
|
||||||
tags_str=part[:tag].collect{|t| "tag_id[]=#{t}"}.join('&')
|
tags_str=part[:tag].collect{|t| "base_tag_id[]=#{t}"}.join('&')
|
||||||
categories_str = "&#{categories_str}" unless categories_str.blank?
|
categories_str = "&#{categories_str}" unless categories_str.blank?
|
||||||
tags_str = "&#{tags_str}" unless tags_str.blank?
|
tags_str = "&#{tags_str}" unless tags_str.blank?
|
||||||
|
|
||||||
options = "&part_id=\#{part.id}#{categories_str}#{tags_str}&page=\#{params[:page]}&search_query=\#{params[:search_query]}&clicked_field_name=\#{params[:clicked_field_name]}&part_title=\#{Rack::Utils.escape(part_title).gsub(\"\+\", \"\%20\") rescue nil}&item_type=page_part&tag_id=\#{params[:tag_id]}&category_id=\#{params[:category_id]}"
|
options = "&part_id=\#{part.id}#{categories_str}#{tags_str}&page=\#{params[:page]}&search_query=\#{params[:search_query]}&clicked_field_name=\#{params[:clicked_field_name]}&part_title=\#{Rack::Utils.escape(part_title).gsub(\"\+\", \"\%20\") rescue nil}&item_type=page_part&tag_id=\#{params[:tag_id]}&category_id=\#{params[:category_id]}"
|
||||||
|
|
||||||
ret << "<orbit_front path='#{url + options}' part_id=#{part.id} class='dymanic_load widget'></orbit_front>"
|
ret << "<orbit_front path='#{url + options}' part_id=#{part.id} class='dymanic_load widget'></orbit_front>"
|
||||||
|
|
||||||
when 'public_r_tag'
|
when 'public_r_tag'
|
||||||
|
|
|
@ -35,7 +35,6 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||||
end
|
end
|
||||||
@frontend_style = @item.frontend_style
|
@frontend_style = @item.frontend_style
|
||||||
end
|
end
|
||||||
|
|
||||||
@item = Page.find(params[:page_id]) rescue nil
|
@item = Page.find(params[:page_id]) rescue nil
|
||||||
if !params[:search_query].blank?
|
if !params[:search_query].blank?
|
||||||
# search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending => false}
|
# search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending => false}
|
||||||
|
|
|
@ -31,6 +31,5 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
<%= paginate( @bulletins, :param_name => :page_main, :params => {:inner => 'false'} ) rescue nil%>
|
||||||
<%= paginate @bulletins, :param_name => :page_main, :params => {:inner => 'false'} %>
|
|
||||||
|
|
||||||
|
|
Reference in New Issue