Class: Cms::ContentBlockController

Inherits:
BaseController show all
Defined in:
app/controllers/cms/content_block_controller.rb

Overview

This is not called directly This is the base class for other content blocks

Instance Method Summary collapse

Methods included from PageHelper

#able_to?, #cms_toolbar, #container, #container_has_block?, #current_page, #page_title, #render_breadcrumbs, #render_portlet

Methods included from PathHelper

#cms_connectable_path, #cms_index_path_for, #cms_index_url_for, #cms_new_path_for, #cms_new_url_for, #edit_cms_connectable_path

Methods included from ErrorHandling

#handle_access_denied, #handle_server_error, included

Instance Method Details

#createObject



29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/cms/content_block_controller.rb', line 29

def create
  if create_block
    after_create_on_success
  else
    after_create_on_failure
  end
rescue Exception => @exception
  raise @exception if @exception.is_a?(Cms::Errors::AccessDenied)
  after_create_on_error
end

#destroyObject



58
59
60
61
# File 'app/controllers/cms/content_block_controller.rb', line 58

def destroy
  do_command("deleted") { @block.destroy }
  redirect_to_first params[:_redirect_to], blocks_path
end

#editObject



40
41
42
43
# File 'app/controllers/cms/content_block_controller.rb', line 40

def edit
  load_block_draft
  render "#{template_directory}/edit"
end

#indexObject

Basic REST Crud Action



13
14
15
16
# File 'app/controllers/cms/content_block_controller.rb', line 13

def index
  load_blocks
  render "#{template_directory}/index"
end

#newObject



23
24
25
26
27
# File 'app/controllers/cms/content_block_controller.rb', line 23

def new
  build_block
  set_default_category
  render "#{template_directory}/new"
end

#publishObject

Additional CMS Action



65
66
67
68
# File 'app/controllers/cms/content_block_controller.rb', line 65

def publish
  do_command("published") { @block.publish! }
  redirect_to_first params[:_redirect_to], block_path
end

#revert_toObject



70
71
72
73
74
75
# File 'app/controllers/cms/content_block_controller.rb', line 70

def revert_to
  do_command("reverted to version #{params[:version]}") do
    revert_block(params[:version])
  end
  redirect_to_first params[:_redirect_to], block_path
end

#showObject



18
19
20
21
# File 'app/controllers/cms/content_block_controller.rb', line 18

def show
  load_block_draft
  render "#{template_directory}/show"
end

#updateObject



45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/cms/content_block_controller.rb', line 45

def update
  if update_block
    after_update_on_success
  else
    after_update_on_failure
  end
rescue ActiveRecord::StaleObjectError => @exception
  after_update_on_edit_conflict
rescue Exception => @exception
  raise @exception if @exception.is_a?(Cms::Errors::AccessDenied)
  after_update_on_error
end

#usagesObject



94
95
96
97
98
# File 'app/controllers/cms/content_block_controller.rb', line 94

def usages
  load_block_draft
  @pages = @block.connected_pages.all(:order => 'name')
  render "#{template_directory}/usages"
end

#versionObject



77
78
79
80
81
82
83
# File 'app/controllers/cms/content_block_controller.rb', line 77

def version
  load_block
  if params[:version]
    @block = @block.as_of_version(params[:version])
  end
  render "#{template_directory}/show"
end

#versionsObject



85
86
87
88
89
90
91
92
# File 'app/controllers/cms/content_block_controller.rb', line 85

def versions
  if model_class.versioned?
    load_block
    render "#{template_directory}/versions"
  else
    render :text => "Not Implemented", :status => :not_implemented
  end    
end