Module: People::NumbersHelper

Defined in:
app/helpers/people/numbers_helper.rb

Overview

COPYRIGHT:

Copyright (c) 2005-2009 North Carolina State University
Developed with funding for the National eXtension Initiative.

LICENSE:

BSD(-compatible)
see LICENSE file or view at http://about.extension.org/wiki/LICENSE

Instance Method Summary (collapse)

Instance Method Details

- (Object) aa_name(aaid)



19
20
21
22
23
24
25
26
27
# File 'app/helpers/people/numbers_helper.rb', line 19

def aa_name(aaid)
  if(aaid.nil? or aaid == 0)
    return 'all'
  elsif(aa = ActivityApplication.find(aaid))
    return aa.shortname
  else
    return 'unknown'
  end
end

- (Object) almost_breadcrumbs(path, filterobject)

this is honestly a bit absurd



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'app/helpers/people/numbers_helper.rb', line 79

def almost_breadcrumbs(path,filterobject)
  breadcrumbs = link_to("Numbers",:controller => '/people/numbers', :action => :index )
  if(filterobject.nil?)
    breadcrumbs += " >> "
    breadcrumbs += "#{path.capitalize}"
  else
    objectklass = filterobject.class.name
    objectid = filterobject.id
    breadcrumbs += " >> "
    breadcrumbs += link_to("#{objectklass.pluralize}",:controller => '/people/numbers', :action => objectklass.downcase.pluralize )
    if(objectklass.downcase.pluralize != path)
      breadcrumbs += " >> "
      breadcrumbs += link_to("#{filterobject.name}",:controller => '/people/numbers', :action => objectklass.downcase, :id => objectid )
      breadcrumbs += " >> "
      breadcrumbs += "#{path.capitalize}"
    else
      breadcrumbs += " >> "
      breadcrumbs += "#{filterobject.name}"
    end
  end
  
  return breadcrumbs  
  
end


74
75
76
# File 'app/helpers/people/numbers_helper.rb', line 74

def link_number_to_userlist(number,options={},htmloptions={})
  link_to_userlist(number,options.merge({:bycount => true}),htmloptions={})
end


42
43
44
# File 'app/helpers/people/numbers_helper.rb', line 42

def link_to_item(item,itemtype,filtered)
   return link_by_count(item.usercount,item.name, url_for(:action => itemtype, :id => item.id))
end


29
30
31
32
# File 'app/helpers/people/numbers_helper.rb', line 29

def link_to_object_numbers_action(linkobject)
  urlparams = {:action => :summary, linkobject.class.name.downcase.to_sym => linkobject.id}
  return link_to(linkobject.name, url_for(urlparams))
end


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/helpers/people/numbers_helper.rb', line 46

def link_to_userlist(text,options={},htmloptions={})
  filteredparameters_list = [:community,:forcecacheupdate]
  filteredparameters_list += Activity.filteredparameters
  filteredparameters = ParamsFilter.new(filteredparameters_list,params)    
  filter_params = filteredparameters.option_values_hash
  
  community = options[:community] || nil
  bycount = (options[:bycount].nil? ? false : options[:bycount])
  if(community)
    urlparams = {:controller => '/people/communities', :action => :userlist, :id => community.id, :connectiontype => 'joined'}
    options.delete(:communitytype)
  else
    urlparams = {:controller => '/people/colleagues', :action => :list}
  end
  urlparams.merge!(filteredparameters.option_values_hash)
  urlparams.merge!(options)
  # must be logged in!
  if(@currentuser.nil?)
    return "#{text}"
  else
    if(bycount)
      return link_by_count(text,"#{text}",url_for(urlparams),htmloptions)
    else
      return link_to("#{text}",url_for(urlparams),htmloptions)
    end
  end
end

- (Object) nilhash_number_with_delimiter(hash, key)



10
11
12
13
14
15
16
# File 'app/helpers/people/numbers_helper.rb', line 10

def nilhash_number_with_delimiter(hash,key) 
  if(hash.blank?)
    return 0
  else
    return number_with_delimiter(hash[key])
  end
end

- (Object) url_for_itemlist(itemlist, filteredparameters, params = {})



34
35
36
37
38
39
40
# File 'app/helpers/people/numbers_helper.rb', line 34

def url_for_itemlist(itemlist,filteredparameters,params={})  
  filter_params = filteredparameters.option_values_hash
  options = {:controller => '/people/numbers', :action => itemlist}
  options.merge!(filter_params)
  options.merge!(params)
  return url_for(options)
end