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
51 52 53 |
# File 'app/controllers/bcms_kcfinder/browse_controller.rb', line 51 def change_dir render :json => {files: list_files(), dirWritable: true}.to_json end |
#command ⇒ Object
57 58 59 |
# File 'app/controllers/bcms_kcfinder/browse_controller.rb', line 57 def command raise "Error: The command '#{params[:command]}' is not implemented yet." end |
#create_new(klass) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/bcms_kcfinder/browse_controller.rb', line 39 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 |
# File 'app/controllers/bcms_kcfinder/browse_controller.rb', line 16 def init @section = Cms::Section.find_by_name_path("/") render :json => {tree: {name: "My Site", 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
29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/bcms_kcfinder/browse_controller.rb', line 29 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 |