Fix: "._type" to ".class"

This commit is contained in:
Christophe Vilayphiou 2012-07-30 17:21:37 +08:00
parent bb154f5be6
commit 7440727acd
10 changed files with 18 additions and 18 deletions

View File

@ -32,7 +32,7 @@ class Admin::PurchasesController < ApplicationController
public_key = OpenSSL::PKey::RSA.new(File.read(APP_CONFIG['main_public_key'])) public_key = OpenSSL::PKey::RSA.new(File.read(APP_CONFIG['main_public_key']))
encrypted_data = public_key.public_encrypt({:purchase_id => purchase.purchase_id, 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, :roaming_id => Site.find(session[:site]).roaming_id,
:url => url}.to_json) :url => url}.to_json)
@ -43,7 +43,7 @@ class Admin::PurchasesController < ApplicationController
temp_file.write response.body temp_file.write response.body
temp_file.rewind temp_file.rewind
zip_name = response['content-disposition'].split('filename=')[1].gsub(/[\\\"]|.zip/, '') rescue '' zip_name = response['content-disposition'].split('filename=')[1].gsub(/[\\\"]|.zip/, '') rescue ''
case purchase._type case purchase.class
when 'Pdesign' when 'Pdesign'
unzip_design(temp_file, zip_name) unzip_design(temp_file, zip_name)
when 'PModuleApp' when 'PModuleApp'

View File

@ -22,7 +22,7 @@ class PagesController < ApplicationController
@item = Item.first(:conditions => {:path => params[:page_name]}) @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)) if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
# impressionist(@item) # impressionist(@item)
case @item._type case @item.class
when 'Page' when 'Page'
render_page render_page
when 'Link' when 'Link'

View File

@ -30,7 +30,7 @@ class SessionsController < Devise::SessionsController
render :action => "new" render :action => "new"
else else
logger.info "===ALL passed" logger.info "===ALL passed"
resource_name = resource._type.downcase resource_name = resource.class.downcase
sign_in(resource_name, resource) sign_in(resource_name, resource)
respond_with resource, :location => redirect_location(resource_name, resource) respond_with resource, :location => redirect_location(resource_name, resource)
end end
@ -48,7 +48,7 @@ class SessionsController < Devise::SessionsController
logger.info "=======Rulingcom account======" logger.info "=======Rulingcom account======"
resource = User.first(conditions:{email: login_uid}) resource = User.first(conditions:{email: login_uid})
if resource.valid_password?(login_password) if resource.valid_password?(login_password)
resource_name = resource._type.downcase resource_name = resource.class.downcase
sign_in(resource_name, resource) sign_in(resource_name, resource)
respond_with resource, :location => redirect_location(resource_name, resource) respond_with resource, :location => redirect_location(resource_name, resource)
else else

View File

@ -14,7 +14,7 @@ module Admin::DashboardHelper
end end
def get_link_to_object(object) def get_link_to_object(object)
case object._type.underscore case object.class.underscore
when 'bulletin' when 'bulletin'
panel_announcement_front_end_bulletin_path(object) panel_announcement_front_end_bulletin_path(object)
when 'news_bulletin' when 'news_bulletin'

View File

@ -3,7 +3,7 @@ module Admin::ItemHelper
def render_node_and_children(node) def render_node_and_children(node)
ret = '' ret = ''
if node if node
case node._type case node.class
when 'Page' when 'Page'
dest = admin_page_path(node) dest = admin_page_path(node)
when 'Link' when 'Link'
@ -15,10 +15,10 @@ module Admin::ItemHelper
ret << "<div class='with_action'><i class='icons-moves'></i>" ret << "<div class='with_action'><i class='icons-moves'></i>"
ret << (link_to node.title, dest, :class => 'js_history') ret << (link_to node.title, dest, :class => 'js_history')
ret << "<div class='quick-edit hide'>" ret << "<div class='quick-edit hide'>"
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.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._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.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._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.lass.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(:delete), eval("delete_admin_#{node.lass.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete js_history')
ret << "</div>" ret << "</div>"
ret << "</div>" ret << "</div>"
ret << render_children(node) ret << render_children(node)

View File

@ -515,7 +515,7 @@
<% @recent_updated.each do |object| %> <% @recent_updated.each do |object| %>
<tr> <tr>
<td><%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %></td> <td><%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %></td>
<td class="span2"><%= link_to t("dashboard.#{object[0]._type.underscore}"), get_link(object[0]._type.underscore) %></td> <td class="span2"><%= link_to t("dashboard.#{object[0].class.underscore}"), get_link(object[0].class.underscore) %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
@ -553,7 +553,7 @@
<% @most_visited.each do |object| %> <% @most_visited.each do |object| %>
<tr> <tr>
<td><%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %></td> <td><%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %></td>
<td class="span2"><%= link_to t("dashboard.#{object[0]._type.underscore}"), get_link(object[0]._type.underscore) %></td> <td class="span2"><%= link_to t("dashboard.#{object[0].class.underscore}"), get_link(object[0].class.underscore) %></td>
<td class="span2"><%= object[1] %></td> <td class="span2"><%= object[1] %></td>
</tr> </tr>
<% end %> <% end %>

View File

@ -2,4 +2,4 @@
<%= render 'admin/items/site_map_left_bar' %> <%= render 'admin/items/site_map_left_bar' %>
<% end -%> <% end -%>
<%= render "admin/#{@item._type.downcase.pluralize}/show" %> <%= render "admin/#{@item.class.downcase.pluralize}/show" %>

View File

@ -1,5 +1,5 @@
$('#back_main').empty(); $('#back_main').empty();
<% case @item._type %> <% case @item.class %>
<% when 'Page' %> <% when 'Page' %>
$('#back_main').append("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>"); $('#back_main').append("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>");
<% when 'Link' %> <% when 'Link' %>

View File

@ -17,7 +17,7 @@ module ParserBackEnd
# item = Item.first(:conditions => { :path => tag.attr['name'] }) # item = Item.first(:conditions => { :path => tag.attr['name'] })
# ret = '' # ret = ''
# ret << "<a href='" # ret << "<a href='"
# ret << eval("admin_#{item._type.downcase}_path(item.id)") # ret << eval("admin_#{item.class.downcase}_path(item.id)")
# ret << "' class='nav'>" # ret << "' class='nav'>"
# ret << item.i18n_variable[I18n.locale] # ret << item.i18n_variable[I18n.locale]
# ret << "</a>" # ret << "</a>"

View File

@ -28,7 +28,7 @@ module ParserCommon
res << " active" if (current_page.id.eql?(page.id) || current_page.descendant_of?(page)) res << " active" if (current_page.id.eql?(page.id) || current_page.descendant_of?(page))
res << "'>" res << "'>"
root = "/" root = "/"
res << "<a href='#{edit ? root + admin_page_path(page.id) : (page._type.eql?('Page') ? root + page.path : page.url)}'><span>#{page.title}</span></a>" res << "<a href='#{edit ? root + admin_page_path(page.id) : (page.class.eql?('Page') ? root + page.path : page.url)}'><span>#{page.title}</span></a>"
if page.visible_children.size > 0 && current < menu.levels if page.visible_children.size > 0 && current < menu.levels
res << "<span class='dot'></span>" res << "<span class='dot'></span>"
res << menu_level(page, current_page, current + 1, menu, edit) res << menu_level(page, current_page, current + 1, menu, edit)
@ -121,7 +121,7 @@ module ParserCommon
menu_page.visible_children.each do |child| menu_page.visible_children.each do |child|
res << "<li class='#{page.id.eql?(child.id) ? 'active' : nil}'>" res << "<li class='#{page.id.eql?(child.id) ? 'active' : nil}'>"
root = "/" root = "/"
res << "<a href='#{edit ? root + admin_page_path(child.id) : (child._type.eql?('Page') ? root + child.path : child.url)}'>#{child.title}</a>" res << "<a href='#{edit ? root + admin_page_path(child.id) : (child.class.eql?('Page') ? root + child.path : child.url)}'>#{child.title}</a>"
res << "</li>" res << "</li>"
end end
res << "</ul>" res << "</ul>"