Class: Admin::PagesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/pages_controller.rb

Instance Method Summary collapse

Instance Method Details

#activateObject



81
82
83
# File 'app/controllers/admin/pages_controller.rb', line 81

def activate
  render :text => @page.activate
end

#createObject



33
34
35
36
37
38
39
40
41
# File 'app/controllers/admin/pages_controller.rb', line 33

def create
  if @page.save
    flash[:notice] = I18n.t('page.create.success').capitalize
     redirect_to([forgeos_cms, :edit, :admin, @page])
  else
    flash[:error] = I18n.t('page.create.failed').capitalize
    render :action => 'new'
  end
end

#destroyObject



60
61
62
63
64
65
66
67
68
# File 'app/controllers/admin/pages_controller.rb', line 60

def destroy
  if @page.destroy
    flash[:notice] = I18n.t('page.destroy.success').capitalize
  else
    flash[:error] = @page.errors if @page
    flash[:error] = I18n.t('page.destroy.failed').capitalize
  end
  render :nothing => true
end

#duplicateObject



28
29
30
31
# File 'app/controllers/admin/pages_controller.rb', line 28

def duplicate
  @page = @page.clone
  render :action => 'new'
end

#editObject



43
44
45
46
47
48
# File 'app/controllers/admin/pages_controller.rb', line 43

def edit
  number_of_cols = @page.min_cols_by_page - @page.page_cols.size
  number_of_cols.times do
    @page.page_cols.build
  end
end

#indexObject



9
10
11
12
13
14
15
16
17
# File 'app/controllers/admin/pages_controller.rb', line 9

def index
  respond_to do |format|
    format.html
    format.json do
      sort
      render :layout => false
    end
  end
end


70
71
72
73
74
75
# File 'app/controllers/admin/pages_controller.rb', line 70

def link
  if request.post?
    @page.update_attributes!(params[:page])
  end
  return redirect_to([forgeos_cms, :admin, @page])
end

#newObject



21
22
23
24
25
26
# File 'app/controllers/admin/pages_controller.rb', line 21

def new
  number_of_cols = @page.min_cols_by_page - @page.page_cols.size
  number_of_cols.times do
    @page.page_cols.build
  end
end

#showObject



19
# File 'app/controllers/admin/pages_controller.rb', line 19

def show; end

#updateObject



50
51
52
53
54
55
56
57
58
# File 'app/controllers/admin/pages_controller.rb', line 50

def update
  if @page.update_attributes(params[:page])
    flash[:notice] = I18n.t('page.update.success').capitalize
    redirect_to([forgeos_cms, :edit, :admin, @page])
  else
    flash[:error] = I18n.t('page.update.failed').capitalize
    render :action => 'edit'
  end
end

#urlObject



77
78
79
# File 'app/controllers/admin/pages_controller.rb', line 77

def url
  render :text => Forgeos::url_generator(params[:url])
end