Helper to build media selectors.
form => the form object
field => field name, which has been defined as a media_attachment
options => can include the following:
:object_name => to override the form object name
:visibility => visibility for the selector
# File vendor/plugins/ubiquo_media/lib/ubiquo_media/media_selector/helper.rb, line 11
11: def media_selector(form, field, options = {})
12: @counter ||= 0
13: @counter += 1
14: locals = {
15: :assets => form.object.send(field),
16: :field => field,
17: :object => form.object,
18: :object_name => options[:object_name] || form.object_name.to_s,
19: :visibility => Ubiquo::Config.context(:ubiquo_media).get(:force_visibility) || options[:visibility],
20: :counter => @counter
21: }
22: render :partial => 'ubiquo/asset_relations/media_selector.html.erb', :locals => locals
23: end
Return a selector containing all allowed types for a media_attachment field
Example:
types = [“image”, “doc”].map { |key| AssetType.find_by_key(key) } type_selector(“images”, types)
Returns:
“
<option value="1,2">-- All --</option> <option value="1">Image</option> <option value="2">Document</option> </select>"
# File vendor/plugins/ubiquo_media/lib/ubiquo_media/media_selector/helper.rb, line 49
49: def type_selector(counter, types)
50: all_opt = [t('ubiquo.media.all'), types.collect(&:id).join(",")]
51: type_opts = [all_opt] + types.collect { |t| [t.name, t.id] }
52: select_tag "asset_type_id_#{counter}".to_sym, options_for_select(type_opts)
53: end
Returns a url where the given asset is accessible
# File vendor/plugins/ubiquo_media/lib/ubiquo_media/media_selector/helper.rb, line 31
31: def url_for_media_attachment(asset, style = nil)
32: url_for_file_attachment(asset, :resource, style)
33: end
Returns an element linking to the given asset in a popup
# File vendor/plugins/ubiquo_media/lib/ubiquo_media/media_selector/helper.rb, line 26
26: def view_asset_link(asset)
27: link_to(t('ubiquo.media.asset_view'), url_for_media_attachment(asset), :class => 'view', :popup => true)
28: end
Disabled; run with $DEBUG to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.