Class: Cms::ContentBlockController

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

Instance Method Summary collapse

Methods included from PageHelper

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

Methods included from PathHelper

#attachment_path_for, #cms_connectable_path, #cms_index_path_for, #cms_index_url_for, #cms_new_path_for, #cms_new_url_for, #cms_sortable_column_path, #edit_cms_connectable_path, #engine_for, #link_to_usages, #path_elements_for

Methods included from ErrorHandling

#handle_access_denied, #handle_server_error, #with_format

Instance Method Details

#createObject



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

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



60
61
62
63
# File 'app/controllers/cms/content_block_controller.rb', line 60

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

#editObject



42
43
44
45
# File 'app/controllers/cms/content_block_controller.rb', line 42

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

#indexObject

Basic REST Crud Action



15
16
17
18
# File 'app/controllers/cms/content_block_controller.rb', line 15

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

#newObject



25
26
27
28
29
# File 'app/controllers/cms/content_block_controller.rb', line 25

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

#publishObject

Additional CMS Action



67
68
69
70
# File 'app/controllers/cms/content_block_controller.rb', line 67

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

#revert_toObject



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

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

#showObject



20
21
22
23
# File 'app/controllers/cms/content_block_controller.rb', line 20

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

#updateObject



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

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



96
97
98
99
100
# File 'app/controllers/cms/content_block_controller.rb', line 96

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

#versionObject



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

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

#versionsObject



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

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