Class: CamaleonCms::PostDefault
- Inherits:
-
CamaleonRecord
- Object
- ActiveRecord::Base
- CamaleonRecord
- CamaleonCms::PostDefault
- Includes:
- CustomFieldsRead, Metas
- Defined in:
- app/models/camaleon_cms/post_default.rb
Direct Known Subclasses
Constant Summary
Constants inherited from CamaleonRecord
CamaleonRecord::TRANSLATION_TAG_HIDE_MAP, CamaleonRecord::TRANSLATION_TAG_HIDE_REGEX, CamaleonRecord::TRANSLATION_TAG_HIDE_SENTINELS, CamaleonRecord::TRANSLATION_TAG_RESTORE_MAP, CamaleonRecord::TRANSLATION_TAG_RESTORE_REGEX
Instance Attribute Summary collapse
-
#draft_id ⇒ Object
attr_accessible :user_id, :title, :slug, :content, :content_filtered, :status, :visibility, :visibility_value, :post_order, :post_type_key, :taxonomy_id, :published_at, :post_parent, :post_order, :is_feature.
Class Method Summary collapse
-
.find_by_slug(slug) ⇒ Object
find a content by slug (support multi language).
-
.find_sti_class(type_name) ⇒ Object
Controls Reading: Prepend 'CamaleonCms::' when pulling from DB "Widget::Assigned" -> "CamaleonCms::Widget::Assigned" "Post" -> "CamaleonCms::Post".
- .inherited(subclass) ⇒ Object
-
.sti_name ⇒ Object
Controls Writing: Strip 'CamaleonCms::' when saving to DB "CamaleonCms::Widget::Assigned" -> "Widget::Assigned" "CamaleonCms::Post" -> "Post".
Instance Method Summary collapse
-
#author ⇒ Object
return the author of this Content.
-
#in_nav_menu_items ⇒ Object
return all menu items in which this post was assigned.
-
#set_params(meta, custom_fields, options) ⇒ Object
Set the meta-field values and the post keywords here.
Methods included from CustomFieldsRead
#add_custom_field_group, #add_custom_field_to_default_group, #get_field_groups, #get_field_object, #get_field_value, #get_field_values, #get_field_values_hash, #get_fields_grouped, #get_fields_object, #get_user_field_groups, #save_field_value, #set_field_value, #set_field_values, #update_field_value
Methods included from Metas
#delete_meta, #delete_option, #fix_save_metas_options_no_changed, #get_meta, #get_option, #options, #save_metas_options, #save_metas_options_skip, #set_meta, #set_metas, #set_option, #set_options
Methods inherited from CamaleonRecord
#ability, #cama_build_cache_key, #cama_fetch_cache, #cama_get_cache, #cama_remove_cache, cama_sanitize_translatable, #cama_set_cache, #can?, #current_site, #current_user, polymorphic_class_for, polymorphic_name, #reset_ability
Instance Attribute Details
#draft_id ⇒ Object
attr_accessible :user_id, :title, :slug, :content, :content_filtered, :status, :visibility, :visibility_value, :post_order, :post_type_key, :taxonomy_id, :published_at, :post_parent, :post_order, :is_feature
50 51 52 |
# File 'app/models/camaleon_cms/post_default.rb', line 50 def draft_id @draft_id end |
Class Method Details
.find_by_slug(slug) ⇒ Object
find a content by slug (support multi language)
73 74 75 76 77 78 79 80 81 |
# File 'app/models/camaleon_cms/post_default.rb', line 73 def self.find_by_slug(slug) # if current_site.present? && current_site.get_meta("languages_site", []).count <= 1 # res = self.where(slug: slug) # else res = where("#{CamaleonCms::Post.table_name}.slug = ? OR #{CamaleonCms::Post.table_name}.slug LIKE ? ", slug, "%-->#{slug}<!--%") # end res.take end |
.find_sti_class(type_name) ⇒ Object
Controls Reading: Prepend 'CamaleonCms::' when pulling from DB "Widget::Assigned" -> "CamaleonCms::Widget::Assigned" "Post" -> "CamaleonCms::Post"
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/models/camaleon_cms/post_default.rb', line 27 def self.find_sti_class(type_name) full_class_name = type_name.start_with?('CamaleonCms::') ? type_name : "CamaleonCms::#{type_name}" klass = begin full_class_name.constantize rescue NameError nil end return klass if klass && klass <= base_class # `super` resolves fully-qualified external classes (plugin STI outside the # CamaleonCms namespace) and enforces ancestry; values it cannot place load as # the base class, as every row did before native STI. begin super rescue ActiveRecord::SubclassNotFound base_class end end |
.inherited(subclass) ⇒ Object
6 7 8 9 10 11 12 |
# File 'app/models/camaleon_cms/post_default.rb', line 6 def self.inherited(subclass) super subclass.class_eval do include CamaleonCms::CommonRelationships end end |
.sti_name ⇒ Object
Controls Writing: Strip 'CamaleonCms::' when saving to DB "CamaleonCms::Widget::Assigned" -> "Widget::Assigned" "CamaleonCms::Post" -> "Post"
20 21 22 |
# File 'app/models/camaleon_cms/post_default.rb', line 20 def self.sti_name name.sub(/^CamaleonCms::/, '') end |
Instance Method Details
#author ⇒ Object
return the author of this Content
84 85 86 87 88 |
# File 'app/models/camaleon_cms/post_default.rb', line 84 def CamaleonCms::User.find(user_id) rescue StandardError CamaleonCms::User.admin_scope.first end |
#in_nav_menu_items ⇒ Object
return all menu items in which this post was assigned
91 92 93 |
# File 'app/models/camaleon_cms/post_default.rb', line 91 def CamaleonCms::NavMenuItem.where(url: id, kind: 'post') end |
#set_params(meta, custom_fields, options) ⇒ Object
Set the meta-field values and the post keywords here
96 97 98 99 100 |
# File 'app/models/camaleon_cms/post_default.rb', line 96 def set_params(, custom_fields, ) () set_field_values(custom_fields) () end |