Merge branch 'development' into desktop

This commit is contained in:
chris 2013-03-05 19:07:58 +08:00
commit 27686a5d04
9 changed files with 66 additions and 21 deletions

View File

@ -73,7 +73,7 @@ class Admin::PagePartsController < ApplicationController
params[:page_part][:category] = []
end
params[:page_part][:widget_field].each{|t| t[2] = (t[2]=="true" ? true : false )}
params[:page_part][:widget_field].each{|t| t[2] = (t[2]=="true" ? true : false )} if !params[:page_part][:widget_field].blank?
if @part.update_attributes(params[:page_part])
set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu')

View File

@ -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

View File

@ -11,28 +11,36 @@ class DefaultWidgetController< OrbitWidgetController
end
def query_for_default_widget
ori_class_name = @default_widget["query"].split('.')[0]
result = nil
result_objects = nil
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=>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=>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
def default_widget
if !params[:id].blank?
redirect_to eval("#{@page_part.module_app.widget_fields_link_method['title']['method']}('#{params[:id]}', {inner: #{params[:inner] || true}})")
else
@ -50,10 +58,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
@data = query_for_default_widget.includes(@widget_image_field).page(params[:page_main]).per(@data_limit)
@data = query_for_default_widget.includes(@widget_image_field).page(params[:page_main]).per(@data_limit).desc(:created_at)
# @data = query_for_default_widget.limit(@data_limit).includes(@widget_image_field)
else
@data = eval(@default_widget["query"]).includes(@widget_image_field).page(params[:page_main]).per(@data_limit).desc(:created_at)
@data = query_for_default_widget.includes(@widget_image_field).desc(:created_at)
# @data = eval(@default_widget["query"]).limit(@data_limit).includes(@widget_image_field).desc(:created_at)
end
case params[:type]
@ -70,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

View File

@ -2,5 +2,5 @@
<%= t("default_widget.widget_data_count") %>
</label>
<div class="controls">
<%= select_tag(field_name,options_for_select(@module_app.get_registration.get_data_count,field_value )) %>
<%= select_tag(field_name,options_for_select((@module_app.get_registration.get_data_count rescue []),field_value )) %>
</div>

View File

@ -1,7 +1,7 @@
<% if @module_app %>
$('#app_page_category').html("<%= j render :partial => 'admin/page_parts/widget_data_source_category' ,:locals=>{:object=>@page}%>");
$('#app_page_tag').html("<%= j render :partial => 'admin/page_parts/widget_data_source_tag',:locals=>{:object=>@page} %>");
$("#data_count").html("<%= j render :partial => 'admin/pages/data_count_field',:locals=>{:field_name=>'page[frontend_data_count]',:field_value=>@page.frontend_data_count} %>");
$("#data_count").html("<%= j render :partial => 'admin/pages/data_count_field',:locals=>{:field_name=>'page[frontend_data_count]',:field_value=>(@page.frontend_data_count rescue nil)} %>");
<% if !@module_app.app_pages.blank? %>
$('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', options_for_select(@app_frontend_urls, @app_frontend_urls.first)) %>");

View File

@ -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}'/>"

View File

@ -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'

View File

@ -35,7 +35,7 @@ module Archive
head_label_i18n 'archive.archive',:icon_class=>"icons-archive"
available_for [:admin,:guest,:manager,:sub_manager]
active_for_controllers ({:private=>['archive_file_categorys','archive_files'],:public=>['panel/archive/back_end/tags']})
active_for_object_auth ['BulletinCategory']
# active_for_object_auth ['BulletinCategory']
head_link_path "panel_archive_back_end_archive_files_path"

View File

@ -44,7 +44,7 @@ module Gallery
head_label_i18n 'gallery.gallery',:icon_class=>"icons-pictures"
available_for [:admin,:guest,:manager,:sub_manager]
active_for_controllers ({:private=>['albums','album_images','gallery_categories','/panel/gallery/back_end/tags']})
active_for_object_auth ['BulletinCategory']
active_for_object_auth ['GalleryCategory']
head_link_path "panel_gallery_back_end_albums_path"