Permalink
Browse files

remove @cache_id from controllers

  • Loading branch information...
robramsaynz committed Apr 7, 2015
1 parent 8a07160 commit ea86ffdacdd5c3e12165cd0aa53ced9f376f6c69
@@ -120,9 +120,6 @@ def password_protect
# by posting a dummy form
before_filter :current_user_can_see_action_menu?, :only => [:new, :create, :edit, :update]

# creates a @cache_id variable based on params[:id]
before_filter :set_cache_id, :only => [:show]

# TODO: NOT USED, delete code here and in lib/zoom_controller_helpers.rb
# related items only track title and url, therefore only update will change those attributes
after_filter :update_zoom_record_for_related_items, :only => [ :update ]
@@ -148,10 +145,6 @@ def adjust_http_headers_for_rss
helper :slideshows
helper :extended_fields

def set_cache_id
@cache_id = params[:id] ? params[:id].to_i : nil
end

# set the current basket to the default
# unless we have urlified_name that is different
# than the default
@@ -677,17 +677,18 @@ def class_and_styless_from(position = nil, count = nil)
{class: class_names.join(' '), style: styles.join }
end

def related_items_count_for_current_item
def related_items_count_for_current_item(item)
@related_items_count_for_current_item ||= begin
cache_id = @cache_id
class_name = zoom_class_from_controller(params[:controller])
unless cache_id
cache_id = @topic.id if @topic.present?
if item
item_id = item.id
class_name = zoom_class_from_controller(params[:controller])
else
item_id = @topic.id if @topic.present?
class_name = 'Topic' if class_name == 'IndexPage'
end
conditions = "(content_item_relations.related_item_id = :cache_id AND content_item_relations.related_item_type = '#{class_name}')"
conditions += " OR (content_item_relations.topic_id = :cache_id)" if params[:controller] == 'topics' || params[:controller] == 'index_page'
ContentItemRelation.count(:conditions => [conditions, { :cache_id => cache_id }])
conditions = "(content_item_relations.related_item_id = :item_id AND content_item_relations.related_item_type = '#{class_name}')"
conditions += " OR (content_item_relations.topic_id = :item_id)" if params[:controller] == 'topics' || params[:controller] == 'index_page'
ContentItemRelation.count(:conditions => [conditions, { :item_id => item_id }])
end
end

@@ -3,15 +3,14 @@
- topics_only ||= false
- position ||= ''

- @total_item_counts = related_items_count_for_current_item
- @total_item_counts = related_items_count_for_current_item(item)
- if @total_item_counts > 0
- options = { :item_classes => (topics_only ? ['Topic'] : nil), :with_counts => true, :start_record => 0,
:end_record => [SystemSetting.number_of_related_images_to_display, SystemSetting.number_of_related_things_to_display_per_type].sort.last }
- @public_items, @public_item_counts = public_related_items_for(item, options)
- @private_items, @private_item_counts = private_related_items_for(item, options)



%div{ :id => "related_items", :class => related_items_class_from(position, related_items.count), :style => related_items_styles_from(position, related_items.count) }
%div{:class => "secondary-content-section-wrapper#{class_suffix_from(position)}"}
%div{:class => "secondary-content-section", :id => "related"}

0 comments on commit ea86ffd

Please sign in to comment.