fix cates and tags
This commit is contained in:
parent
626b2a7bca
commit
dc3966be81
|
@ -234,7 +234,13 @@ class ApplicationController < ActionController::Base
|
|||
ret = ''
|
||||
ret << "/panel/#{@item.module_app.key}/front_end/#{@item.app_frontend_url}.rss"
|
||||
ret << "/#{params[:id]}" if params[:id] && !params[:id].eql?(@item.id.to_s)
|
||||
ret << "?inner=true&category_id=#{params[:category]}&tag_id=#{params[:tag]}&page_main=#{params[:page_main]}"
|
||||
|
||||
categories_str=params[:category].collect{|t| "category_id[]=#{t}"}.join('&')
|
||||
tags_str=params[:tag].collect{|t| "tag_id[]=#{t}"}.join('&')
|
||||
categories_str = "&#{categories_str}" unless categories_str.blank?
|
||||
tags_str = "&#{tags_str}" unless tags_str.blank?
|
||||
|
||||
ret << "?inner=true#{categories_str}#{tags_str}&page_main=#{params[:page_main]}"
|
||||
redirect_to ret
|
||||
end
|
||||
|
||||
|
|
|
@ -11,26 +11,32 @@ class DefaultWidgetController< OrbitWidgetController
|
|||
end
|
||||
|
||||
def query_for_default_widget
|
||||
|
||||
ori_class_name = @default_widget["query"].split('.')[0]
|
||||
result = nil
|
||||
result_objects = nil
|
||||
params["tag_id"] = [] if params["tag_id"]=="[]"
|
||||
params["category_id"] = [] if params["category_id"]=="[]"
|
||||
|
||||
if !params["tag_id"].blank?
|
||||
@tags = Tag.find(params["tag_id"]) rescue nil
|
||||
result_ids = nil
|
||||
if params["category_id"].blank?
|
||||
result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).entries.collect{|t| t.id}}.flatten
|
||||
else
|
||||
result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).where(:category_id.in=>params["category_id"]).available_for_lang(I18n.locale).can_display.collect{|t| t.id}}.flatten
|
||||
|
||||
result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).entries.collect{|t| t.id}}
|
||||
if params["category_id"].blank? #has tag no cate
|
||||
#nothing
|
||||
else #has tag and cate
|
||||
# result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).where(:#{get_category_field_name(ori_class_name)}.in=>params["category_id"]).available_for_lang(I18n.locale).can_display.collect{|t| t.id}}.flatten
|
||||
result_ids << eval("#{ori_class_name}.where(:#{get_category_field_name(ori_class_name)}.in=>params['category_id']).entries.collect{|t| t.id}")
|
||||
result_ids.flatten!
|
||||
|
||||
end
|
||||
result = eval("#{ori_class_name}.where(:id=>result_ids)")
|
||||
elsif params["category_id"].blank?
|
||||
elsif params["category_id"].blank? #no tag no cate
|
||||
|
||||
result = eval(@default_widget["query"])
|
||||
else
|
||||
result = eval("#{ori_class_name}.where(:category_id.in=>params['category_id'])")
|
||||
else #no tag has cate
|
||||
result = eval("#{ori_class_name}.where(:#{get_category_field_name(ori_class_name)}.in=>params['category_id'])")
|
||||
end
|
||||
|
||||
result.available_for_lang(I18n.locale).can_display
|
||||
end
|
||||
|
||||
|
@ -72,4 +78,12 @@ class DefaultWidgetController< OrbitWidgetController
|
|||
end
|
||||
end
|
||||
|
||||
def get_category_field_name(ori_class_name)
|
||||
ori_class_name = ori_class_name.constantize
|
||||
ori_class_name.fields.each_key do |key|
|
||||
return key if key.include?('category_id')
|
||||
end
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -236,7 +236,13 @@ module ParserCommon
|
|||
end
|
||||
ret << "<div id='appfrontend' class='dymanic_load' path='#{url}"
|
||||
ret << "/#{params[:id]}" if params[:id] && !params[:id].eql?(page.id.to_s)
|
||||
ret << "?inner=true&page_id=#{page.id}&category_id=#{category}&tag_id=#{tag}&preview=#{params[:preview]}&page_main=#{params[:page_main]}&search_query=#{params[:search_query]}&name=#{params[:name]}&item_type=page"
|
||||
|
||||
categories_str=category.collect{|t| "category_id[]=#{t}"}.join('&')
|
||||
tags_str=tag.collect{|t| "tag_id[]=#{t}"}.join('&')
|
||||
categories_str = "&#{categories_str}" unless categories_str.blank?
|
||||
tags_str = "&#{tags_str}" unless tags_str.blank?
|
||||
|
||||
ret << "?inner=true&page_id=#{page.id}#{categories_str}#{tags_str}&preview=#{params[:preview]}&page_main=#{params[:page_main]}&search_query=#{params[:search_query]}&name=#{params[:name]}&item_type=page"
|
||||
ret << "'></div>"
|
||||
else
|
||||
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
||||
|
@ -258,7 +264,13 @@ module ParserCommon
|
|||
raise ModuleAppError,"PagePart can't find ModuleApp" if part.module_app.nil?
|
||||
"/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
|
||||
end
|
||||
options = "&part_id=#{part.id}&category_id=#{!part[:category].blank? ? part[:category] : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}&item_type=page_part"
|
||||
|
||||
categories_str=(!part[:category].blank? ? part[:category] : category).collect{|t| "category_id[]=#{t}"}.join('&')
|
||||
tags_str=(!part[:tag].blank? ? part[:tag] : tag).collect{|t| "tag_id[]=#{t}"}.join('&')
|
||||
categories_str = "&#{categories_str}" unless categories_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]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}&item_type=page_part"
|
||||
ret << "<div class='dymanic_load widget' path='#{url + options}'></div>"
|
||||
when 'public_r_tag'
|
||||
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
|
||||
|
|
|
@ -110,6 +110,7 @@ module ParserFrontEnd
|
|||
public_r_tags = []
|
||||
url = ''
|
||||
body.css('.page_content').each do |content|
|
||||
|
||||
ret = ''
|
||||
if (content["main"] == "true" && !page.module_app.nil?)
|
||||
if page.app_frontend_url == 'default_widget'
|
||||
|
@ -119,8 +120,12 @@ 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"
|
||||
end
|
||||
|
||||
categories_str=category.collect{|t| "category_id[]=#{t}"}.join('&')
|
||||
tags_str=tag.collect{|t| "tag_id[]=#{t}"}.join('&')
|
||||
categories_str = "&#{categories_str}" unless categories_str.blank?
|
||||
tags_str = "&#{tags_str}" unless tags_str.blank?
|
||||
|
||||
options = "&page_id=#{page.id}&category_id=\#{category}&tag_id=\#{tag}&preview=\#{params[:preview]}&page_main=\#{params[:page_main]}&search_query=\#{params[:search_query]}&name=\#{params[:name]}&item_type=page"
|
||||
options = "&page_id=\#{page.id}#{categories_str}#{tags_str}&preview=\#{params[:preview]}&page_main=\#{params[:page_main]}&search_query=\#{params[:search_query]}&name=\#{params[:name]}&item_type=page"
|
||||
ret << "<orbit_front path='#{url + options}'></div>"
|
||||
else
|
||||
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
||||
|
@ -137,7 +142,13 @@ module ParserFrontEnd
|
|||
else
|
||||
"/panel/\#{part.module_app.key}/widget/\#{part.widget_path}?inner=true"
|
||||
end
|
||||
options = "&part_id=\#{part.id}&category_id=\#{part[:category]}&tag_id=\#{part[:tag]}&page=\#{params[:page]}&search_query=\#{params[:search_query]}&part_title=\#{Rack::Utils.escape(part_title).gsub(\"\+\", \"\%20\") rescue nil}&item_type=page_part"
|
||||
|
||||
categories_str=part[:category].collect{|t| "category_id[]=#{t}"}.join('&')
|
||||
tags_str=part[:tag].collect{|t| "tag_id[]=#{t}"}.join('&')
|
||||
categories_str = "&#{categories_str}" unless categories_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]}&part_title=\#{Rack::Utils.escape(part_title).gsub(\"\+\", \"\%20\") rescue nil}&item_type=page_part"
|
||||
ret << "<orbit_front path='#{url + options}' part_id=#{part.id} class='dymanic_load widget'></orbit_front>"
|
||||
|
||||
when 'public_r_tag'
|
||||
|
|
Loading…
Reference in New Issue