2009-05-07 17:18:16 +00:00
|
|
|
class Admin::PagesController < ApplicationController
|
2009-05-07 18:13:27 +00:00
|
|
|
|
2011-05-09 10:49:57 +00:00
|
|
|
layout "content"
|
2010-03-04 08:33:26 +00:00
|
|
|
before_filter :authenticate_user!
|
2010-01-14 10:30:53 +00:00
|
|
|
before_filter :find_parent_item
|
2011-04-13 10:19:51 +00:00
|
|
|
before_filter :is_admin?
|
2009-05-07 18:13:27 +00:00
|
|
|
|
2009-05-07 17:18:16 +00:00
|
|
|
def show
|
2010-01-14 10:30:53 +00:00
|
|
|
#TODO
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@page = Page.new
|
2009-05-22 06:43:52 +00:00
|
|
|
@page.is_published = true
|
2011-04-13 10:19:51 +00:00
|
|
|
@page.parent_id = @parent_item.id rescue nil
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@page = Page.find(params[:id])
|
2011-03-02 09:28:33 +00:00
|
|
|
@page.content = parse_content(@page.content, {:locale => 'show'})
|
2011-04-13 10:19:51 +00:00
|
|
|
@i18n_variable = @page.i18n_variable
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@page = Page.new(params[:page])
|
2011-03-02 09:28:33 +00:00
|
|
|
@page.content = parse_content(@page.content, {:locale => 'create'})
|
2010-01-04 09:49:55 +00:00
|
|
|
if @page.save
|
2011-04-13 10:19:51 +00:00
|
|
|
flash[:notice] = t('admin.create_success_page')
|
|
|
|
redirect_to admin_items_url( :parent_id => @page.parent_id )
|
2010-01-04 09:49:55 +00:00
|
|
|
else
|
|
|
|
render :action => "new"
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@page = Page.find(params[:id])
|
2011-03-02 09:28:33 +00:00
|
|
|
parse_content(@page.content, {:locale => 'destroy'})
|
2010-01-04 09:49:55 +00:00
|
|
|
if @page.update_attributes(params[:page])
|
2011-03-02 09:28:33 +00:00
|
|
|
@page.content = parse_content(@page.content, {:locale => 'create'})
|
|
|
|
@page.save!
|
2011-04-13 10:19:51 +00:00
|
|
|
flash[:notice] = t('admin.update_success_page')
|
|
|
|
redirect_to admin_items_url( :parent_id => @page.parent_id )
|
2010-01-04 09:49:55 +00:00
|
|
|
else
|
|
|
|
render :action => "edit"
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@page = Page.find(params[:id])
|
|
|
|
@page.destroy
|
2011-01-28 06:44:08 +00:00
|
|
|
@page.destroy_i18n_variable
|
2009-05-07 17:18:16 +00:00
|
|
|
|
2011-04-13 10:19:51 +00:00
|
|
|
redirect_to admin_items_url( :parent_id => @page.parent_id )
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
2010-01-04 09:49:55 +00:00
|
|
|
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|