From 7440727acde1ba70c9e897d7cb78d6919a2436ff Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 30 Jul 2012 17:21:37 +0800 Subject: [PATCH] Fix: "._type" to ".class" --- app/controllers/admin/purchases_controller.rb | 4 ++-- app/controllers/pages_controller.rb | 2 +- app/controllers/sessions_controller.rb | 4 ++-- app/helpers/admin/dashboard_helper.rb | 2 +- app/helpers/admin/item_helper.rb | 10 +++++----- app/views/admin/dashboards/index.html.erb | 4 ++-- app/views/admin/items/index.html.erb | 2 +- app/views/admin/items/index.js.erb | 2 +- lib/parsers/parser_back_end.rb | 2 +- lib/parsers/parser_common.rb | 4 ++-- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/controllers/admin/purchases_controller.rb b/app/controllers/admin/purchases_controller.rb index 00980cec..7caaf730 100644 --- a/app/controllers/admin/purchases_controller.rb +++ b/app/controllers/admin/purchases_controller.rb @@ -32,7 +32,7 @@ class Admin::PurchasesController < ApplicationController public_key = OpenSSL::PKey::RSA.new(File.read(APP_CONFIG['main_public_key'])) encrypted_data = public_key.public_encrypt({:purchase_id => purchase.purchase_id, - :purchase_type => purchase._type, + :purchase_type => purchase.class, :roaming_id => Site.find(session[:site]).roaming_id, :url => url}.to_json) @@ -43,7 +43,7 @@ class Admin::PurchasesController < ApplicationController temp_file.write response.body temp_file.rewind zip_name = response['content-disposition'].split('filename=')[1].gsub(/[\\\"]|.zip/, '') rescue '' - case purchase._type + case purchase.class when 'Pdesign' unzip_design(temp_file, zip_name) when 'PModuleApp' diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 3eedd702..e0193715 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -22,7 +22,7 @@ class PagesController < ApplicationController @item = Item.first(:conditions => {:path => params[:page_name]}) if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s)) # impressionist(@item) - case @item._type + case @item.class when 'Page' render_page when 'Link' diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 748c225c..621f93d3 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -30,7 +30,7 @@ class SessionsController < Devise::SessionsController render :action => "new" else logger.info "===ALL passed" - resource_name = resource._type.downcase + resource_name = resource.class.downcase sign_in(resource_name, resource) respond_with resource, :location => redirect_location(resource_name, resource) end @@ -48,7 +48,7 @@ class SessionsController < Devise::SessionsController logger.info "=======Rulingcom account======" resource = User.first(conditions:{email: login_uid}) if resource.valid_password?(login_password) - resource_name = resource._type.downcase + resource_name = resource.class.downcase sign_in(resource_name, resource) respond_with resource, :location => redirect_location(resource_name, resource) else diff --git a/app/helpers/admin/dashboard_helper.rb b/app/helpers/admin/dashboard_helper.rb index dfe5763f..afeaa278 100644 --- a/app/helpers/admin/dashboard_helper.rb +++ b/app/helpers/admin/dashboard_helper.rb @@ -14,7 +14,7 @@ module Admin::DashboardHelper end def get_link_to_object(object) - case object._type.underscore + case object.class.underscore when 'bulletin' panel_announcement_front_end_bulletin_path(object) when 'news_bulletin' diff --git a/app/helpers/admin/item_helper.rb b/app/helpers/admin/item_helper.rb index e30e44ca..4aec798e 100644 --- a/app/helpers/admin/item_helper.rb +++ b/app/helpers/admin/item_helper.rb @@ -3,7 +3,7 @@ module Admin::ItemHelper def render_node_and_children(node) ret = '' if node - case node._type + case node.class when 'Page' dest = admin_page_path(node) when 'Link' @@ -15,10 +15,10 @@ module Admin::ItemHelper ret << "
" ret << (link_to node.title, dest, :class => 'js_history') ret << "
" - ret << (link_to t('admin.edit'), eval("edit_admin_#{node._type.downcase}_path(node)"), :class => 'js_history') if node._type.eql?('Page') - ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node._type.eql?('Page') - ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node._type.eql?('Page') - ret << (link_to t(:delete), eval("delete_admin_#{node._type.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete js_history') + ret << (link_to t('admin.edit'), eval("edit_admin_#{node.lass.downcase}_path(node)"), :class => 'js_history') if node.lass.eql?('Page') + ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node.lass.eql?('Page') + ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node.lass.eql?('Page') + ret << (link_to t(:delete), eval("delete_admin_#{node.lass.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete js_history') ret << "
" ret << "
" ret << render_children(node) diff --git a/app/views/admin/dashboards/index.html.erb b/app/views/admin/dashboards/index.html.erb index 180a0469..fd821420 100644 --- a/app/views/admin/dashboards/index.html.erb +++ b/app/views/admin/dashboards/index.html.erb @@ -515,7 +515,7 @@ <% @recent_updated.each do |object| %> <%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %> - <%= link_to t("dashboard.#{object[0]._type.underscore}"), get_link(object[0]._type.underscore) %> + <%= link_to t("dashboard.#{object[0].class.underscore}"), get_link(object[0].class.underscore) %> <% end %> @@ -553,7 +553,7 @@ <% @most_visited.each do |object| %> <%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %> - <%= link_to t("dashboard.#{object[0]._type.underscore}"), get_link(object[0]._type.underscore) %> + <%= link_to t("dashboard.#{object[0].class.underscore}"), get_link(object[0].class.underscore) %> <%= object[1] %> <% end %> diff --git a/app/views/admin/items/index.html.erb b/app/views/admin/items/index.html.erb index 2a8a12bb..f3d6c1c4 100644 --- a/app/views/admin/items/index.html.erb +++ b/app/views/admin/items/index.html.erb @@ -2,4 +2,4 @@ <%= render 'admin/items/site_map_left_bar' %> <% end -%> -<%= render "admin/#{@item._type.downcase.pluralize}/show" %> +<%= render "admin/#{@item.class.downcase.pluralize}/show" %> diff --git a/app/views/admin/items/index.js.erb b/app/views/admin/items/index.js.erb index 1ff6abb5..fb2d5702 100644 --- a/app/views/admin/items/index.js.erb +++ b/app/views/admin/items/index.js.erb @@ -1,5 +1,5 @@ $('#back_main').empty(); -<% case @item._type %> +<% case @item.class %> <% when 'Page' %> $('#back_main').append("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>"); <% when 'Link' %> diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb index aed8f36b..bce4c064 100644 --- a/lib/parsers/parser_back_end.rb +++ b/lib/parsers/parser_back_end.rb @@ -17,7 +17,7 @@ module ParserBackEnd # item = Item.first(:conditions => { :path => tag.attr['name'] }) # ret = '' # ret << "" # ret << item.i18n_variable[I18n.locale] # ret << "" diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 2c57f3f4..39a9733f 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -28,7 +28,7 @@ module ParserCommon res << " active" if (current_page.id.eql?(page.id) || current_page.descendant_of?(page)) res << "'>" root = "/" - res << "#{page.title}" + res << "#{page.title}" if page.visible_children.size > 0 && current < menu.levels res << "" res << menu_level(page, current_page, current + 1, menu, edit) @@ -121,7 +121,7 @@ module ParserCommon menu_page.visible_children.each do |child| res << "
  • " root = "/" - res << "#{child.title}" + res << "#{child.title}" res << "
  • " end res << ""