2010-05-10 22:39:52 +00:00
|
|
|
module Admin
|
|
|
|
class LayoutsController < BaseController
|
2010-05-02 23:33:17 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
sections 'settings'
|
2010-05-02 23:33:17 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def index
|
2010-06-22 13:04:40 +00:00
|
|
|
@layouts = current_site.layouts.order_by([[:name, :asc]])
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-05-09 12:44:53 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def new
|
|
|
|
@layout = current_site.layouts.build
|
|
|
|
end
|
2010-05-02 23:33:17 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def edit
|
|
|
|
@layout = current_site.layouts.find(params[:id])
|
|
|
|
end
|
2010-05-02 23:33:17 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def create
|
|
|
|
@layout = current_site.layouts.build(params[:layout])
|
2010-05-02 23:33:17 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
if @layout.save
|
|
|
|
flash_success!
|
|
|
|
redirect_to edit_admin_layout_url(@layout)
|
|
|
|
else
|
2010-06-24 09:14:08 +00:00
|
|
|
logger.debug "===> #{@layout.errors.inspect}"
|
2010-05-10 22:39:52 +00:00
|
|
|
flash_error!
|
|
|
|
render :action => 'new'
|
|
|
|
end
|
2010-05-02 23:33:17 +00:00
|
|
|
end
|
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def update
|
|
|
|
@layout = current_site.layouts.find(params[:id])
|
2010-05-02 23:33:17 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
if @layout.update_attributes(params[:layout])
|
|
|
|
flash_success!
|
|
|
|
redirect_to edit_admin_layout_url(@layout)
|
|
|
|
else
|
|
|
|
flash_error!
|
|
|
|
render :action => "edit"
|
|
|
|
end
|
2010-05-02 23:33:17 +00:00
|
|
|
end
|
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def destroy
|
|
|
|
@layout = current_site.layouts.find(params[:id])
|
2010-05-02 23:33:17 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
begin
|
|
|
|
@layout.destroy
|
|
|
|
flash_success!
|
|
|
|
rescue Exception => e
|
|
|
|
flash[:error] = e.to_s
|
|
|
|
end
|
2010-05-02 23:33:17 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
redirect_to admin_layouts_url
|
|
|
|
end
|
2010-05-02 23:33:17 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-05-02 23:33:17 +00:00
|
|
|
end
|