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

#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_server_error, included

Instance Method Details

#createObject



29
30
31
32
33
34
35
36
37
# 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
  after_create_on_error
end

#destroyObject



56
57
58
59
# File 'app/controllers/cms/content_block_controller.rb', line 56

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

#editObject



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

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



63
64
65
66
# File 'app/controllers/cms/content_block_controller.rb', line 63

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

#revert_toObject



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

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



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

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
  after_update_on_error
end

#usagesObject



92
93
94
95
96
# File 'app/controllers/cms/content_block_controller.rb', line 92

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

#versionObject



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

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

#versionsObject



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

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