Class CharactersController
In: app/controllers/characters_controller.rb
Parent: ApplicationController

Methods

Included Modules

CharacterRadicalsHelper

Public Instance methods

[Source]

     # File app/controllers/characters_controller.rb, line 130
130:   def character_family
131:     save_setting_session(:character_family_id)
132:     redirect_to(:controller => :characters, :action => :list)
133:   end

[Source]

     # File app/controllers/characters_controller.rb, line 114
114:   def character_of_moment
115:     if params[:id]
116:       @character = Character.find_by_id(params[:id])
117:     else
118:       @character = Character.get_character_of_moment
119:     end
120:   end

[Source]

     # File app/controllers/characters_controller.rb, line 126
126:   def character_of_moment_characters
127:     character_of_moment_remote_call
128:   end

[Source]

     # File app/controllers/characters_controller.rb, line 122
122:   def character_of_moment_radicals
123:     character_of_moment_remote_call
124:   end

[Source]

     # File app/controllers/characters_controller.rb, line 74
 74:   def conditions_for_collection
 75:     query     = ''
 76:     variables = Array.new
 77:     
 78:     # ensure we query only for characters from the target
 79:     # dictionary language
 80:     query     << 'characters.language_id = ?'
 81:     variables << [ session[:language_dictionary_id].to_i ]
 82:     
 83:     # limit our characters to a specific family if 
 84:     # so specified
 85:     if session[:character_family_id]
 86:       query << ' AND characters.language_character_family_id = ?'
 87:       variables << [ session[:character_family_id].to_i ]
 88:     end
 89:  
 90:     # limit our characters that only include the specified radicals
 91:     if session[:character_radical_ids] && (not session[:character_radical_ids].empty?)
 92:       query_sub_strings = Array.new
 93:       characters_of_radials = CharacterRadical.find_characters(session[:character_radical_ids].keys)
 94:       # only filter if there are characters that have all the radicals
 95:       if not characters_of_radials.empty?
 96:         query << ' AND ('
 97:         for character_radical in characters_of_radials
 98:           query_sub_strings << ' characters.id = ? '
 99:           variables         << [ character_radical.character_id ]
100:         end
101:         query << query_sub_strings.join(' OR ')
102:         query << ' )'
103:       else
104:         # intentionally short-circuit the results to return an empty set
105:         query << ' AND characters.id = -1'
106:       end
107:     end
108:     
109:     parameters = [query]
110:     variables.each{|variable| parameters << variable }
111:     return parameters
112:   end

[Source]

    # File app/controllers/characters_controller.rb, line 66
66:   def filter_characters
67:     render(:partial => 'characters/filter_by_character_family')
68:   end

[Source]

    # File app/controllers/characters_controller.rb, line 70
70:   def find_by_radicals
71:     render(:partial => 'character_radicals/filter_by_character_radicals')
72:   end

Protected Instance methods

[Source]

     # File app/controllers/characters_controller.rb, line 137
137:   def character_of_moment_remote_call
138:     @character = Character.find_by_id(params[:id])
139:     render(:layout => false)
140:   end

[Source]

     # File app/controllers/characters_controller.rb, line 154
154:   def create_authorized?
155:     return is_authorized_as?(UserRole::USER_ROLE_ADMIN)
156:   end

[Source]

     # File app/controllers/characters_controller.rb, line 158
158:   def destroy_authorized?
159:     return is_authorized_as?(UserRole::USER_ROLE_ADMIN)
160:   end

[Source]

     # File app/controllers/characters_controller.rb, line 146
146:   def read_authorized?
147:     return is_authorized_as?(UserRole::USER_ROLE_USER)
148:   end

[Source]

     # File app/controllers/characters_controller.rb, line 142
142:   def search_authorized?
143:     return is_authorized_as?(UserRole::USER_ROLE_USER)
144:   end

[Source]

     # File app/controllers/characters_controller.rb, line 150
150:   def update_authorized?
151:     return is_authorized_as?(UserRole::USER_ROLE_USER)
152:   end

[Validate]