def flashobject_tags(source, options={})
path = flashobject_path(source)
verify_file_exists = options.fetch(:verify_file_exists, ENV['RAILS_ENV'] == 'development')
if verify_file_exists and not File.exists?(File.join(RAILS_ROOT, 'public', path).sub(/\?\d+/, ''))
return "<div><strong>Warning:</strong> The file <code>#{File.join('public', path)}</code> does not exist. Execute <tt>rake openlaszlo:build:applets</tt> to create it.</div>"
end
div_id = options[:div_id] || 'flashcontent'
flash_id = options[:flash_id] || File.basename(source, '.swf')
width = options[:width] || '100%'
height = options[:height] || '100%'
background_color = options[:background_color] || '#ffffff'
flash_version = options[:flash_version] || 7
variables = options.fetch(:variables, {:lzproxied => false})
parameters = options.fetch(:parameters, {:scale => 'noscale'})
fallback_html = options[:fallback_html] || %q{<p>Requires the Flash plugin. If the plugin is already installed, click <a href="?detectflash=false">here</a>.</p>}
if options.fetch(:check_for_javascript_include, ENV['RAILS_ENV'] == 'development')
check_for_javascript ="if (typeof FlashObject == 'undefined') document.getElementById('#{div_id}').innerHTML = '<strong>Warning:</strong> FlashObject is undefined. Did you forget to include <tt><%= javascript_include_tag :defaults %></tt> in your view file?';"
end
return "<div id=\"\#{div_id}\" style=\"height: \#{height}\">\n\#{fallback_html}\n</div>\n<script type=\"text/javascript\">//<![CDATA[\n\#{check_for_javascript}\nvar fo = new FlashObject(\"\#{path}\", \"\#{flash_id}\", \"\#{width}\", \"\#{height}\", \"\#{flash_version}\", \"\#{background_color}\");\n\#{parameters.map{|k,v|%Q[fo.addVariable(\"\#{k}\", \"\#{v}\");]}.join(\"\\n\")}\n\#{variables.map{|k,v|%Q[fo.addVariable(\"\#{k}\", \"\#{v}\");]}.join(\"\\n\")}\nfo.write(\"\#{div_id}\");\n//]]>\n</script>\n"
end