Class | Cms::SectionsController |
In: |
app/controllers/cms/sections_controller.rb
|
Parent: | Cms::BaseController |
# File app/controllers/cms/sections_controller.rb, line 22 22: def create 23: @section = Section.new(params[:section]) 24: @section.parent = @parent 25: if @section.save 26: flash[:notice] = "Section '#{@section.name}' was created" 27: redirect_to [:cms, @section] 28: else 29: render :action => 'new' 30: end 31: end
# File app/controllers/cms/sections_controller.rb, line 48 48: def destroy 49: @section = Section.find(params[:id]) 50: respond_to do |format| 51: if @section.deletable? && @section.destroy 52: message = "Section '#{@section.name}' was deleted." 53: format.html { flash[:notice] = message; redirect_to(cms_sitemap_url) } 54: format.json { render :json => {:success => true, :message => message } } 55: else 56: message = "Section '#{@section.name}' could not be deleted" 57: format.html { flash[:error] = message; redirect_to(cms_sitemap_url) } 58: format.json { render :json => {:success => false, :message => message } } 59: end 60: end 61: end
# File app/controllers/cms/sections_controller.rb, line 33 33: def edit 34: @section = Section.find(params[:id]) 35: raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@section) 36: end
# File app/controllers/cms/sections_controller.rb, line 72 72: def file_browser 73: @section = Section.find_by_name_path(params[:CurrentFolder]) 74: if request.post? && params[:NewFile] 75: handle_file_browser_upload 76: else 77: render_file_browser 78: end 79: end
# File app/controllers/cms/sections_controller.rb, line 9 9: def index 10: redirect_to cms_sitemap_path 11: end
# File app/controllers/cms/sections_controller.rb, line 63 63: def move 64: @section = Section.find(params[:id]) 65: if params[:section_id] 66: @move_to = Section.find(params[:section_id]) 67: else 68: @move_to = Section.root.first 69: end 70: end
# File app/controllers/cms/sections_controller.rb, line 17 17: def new 18: @section = @parent.sections.build 19: @section.groups = public_groups + cms_groups 20: end
# File app/controllers/cms/sections_controller.rb, line 13 13: def show 14: redirect_to cms_sitemap_path 15: end
# File app/controllers/cms/sections_controller.rb, line 38 38: def update 39: @section = Section.find(params[:id]) 40: if @section.update_attributes(params[:section]) 41: flash[:notice] = "Section '#{@section.name}' was updated" 42: redirect_to [:cms, @section] 43: else 44: render :action => 'edit' 45: end 46: end
# File app/controllers/cms/sections_controller.rb, line 118 118: def cms_groups 119: @cms_groups ||= Group.cms_access.all(:order => "groups.name") 120: end
# File app/controllers/cms/sections_controller.rb, line 86 86: def handle_file_browser_upload 87: begin 88: case params[:Type].downcase 89: when "file" 90: FileBlock.create!(:section => @section, :file => params[:NewFile]) 91: when "image" 92: ImageBlock.create!(:section => @section, :file => params[:NewFile]) 93: end 94: result = "0" 95: rescue Exception => e 96: result = "1,'#{escape_javascript(e.message)}'" 97: end 98: render :text => %Q{<script type="text/javascript">window.parent.frames['frmUpload'].OnUploadCompleted(#{result});</script>}, :layout => false 99: end
# File app/controllers/cms/sections_controller.rb, line 82 82: def load_parent 83: @parent = Section.find(params[:section_id]) 84: end
# File app/controllers/cms/sections_controller.rb, line 114 114: def public_groups 115: @public_groups ||= Group.public.all(:order => "groups.name") 116: end
# File app/controllers/cms/sections_controller.rb, line 101 101: def render_file_browser 102: headers['Content-Type'] = "text/xml" 103: @files = case params[:Type].downcase 104: when "file" 105: FileBlock.by_section(@section) 106: when "image" 107: ImageBlock.by_section(@section) 108: else 109: @section.pages 110: end 111: render 'cms/sections/file_browser.xml.builder', :layout => false 112: end