Class | Cms::SectionsController |
In: |
app/controllers/cms/sections_controller.rb
|
Parent: | Cms::BaseController |
# File app/controllers/cms/sections_controller.rb, line 23 23: def create 24: @section = Section.new(params[:section]) 25: @section.parent = @parent 26: @section.groups = @section.parent.groups unless current_user.able_to?(:administrate) 27: if @section.save 28: flash[:notice] = "Section '#{@section.name}' was created" 29: redirect_to [:cms, @section] 30: else 31: render :action => 'new' 32: end 33: end
# File app/controllers/cms/sections_controller.rb, line 49 49: def destroy 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 71 71: def file_browser 72: @section = Section.find_by_name_path(params[:CurrentFolder]) 73: if request.post? && params[:NewFile] 74: handle_file_browser_upload 75: else 76: render_file_browser 77: end 78: end
# File app/controllers/cms/sections_controller.rb, line 10 10: def index 11: redirect_to cms_sitemap_path 12: end
# File app/controllers/cms/sections_controller.rb, line 63 63: def move 64: if params[:section_id] 65: @move_to = Section.find(params[:section_id]) 66: else 67: @move_to = Section.root.first 68: end 69: end
# File app/controllers/cms/sections_controller.rb, line 18 18: def new 19: @section = @parent.sections.build 20: @section.groups = @parent.groups 21: end
# File app/controllers/cms/sections_controller.rb, line 14 14: def show 15: redirect_to cms_sitemap_path 16: end
# File app/controllers/cms/sections_controller.rb, line 38 38: def update 39: params[:section].delete('group_ids') if params[:section] && !current_user.able_to?(:administrate) 40: @section.attributes = params[:section] 41: if @section.save 42: flash[:notice] = "Section '#{@section.name}' was updated" 43: redirect_to [:cms, @section] 44: else 45: render :action => 'edit' 46: end 47: end
# File app/controllers/cms/sections_controller.rb, line 123 123: def cms_groups 124: @cms_groups ||= Group.cms_access.all(:order => "groups.name") 125: end
# File app/controllers/cms/sections_controller.rb, line 91 91: def handle_file_browser_upload 92: begin 93: case params[:Type].downcase 94: when "file" 95: FileBlock.create!(:section => @section, :file => params[:NewFile]) 96: when "image" 97: ImageBlock.create!(:section => @section, :file => params[:NewFile]) 98: end 99: result = "0" 100: rescue Exception => e 101: result = "1,'#{escape_javascript(e.message)}'" 102: end 103: render :text => %Q{<script type="text/javascript">window.parent.frames['frmUpload'].OnUploadCompleted(#{result});</script>}, :layout => false 104: end
# File app/controllers/cms/sections_controller.rb, line 81 81: def load_parent 82: @parent = Section.find(params[:section_id]) 83: raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@parent) 84: end
# File app/controllers/cms/sections_controller.rb, line 86 86: def load_section 87: @section = Section.find(params[:id]) 88: raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@section) 89: end
# File app/controllers/cms/sections_controller.rb, line 119 119: def public_groups 120: @public_groups ||= Group.public.all(:order => "groups.name") 121: end
# File app/controllers/cms/sections_controller.rb, line 106 106: def render_file_browser 107: headers['Content-Type'] = "text/xml" 108: @files = case params[:Type].downcase 109: when "file" 110: FileBlock.by_section(@section) 111: when "image" 112: ImageBlock.by_section(@section) 113: else 114: @section.pages 115: end 116: render 'cms/sections/file_browser.xml.builder', :layout => false 117: end