Class: BcmsKcfinder::BrowseController
- Inherits:
-
Cms::BaseController
- Object
- Cms::BaseController
- BcmsKcfinder::BrowseController
- Defined in:
- app/controllers/bcms_kcfinder/browse_controller.rb
Instance Method Summary collapse
-
#change_dir ⇒ Object
Change to a directory and return the files for that directory.
- #command ⇒ Object
- #create_new(klass) ⇒ Object
- #index ⇒ Object
-
#init ⇒ Object
At the start, the entire Sitemap tree has to be defined, though pages below the top level do not need to be included until a ‘chDir’ command is issued.
- #upload ⇒ Object
Instance Method Details
#change_dir ⇒ Object
Change to a directory and return the files for that directory
53 54 55 |
# File 'app/controllers/bcms_kcfinder/browse_controller.rb', line 53 def change_dir render :json => {files: list_files(), dirWritable: true}.to_json end |
#command ⇒ Object
59 60 61 |
# File 'app/controllers/bcms_kcfinder/browse_controller.rb', line 59 def command raise "Error: The command '#{params[:command]}' is not implemented yet." end |
#create_new(klass) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/bcms_kcfinder/browse_controller.rb', line 41 def create_new(klass) uploaded_file = params[:upload].first f = klass.new(:name => uploaded_file.original_filename, :publish_on_save => true) a = f..build(:parent => @section, :data_file_path => uploaded_file.original_filename, :attachment_name => 'file', :data => uploaded_file) f.save! f end |
#index ⇒ Object
11 12 |
# File 'app/controllers/bcms_kcfinder/browse_controller.rb', line 11 def index end |
#init ⇒ Object
At the start, the entire Sitemap tree has to be defined, though pages below the top level do not need to be included until a ‘chDir’ command is issued.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/bcms_kcfinder/browse_controller.rb', line 16 def init logger.warn "Use the right root section" @root_section = Cms::Section.root.first @section = Cms::Section.find_by_name_path("/") render :json => {tree: {name: @root_section.name, readable: true, writable: true, removable: false, current: true, hasDirs: !@section.child_sections.empty?, dirs: child_sections_to_dirs(@section)}, files: list_files(), dirWritable: true}.to_json end |
#upload ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/bcms_kcfinder/browse_controller.rb', line 31 def upload content_block = case params[:type].downcase when "files" create_new(Cms::FileBlock) when "images" create_new(Cms::ImageBlock) end render :text => content_block.path end |