diff --git a/app/controllers/default_widget_controller.rb b/app/controllers/default_widget_controller.rb index 63314529b..370b1de94 100644 --- a/app/controllers/default_widget_controller.rb +++ b/app/controllers/default_widget_controller.rb @@ -40,6 +40,7 @@ class DefaultWidgetController< OrbitWidgetController def default_widget @search = params["search_query"].blank? ? false : true + if !params[:id].blank? and !params["clicked_field_name"].blank? clicked_field_name = params["clicked_field_name"].to_sym redirect_to eval("#{@page_part.module_app.widget_fields_link_method[clicked_field_name][:method]}('#{params[:id]}', {inner: #{params[:inner] || true}})") @@ -69,7 +70,10 @@ class DefaultWidgetController< OrbitWidgetController @data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3) end - if @paginate || @search + if params[:click] + @data = get_more_btn_data.page(params[:page_main]).per(@data_limit) + + elsif @paginate || @search if @search @data = search_result.page(params[:page_main]).per(@data_limit) rescue [] else #regular listing @@ -93,6 +97,15 @@ class DefaultWidgetController< OrbitWidgetController end end end + + def get_more_btn_data + filterids = PagePart.find(params[:part_id]).category + model = eval(@default_widget["query"]) + data = model.where(:category_id.in => filterids) + data.available_for_lang(I18n.locale).can_display.desc(:is_top, :postdate) + end + + def get_category_field_name @ori_class_name = @ori_class_name.constantize diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index b16ed65fc..db7fcf964 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -64,6 +64,8 @@ class PagesController < ApplicationController url = "/#{@item.path}" options = '' options << "#{options.blank? ? '?' : '&'}page_main=#{params[:page_main]}" unless params[:page_main].blank? + options << "#{options.blank? ? '?' : '&'}click=#{params[:click]}" unless params[:click].blank? + options << "#{options.blank? ? '?' : '&'}part_id=#{params[:page_part_id]}" unless params[:page_part_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? @@ -105,48 +107,48 @@ class PagesController < ApplicationController protected def get_item - if params[:page_id] - @item = Item.find(params[:page_id]) - elsif params[:same_page_id] - @item = Item.find(params[:same_page_id]) - else - category_ids = Array(params[:category_id]) unless params[:category_id].nil? - tag_ids = Array(params[:tag_id]) unless params[:tag_id].nil? - module_app = ModuleApp.first(:conditions => {:key => params[:app_name]}) + # if params[:page_id] + # @item = Item.find(params[:page_id]) + # elsif params[:same_page_id] + # @item = Item.find(params[:same_page_id]) + # else + # category_ids = Array(params[:category_id]) unless params[:category_id].nil? + # tag_ids = Array(params[:tag_id]) unless params[:tag_id].nil? + # module_app = ModuleApp.first(:conditions => {:key => params[:app_name]}) - default_query = { is_published: true, module_app_id: module_app.id, :app_frontend_url.in => [params[:app_action], 'default_widget'] } - specific_categories = { :category => category_ids } - in_categories = { :category.in => category_ids } - nil_categories = { :category.in => [nil, []] } - specific_tags = { :tag => tag_ids } - in_tags = { :tag.in => tag_ids } - nil_tags = { :tag.in => [nil, []] } + # default_query = { is_published: true, module_app_id: module_app.id, :app_frontend_url.in => [params[:app_action], 'default_widget'] } + # specific_categories = { :category => category_ids } + # in_categories = { :category.in => category_ids } + # nil_categories = { :category.in => [nil, []] } + # specific_tags = { :tag => tag_ids } + # in_tags = { :tag.in => tag_ids } + # nil_tags = { :tag.in => [nil, []] } - if !category_ids.blank? && !tag_ids.blank? - @item = Item.where(default_query.merge(specific_categories).merge(specific_tags)).first - @item = Item.where(default_query.merge(specific_categories).merge(in_tags)).first unless @item - @item = Item.where(default_query.merge(specific_categories).merge(nil_tags)).first unless @item - @item = Item.where(default_query.merge(specific_tags).merge(in_categories)).first unless @item - @item = Item.where(default_query.merge(specific_tags).merge(nil_categories)).first unless @item - @item = Item.where(default_query.merge(in_categories).merge(in_tags)).first unless @item - @item = Item.where(default_query.merge(in_categories).merge(nil_tags)).first unless @item - @item = Item.where(default_query.merge(in_tags).merge(nil_categories)).first unless @item - elsif !category_ids.blank? - @item = Item.where(default_query.merge(specific_categories).merge(nil_tags)).first - @item = Item.where(default_query.merge(specific_categories)).first unless @item - @item = Item.where(default_query.merge(in_categories).merge(nil_tags)).first unless @item - @item = Item.where(default_query.merge(in_categories)).first unless @item - elsif !tag_ids.blank? - @item = Item.where(default_query.merge(specific_tags).merge(nil_categories)).first - @item = Item.where(default_query.merge(specific_tags)).first unless @item - @item = Item.where(default_query.merge(in_tags).merge(nil_categories)).first unless @item - @item = Item.where(default_query.merge(in_tags)).first unless @item - end - @item = Item.find(params[:orig_page]) unless @item || params[:orig_page].blank? - @item = Item.where(default_query.merge(nil_categories).merge(nil_tags)).first unless @item - @item = Item.where(default_query).first unless @item - end - raise PageError, 'Missing Frontend Page' if @item.nil? + # if !category_ids.blank? && !tag_ids.blank? + # @item = Item.where(default_query.merge(specific_categories).merge(specific_tags)).first + # @item = Item.where(default_query.merge(specific_categories).merge(in_tags)).first unless @item + # @item = Item.where(default_query.merge(specific_categories).merge(nil_tags)).first unless @item + # @item = Item.where(default_query.merge(specific_tags).merge(in_categories)).first unless @item + # @item = Item.where(default_query.merge(specific_tags).merge(nil_categories)).first unless @item + # @item = Item.where(default_query.merge(in_categories).merge(in_tags)).first unless @item + # @item = Item.where(default_query.merge(in_categories).merge(nil_tags)).first unless @item + # @item = Item.where(default_query.merge(in_tags).merge(nil_categories)).first unless @item + # elsif !category_ids.blank? + # @item = Item.where(default_query.merge(specific_categories).merge(nil_tags)).first + # @item = Item.where(default_query.merge(specific_categories)).first unless @item + # @item = Item.where(default_query.merge(in_categories).merge(nil_tags)).first unless @item + # @item = Item.where(default_query.merge(in_categories)).first unless @item + # elsif !tag_ids.blank? + # @item = Item.where(default_query.merge(specific_tags).merge(nil_categories)).first + # @item = Item.where(default_query.merge(specific_tags)).first unless @item + # @item = Item.where(default_query.merge(in_tags).merge(nil_categories)).first unless @item + # @item = Item.where(default_query.merge(in_tags)).first unless @item + # end + # @item = Item.find(params[:orig_page]) unless @item || params[:orig_page].blank? + # @item = Item.where(default_query.merge(nil_categories).merge(nil_tags)).first unless @item + # @item = Item.where(default_query).first unless @item + # end + # raise PageError, 'Missing Frontend Page' if @item.nil? # if params[:page_id] # @item = Item.find(params[:page_id]) @@ -170,6 +172,15 @@ class PagesController < ApplicationController # @item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action]).first unless @item # end # raise PageError,'Missing Frontend Page' if @item.nil? + if params[:page_id] + @item = Item.find(params[:page_id]) + elsif params[:same_page_id] + @item = Item.find(params[:same_page_id]) + else + module_app = ModuleApp.first(:conditions => {:key => params[:app_name]}) + @item = Item.root.children.where(:module_app_id => module_app.id).first + end + raise PageError,'Missing Frontend Page' if @item.nil? end def check_frontend_open diff --git a/config/mongoid.yml b/config/mongoid.yml index ebfecd6ef..0b1b1cfc6 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -8,13 +8,13 @@ defaults: &defaults development: <<: *defaults - database: test_site + database: orbit_site_new test: <<: *defaults - database: test_site + database: orbit_site_new # set these environment variables on your prod server production: diff --git a/lib/orbit_app/helper/default_widget_tag_helper.rb b/lib/orbit_app/helper/default_widget_tag_helper.rb index 58a789e56..a831095c4 100644 --- a/lib/orbit_app/helper/default_widget_tag_helper.rb +++ b/lib/orbit_app/helper/default_widget_tag_helper.rb @@ -12,10 +12,11 @@ module DefaultWidgetTagHelper if param.is_a?(Array) and !param.blank? params_str << param.collect{|t| "#{index}[]=#{t}"}.join("&") params.delete index + params_str = params_str + "&" end end - params_str = params_str + (params_str.eql?("?") ? params.to_param : "&#{params.to_param}" ) + params_str = params_str + "&click=more_btn&page_part_id=#{@params[:part_id]}" content_tag :div,:class=> 'more' do link_to I18n.t(@more_link[:label_i18n]),[eval("#{@more_link[:path_method]}"),params_str].join() end diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 49e7d1a60..3fa923a27 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -19,12 +19,12 @@ module ParserFrontEnd end def parse_page_content(page,args={}) + 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"].blank? and args["tag_id"].is_a? String # tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id] # category = params[:category_id].blank? ? page[:category] : params[:category_id] body = Nokogiri::HTML(page.content) - if @edit body.css('.page_part').each do |page_part| part = PagePart.find(page_part['part_id']) rescue nil @@ -41,6 +41,7 @@ module ParserFrontEnd end body.css('orbit_front').each do |front| + if front['value'] fragment = Nokogiri::HTML::DocumentFragment.new(body, "
#{eval(front['value']).to_s}
") else diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index 06d359efa..834d59f39 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -9,6 +9,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController end def search_result + debugger if params[:search_query] == "" @bulletins = get_bulletins_for_index