app/controllers/cms/content_controller.rb in we5-browsercms-3.0.2 vs app/controllers/cms/content_controller.rb in we5-browsercms-3.0.5

- old
+ new

@@ -56,10 +56,11 @@ # This is the method all actions delegate to # check_access_to_page will also call this directly # if caching is not enabled def render_page @_page_route.execute(self) if @_page_route + prepare_connectables_for_render render :layout => @page.layout, :action => 'show' end def render_page_with_caching render_page @@ -92,16 +93,44 @@ # by previous attempts to render the page within this request @template.instance_variables.select{|v| v =~ /@content_for_/ }.each do |v| @template.instance_variable_set("#{v}", nil) end + prepare_connectables_for_render render :layout => @page.layout, :template => 'cms/content/show', :status => status else handle_server_error(exception) end - end + end + + # If any of the page's connectables (portlets, etc) are renderable, they may have a render method + # which does "controller" stuff, so we need to get that run before rendering the page. + def prepare_connectables_for_render + @_connectors = @page.connectors.for_page_version(@page.version) + @_connectables = @_connectors.map(&:connectable_with_deleted) + unless (logged_in? && current_user.able_to?(:administrate, :edit_content, :publish_content)) + worst_exception = nil + @_connectables.each do |c| + begin + c.prepare_to_render(self) + rescue + logger.debug "THROWN EXCEPTION by connectable #{c}: #{$!}" + case $! + when ActiveRecord::RecordNotFound + raise + when Cms::Errors::AccessDenied + worst_exception = $! + else + c.render_exception = $! + end + end + end + raise worst_exception if worst_exception + end + end + # ----- Before Filters ------------------------------------------------------- def construct_path @paths = params[:page_path] || params[:path] || [] @path = "/#{@paths.join("/")}" end @@ -222,6 +251,6 @@ session[:page_mode] = @mode end -end \ No newline at end of file +end