Class: Bolt::PagesController

Inherits:
BoltController show all
Defined in:
app/controllers/bolt/pages_controller.rb

Instance Method Summary collapse

Methods inherited from BoltController

#blank

Methods included from ConfigHelper

#bolt_config_dashboard_url, #bolt_config_email_from_address, #bolt_config_hostname, #bolt_config_javascript_includes, #bolt_config_logo, #bolt_config_stylesheet_includes, #bolt_config_website_name

Methods included from BoltHelper

#bolt_check_box, #bolt_check_box_group, #bolt_collection_select, #bolt_date_select, #bolt_datetime_select, #bolt_file_field, #bolt_generate_page_title, #bolt_get_access_level_array, #bolt_get_access_level_text, #bolt_get_full_version_string, #bolt_get_short_version_string, #bolt_get_version_info, #bolt_hidden_field, #bolt_password_field, #bolt_radio_button, #bolt_radio_button_group, #bolt_select, #bolt_show_icon, #bolt_show_row_icon, #bolt_table_cell_link, #bolt_table_cell_no_link, #bolt_text_area, #bolt_text_area_big, #bolt_text_field, #bolt_time_select, #bolt_time_zone_select

Instance Method Details

#createObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/bolt/pages_controller.rb', line 27

def create     
  if(!params[:parent].blank? && params[:parent].to_i > 0)
    parent = Page.find(params[:parent].to_i)
  end
  @page = Page.new params[:page]        
  @page.parent_id = parent.id if(!parent.nil?)
       
  if @page.save
    flash[:notice] = 'Page created'
    redirect_to bolt_pages_path
  else
    flash.now[:warning] = 'There were problems when trying to create a new page'
    render :action => :new
  end
end

#destroyObject



65
66
67
68
69
70
# File 'app/controllers/bolt/pages_controller.rb', line 65

def destroy
  @page = Page.find params[:id]
  @page.destroy
  flash[:notice] = 'Page has been deleted'
  redirect_to bolt_pages_path
end

#destroy_multipleObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'app/controllers/bolt/pages_controller.rb', line 73

def destroy_multiple
  ids= params[:id]
  idarr=ids.split(',')
  idarr.each do |del|
   #@page = Page.find(del)
   total_rows=Page.find(:all, :conditions => { :id => del}).count
   if(total_rows > 0)
    Page.destroy(del)
   end
 end
 respond_to do |format|
   format.html { redirect_to :action =>"index"  }
   # format.json { head :ok }
 end
end

#indexObject

optional filters for defining usage according to Bolt::Users access_levels before_filter :needs_admin, :except => [:action1, :action2] before_filter :needs_admin_or_current_user, :only => [:action1, :action2]



8
9
10
11
# File 'app/controllers/bolt/pages_controller.rb', line 8

def index
  @bolt_page_title = 'Pages'
  @pages = Page.parent_menu.paginate :page => params[:page]
end

#newObject



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

def new
  @bolt_page_title = 'Add a new page'
media_id =Medium.where(:link_title  => 'banners')
   @site_images =MediaImage.where(:medium_id => media_id)
  @page = Page.new
end

#showObject



13
14
15
16
17
18
# File 'app/controllers/bolt/pages_controller.rb', line 13

def show
  @bolt_page_title = 'View page'
  media_id =Medium.where(:link_title  => 'banners')
   @site_images =MediaImage.where(:medium_id => media_id)
  @page = Page.find params[:id]
end

#updateObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/bolt/pages_controller.rb', line 43

def update
  @bolt_page_title = 'Update page'
  @page = Page.find params[:id]
  if(params[:parent].to_i > 0 && params[:parent].to_i != @page.parent_id)
	  parent = Page.find_by_id(params[:parent])	
	  if(!parent.nil?)
          @page.parent_id = parent.id
      end
  elsif(params[:parent].blank? || params[:parent].nil?) 
       	@page.parent_id = nil      
  end
  
  
  if @page.update_attributes params[:page]
    flash[:notice] = 'Page has been updated'
    redirect_to bolt_pages_path
  else
    flash.now[:warning] = 'There were problems when trying to update this page'
    render :action => :show
  end
end