ref: master
app/helpers/box_organizer_helper.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
module BoxOrganizerHelper def display_icon(block) image_path = nil plugin = @plugins.fetch_first_plugin(:has_block?, block) theme = Theme.new(environment.theme) # remove this if File.exists?(File.join(theme.filesystem_path, block.icon_path)) image_path = File.join(theme.public_path, block.icon_path) elsif plugin && File.exists?(File.join(Rails.root, 'public', plugin.public_path, block.icon_path)) image_path = File.join('/', plugin.public_path, block.icon_path) elsif File.exists?(File.join(Rails.root, 'public', block.icon_path)) image_path = block.icon_path else image_path = block.default_icon_path end image_tag(image_path, height: '48', width: '48', class: 'block-type-icon', alt: '' ) end def display_previews(block) images_path = nil plugin = @plugins.fetch_first_plugin(:has_block?, block) theme = Theme.new(environment.theme) # remove this images_path = Dir.glob(File.join(theme.filesystem_path, 'images', block.preview_path, '*')) images_path = images_path.map{|path| path.gsub(theme.filesystem_path, theme.public_path) } unless images_path.empty? images_path = Dir.glob(File.join(Rails.root, 'public', plugin.public_path, 'images', block.preview_path, '*')) if plugin && images_path.empty? images_path = images_path.map{|path| path.gsub(File.join(Rails.root, 'public'), '') } unless images_path.empty? images_path = Dir.glob(File.join(Rails.root, 'public', 'images', block.preview_path, '*')) if images_path.empty? images_path = images_path.map{|path| path.gsub(File.join(Rails.root, 'public'), '') } unless images_path.empty? images_path = 1.upto(3).map{block.default_preview_path} if images_path.empty? content_tag(:ul, images_path.map do |preview| content_tag(:li, image_tag(preview, height: '240', alt: '')) end.join("\n").html_safe ) end def icon_selector(icon = 'no-ico') render :partial => 'icon_selector', :locals => { :icon => icon } end def extra_option_checkbox(option) if [:human_name, :name, :value, :checked, :options].all? {|k| option.key? k} labelled_check_box(option[:human_name], option[:name], option[:value], option[:checked], option[:options]) end end end |