Class ContentType
In: app/models/content_type.rb
Parent: ActiveRecord::Base

API for interaction with the database table ‘content_types’, and it‘s related data model.

Methods

exists   get   get_all_ids  

Attributes

groups  [RW]  Accessor methods.
index_fields  [RW]  Accessor methods.
item_fields  [RW]  Accessor methods.
items  [RW]  Accessor methods.

Public Class methods

Determine if a content type is available.

[Source]

    # File app/models/content_type.rb, line 16
16:   def self.exists (
17:     project_id, 
18:     project_host_id, 
19:     content_type_name
20:   )
21:     count = count_by_sql('SELECT   count(*) '      +
22:                          'FROM ' + table_name      + "
23:                           WHERE    name            = '#{content_type_name}' 
24:                           AND      project_id      = #{project_id}
25:                           AND      project_host_id = #{project_host_id}")
26: 
27:     (1 == count) ? (TRUE) : (FALSE)
28:   end

Retrieve all information for a particular content type, by name or id.

[Source]

    # File app/models/content_type.rb, line 34
34:   def self.get (
35:     project_id, 
36:     project_host_id, 
37:     id
38:   )
39:     # The identifier is a content type id.
40:     if (id.to_s =~ /#{ID}/)
41:       content_type = find_by_id_and_project_id_and_project_host_id(id,  
42:                                                                 project_id,
43:                                                                 project_host_id)
44:     # The identifier is a content type name.
45:     elsif (id.to_s =~ /#{CONTENT_TYPE_NAME}/)
46:       content_type = find_by_name_and_project_id_and_project_host_id(id, 
47:                                                                 project_id,
48:                                                                 project_host_id)
49:     end
50: 
51:     (content_type) ? (content_type) : (FALSE)
52:   end

Retrieve all available content type ids for a project host.

[Source]

    # File app/models/content_type.rb, line 58
58:   def self.get_all_ids (
59:     project_id, 
60:     project_host_id
61:   )
62:     types = find_by_sql("SELECT id
63:                          FROM   #{table_name}
64:                          WHERE  project_id      = #{project_id}
65:                          AND    project_host_id = #{project_host_id}")
66:     ids = []
67:     types.each { |type| ids << type.id }
68:     ids
69:   end

[Validate]