Class: Cms::PagesController
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
#handle_access_denied, #handle_server_error, #with_format
Instance Method Details
#create ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/cms/pages_controller.rb', line 25
def create
@page = Page.new(params[:page])
@page.section = @section
if @page.save
flash[:notice] = "Page was '#{@page.name}' created."
redirect_to @page
else
render :action => "new"
end
end
|
#destroy ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'app/controllers/cms/pages_controller.rb', line 48
def destroy
respond_to do |format|
if @page.destroy
message = "Page '#{@page.name}' was deleted."
format.html { flash[:notice] = message; redirect_to(sitemap_url) }
format.json { render :json => {:success => true, :message => message } }
else
message = "Page '#{@page.name}' could not be deleted"
format.html { flash[:error] = message; redirect_to(sitemap_url) }
format.json { render :json => {:success => false, :message => message } }
end
end
end
|
#new ⇒ Object
13
14
15
16
17
18
19
|
# File 'app/controllers/cms/pages_controller.rb', line 13
def new
@page = Page.new(:section => @section, :cacheable => true)
if @section.child_nodes.count < 1
@page.name = "Overview"
@page.path = @section.path
end
end
|
#revert_to ⇒ Object
90
91
92
93
94
95
96
97
98
99
|
# File 'app/controllers/cms/pages_controller.rb', line 90
def revert_to
if @page.revert_to(params[:version])
flash[:notice] = "Page '#{@page.name}' was reverted to version #{params[:version]}"
end
respond_to do |format|
format.html { redirect_to @page.path }
format.js { render :template => 'cms/shared/show_notice' }
end
end
|
#show ⇒ Object
21
22
23
|
# File 'app/controllers/cms/pages_controller.rb', line 21
def show
redirect_to Page.find(params[:id]).path
end
|
#update ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/controllers/cms/pages_controller.rb', line 36
def update
if @page.update_attributes(params[:page])
flash[:notice] = "Page was '#{@page.name}' updated."
redirect_to @page
else
render :action => "edit"
end
rescue ActiveRecord::StaleObjectError => e
@other_version = @page.class.find(@page.id)
render :action => "edit"
end
|
#version ⇒ Object
81
82
83
84
85
86
87
88
|
# File 'app/controllers/cms/pages_controller.rb', line 81
def version
@page = @page.as_of_version(params[:version])
@show_toolbar = true
@show_page_toolbar = true
@_connectors = @page.connectors.for_page_version(@page.version)
@_connectables = @_connectors.map(&:connectable_with_deleted)
render :layout => @page.layout, :template => 'cms/content/show'
end
|