Orbit/app/controllers/admin/pages_controller.rb

65 lines
1.5 KiB
Ruby
Raw Normal View History

class Admin::PagesController < ApplicationController
layout "content"
2011-05-13 01:08:42 +00:00
before_filter :authenticate_user!
before_filter :find_parent_item
before_filter :is_admin?
2011-05-13 01:08:42 +00:00
before_filter :set_current_item
def show
@item = Page.find(params[:id])
2011-05-13 01:08:42 +00:00
respond_to do |format|
format.html {
render 'admin/items/index'
}
format.js {}
end
end
def new
@item = Page.new
@item.is_published = true
@item.parent_id = @parent_item.id rescue nil
end
def edit
@item = Page.find(params[:id])
@item.content = parse_content(@item.content, {:locale => 'show'})
@i18n_variable = @item.i18n_variable
end
def create
@item = Page.new(params[:page])
@item.content = parse_content(@item.content, {:locale => 'create'})
if @item.save
flash[:notice] = t('admin.create_success_page')
redirect_to admin_items_url( :parent_id => @item.parent_id )
2010-01-04 09:49:55 +00:00
else
render :action => "new"
end
end
def update
@item = Page.find(params[:id])
parse_content(@item.content, {:locale => 'destroy'})
if @item.update_attributes(params[:page])
@item.content = parse_content(@item.content, {:locale => 'create'})
@item.save!
flash[:notice] = t('admin.update_success_page')
redirect_to admin_items_url( :parent_id => @item.parent_id )
2010-01-04 09:49:55 +00:00
else
render :action => "edit"
end
end
def destroy
@item = Page.find(params[:id])
@item.destroy
@item.destroy_i18n_variable
redirect_to admin_items_url( :parent_id => @item.parent_id )
end
2010-01-04 09:49:55 +00:00
end