Module WordsHelper
In: app/helpers/words_helper.rb

Methods

Constants

MY_VOCABALARY_LISTS = 'my_vocablary_lists'

Public Instance methods

[Source]

    # File app/helpers/words_helper.rb, line 80
80:   def active_scaffold_input_my_vocabulary_list(column, options)
81:     raise column.association.active_record.inspect
82:   end

[Source]

    # File app/helpers/words_helper.rb, line 21
21:   def comments_show_column(record)
22:     render :active_scaffold => 'comments', :constraints => { :commentable_id => record.id, :commentable_type => 'Word'}
23:   end

[Source]

    # File app/helpers/words_helper.rb, line 58
58:   def definitions_column(record)
59:     display_array(filter_by_language_id(record.definitions,session[:language_target_id]), @@MAXIMUM_TO_DISPLAY_LIST, :definition)
60:   end

[Source]

    # File app/helpers/words_helper.rb, line 62
62:   def definitions_show_column(record)
63:     display_array(filter_by_language_id(record.definitions,session[:language_target_id]), @@MAXIMUM_TO_DISPLAY_SHOW, :definition)
64:   end

[Source]

    # File app/helpers/words_helper.rb, line 8
 8:   def language_definitions_map(definitions)
 9:     language_definitions_map = Hash.new
10:     for definition in definitions
11:       language            = definition.language.language
12:       language_definition = definition.definition
13:       unless language_definitions_map[language]
14:         language_definitions_map[language] = Array.new
15:       end
16:       language_definitions_map[language] << language_definition
17:     end
18:     return language_definitions_map
19:   end

[Source]

    # File app/helpers/words_helper.rb, line 54
54:   def link_to_character(character)
55:     link_to(character, {:controller => :characters, :action => :list, :search => character})
56:   end

Provides links to characters that make up the spelling of the word

[Source]

    # File app/helpers/words_helper.rb, line 26
26:   def search_characters_column(record)
27:     unique_characters = Hash.new
28:     record.spelling.each_char{ |character| unique_characters[character] = character }
29:     unique_characters.keys.sort.map{ |character| 
30:       link_to(character, {:controller => :characters, :action => :list, :search => character}) 
31:     }.join(', ')
32:   end

[Source]

    # File app/helpers/words_helper.rb, line 66
66:   def sentences_column(record)
67:     display_array(filter_by_language_id(record.sentences, session[:language_dictionary_id]), @@MAXIMUM_TO_DISPLAY_LIST, :sentence)
68:   end

[Source]

    # File app/helpers/words_helper.rb, line 70
70:   def sentences_show_column(record)
71:     if record.respond_to?(:spelling)
72:       return if record.spelling.empty?
73:       render :active_scaffold => 'sentences', :conditions => ['sentences.language_id = ? and sentences.sentence LIKE ?', record.language_id, '%' + record.spelling + '%']
74:     elsif record.respond_to?(:character)
75:       return if record.character.empty?
76:       render :active_scaffold => 'sentences', :conditions => ['sentences.language_id = ? and sentences.sentence LIKE ?', record.language_id, '%' + record.character + '%']
77:     end
78:   end

[Source]

    # File app/helpers/words_helper.rb, line 34
34:   def spelling_column(word)
35:     links = Array.new
36:     word.spelling.each_char{ |character| links << link_to_character(character) }
37:     links.join('')
38:   end

[Source]

    # File app/helpers/words_helper.rb, line 40
40:   def spelling_link(word)
41:     kanji_family = LanguageCharacterFamily.find_by_family('kanji')
42:     links = Array.new
43:     word.spelling.each_char{ |character|
44:       found_character = Character.find_by_character_and_language_character_family_id(character,kanji_family.id)
45:       if found_character
46:         links << link_to_character_of_moment_popup(found_character.character, :character_id => found_character.id) 
47:       else
48:         links << character
49:       end
50:     }
51:     links.join('')
52:   end

[Source]

     # File app/helpers/words_helper.rb, line 84
 84:   def vocabulary_lists_form_column(record, input_name) 
 85: #    return render(:active_scaffold => 'vocabulary_lists_words', :constraints => {:word_id => record.id})
 86:     all_vocabulary_lists_for_word = VocabularyListsWord.find_all_by_word_id(record.id).map do |vocabulary_list_word|
 87:       vocabulary_list_word.vocabulary_list
 88:     end
 89:     
 90:     all_vocabulary_lists_for_user = VocabularyListsUser.find_all_by_user_id(session[:user_id]).map do |vocabulary_list_user|
 91:       vocabulary_list_user.vocabulary_list
 92:     end
 93:     
 94:     vocabulary_lists_for_language = VocabularyList.find_all_by_language_id(session[:language_dictionary_id])
 95: 
 96:     unless is_authorized_as?(UserRole::USER_ROLE_ADMIN)
 97:       all_vocabulary_lists_for_user_and_language = vocabulary_lists_for_language.delete_if do |vocabulary_list|
 98:         not all_vocabulary_lists_for_user.include?(vocabulary_list)
 99:       end
100:     else
101:       all_vocabulary_lists_for_user_and_language = vocabulary_lists_for_language
102:     end
103:     
104:     check_boxes = "<ul class='kb_my_vocablary_lists'>"
105:     for vocabulary_list in all_vocabulary_lists_for_user_and_language
106:       variable = "#{MY_VOCABALARY_LISTS}[]"
107:       word_is_in_vocabulary_list = all_vocabulary_lists_for_word.include?(vocabulary_list)
108:       check_boxes << '<li>' << check_box_tag(variable, vocabulary_list.id, word_is_in_vocabulary_list) << label_tag(variable, vocabulary_list.to_long_label) << '</li>' 
109:     end
110:     check_boxes << '</ul>'
111:     
112:     return check_boxes
113:   end

[Validate]