This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/controllers/admin/pages_controller.rb

100 lines
2.1 KiB
Ruby
Raw Normal View History

class Admin::PagesController < ApplicationController
layout "site_editor"
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
2011-12-23 10:34:21 +00:00
@apps = ModuleApp.all
@item.is_published = true
@item.parent_id = @parent_item.id rescue nil
@designs = Design.all.entries
2011-08-25 07:08:31 +00:00
@default_design = Design.first
end
def edit
@item = Page.find(params[:id])
2011-12-23 10:34:21 +00:00
@apps = ModuleApp.all
@i18n_variable = @item.i18n_variable
@designs = Design.all.entries
@design = @item.design
end
def create
@item = Page.new(params[:page])
if @item.save
2011-06-01 02:24:14 +00:00
@item.create_parts
@item.save
flash.now[:notice] = t('admin.create_success_page')
respond_to do |format|
format.html {
2011-06-01 04:00:41 +00:00
redirect_to admin_page_url(@item)
2011-06-01 02:24:14 +00:00
}
format.js {}
2011-06-01 02:24:14 +00:00
end
2010-01-04 09:49:55 +00:00
else
2011-06-01 02:24:14 +00:00
flash.now[:error] = t('admin.create_error_page')
@i18n_variable = @item.i18n_variable
render :action => "new"
end
end
def update
@item = Page.find(params[:id])
if @item.update_attributes(params[:page])
flash[:notice] = t('admin.update_success_page')
respond_to do |format|
format.html {
redirect_to admin_page_url(@item)
}
format.js {}
end
else
render :action => "edit"
end
end
def destroy
@item = Page.find(params[:id])
@item.destroy
2011-06-01 04:00:41 +00:00
@item.destroy_page_parts
@item.destroy_i18n_variable
2011-06-01 04:00:41 +00:00
respond_to do |format|
format.html {
redirect_to admin_items_url( :parent_id => @item.parent_id )
}
format.js {}
end
end
def delete
respond_to do |format|
format.html {}
format.js { destroy }
end
end
2010-01-04 09:49:55 +00:00
def reload_themes
@design = Design.find(params[:id])
@themes = @design.themes
respond_to do |format|
format.js {}
end
end
end