2009-05-07 17:18:16 +00:00
|
|
|
class Admin::PagesController < ApplicationController
|
2009-05-07 18:13:27 +00:00
|
|
|
|
2011-12-05 01:54:41 +00:00
|
|
|
layout "site_editor"
|
2011-05-13 01:08:42 +00:00
|
|
|
|
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?
|
2011-05-13 01:08:42 +00:00
|
|
|
before_filter :set_current_item
|
2009-05-07 18:13:27 +00:00
|
|
|
|
2009-05-07 17:18:16 +00:00
|
|
|
def show
|
2011-05-25 06:50:56 +00:00
|
|
|
@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
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
2011-05-25 06:50:56 +00:00
|
|
|
@item = Page.new
|
2012-02-17 06:54:11 +00:00
|
|
|
@item.parent = Item.find(params[:parent_id]) rescue nil
|
2011-12-20 08:47:17 +00:00
|
|
|
@apps = ModuleApp.all
|
2011-08-23 18:06:27 +00:00
|
|
|
@designs = Design.all.entries
|
2012-02-17 06:54:11 +00:00
|
|
|
@design = Design.first
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
2011-08-23 18:34:24 +00:00
|
|
|
@item = Page.find(params[:id])
|
2011-12-20 08:47:17 +00:00
|
|
|
@apps = ModuleApp.all
|
2011-08-23 18:34:24 +00:00
|
|
|
@designs = Design.all.entries
|
2012-02-17 06:54:11 +00:00
|
|
|
@design = @item.design ? @item.design : @designs.first
|
2012-01-31 08:35:40 +00:00
|
|
|
@app_frontend_urls = @item.module_app.app_pages if @item.module_app
|
2012-02-23 07:48:23 +00:00
|
|
|
@categories = BulletinCategory.all if @item.module_app && @item.module_app.key.eql?('announcement')
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2011-05-25 06:50:56 +00:00
|
|
|
@item = Page.new(params[:page])
|
2012-02-21 11:22:42 +00:00
|
|
|
|
|
|
|
if @item.module_app.key == 'page_content'
|
|
|
|
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
|
|
|
|
end
|
|
|
|
|
2011-05-25 06:50:56 +00:00
|
|
|
if @item.save
|
2011-06-01 02:24:14 +00:00
|
|
|
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
|
|
|
}
|
2011-06-10 02:31:50 +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')
|
2012-02-17 06:54:11 +00:00
|
|
|
@apps = ModuleApp.all
|
|
|
|
@designs = Design.all.entries
|
|
|
|
@design = Design.first
|
2011-06-01 02:24:14 +00:00
|
|
|
render :action => "new"
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2011-08-23 18:34:24 +00:00
|
|
|
@item = Page.find(params[:id])
|
2012-02-21 11:22:42 +00:00
|
|
|
|
2012-02-24 07:14:23 +00:00
|
|
|
if @item.module_app && @item.module_app.key == 'page_content' && @item.page_contexts.blank?
|
2012-02-21 11:22:42 +00:00
|
|
|
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
|
|
|
|
end
|
|
|
|
|
2011-08-25 00:13:38 +00:00
|
|
|
if @item.update_attributes(params[:page])
|
2011-08-23 18:34:24 +00:00
|
|
|
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
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2011-05-25 06:50:56 +00:00
|
|
|
@item = Page.find(params[:id])
|
|
|
|
@item.destroy
|
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
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
2010-01-04 09:49:55 +00:00
|
|
|
|
2011-08-25 00:13:38 +00:00
|
|
|
def reload_themes
|
|
|
|
@design = Design.find(params[:id])
|
|
|
|
@themes = @design.themes
|
|
|
|
respond_to do |format|
|
|
|
|
format.js {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|