Module: Cms::ComponentsHelper
- Defined in:
- app/helpers/cms/components_helper.rb
Instance Method Summary collapse
- #component_delete_link(path) ⇒ Object
- #component_edit_link(path) ⇒ Object
- #component_folder_open?(folder_id) ⇒ Boolean
- #list_files(files, hidden = false) ⇒ Object
Instance Method Details
#component_delete_link(path) ⇒ Object
11 12 13 14 |
# File 'app/helpers/cms/components_helper.rb', line 11 def component_delete_link(path) full_path = Cms::Component.component_path(@context, path) link_to(cms_icon('delete.png', :title => 'Delete'), {:controller => 'cms/components', :action => 'destroy', :url => CGI::escape(full_path)}, :confirm => "Are you sure you want to remove '#{full_path}'?") end |
#component_edit_link(path) ⇒ Object
6 7 8 9 |
# File 'app/helpers/cms/components_helper.rb', line 6 def component_edit_link(path) full_path = Cms::Component.component_path(@context, path) link_to(truncate(File.basename(path), :length => 15), {:controller => 'cms/components', :action => 'edit', :url => CGI::escape(full_path)}) end |
#component_folder_open?(folder_id) ⇒ Boolean
2 3 4 |
# File 'app/helpers/cms/components_helper.rb', line 2 def component_folder_open?(folder_id) ('component_folders')[folder_id].present? end |
#list_files(files, hidden = false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/helpers/cms/components_helper.rb', line 16 def list_files(files, hidden = false) html = '' html += hidden ? %[<ul class="tree" style="display:none">] : %[<ul class="tree">] for file in files do html += "<li>" if File.directory?(file) folder_id = "folder_#{Digest::MD5.hexdigest(file)}" html += cms_icon('folder.png', :class => 'folder', :id => folder_id) + ' ' + component_delete_link(file) + ' ' html += content_tag(:span, File.basename(file), :title => Cms::Component.component_path(@context, file)) html += list_files(Cms::Component.files(file), !component_folder_open?(folder_id)) else html += file_type_icon(File.basename(file)) + ' ' html += component_delete_link(file) + ' ' if Cms::Component.editable?(file) html += component_edit_link(file) else html += content_tag(:span, truncate(File.basename(file), :length => 15), :title => Cms::Component.component_path(@context, file)) end end html += "</li>" end html += "</ul>" html.html_safe end |